summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorMarius Storm-Olsen <marius.storm-olsen@nokia.com>2012-05-10 09:56:00 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-10 11:34:25 +0200
commit2d23374a6f88bac2f5f2d7f0528e9e554b4a4cbb (patch)
tree5b27e35d6767778c028d2f3b9ca37b4545c04a59 /src/widgets
parent7f2c22e8910f43728f13d76aa2c50c29a19f3ee0 (diff)
parent9456528aac80c6d4c41fa96d88696dc55414b710 (diff)
Merge "Merge branch 'docs-refactoring' into master" into refs/staging/master
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp8
-rw-r--r--src/widgets/dialogs/qdialog.cpp14
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp28
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp6
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp30
-rw-r--r--src/widgets/dialogs/qinputdialog.cpp32
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp24
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp8
-rw-r--r--src/widgets/dialogs/qwizard.cpp208
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part1-labeled-layout.pngbin0 -> 19114 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part1-labeled-screenshot.pngbin0 -> 23223 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part1-screenshot.pngbin0 -> 9872 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part2-add-contact.pngbin0 -> 12936 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part2-add-flowchart.pngbin0 -> 23533 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part2-add-successful.pngbin0 -> 10825 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part2-labeled-layout.pngbin0 -> 27103 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part2-signals-and-slots.pngbin0 -> 9968 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part2-stretch-effects.pngbin0 -> 12268 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part3-labeled-layout.pngbin0 -> 27467 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part3-linkedlist.pngbin0 -> 10209 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part3-screenshot.pngbin0 -> 14041 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part4-remove.pngbin0 -> 22248 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part5-finddialog.pngbin0 -> 10046 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part5-notfound.pngbin0 -> 10789 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part5-screenshot.pngbin0 -> 15849 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part5-signals-and-slots.pngbin0 -> 5542 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part6-load.pngbin0 -> 24797 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part6-save.pngbin0 -> 24747 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part6-screenshot.pngbin0 -> 16819 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-part7-screenshot.pngbin0 -> 18369 bytes
-rw-r--r--src/widgets/doc/images/addressbook-tutorial-screenshot.pngbin0 -> 15275 bytes
-rw-r--r--src/widgets/doc/images/assistant-toolbar.pngbin0 -> 6532 bytes
-rw-r--r--src/widgets/doc/images/buttonbox-gnomelayout-horizontal.pngbin0 -> 4188 bytes
-rw-r--r--src/widgets/doc/images/buttonbox-gnomelayout-vertical.pngbin0 -> 5027 bytes
-rw-r--r--src/widgets/doc/images/buttonbox-kdelayout-horizontal.pngbin0 -> 2862 bytes
-rw-r--r--src/widgets/doc/images/buttonbox-kdelayout-vertical.pngbin0 -> 3298 bytes
-rw-r--r--src/widgets/doc/images/buttonbox-mac-modeless-horizontal.pngbin0 -> 4123 bytes
-rw-r--r--src/widgets/doc/images/buttonbox-mac-modeless-vertical.pngbin0 -> 5177 bytes
-rw-r--r--src/widgets/doc/images/buttonbox-maclayout-horizontal.pngbin0 -> 5409 bytes
-rw-r--r--src/widgets/doc/images/buttonbox-maclayout-vertical.pngbin0 -> 7340 bytes
-rw-r--r--src/widgets/doc/images/buttonbox-winlayout-horizontal.pngbin0 -> 2780 bytes
-rw-r--r--src/widgets/doc/images/buttonbox-winlayout-vertical.pngbin0 -> 3184 bytes
-rw-r--r--src/widgets/doc/images/cde-calendarwidget.pngbin0 -> 10187 bytes
-rw-r--r--src/widgets/doc/images/cde-checkbox.pngbin0 -> 1331 bytes
-rw-r--r--src/widgets/doc/images/cde-combobox.pngbin0 -> 1269 bytes
-rw-r--r--src/widgets/doc/images/cde-dateedit.pngbin0 -> 1183 bytes
-rw-r--r--src/widgets/doc/images/cde-datetimeedit.pngbin0 -> 1701 bytes
-rw-r--r--src/widgets/doc/images/cde-dial.pngbin0 -> 4481 bytes
-rw-r--r--src/widgets/doc/images/cde-doublespinbox.pngbin0 -> 1007 bytes
-rw-r--r--src/widgets/doc/images/cde-fontcombobox.pngbin0 -> 1603 bytes
-rw-r--r--src/widgets/doc/images/cde-frame.pngbin0 -> 2976 bytes
-rw-r--r--src/widgets/doc/images/cde-groupbox.pngbin0 -> 2592 bytes
-rw-r--r--src/widgets/doc/images/cde-horizontalscrollbar.pngbin0 -> 569 bytes
-rw-r--r--src/widgets/doc/images/cde-label.pngbin0 -> 1043 bytes
-rw-r--r--src/widgets/doc/images/cde-lcdnumber.pngbin0 -> 538 bytes
-rw-r--r--src/widgets/doc/images/cde-lineedit.pngbin0 -> 1355 bytes
-rw-r--r--src/widgets/doc/images/cde-listview.pngbin0 -> 5166 bytes
-rw-r--r--src/widgets/doc/images/cde-progressbar.pngbin0 -> 934 bytes
-rw-r--r--src/widgets/doc/images/cde-pushbutton.pngbin0 -> 1099 bytes
-rw-r--r--src/widgets/doc/images/cde-radiobutton.pngbin0 -> 1562 bytes
-rw-r--r--src/widgets/doc/images/cde-slider.pngbin0 -> 526 bytes
-rw-r--r--src/widgets/doc/images/cde-spinbox.pngbin0 -> 863 bytes
-rw-r--r--src/widgets/doc/images/cde-tableview.pngbin0 -> 2467 bytes
-rw-r--r--src/widgets/doc/images/cde-tabwidget.pngbin0 -> 2483 bytes
-rw-r--r--src/widgets/doc/images/cde-textedit.pngbin0 -> 7374 bytes
-rw-r--r--src/widgets/doc/images/cde-timeedit.pngbin0 -> 1248 bytes
-rw-r--r--src/widgets/doc/images/cde-toolbox.pngbin0 -> 1813 bytes
-rw-r--r--src/widgets/doc/images/cde-toolbutton.pngbin0 -> 1169 bytes
-rw-r--r--src/widgets/doc/images/cde-treeview.pngbin0 -> 6703 bytes
-rw-r--r--src/widgets/doc/images/checkboxes-exclusive.pngbin0 -> 5079 bytes
-rw-r--r--src/widgets/doc/images/checkboxes-non-exclusive.pngbin0 -> 5614 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-calendarwidget.pngbin0 -> 9748 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-checkbox.pngbin0 -> 1416 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-combobox.pngbin0 -> 2348 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-dateedit.pngbin0 -> 1369 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-datetimeedit.pngbin0 -> 1892 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-dial.pngbin0 -> 4297 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-doublespinbox.pngbin0 -> 1141 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-fontcombobox.pngbin0 -> 1835 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-frame.pngbin0 -> 2989 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-groupbox.pngbin0 -> 2630 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-horizontalscrollbar.pngbin0 -> 837 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-label.pngbin0 -> 1043 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-lcdnumber.pngbin0 -> 538 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-lineedit.pngbin0 -> 1406 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-listview.pngbin0 -> 5559 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-progressbar.pngbin0 -> 1292 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-pushbutton-menu.pngbin0 -> 3177 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-pushbutton.pngbin0 -> 1332 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-radiobutton.pngbin0 -> 1782 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-slider.pngbin0 -> 671 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-spinbox.pngbin0 -> 983 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-tableview.pngbin0 -> 2465 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-tabwidget.pngbin0 -> 5007 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-textedit.pngbin0 -> 7560 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-timeedit.pngbin0 -> 1388 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-toolbox.pngbin0 -> 1445 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-toolbutton.pngbin0 -> 1469 bytes
-rw-r--r--src/widgets/doc/images/cleanlooks-treeview.pngbin0 -> 6981 bytes
-rw-r--r--src/widgets/doc/images/clock.pngbin0 -> 16514 bytes
-rw-r--r--src/widgets/doc/images/columnview.pngbin0 -> 3480 bytes
-rw-r--r--src/widgets/doc/images/designer-stylesheet-options.pngbin0 -> 18914 bytes
-rw-r--r--src/widgets/doc/images/designer-stylesheet-usage.pngbin0 -> 8128 bytes
-rw-r--r--src/widgets/doc/images/designer-validator-highlighter.pngbin0 -> 27153 bytes
-rw-r--r--src/widgets/doc/images/dummy_tree.pngbin0 -> 20189 bytes
-rw-r--r--src/widgets/doc/images/example_model.pngbin0 -> 16577 bytes
-rw-r--r--src/widgets/doc/images/filedialogurls.pngbin0 -> 29132 bytes
-rw-r--r--src/widgets/doc/images/frames.pngbin0 -> 25735 bytes
-rw-r--r--src/widgets/doc/images/graphicsview-ellipseitem-pie.pngbin0 -> 6683 bytes
-rw-r--r--src/widgets/doc/images/graphicsview-ellipseitem.pngbin0 -> 5801 bytes
-rw-r--r--src/widgets/doc/images/graphicsview-items.pngbin0 -> 62593 bytes
-rw-r--r--src/widgets/doc/images/graphicsview-pathitem.pngbin0 -> 5710 bytes
-rw-r--r--src/widgets/doc/images/graphicsview-pixmapitem.pngbin0 -> 10764 bytes
-rw-r--r--src/widgets/doc/images/graphicsview-polygonitem.pngbin0 -> 5829 bytes
-rw-r--r--src/widgets/doc/images/graphicsview-rectitem.pngbin0 -> 3305 bytes
-rw-r--r--src/widgets/doc/images/graphicsview-zorder.pngbin0 -> 6724 bytes
-rw-r--r--src/widgets/doc/images/gridlayout.pngbin0 -> 1445 bytes
-rw-r--r--src/widgets/doc/images/gtk-calendarwidget.pngbin0 -> 16761 bytes
-rw-r--r--src/widgets/doc/images/gtk-checkbox.pngbin0 -> 2323 bytes
-rw-r--r--src/widgets/doc/images/gtk-combobox.pngbin0 -> 2730 bytes
-rw-r--r--src/widgets/doc/images/gtk-dateedit.pngbin0 -> 2163 bytes
-rw-r--r--src/widgets/doc/images/gtk-datetimeedit.pngbin0 -> 2923 bytes
-rw-r--r--src/widgets/doc/images/gtk-dial.pngbin0 -> 7221 bytes
-rw-r--r--src/widgets/doc/images/gtk-doublespinbox.pngbin0 -> 2325 bytes
-rw-r--r--src/widgets/doc/images/gtk-fontcombobox.pngbin0 -> 3022 bytes
-rw-r--r--src/widgets/doc/images/gtk-frame.pngbin0 -> 2340 bytes
-rw-r--r--src/widgets/doc/images/gtk-groupbox.pngbin0 -> 6650 bytes
-rw-r--r--src/widgets/doc/images/gtk-horizontalscrollbar.pngbin0 -> 1701 bytes
-rw-r--r--src/widgets/doc/images/gtk-label.pngbin0 -> 1582 bytes
-rw-r--r--src/widgets/doc/images/gtk-lcdnumber.pngbin0 -> 1193 bytes
-rw-r--r--src/widgets/doc/images/gtk-lineedit.pngbin0 -> 2528 bytes
-rw-r--r--src/widgets/doc/images/gtk-listview.pngbin0 -> 8493 bytes
-rw-r--r--src/widgets/doc/images/gtk-progressbar.pngbin0 -> 2228 bytes
-rw-r--r--src/widgets/doc/images/gtk-pushbutton.pngbin0 -> 2153 bytes
-rw-r--r--src/widgets/doc/images/gtk-radiobutton.pngbin0 -> 3142 bytes
-rw-r--r--src/widgets/doc/images/gtk-slider.pngbin0 -> 1359 bytes
-rw-r--r--src/widgets/doc/images/gtk-spinbox.pngbin0 -> 2078 bytes
-rw-r--r--src/widgets/doc/images/gtk-tableview.pngbin0 -> 8364 bytes
-rw-r--r--src/widgets/doc/images/gtk-tabwidget.pngbin0 -> 8179 bytes
-rw-r--r--src/widgets/doc/images/gtk-textedit.pngbin0 -> 12641 bytes
-rw-r--r--src/widgets/doc/images/gtk-timeedit.pngbin0 -> 2621 bytes
-rw-r--r--src/widgets/doc/images/gtk-toolbox.pngbin0 -> 4240 bytes
-rw-r--r--src/widgets/doc/images/gtk-toolbutton.pngbin0 -> 2260 bytes
-rw-r--r--src/widgets/doc/images/gtk-treeview.pngbin0 -> 9722 bytes
-rw-r--r--src/widgets/doc/images/javastyle/branchindicatorimage.pngbin0 -> 18867 bytes
-rw-r--r--src/widgets/doc/images/javastyle/button.pngbin0 -> 5475 bytes
-rw-r--r--src/widgets/doc/images/javastyle/checkbox.pngbin0 -> 3634 bytes
-rw-r--r--src/widgets/doc/images/javastyle/checkboxexample.pngbin0 -> 911 bytes
-rw-r--r--src/widgets/doc/images/javastyle/combobox.pngbin0 -> 3537 bytes
-rw-r--r--src/widgets/doc/images/javastyle/comboboximage.pngbin0 -> 6527 bytes
-rw-r--r--src/widgets/doc/images/javastyle/conceptualpushbuttontree.pngbin0 -> 3590 bytes
-rw-r--r--src/widgets/doc/images/javastyle/dockwidget.pngbin0 -> 7181 bytes
-rw-r--r--src/widgets/doc/images/javastyle/dockwidgetimage.pngbin0 -> 21774 bytes
-rw-r--r--src/widgets/doc/images/javastyle/groupbox.pngbin0 -> 2010 bytes
-rw-r--r--src/widgets/doc/images/javastyle/groupboximage.pngbin0 -> 7067 bytes
-rw-r--r--src/widgets/doc/images/javastyle/header.pngbin0 -> 4399 bytes
-rw-r--r--src/widgets/doc/images/javastyle/headerimage.pngbin0 -> 6474 bytes
-rw-r--r--src/widgets/doc/images/javastyle/menu.pngbin0 -> 6508 bytes
-rw-r--r--src/widgets/doc/images/javastyle/menubar.pngbin0 -> 4315 bytes
-rw-r--r--src/widgets/doc/images/javastyle/menubarimage.pngbin0 -> 4487 bytes
-rw-r--r--src/widgets/doc/images/javastyle/menuimage.pngbin0 -> 5584 bytes
-rw-r--r--src/widgets/doc/images/javastyle/progressbar.pngbin0 -> 4493 bytes
-rw-r--r--src/widgets/doc/images/javastyle/progressbarimage.pngbin0 -> 6921 bytes
-rw-r--r--src/widgets/doc/images/javastyle/pushbutton.pngbin0 -> 6820 bytes
-rw-r--r--src/widgets/doc/images/javastyle/rubberband.pngbin0 -> 765 bytes
-rw-r--r--src/widgets/doc/images/javastyle/rubberbandimage.pngbin0 -> 6452 bytes
-rw-r--r--src/widgets/doc/images/javastyle/scrollbar.pngbin0 -> 7199 bytes
-rw-r--r--src/widgets/doc/images/javastyle/scrollbarimage.pngbin0 -> 6196 bytes
-rw-r--r--src/widgets/doc/images/javastyle/sizegrip.pngbin0 -> 708 bytes
-rw-r--r--src/widgets/doc/images/javastyle/sizegripimage.pngbin0 -> 1793 bytes
-rw-r--r--src/widgets/doc/images/javastyle/slider.pngbin0 -> 2844 bytes
-rw-r--r--src/widgets/doc/images/javastyle/sliderimage.pngbin0 -> 3442 bytes
-rw-r--r--src/widgets/doc/images/javastyle/spinbox.pngbin0 -> 2864 bytes
-rw-r--r--src/widgets/doc/images/javastyle/spinboximage.pngbin0 -> 4544 bytes
-rw-r--r--src/widgets/doc/images/javastyle/tab.pngbin0 -> 12176 bytes
-rw-r--r--src/widgets/doc/images/javastyle/tabwidget.pngbin0 -> 4725 bytes
-rw-r--r--src/widgets/doc/images/javastyle/titlebar.pngbin0 -> 2609 bytes
-rw-r--r--src/widgets/doc/images/javastyle/titlebarimage.pngbin0 -> 6882 bytes
-rw-r--r--src/widgets/doc/images/javastyle/toolbar.pngbin0 -> 6303 bytes
-rw-r--r--src/widgets/doc/images/javastyle/toolbarimage.pngbin0 -> 8245 bytes
-rw-r--r--src/widgets/doc/images/javastyle/toolbox.pngbin0 -> 3211 bytes
-rw-r--r--src/widgets/doc/images/javastyle/toolboximage.pngbin0 -> 5580 bytes
-rw-r--r--src/widgets/doc/images/javastyle/toolbutton.pngbin0 -> 4487 bytes
-rw-r--r--src/widgets/doc/images/javastyle/toolbuttonimage.pngbin0 -> 5124 bytes
-rw-r--r--src/widgets/doc/images/javastyle/windowstabimage.pngbin0 -> 6898 bytes
-rw-r--r--src/widgets/doc/images/licensewizard-flow.pngbin0 -> 15306 bytes
-rw-r--r--src/widgets/doc/images/list_table_tree.pngbin0 -> 85530 bytes
-rwxr-xr-xsrc/widgets/doc/images/listview.pngbin0 -> 9695 bytes
-rw-r--r--src/widgets/doc/images/macintosh-calendarwidget.pngbin0 -> 13560 bytes
-rw-r--r--src/widgets/doc/images/macintosh-checkbox.pngbin0 -> 2473 bytes
-rw-r--r--src/widgets/doc/images/macintosh-combobox.pngbin0 -> 3273 bytes
-rw-r--r--src/widgets/doc/images/macintosh-dateedit.pngbin0 -> 1703 bytes
-rw-r--r--src/widgets/doc/images/macintosh-datetimeedit.pngbin0 -> 2633 bytes
-rw-r--r--src/widgets/doc/images/macintosh-dial.pngbin0 -> 2563 bytes
-rw-r--r--src/widgets/doc/images/macintosh-doublespinbox.pngbin0 -> 2306 bytes
-rw-r--r--src/widgets/doc/images/macintosh-fontcombobox.pngbin0 -> 2967 bytes
-rw-r--r--src/widgets/doc/images/macintosh-frame.pngbin0 -> 6187 bytes
-rw-r--r--src/widgets/doc/images/macintosh-groupbox.pngbin0 -> 6469 bytes
-rw-r--r--src/widgets/doc/images/macintosh-horizontalscrollbar.pngbin0 -> 2242 bytes
-rw-r--r--src/widgets/doc/images/macintosh-label.pngbin0 -> 1450 bytes
-rw-r--r--src/widgets/doc/images/macintosh-lcdnumber.pngbin0 -> 492 bytes
-rw-r--r--src/widgets/doc/images/macintosh-lineedit.pngbin0 -> 1854 bytes
-rw-r--r--src/widgets/doc/images/macintosh-listview.pngbin0 -> 9987 bytes
-rw-r--r--src/widgets/doc/images/macintosh-menu.pngbin0 -> 6891 bytes
-rw-r--r--src/widgets/doc/images/macintosh-progressbar.pngbin0 -> 1127 bytes
-rw-r--r--src/widgets/doc/images/macintosh-pushbutton.pngbin0 -> 2966 bytes
-rw-r--r--src/widgets/doc/images/macintosh-radiobutton.pngbin0 -> 2914 bytes
-rw-r--r--src/widgets/doc/images/macintosh-slider.pngbin0 -> 1694 bytes
-rw-r--r--src/widgets/doc/images/macintosh-spinbox.pngbin0 -> 1964 bytes
-rw-r--r--src/widgets/doc/images/macintosh-tableview.pngbin0 -> 10024 bytes
-rw-r--r--src/widgets/doc/images/macintosh-tabwidget.pngbin0 -> 9562 bytes
-rw-r--r--src/widgets/doc/images/macintosh-textedit.pngbin0 -> 7845 bytes
-rw-r--r--src/widgets/doc/images/macintosh-timeedit.pngbin0 -> 2244 bytes
-rw-r--r--src/widgets/doc/images/macintosh-toolbox.pngbin0 -> 2576 bytes
-rw-r--r--src/widgets/doc/images/macintosh-toolbutton.pngbin0 -> 2003 bytes
-rw-r--r--src/widgets/doc/images/macintosh-treeview.pngbin0 -> 11728 bytes
-rw-r--r--src/widgets/doc/images/mainwindow-docks-example.pngbin0 -> 14427 bytes
-rw-r--r--src/widgets/doc/images/mainwindow-docks.pngbin0 -> 37240 bytes
-rw-r--r--src/widgets/doc/images/mainwindowlayout.pngbin0 -> 6782 bytes
-rw-r--r--src/widgets/doc/images/mdi-cascade.pngbin0 -> 14590 bytes
-rw-r--r--src/widgets/doc/images/mdi-tile.pngbin0 -> 31624 bytes
-rwxr-xr-xsrc/widgets/doc/images/modelview-combobox.pngbin0 -> 5022 bytes
-rw-r--r--src/widgets/doc/images/modelview-header.pngbin0 -> 30302 bytes
-rw-r--r--src/widgets/doc/images/modelview-models.pngbin0 -> 20540 bytes
-rw-r--r--src/widgets/doc/images/modelview-overview.pngbin0 -> 15042 bytes
-rw-r--r--src/widgets/doc/images/modelview-roles.pngbin0 -> 24954 bytes
-rw-r--r--src/widgets/doc/images/modelview-tablemodel.pngbin0 -> 12256 bytes
-rw-r--r--src/widgets/doc/images/modelview-treemodel.pngbin0 -> 9193 bytes
-rw-r--r--src/widgets/doc/images/modelview.pngbin0 -> 2887 bytes
-rw-r--r--src/widgets/doc/images/motif-calendarwidget.pngbin0 -> 9989 bytes
-rw-r--r--src/widgets/doc/images/motif-checkbox.pngbin0 -> 1284 bytes
-rw-r--r--src/widgets/doc/images/motif-combobox.pngbin0 -> 1276 bytes
-rw-r--r--src/widgets/doc/images/motif-dateedit.pngbin0 -> 1214 bytes
-rw-r--r--src/widgets/doc/images/motif-datetimeedit.pngbin0 -> 1730 bytes
-rw-r--r--src/widgets/doc/images/motif-dial.pngbin0 -> 2017 bytes
-rw-r--r--src/widgets/doc/images/motif-doublespinbox.pngbin0 -> 1019 bytes
-rw-r--r--src/widgets/doc/images/motif-fontcombobox.pngbin0 -> 1633 bytes
-rw-r--r--src/widgets/doc/images/motif-frame.pngbin0 -> 5631 bytes
-rw-r--r--src/widgets/doc/images/motif-groupbox.pngbin0 -> 2514 bytes
-rw-r--r--src/widgets/doc/images/motif-horizontalscrollbar.pngbin0 -> 628 bytes
-rw-r--r--src/widgets/doc/images/motif-label.pngbin0 -> 699 bytes
-rw-r--r--src/widgets/doc/images/motif-lcdnumber.pngbin0 -> 538 bytes
-rw-r--r--src/widgets/doc/images/motif-lineedit.pngbin0 -> 1360 bytes
-rw-r--r--src/widgets/doc/images/motif-listview.pngbin0 -> 5189 bytes
-rw-r--r--src/widgets/doc/images/motif-menubar.pngbin0 -> 1350 bytes
-rw-r--r--src/widgets/doc/images/motif-progressbar.pngbin0 -> 927 bytes
-rw-r--r--src/widgets/doc/images/motif-pushbutton.pngbin0 -> 1045 bytes
-rw-r--r--src/widgets/doc/images/motif-radiobutton.pngbin0 -> 1545 bytes
-rw-r--r--src/widgets/doc/images/motif-slider.pngbin0 -> 543 bytes
-rw-r--r--src/widgets/doc/images/motif-spinbox.pngbin0 -> 875 bytes
-rw-r--r--src/widgets/doc/images/motif-tableview.pngbin0 -> 3102 bytes
-rw-r--r--src/widgets/doc/images/motif-tabwidget.pngbin0 -> 2490 bytes
-rw-r--r--src/widgets/doc/images/motif-textedit.pngbin0 -> 7378 bytes
-rw-r--r--src/widgets/doc/images/motif-timeedit.pngbin0 -> 1280 bytes
-rw-r--r--src/widgets/doc/images/motif-toolbox.pngbin0 -> 1667 bytes
-rw-r--r--src/widgets/doc/images/motif-toolbutton.pngbin0 -> 1152 bytes
-rw-r--r--src/widgets/doc/images/motif-treeview.pngbin0 -> 6386 bytes
-rw-r--r--src/widgets/doc/images/msgbox1.pngbin0 -> 4529 bytes
-rw-r--r--src/widgets/doc/images/msgbox2.pngbin0 -> 9175 bytes
-rw-r--r--src/widgets/doc/images/msgbox3.pngbin0 -> 9589 bytes
-rw-r--r--src/widgets/doc/images/msgbox4.pngbin0 -> 17520 bytes
-rw-r--r--src/widgets/doc/images/pangesture.pngbin0 -> 7153 bytes
-rw-r--r--src/widgets/doc/images/parent-child-widgets.pngbin0 -> 47824 bytes
-rw-r--r--src/widgets/doc/images/pinchgesture.pngbin0 -> 10094 bytes
-rw-r--r--src/widgets/doc/images/plastique-calendarwidget.pngbin0 -> 9629 bytes
-rw-r--r--src/widgets/doc/images/plastique-checkbox.pngbin0 -> 1069 bytes
-rw-r--r--src/widgets/doc/images/plastique-colordialog.pngbin0 -> 22595 bytes
-rw-r--r--src/widgets/doc/images/plastique-combobox.pngbin0 -> 1714 bytes
-rw-r--r--src/widgets/doc/images/plastique-dateedit.pngbin0 -> 1271 bytes
-rw-r--r--src/widgets/doc/images/plastique-datetimeedit.pngbin0 -> 1771 bytes
-rw-r--r--src/widgets/doc/images/plastique-dial.pngbin0 -> 2995 bytes
-rw-r--r--src/widgets/doc/images/plastique-doublespinbox.pngbin0 -> 1102 bytes
-rw-r--r--src/widgets/doc/images/plastique-fontcombobox.pngbin0 -> 1904 bytes
-rw-r--r--src/widgets/doc/images/plastique-fontdialog.pngbin0 -> 23835 bytes
-rw-r--r--src/widgets/doc/images/plastique-frame.pngbin0 -> 5616 bytes
-rw-r--r--src/widgets/doc/images/plastique-groupbox.pngbin0 -> 2704 bytes
-rw-r--r--src/widgets/doc/images/plastique-horizontalscrollbar.pngbin0 -> 868 bytes
-rw-r--r--src/widgets/doc/images/plastique-label.pngbin0 -> 696 bytes
-rw-r--r--src/widgets/doc/images/plastique-lcdnumber.pngbin0 -> 470 bytes
-rw-r--r--src/widgets/doc/images/plastique-lineedit.pngbin0 -> 1015 bytes
-rw-r--r--src/widgets/doc/images/plastique-listview.pngbin0 -> 4895 bytes
-rw-r--r--src/widgets/doc/images/plastique-menu.pngbin0 -> 3867 bytes
-rw-r--r--src/widgets/doc/images/plastique-menubar.pngbin0 -> 1030 bytes
-rw-r--r--src/widgets/doc/images/plastique-progressbar.pngbin0 -> 1044 bytes
-rw-r--r--src/widgets/doc/images/plastique-progressdialog.pngbin0 -> 6311 bytes
-rw-r--r--src/widgets/doc/images/plastique-pushbutton-menu.pngbin0 -> 3354 bytes
-rw-r--r--src/widgets/doc/images/plastique-pushbutton.pngbin0 -> 1409 bytes
-rw-r--r--src/widgets/doc/images/plastique-radiobutton.pngbin0 -> 1667 bytes
-rw-r--r--src/widgets/doc/images/plastique-sizegrip.pngbin0 -> 8168 bytes
-rw-r--r--src/widgets/doc/images/plastique-slider.pngbin0 -> 632 bytes
-rw-r--r--src/widgets/doc/images/plastique-spinbox.pngbin0 -> 968 bytes
-rw-r--r--src/widgets/doc/images/plastique-statusbar.pngbin0 -> 878 bytes
-rw-r--r--src/widgets/doc/images/plastique-tabbar-truncated.pngbin0 -> 2986 bytes
-rw-r--r--src/widgets/doc/images/plastique-tabbar.pngbin0 -> 2721 bytes
-rw-r--r--src/widgets/doc/images/plastique-tableview.pngbin0 -> 6052 bytes
-rw-r--r--src/widgets/doc/images/plastique-tabwidget.pngbin0 -> 4705 bytes
-rw-r--r--src/widgets/doc/images/plastique-textedit.pngbin0 -> 5141 bytes
-rw-r--r--src/widgets/doc/images/plastique-timeedit.pngbin0 -> 1336 bytes
-rw-r--r--src/widgets/doc/images/plastique-toolbox.pngbin0 -> 1858 bytes
-rw-r--r--src/widgets/doc/images/plastique-toolbutton.pngbin0 -> 1254 bytes
-rw-r--r--src/widgets/doc/images/plastique-treeview.pngbin0 -> 8453 bytes
-rw-r--r--src/widgets/doc/images/progressBar-stylesheet.pngbin0 -> 455 bytes
-rw-r--r--src/widgets/doc/images/progressBar2-stylesheet.pngbin0 -> 494 bytes
-rw-r--r--src/widgets/doc/images/propagation-custom.pngbin0 -> 163413 bytes
-rw-r--r--src/widgets/doc/images/propagation-standard.pngbin0 -> 83382 bytes
-rw-r--r--src/widgets/doc/images/qcalendarwidget-grid.pngbin0 -> 9601 bytes
-rw-r--r--src/widgets/doc/images/qcalendarwidget-maximum.pngbin0 -> 9709 bytes
-rw-r--r--src/widgets/doc/images/qcalendarwidget-minimum.pngbin0 -> 9770 bytes
-rw-r--r--src/widgets/doc/images/qcolumnview.pngbin0 -> 3075 bytes
-rw-r--r--src/widgets/doc/images/qcompleter.pngbin0 -> 17017 bytes
-rw-r--r--src/widgets/doc/images/qdesktopwidget.pngbin0 -> 42328 bytes
-rw-r--r--src/widgets/doc/images/qformlayout-kde.pngbin0 -> 1703 bytes
-rw-r--r--src/widgets/doc/images/qformlayout-mac.pngbin0 -> 1706 bytes
-rw-r--r--src/widgets/doc/images/qformlayout-qpe.pngbin0 -> 1764 bytes
-rw-r--r--src/widgets/doc/images/qformlayout-win.pngbin0 -> 1743 bytes
-rw-r--r--src/widgets/doc/images/qformlayout-with-6-children.pngbin0 -> 3264 bytes
-rw-r--r--src/widgets/doc/images/qgraphicsproxywidget-embed.pngbin0 -> 2199 bytes
-rw-r--r--src/widgets/doc/images/qgridlayout-with-5-children.pngbin0 -> 3201 bytes
-rw-r--r--src/widgets/doc/images/qhboxlayout-with-5-children.pngbin0 -> 2652 bytes
-rw-r--r--src/widgets/doc/images/qmdisubwindowlayout.pngbin0 -> 3153 bytes
-rw-r--r--src/widgets/doc/images/qscrollarea-noscrollbars.pngbin0 -> 54671 bytes
-rw-r--r--src/widgets/doc/images/qscrollarea-onescrollbar.pngbin0 -> 77476 bytes
-rw-r--r--src/widgets/doc/images/qscrollarea-twoscrollbars.pngbin0 -> 78046 bytes
-rw-r--r--src/widgets/doc/images/qscrollbar-picture.pngbin0 -> 6568 bytes
-rw-r--r--src/widgets/doc/images/qscrollbar-values.pngbin0 -> 15902 bytes
-rw-r--r--src/widgets/doc/images/qspinbox-plusminus.pngbin0 -> 375 bytes
-rw-r--r--src/widgets/doc/images/qspinbox-updown.pngbin0 -> 402 bytes
-rw-r--r--src/widgets/doc/images/qstyle-comboboxes.pngbin0 -> 19437 bytes
-rw-r--r--src/widgets/doc/images/qstyleoptiontoolbar-position.pngbin0 -> 13707 bytes
-rw-r--r--src/widgets/doc/images/qtableview-resized.pngbin0 -> 42232 bytes
-rw-r--r--src/widgets/doc/images/qtwizard-aero1.pngbin0 -> 11749 bytes
-rw-r--r--src/widgets/doc/images/qtwizard-aero2.pngbin0 -> 16560 bytes
-rw-r--r--src/widgets/doc/images/qtwizard-classic1.pngbin0 -> 39640 bytes
-rw-r--r--src/widgets/doc/images/qtwizard-classic2.pngbin0 -> 8616 bytes
-rw-r--r--src/widgets/doc/images/qtwizard-mac1.pngbin0 -> 25478 bytes
-rw-r--r--src/widgets/doc/images/qtwizard-mac2.pngbin0 -> 29591 bytes
-rw-r--r--src/widgets/doc/images/qtwizard-macpage.pngbin0 -> 23095 bytes
-rw-r--r--src/widgets/doc/images/qtwizard-modern1.pngbin0 -> 45093 bytes
-rw-r--r--src/widgets/doc/images/qtwizard-modern2.pngbin0 -> 15081 bytes
-rw-r--r--src/widgets/doc/images/qtwizard-nonmacpage.pngbin0 -> 26557 bytes
-rw-r--r--src/widgets/doc/images/qundoview.pngbin0 -> 5993 bytes
-rw-r--r--src/widgets/doc/images/qvboxlayout-with-5-children.pngbin0 -> 2974 bytes
-rw-r--r--src/widgets/doc/images/readonlytable_role.pngbin0 -> 27467 bytes
-rw-r--r--src/widgets/doc/images/selected-items1.pngbin0 -> 31870 bytes
-rw-r--r--src/widgets/doc/images/selected-items2.pngbin0 -> 32025 bytes
-rw-r--r--src/widgets/doc/images/selected-items3.pngbin0 -> 32100 bytes
-rw-r--r--src/widgets/doc/images/selection-extended.pngbin0 -> 11401 bytes
-rw-r--r--src/widgets/doc/images/selection-multi.pngbin0 -> 13058 bytes
-rw-r--r--src/widgets/doc/images/selection-single.pngbin0 -> 7849 bytes
-rw-r--r--src/widgets/doc/images/selection2.pngbin0 -> 23784 bytes
-rw-r--r--src/widgets/doc/images/shareddirmodel.pngbin0 -> 45891 bytes
-rw-r--r--src/widgets/doc/images/sharedmodel-tableviews.pngbin0 -> 16811 bytes
-rw-r--r--src/widgets/doc/images/sharedselection-tableviews.pngbin0 -> 14212 bytes
-rw-r--r--src/widgets/doc/images/simpleanchorlayout-example.pngbin0 -> 13463 bytes
-rw-r--r--src/widgets/doc/images/spinboxdelegate-example.pngbin0 -> 4762 bytes
-rw-r--r--src/widgets/doc/images/standard-views.pngbin0 -> 44495 bytes
-rw-r--r--src/widgets/doc/images/standardwidget.pngbin0 -> 1466 bytes
-rw-r--r--src/widgets/doc/images/stardelegate.pngbin0 -> 12230 bytes
-rw-r--r--src/widgets/doc/images/stringlistmodel.pngbin0 -> 4849 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-border-image-normal.pngbin0 -> 5769 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-border-image-stretched.pngbin0 -> 12170 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-border-image-wrong.pngbin0 -> 12887 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-boxmodel.pngbin0 -> 18144 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-branch-closed.pngbin0 -> 334 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-branch-end.pngbin0 -> 182 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-branch-more.pngbin0 -> 136 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-branch-open.pngbin0 -> 346 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-coffee-cleanlooks.pngbin0 -> 14820 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-coffee-xp.pngbin0 -> 14200 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-pagefold-mac.pngbin0 -> 20618 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-pagefold.pngbin0 -> 15989 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-redbutton1.pngbin0 -> 378 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-redbutton2.pngbin0 -> 410 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-redbutton3.pngbin0 -> 664 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-scrollbar1.pngbin0 -> 150 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-scrollbar2.pngbin0 -> 169 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-treeview.pngbin0 -> 2412 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-vline.pngbin0 -> 124 bytes
-rw-r--r--src/widgets/doc/images/swipegesture.pngbin0 -> 6864 bytes
-rw-r--r--src/widgets/doc/images/system-tray.pngbin0 -> 6326 bytes
-rw-r--r--src/widgets/doc/images/tabWidget-stylesheet1.pngbin0 -> 1321 bytes
-rw-r--r--src/widgets/doc/images/tabWidget-stylesheet2.pngbin0 -> 1434 bytes
-rw-r--r--src/widgets/doc/images/tabWidget-stylesheet3.pngbin0 -> 1206 bytes
-rw-r--r--src/widgets/doc/images/tableWidget-stylesheet.pngbin0 -> 3478 bytes
-rwxr-xr-xsrc/widgets/doc/images/tableview.pngbin0 -> 10102 bytes
-rw-r--r--src/widgets/doc/images/tree_2_with_algorithm.pngbin0 -> 16921 bytes
-rw-r--r--src/widgets/doc/images/treeview.pngbin0 -> 17173 bytes
-rw-r--r--src/widgets/doc/images/widgetdelegate.pngbin0 -> 7449 bytes
-rw-r--r--src/widgets/doc/images/widgetmapper.pngbin0 -> 20145 bytes
-rw-r--r--src/widgets/doc/images/widgets-tutorial-childwidget.pngbin0 -> 8547 bytes
-rw-r--r--src/widgets/doc/images/widgets-tutorial-nestedlayouts.pngbin0 -> 23287 bytes
-rw-r--r--src/widgets/doc/images/widgets-tutorial-toplevel.pngbin0 -> 6087 bytes
-rw-r--r--src/widgets/doc/images/widgets-tutorial-windowlayout.pngbin0 -> 5849 bytes
-rw-r--r--src/widgets/doc/images/windows-calendarwidget.pngbin0 -> 5055 bytes
-rw-r--r--src/widgets/doc/images/windows-checkbox.pngbin0 -> 929 bytes
-rw-r--r--src/widgets/doc/images/windows-combobox.pngbin0 -> 1002 bytes
-rw-r--r--src/widgets/doc/images/windows-dateedit.pngbin0 -> 817 bytes
-rw-r--r--src/widgets/doc/images/windows-datetimeedit.pngbin0 -> 1026 bytes
-rw-r--r--src/widgets/doc/images/windows-dial.pngbin0 -> 4598 bytes
-rw-r--r--src/widgets/doc/images/windows-doublespinbox.pngbin0 -> 762 bytes
-rw-r--r--src/widgets/doc/images/windows-fontcombobox.pngbin0 -> 1022 bytes
-rw-r--r--src/widgets/doc/images/windows-frame.pngbin0 -> 1837 bytes
-rw-r--r--src/widgets/doc/images/windows-groupbox.pngbin0 -> 1617 bytes
-rw-r--r--src/widgets/doc/images/windows-horizontalscrollbar.pngbin0 -> 566 bytes
-rw-r--r--src/widgets/doc/images/windows-label.pngbin0 -> 696 bytes
-rw-r--r--src/widgets/doc/images/windows-lcdnumber.pngbin0 -> 491 bytes
-rw-r--r--src/widgets/doc/images/windows-lineedit.pngbin0 -> 884 bytes
-rw-r--r--src/widgets/doc/images/windows-listview.pngbin0 -> 2781 bytes
-rw-r--r--src/widgets/doc/images/windows-progressbar.pngbin0 -> 674 bytes
-rw-r--r--src/widgets/doc/images/windows-pushbutton.pngbin0 -> 722 bytes
-rw-r--r--src/widgets/doc/images/windows-radiobutton.pngbin0 -> 1005 bytes
-rw-r--r--src/widgets/doc/images/windows-slider.pngbin0 -> 485 bytes
-rw-r--r--src/widgets/doc/images/windows-spinbox.pngbin0 -> 667 bytes
-rw-r--r--src/widgets/doc/images/windows-tableview.pngbin0 -> 1738 bytes
-rw-r--r--src/widgets/doc/images/windows-tabwidget.pngbin0 -> 1707 bytes
-rw-r--r--src/widgets/doc/images/windows-textedit.pngbin0 -> 3192 bytes
-rw-r--r--src/widgets/doc/images/windows-timeedit.pngbin0 -> 873 bytes
-rw-r--r--src/widgets/doc/images/windows-toolbox.pngbin0 -> 925 bytes
-rw-r--r--src/widgets/doc/images/windows-toolbutton.pngbin0 -> 771 bytes
-rw-r--r--src/widgets/doc/images/windows-treeview.pngbin0 -> 2723 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-calendarwidget.pngbin0 -> 5144 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-checkbox.pngbin0 -> 1115 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-combobox.pngbin0 -> 1457 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-dateedit.pngbin0 -> 855 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-datetimeedit.pngbin0 -> 1034 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-dial.pngbin0 -> 2431 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-doublespinbox.pngbin0 -> 852 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-fontcombobox.pngbin0 -> 919 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-frame.pngbin0 -> 1800 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-groupbox.pngbin0 -> 1991 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-horizontalscrollbar.pngbin0 -> 1049 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-label.pngbin0 -> 599 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-lcdnumber.pngbin0 -> 491 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-lineedit.pngbin0 -> 873 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-listview.pngbin0 -> 6872 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-progressbar.pngbin0 -> 1437 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-pushbutton.pngbin0 -> 1085 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-radiobutton.pngbin0 -> 1266 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-slider.pngbin0 -> 624 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-spinbox.pngbin0 -> 767 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-tableview.pngbin0 -> 3941 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-tabwidget.pngbin0 -> 3286 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-textedit.pngbin0 -> 3122 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-timeedit.pngbin0 -> 764 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-toolbox.pngbin0 -> 891 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-toolbutton.pngbin0 -> 981 bytes
-rw-r--r--src/widgets/doc/images/windowsvista-treeview.pngbin0 -> 5760 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-calendarwidget.pngbin0 -> 5009 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-checkbox.pngbin0 -> 1006 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-combobox.pngbin0 -> 1450 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-dateedit.pngbin0 -> 1107 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-datetimeedit.pngbin0 -> 1321 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-dial.pngbin0 -> 4598 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-doublespinbox.pngbin0 -> 1065 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-fontcombobox.pngbin0 -> 1408 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-frame.pngbin0 -> 1837 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-groupbox.pngbin0 -> 2016 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-horizontalscrollbar.pngbin0 -> 1498 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-label.pngbin0 -> 696 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-lcdnumber.pngbin0 -> 493 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-lineedit.pngbin0 -> 861 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-listview.pngbin0 -> 5391 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-menu.pngbin0 -> 1442 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-progressbar.pngbin0 -> 1007 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-pushbutton.pngbin0 -> 1462 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-radiobutton.pngbin0 -> 1270 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-slider.pngbin0 -> 732 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-spinbox.pngbin0 -> 974 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-tableview.pngbin0 -> 3204 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-tabwidget.pngbin0 -> 5220 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-textedit.pngbin0 -> 3159 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-timeedit.pngbin0 -> 1172 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-toolbox.pngbin0 -> 925 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-toolbutton.pngbin0 -> 1549 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-treeview.pngbin0 -> 5795 bytes
-rw-r--r--src/widgets/doc/qtwidgets.qdocconf92
-rw-r--r--src/widgets/doc/snippets/code/doc_src_layout.cpp166
-rw-r--r--src/widgets/doc/snippets/code/doc_src_model-view-programming.cpp76
-rw-r--r--src/widgets/doc/snippets/code/doc_src_qt4-mainwindow.cpp110
-rw-r--r--src/widgets/doc/snippets/code/doc_src_qt4-styles.cpp82
-rw-r--r--src/widgets/doc/snippets/code/doc_src_qtwidgets.cpp43
-rw-r--r--src/widgets/doc/snippets/code/doc_src_qtwidgets.pro3
-rw-r--r--src/widgets/doc/snippets/code/doc_src_styles.cpp134
-rw-r--r--src/widgets/doc/snippets/code/doc_src_stylesheet.cpp140
-rw-r--r--src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc1866
-rw-r--r--src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp131
-rw-r--r--src/widgets/doc/snippets/code/src_gui_dialogs_qfontdialog.cpp85
-rw-r--r--src/widgets/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp148
-rw-r--r--src/widgets/doc/snippets/code/src_gui_dialogs_qwizard.cpp80
-rw-r--r--src/widgets/doc/snippets/code/src_gui_effects_qgraphicseffect.cpp83
-rw-r--r--src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp53
-rw-r--r--src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp278
-rw-r--r--src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp53
-rw-r--r--src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp87
-rw-r--r--src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp122
-rw-r--r--src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp45
-rw-r--r--src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp132
-rw-r--r--src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp66
-rw-r--r--src/widgets/doc/snippets/code/src_gui_image_qicon.cpp71
-rw-r--r--src/widgets/doc/snippets/code/src_gui_image_qpixmapfilter.cpp62
-rw-r--r--src/widgets/doc/snippets/code/src_gui_itemviews_qabstractitemview.cpp58
-rw-r--r--src/widgets/doc/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp63
-rw-r--r--src/widgets/doc/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp63
-rw-r--r--src/widgets/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp82
-rw-r--r--src/widgets/doc/snippets/code/src_gui_itemviews_qtablewidget.cpp45
-rw-r--r--src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp48
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qaction.cpp49
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp183
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp76
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp67
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp53
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qshortcut.cpp55
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp137
-rw-r--r--src/widgets/doc/snippets/code/src_gui_painting_qdrawutil.cpp98
-rw-r--r--src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp85
-rw-r--r--src/widgets/doc/snippets/code/src_gui_styles_qstyle.cpp48
-rw-r--r--src/widgets/doc/snippets/code/src_gui_styles_qstyleoption.cpp54
-rw-r--r--src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp63
-rw-r--r--src/widgets/doc/snippets/code/src_gui_util_qundostack.cpp109
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qabstractbutton.cpp60
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qabstractspinbox.cpp48
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qcalendarwidget.cpp79
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qcheckbox.cpp43
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qdatetimeedit.cpp79
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qdockwidget.cpp48
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qframe.cpp48
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qgroupbox.cpp43
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qlabel.cpp64
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qlineedit.cpp50
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qmainwindow.cpp59
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qmenu.cpp77
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp48
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qplaintextedit.cpp55
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qpushbutton.cpp43
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qradiobutton.cpp43
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qrubberband.cpp62
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qscrollarea.cpp49
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qspinbox.cpp80
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp55
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qsplitter.cpp47
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qstatusbar.cpp43
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qtextbrowser.cpp44
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qtextedit.cpp60
-rw-r--r--src/widgets/doc/snippets/customstyle/customstyle.cpp92
-rw-r--r--src/widgets/doc/snippets/customstyle/customstyle.h60
-rw-r--r--src/widgets/doc/snippets/customstyle/customstyle.pro2
-rw-r--r--src/widgets/doc/snippets/customstyle/main.cpp54
-rw-r--r--src/widgets/doc/snippets/customviewstyle.cpp69
-rw-r--r--src/widgets/doc/snippets/dialogs/dialogs.cpp268
-rw-r--r--src/widgets/doc/snippets/dockwidgets/mainwindow.cpp122
-rw-r--r--src/widgets/doc/snippets/filedialogurls.cpp61
-rw-r--r--src/widgets/doc/snippets/graphicssceneadditemsnippet.cpp80
-rw-r--r--src/widgets/doc/snippets/itemselection/itemselection.pro3
-rw-r--r--src/widgets/doc/snippets/itemselection/main.cpp115
-rw-r--r--src/widgets/doc/snippets/itemselection/model.cpp238
-rw-r--r--src/widgets/doc/snippets/itemselection/model.h74
-rw-r--r--src/widgets/doc/snippets/javastyle.cpp2745
-rw-r--r--src/widgets/doc/snippets/layouts/layouts.cpp165
-rw-r--r--src/widgets/doc/snippets/mainwindowsnippet.cpp92
-rw-r--r--src/widgets/doc/snippets/mdiareasnippets.cpp97
-rw-r--r--src/widgets/doc/snippets/myscrollarea.cpp128
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/main.cpp51
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/mainwindow.cpp83
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/mainwindow.h61
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/model.cpp167
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/model.h73
-rw-r--r--src/widgets/doc/snippets/qlistview-dnd/qlistview-dnd.pro5
-rw-r--r--src/widgets/doc/snippets/qlistwidget-dnd/main.cpp51
-rw-r--r--src/widgets/doc/snippets/qlistwidget-dnd/mainwindow.cpp87
-rw-r--r--src/widgets/doc/snippets/qlistwidget-dnd/mainwindow.h62
-rw-r--r--src/widgets/doc/snippets/qlistwidget-dnd/qlistwidget-dnd.pro3
-rw-r--r--src/widgets/doc/snippets/qlistwidget-using/mainwindow.cpp158
-rw-r--r--src/widgets/doc/snippets/qmacnativewidget/main.mm84
-rw-r--r--src/widgets/doc/snippets/qsortfilterproxymodel/main.cpp77
-rw-r--r--src/widgets/doc/snippets/qsortfilterproxymodel/qsortfilterproxymodel.pro1
-rw-r--r--src/widgets/doc/snippets/qsplashscreen/main.cpp63
-rw-r--r--src/widgets/doc/snippets/qstackedlayout/main.cpp89
-rw-r--r--src/widgets/doc/snippets/qstackedwidget/main.cpp87
-rw-r--r--src/widgets/doc/snippets/qstyleoption/main.cpp139
-rw-r--r--src/widgets/doc/snippets/qstyleplugin/main.cpp97
-rw-r--r--src/widgets/doc/snippets/qtablewidget-resizing/mainwindow.cpp115
-rw-r--r--src/widgets/doc/snippets/qtablewidget-using/Images/cubed.pngbin0 -> 437 bytes
-rw-r--r--src/widgets/doc/snippets/qtablewidget-using/Images/squared.pngbin0 -> 440 bytes
-rw-r--r--src/widgets/doc/snippets/qtablewidget-using/images.qrc6
-rw-r--r--src/widgets/doc/snippets/qtablewidget-using/main.cpp51
-rw-r--r--src/widgets/doc/snippets/qtablewidget-using/mainwindow.cpp150
-rw-r--r--src/widgets/doc/snippets/qtablewidget-using/mainwindow.h70
-rw-r--r--src/widgets/doc/snippets/qtablewidget-using/qtablewidget-using.pro4
-rw-r--r--src/widgets/doc/snippets/qtreewidget-using/mainwindow.cpp230
-rw-r--r--src/widgets/doc/snippets/qtreewidgetitemiterator-using/mainwindow.cpp197
-rw-r--r--src/widgets/doc/snippets/reading-selections/main.cpp59
-rw-r--r--src/widgets/doc/snippets/reading-selections/model.cpp238
-rw-r--r--src/widgets/doc/snippets/reading-selections/model.h74
-rw-r--r--src/widgets/doc/snippets/reading-selections/reading-selections.pro2
-rw-r--r--src/widgets/doc/snippets/reading-selections/window.cpp120
-rw-r--r--src/widgets/doc/snippets/reading-selections/window.h67
-rw-r--r--src/widgets/doc/snippets/shareddirmodel/main.cpp81
-rw-r--r--src/widgets/doc/snippets/sharedtablemodel/main.cpp89
-rw-r--r--src/widgets/doc/snippets/sharedtablemodel/model.cpp236
-rw-r--r--src/widgets/doc/snippets/sharedtablemodel/model.h74
-rw-r--r--src/widgets/doc/snippets/sharedtablemodel/sharedtablemodel.pro2
-rw-r--r--src/widgets/doc/snippets/simplemodel-use/main.cpp95
-rw-r--r--src/widgets/doc/snippets/simplemodel-use/simplemodel-use.pro1
-rw-r--r--src/widgets/doc/snippets/splitter/splitter.cpp84
-rw-r--r--src/widgets/doc/snippets/splitterhandle/splitter.cpp78
-rw-r--r--src/widgets/doc/snippets/splitterhandle/splitter.h73
-rw-r--r--src/widgets/doc/snippets/stringlistmodel/main.cpp83
-rw-r--r--src/widgets/doc/snippets/stringlistmodel/model.cpp211
-rw-r--r--src/widgets/doc/snippets/stringlistmodel/model.h82
-rw-r--r--src/widgets/doc/snippets/stringlistmodel/stringlistmodel.pro3
-rw-r--r--src/widgets/doc/snippets/styles/styles.cpp91
-rw-r--r--src/widgets/doc/snippets/stylesheet/common-mistakes.cpp52
-rw-r--r--src/widgets/doc/snippets/textdocument-imagedrop/textedit.cpp71
-rw-r--r--src/widgets/doc/snippets/timeline/main.cpp72
-rw-r--r--src/widgets/doc/snippets/updating-selections/main.cpp59
-rw-r--r--src/widgets/doc/snippets/updating-selections/model.cpp236
-rw-r--r--src/widgets/doc/snippets/updating-selections/model.h74
-rw-r--r--src/widgets/doc/snippets/updating-selections/updating-selections.pro2
-rw-r--r--src/widgets/doc/snippets/updating-selections/window.cpp109
-rw-r--r--src/widgets/doc/snippets/updating-selections/window.h67
-rw-r--r--src/widgets/doc/snippets/whatsthis/whatsthis.cpp64
-rw-r--r--src/widgets/doc/snippets/widget-mask/main.cpp54
-rw-r--r--src/widgets/doc/snippets/widgetdelegate.cpp66
-rw-r--r--src/widgets/doc/snippets/widgets-tutorial/template.cpp56
-rw-r--r--src/widgets/doc/src/addressbook-fr.qdoc1036
-rw-r--r--src/widgets/doc/src/addressbook.qdoc981
-rw-r--r--src/widgets/doc/src/model-view-programming.qdoc2339
-rw-r--r--src/widgets/doc/src/modelview.qdoc897
-rw-r--r--src/widgets/doc/src/qtwidgets.qdoc45
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/focus.qdoc186
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery-cde.qdoc133
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery-cleanlooks.qdoc138
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery-gtk.qdoc141
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery-macintosh.qdoc138
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery-motif.qdoc138
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery-plastique.qdoc138
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery-windows.qdoc138
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery-windowsvista.qdoc138
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery-windowsxp.qdoc138
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery.qdoc84
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/layout.qdoc396
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/styles.qdoc2102
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc3963
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/widgets.qdoc162
-rw-r--r--src/widgets/doc/src/widgets-tutorial.qdoc249
-rw-r--r--src/widgets/doc/src/windows-and-dialogs/dialogs.qdoc60
-rw-r--r--src/widgets/doc/src/windows-and-dialogs/mainwindow.qdoc261
-rw-r--r--src/widgets/effects/qgraphicseffect.cpp6
-rw-r--r--src/widgets/effects/qpixmapfilter.cpp6
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout.cpp12
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayout.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp48
-rw-r--r--src/widgets/graphicsview/qgraphicsitemanimation.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicslinearlayout.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp6
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp14
-rw-r--r--src/widgets/graphicsview/qgraphicssceneevent.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp16
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.cpp6
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.cpp2
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp6
-rw-r--r--src/widgets/itemviews/qdatawidgetmapper.cpp6
-rw-r--r--src/widgets/itemviews/qitemdelegate.cpp20
-rw-r--r--src/widgets/itemviews/qitemeditorfactory.cpp8
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp12
-rw-r--r--src/widgets/itemviews/qstandarditemmodel.cpp10
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.cpp18
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp14
-rw-r--r--src/widgets/itemviews/qtreeview.cpp4
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp6
-rw-r--r--src/widgets/itemviews/qtreewidgetitemiterator.cpp2
-rw-r--r--src/widgets/kernel/qaction.cpp10
-rw-r--r--src/widgets/kernel/qactiongroup.cpp6
-rw-r--r--src/widgets/kernel/qapplication.cpp36
-rw-r--r--src/widgets/kernel/qboxlayout.cpp24
-rw-r--r--src/widgets/kernel/qformlayout.cpp6
-rw-r--r--src/widgets/kernel/qicon.cpp10
-rw-r--r--src/widgets/kernel/qlayout.cpp4
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp2
-rw-r--r--src/widgets/kernel/qshortcut.cpp10
-rw-r--r--src/widgets/kernel/qstackedlayout.cpp8
-rw-r--r--src/widgets/kernel/qwhatsthis.cpp2
-rw-r--r--src/widgets/kernel/qwidget.cpp30
-rw-r--r--src/widgets/styles/qdrawutil.cpp20
-rw-r--r--src/widgets/styles/qproxystyle.cpp2
-rw-r--r--src/widgets/styles/qstyle.cpp30
-rw-r--r--src/widgets/styles/qstyleoption.cpp8
-rw-r--r--src/widgets/styles/qstylepainter.cpp8
-rw-r--r--src/widgets/styles/qstyleplugin.cpp6
-rw-r--r--src/widgets/util/qcompleter.cpp6
-rw-r--r--src/widgets/util/qundostack.cpp12
-rw-r--r--src/widgets/widgets.pro3
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp6
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp4
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp4
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp12
-rw-r--r--src/widgets/widgets/qcheckbox.cpp2
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp14
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp8
-rw-r--r--src/widgets/widgets/qdockwidget.cpp2
-rw-r--r--src/widgets/widgets/qframe.cpp2
-rw-r--r--src/widgets/widgets/qgroupbox.cpp4
-rw-r--r--src/widgets/widgets/qlabel.cpp6
-rw-r--r--src/widgets/widgets/qlineedit.cpp2
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.mm2
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.mm4
-rw-r--r--src/widgets/widgets/qmainwindow.cpp12
-rw-r--r--src/widgets/widgets/qmdiarea.cpp4
-rw-r--r--src/widgets/widgets/qmenu.cpp14
-rw-r--r--src/widgets/widgets/qmenubar.cpp12
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp8
-rw-r--r--src/widgets/widgets/qpushbutton.cpp2
-rw-r--r--src/widgets/widgets/qradiobutton.cpp2
-rw-r--r--src/widgets/widgets/qrubberband.cpp2
-rw-r--r--src/widgets/widgets/qscrollarea.cpp2
-rw-r--r--src/widgets/widgets/qspinbox.cpp20
-rw-r--r--src/widgets/widgets/qsplashscreen.cpp6
-rw-r--r--src/widgets/widgets/qsplitter.cpp14
-rw-r--r--src/widgets/widgets/qstackedwidget.cpp8
-rw-r--r--src/widgets/widgets/qstatusbar.cpp6
-rw-r--r--src/widgets/widgets/qtextbrowser.cpp2
-rw-r--r--src/widgets/widgets/qtextedit.cpp14
722 files changed, 31041 insertions, 513 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 0dd3d3cdfc..7a4c30f399 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -1717,7 +1717,7 @@ QColor QColorDialog::currentColor() const
}
/*!
- Returns the color that the user selected by clicking the \gui{OK}
+ Returns the color that the user selected by clicking the \uicontrol{OK}
or equivalent button.
\note This color is not always the same as the color held by the
@@ -1795,7 +1795,7 @@ QColorDialog::ColorDialogOptions QColorDialog::options() const
of a color dialog.
\value ShowAlphaChannel Allow the user to select the alpha component of a color.
- \value NoButtons Don't display \gui{OK} and \gui{Cancel} buttons. (Useful for "live dialogs".)
+ \value NoButtons Don't display \uicontrol{OK} and \uicontrol{Cancel} buttons. (Useful for "live dialogs".)
\value DontUseNativeDialog Use Qt's standard color dialog on the Mac instead of Apple's
native color panel.
@@ -1819,7 +1819,7 @@ bool QColorDialogPrivate::sharedColorPanelAvailable = true;
/*!
\fn void QColorDialog::colorSelected(const QColor &color);
- This signal is emitted just after the user has clicked \gui{OK} to
+ This signal is emitted just after the user has clicked \uicontrol{OK} to
select a color to use. The chosen color is specified by \a color.
\sa color, currentColorChanged()
@@ -1933,7 +1933,7 @@ QColor QColorDialog::getColor(const QColor &initial, QWidget *parent, const QStr
initially set to \a initial. The dialog is a child of \a parent.
If \a ok is non-null, \e *\a ok is set to true if the user clicked
- \gui{OK}, and to false if the user clicked Cancel.
+ \uicontrol{OK}, and to false if the user clicked Cancel.
If the user clicks Cancel, the \a initial value is returned.
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index f3e0773eac..26e6293b7d 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -180,8 +180,8 @@ void QDialogPrivate::deletePlatformHelper()
exec() function. When the user closes the dialog, exec() will
provide a useful \link #return return value\endlink. Typically,
to get the dialog to close and return the appropriate value, we
- connect a default button, e.g. \gui OK, to the accept() slot and a
- \gui Cancel button to the reject() slot.
+ connect a default button, e.g. \uicontrol OK, to the accept() slot and a
+ \uicontrol Cancel button to the reject() slot.
Alternatively you can call the done() slot with \c Accepted or
\c Rejected.
@@ -238,7 +238,7 @@ void QDialogPrivate::deletePlatformHelper()
partial dialog that shows the most commonly used options, and a
full dialog that shows all the options. Typically an extensible
dialog will initially appear as a partial dialog, but with a
- \gui More toggle button. If the user presses the \gui More button down,
+ \uicontrol More toggle button. If the user presses the \uicontrol More button down,
the dialog is expanded. The \l{Extension Example} shows how to achieve
extensible dialogs using Qt.
@@ -246,8 +246,8 @@ void QDialogPrivate::deletePlatformHelper()
\section1 Return Value (Modal Dialogs)
Modal dialogs are often used in situations where a return value is
- required, e.g. to indicate whether the user pressed \gui OK or
- \gui Cancel. A dialog can be closed by calling the accept() or the
+ required, e.g. to indicate whether the user pressed \uicontrol OK or
+ \uicontrol Cancel. A dialog can be closed by calling the accept() or the
reject() slots, and exec() will return \c Accepted or \c Rejected
as appropriate. The exec() call returns the result of the dialog.
The result is also available from result() if the dialog has not
@@ -264,11 +264,11 @@ void QDialogPrivate::deletePlatformHelper()
A modal dialog:
- \snippet doc/src/snippets/dialogs/dialogs.cpp 1
+ \snippet dialogs/dialogs.cpp 1
A modeless dialog:
- \snippet doc/src/snippets/dialogs/dialogs.cpp 0
+ \snippet dialogs/dialogs.cpp 0
\sa QDialogButtonBox, QTabWidget, QWidget, QProgressDialog,
{fowler}{GUI Design Handbook: Dialogs, Standard}, {Extension Example},
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 057728e254..18b98b50f3 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -108,7 +108,7 @@ Q_WIDGETS_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_h
functions. On Windows, Mac OS X, KDE and GNOME, these static functions will
call the native file dialog when possible.
- \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 0
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 0
In the above example, a modal QFileDialog is created using a static
function. The dialog initially displays the contents of the "/home/jana"
@@ -119,13 +119,13 @@ Q_WIDGETS_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_h
If you want to use multiple filters, separate each one with
\e two semicolons. For example:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 1
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 1
You can create your own QFileDialog without using the static
functions. By calling setFileMode(), you can specify what the user must
select in the dialog:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 2
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 2
In the above example, the mode of the file dialog is set to
AnyFile, meaning that the user can select any file, or even specify a
@@ -138,7 +138,7 @@ Q_WIDGETS_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_h
this indicates what types of objects the user is expected to select.
Use setNameFilter() to set the dialog's file filter. For example:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 3
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 3
In the above example, the filter is set to \c{"Images (*.png *.xpm *.jpg)"},
this means that only files with the extension \c png, \c xpm,
@@ -154,12 +154,12 @@ Q_WIDGETS_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_h
information alongside each name, such as the file size and modification
date. Set the mode with setViewMode():
- \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 4
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 4
The last important function you will need to use when creating your
own file dialog is selectedFiles().
- \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 5
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 5
In the above example, a modal file dialog is created and shown. If
the user clicked OK, the file they selected is put in \c fileName.
@@ -375,7 +375,7 @@ QFileDialog::~QFileDialog()
For instance:
- \snippet doc/src/snippets/filedialogurls.cpp 0
+ \snippet filedialogurls.cpp 0
The file dialog will then look like this:
@@ -1098,7 +1098,7 @@ QStringList qt_make_filter_list(const QString &filter)
text contained in the parentheses is used as the filter. This means
that these calls are all equivalent:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 6
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 6
\sa setNameFilters()
*/
@@ -1154,7 +1154,7 @@ QStringList qt_strip_filters(const QStringList &filters)
Sets the \a filters used in the file dialog.
- \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 7
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 7
*/
void QFileDialog::setNameFilters(const QStringList &filters)
{
@@ -1705,7 +1705,7 @@ extern QString qt_win_get_existing_directory(const QFileDialogArgs &args);
This is a convenience static function that returns an existing file
selected by the user. If the user presses Cancel, it returns a null string.
- \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 8
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 8
The function creates a modal file dialog with the given \a parent widget.
If \a parent is not 0, the dialog will be shown centered over the parent
@@ -1787,7 +1787,7 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
This is a convenience static function that will return one or more existing
files selected by the user.
- \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 9
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 9
This function creates a modal file dialog with the given \a parent widget.
If \a parent is not 0, the dialog will be shown centered over the parent
@@ -1824,7 +1824,7 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
\note If you want to iterate over the list of files, you should iterate
over a copy. For example:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 10
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 10
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
@@ -1876,7 +1876,7 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
\a parent is not 0, the dialog will be shown centered over the parent
widget.
- \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 11
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 11
The file dialog's working directory will be set to \a dir. If \a dir
includes a file name, the file will be selected. Only files that match the
@@ -1960,7 +1960,7 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
This is a convenience static function that will return an existing
directory selected by the user.
- \snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 12
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 12
This function creates a modal file dialog with the given \a parent widget.
If \a parent is not 0, the dialog will be shown centered over the parent
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 40cc100c53..06733a8932 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -95,16 +95,16 @@ QT_BEGIN_NAMESPACE
A directory model that displays the contents of a default directory
is usually constructed with a parent object:
- \snippet doc/src/snippets/shareddirmodel/main.cpp 2
+ \snippet shareddirmodel/main.cpp 2
A tree view can be used to display the contents of the model
- \snippet doc/src/snippets/shareddirmodel/main.cpp 4
+ \snippet shareddirmodel/main.cpp 4
and the contents of a particular directory can be displayed by
setting the tree view's root index:
- \snippet doc/src/snippets/shareddirmodel/main.cpp 7
+ \snippet shareddirmodel/main.cpp 7
The view's root index can be used to control how much of a
hierarchical model is displayed. QDirModel provides a convenience
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index 3e3a149386..b13e87b4de 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -122,10 +122,10 @@ static const Qt::WindowFlags DefaultWindowFlags =
Examples:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 0
+ \snippet code/src_gui_dialogs_qfontdialog.cpp 0
The dialog can also be used to set a widget's font directly:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 1
+ \snippet code/src_gui_dialogs_qfontdialog.cpp 1
If the user clicks OK the font they chose will be used for myWidget,
and if they click Cancel the original font is used.
@@ -345,20 +345,20 @@ QFontDialog::~QFontDialog()
/*!
Executes a modal font dialog and returns a font.
- If the user clicks \gui OK, the selected font is returned. If the user
- clicks \gui Cancel, the \a initial font is returned.
+ If the user clicks \uicontrol OK, the selected font is returned. If the user
+ clicks \uicontrol Cancel, the \a initial font is returned.
The dialog is constructed with the given \a parent and the options specified
in \a options. \a title is shown as the window title of the dialog and \a
initial is the initially selected font. If the \a ok parameter is not-null,
- the value it refers to is set to true if the user clicks \gui OK, and set to
- false if the user clicks \gui Cancel.
+ the value it refers to is set to true if the user clicks \uicontrol OK, and set to
+ false if the user clicks \uicontrol Cancel.
Examples:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 2
+ \snippet code/src_gui_dialogs_qfontdialog.cpp 2
The dialog can also be used to set a widget's font directly:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 3
+ \snippet code/src_gui_dialogs_qfontdialog.cpp 3
In this example, if the user clicks OK the font they chose will be
used, and if they click Cancel the original font is used.
@@ -377,16 +377,16 @@ QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, cons
Executes a modal font dialog and returns a font.
- If the user clicks \gui OK, the selected font is returned. If the user
- clicks \gui Cancel, the Qt default font is returned.
+ If the user clicks \uicontrol OK, the selected font is returned. If the user
+ clicks \uicontrol Cancel, the Qt default font is returned.
The dialog is constructed with the given \a parent.
If the \a ok parameter is not-null, the value it refers to is set
- to true if the user clicks \gui OK, and false if the user clicks
- \gui Cancel.
+ to true if the user clicks \uicontrol OK, and false if the user clicks
+ \uicontrol Cancel.
Example:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 4
+ \snippet code/src_gui_dialogs_qfontdialog.cpp 4
\warning Do not delete \a parent during the execution of the dialog.
If you want to do this, you should create the dialog
@@ -829,7 +829,7 @@ QFont QFontDialog::currentFont() const
}
/*!
- Returns the font that the user selected by clicking the \gui{OK}
+ Returns the font that the user selected by clicking the \uicontrol{OK}
or equivalent button.
\note This font is not always the same as the font held by the
@@ -849,7 +849,7 @@ QFont QFontDialog::selectedFont() const
This enum specifies various options that affect the look and feel
of a font dialog.
- \value NoButtons Don't display \gui{OK} and \gui{Cancel} buttons. (Useful for "live dialogs".)
+ \value NoButtons Don't display \uicontrol{OK} and \uicontrol{Cancel} buttons. (Useful for "live dialogs".)
\value DontUseNativeDialog Use Qt's standard font dialog on the Mac instead of Apple's
native font panel. (Currently, the native dialog is never used,
but this is likely to change in future Qt releases.)
diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp
index 737d6bb467..13be3fcbe4 100644
--- a/src/widgets/dialogs/qinputdialog.cpp
+++ b/src/widgets/dialogs/qinputdialog.cpp
@@ -442,9 +442,9 @@ void QInputDialogPrivate::_q_currentRowChanged(const QModelIndex &newIndex,
getDouble(), and getItem(). All the functions can be used in a similar way,
for example:
- \snippet examples/dialogs/standarddialogs/dialog.cpp 3
+ \snippet dialogs/standarddialogs/dialog.cpp 3
- The \c ok variable is set to true if the user clicks \gui OK; otherwise it
+ The \c ok variable is set to true if the user clicks \uicontrol OK; otherwise it
is set to false.
\img inputdialogs.png Input Dialogs
@@ -576,7 +576,7 @@ QString QInputDialog::labelText() const
This enum specifies various options that affect the look and feel
of an input dialog.
- \value NoButtons Don't display \gui{OK} and \gui{Cancel} buttons. (Useful for "live dialogs".)
+ \value NoButtons Don't display \uicontrol{OK} and \uicontrol{Cancel} buttons. (Useful for "live dialogs".)
\value UseListViewForComboBoxItems Use a QListView rather than a non-editable QComboBox for
displaying the items set with setComboBoxItems().
@@ -1133,7 +1133,7 @@ void QInputDialog::done(int result)
edit widget if an input method is active.
If \a ok is nonnull \e *\a ok will be set to true if the user pressed
- \gui OK and to false if the user pressed \gui Cancel. The dialog's parent
+ \uicontrol OK and to false if the user pressed \uicontrol Cancel. The dialog's parent
is \a parent. The dialog will be modal and uses the specified widget
\a flags.
@@ -1142,7 +1142,7 @@ void QInputDialog::done(int result)
Use this static function like this:
- \snippet examples/dialogs/standarddialogs/dialog.cpp 3
+ \snippet dialogs/standarddialogs/dialog.cpp 3
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
@@ -1185,8 +1185,8 @@ QString QInputDialog::getText(QWidget *parent, const QString &title, const QStri
\a step is the amount by which the values change as the user presses the
arrow buttons to increment or decrement the value.
- If \a ok is nonnull *\a ok will be set to true if the user pressed \gui OK
- and to false if the user pressed \gui Cancel. The dialog's parent is
+ If \a ok is nonnull *\a ok will be set to true if the user pressed \uicontrol OK
+ and to false if the user pressed \uicontrol Cancel. The dialog's parent is
\a parent. The dialog will be modal and uses the widget \a flags.
On success, this function returns the integer which has been entered by the
@@ -1194,7 +1194,7 @@ QString QInputDialog::getText(QWidget *parent, const QString &title, const QStri
Use this static function like this:
- \snippet examples/dialogs/standarddialogs/dialog.cpp 0
+ \snippet dialogs/standarddialogs/dialog.cpp 0
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
@@ -1234,8 +1234,8 @@ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &l
\a min and \a max are the minimum and maximum values the user may choose.
\a decimals is the maximum number of decimal places the number may have.
- If \a ok is nonnull, *\a ok will be set to true if the user pressed \gui OK
- and to false if the user pressed \gui Cancel. The dialog's parent is
+ If \a ok is nonnull, *\a ok will be set to true if the user pressed \uicontrol OK
+ and to false if the user pressed \uicontrol Cancel. The dialog's parent is
\a parent. The dialog will be modal and uses the widget \a flags.
This function returns the floating point number which has been entered by
@@ -1243,7 +1243,7 @@ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &l
Use this static function like this:
- \snippet examples/dialogs/standarddialogs/dialog.cpp 1
+ \snippet dialogs/standarddialogs/dialog.cpp 1
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
@@ -1289,7 +1289,7 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr
user may only select one of the existing items.
If \a ok is nonnull \e *\a ok will be set to true if the user pressed
- \gui OK and to false if the user pressed \gui Cancel. The dialog's parent
+ \uicontrol OK and to false if the user pressed \uicontrol Cancel. The dialog's parent
is \a parent. The dialog will be modal and uses the widget \a flags.
This function returns the text of the current item, or if \a editable is
@@ -1297,7 +1297,7 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr
Use this static function like this:
- \snippet examples/dialogs/standarddialogs/dialog.cpp 2
+ \snippet dialogs/standarddialogs/dialog.cpp 2
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
@@ -1379,7 +1379,7 @@ QString QInputDialog::getItem(QWidget *parent, const QString &title, const QStri
\fn void QInputDialog::doubleValueSelected(double value)
This signal is emitted whenever the user selects a double value by
- accepting the dialog; for example, by clicking the \gui{OK} button.
+ accepting the dialog; for example, by clicking the \uicontrol{OK} button.
The selected value is specified by \a value.
This signal is only relevant when the input dialog is used in
@@ -1400,7 +1400,7 @@ QString QInputDialog::getItem(QWidget *parent, const QString &title, const QStri
\fn void QInputDialog::intValueSelected(int value)
This signal is emitted whenever the user selects a integer value by
- accepting the dialog; for example, by clicking the \gui{OK} button.
+ accepting the dialog; for example, by clicking the \uicontrol{OK} button.
The selected value is specified by \a value.
This signal is only relevant when the input dialog is used in
@@ -1421,7 +1421,7 @@ QString QInputDialog::getItem(QWidget *parent, const QString &title, const QStri
\fn void QInputDialog::textValueSelected(const QString &text)
This signal is emitted whenever the user selects a text string by
- accepting the dialog; for example, by clicking the \gui{OK} button.
+ accepting the dialog; for example, by clicking the \uicontrol{OK} button.
The selected string is specified by \a text.
This signal is only relevant when the input dialog is used in
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 784748fe73..cb32de4bca 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -498,9 +498,9 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
the message. The simplest configuration is to set only the
\l{QMessageBox::text} {message text} property.
- \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 5
+ \snippet code/src_gui_dialogs_qmessagebox.cpp 5
- The user must click the \gui{OK} button to dismiss the message
+ The user must click the \uicontrol{OK} button to dismiss the message
box. The rest of the GUI is blocked until the message box is
dismissed.
@@ -514,13 +514,13 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
responses. The buttons are specified by combining values from
StandardButtons using the bitwise OR operator. The display order
for the buttons is platform-dependent. For example, on Windows,
- \gui{Save} is displayed to the left of \gui{Cancel}, whereas on
+ \uicontrol{Save} is displayed to the left of \uicontrol{Cancel}, whereas on
Mac OS, the order is reversed.
Mark one of your standard buttons to be your
\l{QMessageBox::defaultButton()} {default button}.
- \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 6
+ \snippet code/src_gui_dialogs_qmessagebox.cpp 6
This is the approach recommended in the
\l{http://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/AppleHIGuidelines/Windows/Windows.html#//apple_ref/doc/uid/20000961-BABCAJID}
@@ -534,16 +534,16 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
The exec() slot returns the StandardButtons value of the button
that was clicked.
- \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 7
+ \snippet code/src_gui_dialogs_qmessagebox.cpp 7
To give the user more information to help him answer the question,
set the \l{QMessageBox::detailedText} {detailed text} property. If
the \l{QMessageBox::detailedText} {detailed text} property is set,
- the \gui{Show Details...} button will be shown.
+ the \uicontrol{Show Details...} button will be shown.
\image msgbox3.png
- Clicking the \gui{Show Details...} button displays the detailed text.
+ Clicking the \uicontrol{Show Details...} button displays the detailed text.
\image msgbox4.png
@@ -632,7 +632,7 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
Static functions are available for creating information(),
question(), warning(), and critical() message boxes.
- \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 0
+ \snippet code/src_gui_dialogs_qmessagebox.cpp 0
The \l{dialogs/standarddialogs}{Standard Dialogs} example shows
how to use QMessageBox and the other built-in Qt dialogs.
@@ -647,7 +647,7 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
platform). You can test the value of clickedButton() after calling
exec(). For example,
- \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 2
+ \snippet code/src_gui_dialogs_qmessagebox.cpp 2
\section1 Default and Escape Keys
@@ -1028,7 +1028,7 @@ void QMessageBoxPrivate::detectEscapeButton()
Example:
- \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 3
+ \snippet code/src_gui_dialogs_qmessagebox.cpp 3
\sa standardButton(), button()
*/
@@ -1707,7 +1707,7 @@ void QMessageBox::about(QWidget *parent, const QString &title, const QString &te
and centered over \a parent (if \a parent is not 0). The message
includes the version number of Qt being used by the application.
- This is useful for inclusion in the \gui Help menu of an application,
+ This is useful for inclusion in the \uicontrol Help menu of an application,
as shown in the \l{mainwindows/menus}{Menus} example.
QApplication provides this functionality as a slot.
@@ -1964,7 +1964,7 @@ void QMessageBoxPrivate::retranslateStrings()
to make it the cancel or close button (clicked when \key Esc is
pressed).
- \snippet doc/src/snippets/dialogs/dialogs.cpp 2
+ \snippet dialogs/dialogs.cpp 2
The message box is an \l{Qt::ApplicationModal} {application modal}
dialog box.
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index 350fb57e20..97e628e96b 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -244,7 +244,7 @@ void QProgressDialogPrivate::_q_disconnectOnClose()
to use for the programmer. Do the operation in a loop, call \l setValue() at
intervals, and check for cancellation with wasCanceled(). For example:
- \snippet doc/src/snippets/dialogs/dialogs.cpp 3
+ \snippet dialogs/dialogs.cpp 3
A modeless progress dialog is suitable for operations that take
place in the background, where the user is able to interact with the
@@ -257,11 +257,11 @@ void QProgressDialogPrivate::_q_disconnectOnClose()
canceled() signal to a slot that stops the operation, and call \l
setValue() at intervals. For example:
- \snippet doc/src/snippets/dialogs/dialogs.cpp 4
+ \snippet dialogs/dialogs.cpp 4
\codeline
- \snippet doc/src/snippets/dialogs/dialogs.cpp 5
+ \snippet dialogs/dialogs.cpp 5
\codeline
- \snippet doc/src/snippets/dialogs/dialogs.cpp 6
+ \snippet dialogs/dialogs.cpp 6
In both modes the progress dialog may be customized by
replacing the child widgets with custom widgets by using setLabel(),
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index ac19ec8d22..36327741c8 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -1809,17 +1809,17 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
\l{dialogs/classwizard}{Class Wizard} and \l{dialogs/licensewizard}{License
Wizard}.
- \snippet examples/dialogs/trivialwizard/trivialwizard.cpp 1
- \snippet examples/dialogs/trivialwizard/trivialwizard.cpp 3
+ \snippet dialogs/trivialwizard/trivialwizard.cpp 1
+ \snippet dialogs/trivialwizard/trivialwizard.cpp 3
\dots
- \snippet examples/dialogs/trivialwizard/trivialwizard.cpp 4
+ \snippet dialogs/trivialwizard/trivialwizard.cpp 4
\codeline
- \snippet examples/dialogs/trivialwizard/trivialwizard.cpp 5
- \snippet examples/dialogs/trivialwizard/trivialwizard.cpp 7
+ \snippet dialogs/trivialwizard/trivialwizard.cpp 5
+ \snippet dialogs/trivialwizard/trivialwizard.cpp 7
\dots
- \snippet examples/dialogs/trivialwizard/trivialwizard.cpp 8
+ \snippet dialogs/trivialwizard/trivialwizard.cpp 8
\codeline
- \snippet examples/dialogs/trivialwizard/trivialwizard.cpp 10
+ \snippet dialogs/trivialwizard/trivialwizard.cpp 10
\section1 Wizard Look and Feel
@@ -1856,19 +1856,19 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
In addition to the wizard style, there are several options that
control the look and feel of the wizard. These can be set using
setOption() or setOptions(). For example, HaveHelpButton makes
- QWizard show a \gui Help button along with the other wizard
+ QWizard show a \uicontrol Help button along with the other wizard
buttons.
You can even change the order of the wizard buttons to any
arbitrary order using setButtonLayout(), and you can add up to
- three custom buttons (e.g., a \gui Print button) to the button
+ three custom buttons (e.g., a \uicontrol Print button) to the button
row. This is achieved by calling setButton() or setButtonText()
with CustomButton1, CustomButton2, or CustomButton3 to set up the
button, and by enabling the HaveCustomButton1, HaveCustomButton2,
or HaveCustomButton3 options. Whenever the user clicks a custom
button, customButtonClicked() is emitted. For example:
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 29
+ \snippet dialogs/licensewizard/licensewizard.cpp 29
\section1 Elements of a Wizard Page
@@ -1936,12 +1936,12 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
To register a field, call QWizardPage::registerField() field.
For example:
- \snippet examples/dialogs/classwizard/classwizard.cpp 8
+ \snippet dialogs/classwizard/classwizard.cpp 8
\dots
- \snippet examples/dialogs/classwizard/classwizard.cpp 10
- \snippet examples/dialogs/classwizard/classwizard.cpp 11
+ \snippet dialogs/classwizard/classwizard.cpp 10
+ \snippet dialogs/classwizard/classwizard.cpp 11
\dots
- \snippet examples/dialogs/classwizard/classwizard.cpp 13
+ \snippet dialogs/classwizard/classwizard.cpp 13
The above code registers three fields, \c className, \c
baseClass, and \c qobjectMacro, which are associated with three
@@ -1952,7 +1952,7 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
The fields of any page are accessible from any other page. For
example:
- \snippet examples/dialogs/classwizard/classwizard.cpp 17
+ \snippet dialogs/classwizard/classwizard.cpp 17
Here, we call QWizardPage::field() to access the contents of the
\c className field (which was defined in the \c ClassInfoPage)
@@ -1971,7 +1971,7 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
If an asterisk (\c *) is appended to the name when the property
is registered, the field is a \e{mandatory field}. When a page has
- mandatory fields, the \gui Next and/or \gui Finish buttons are
+ mandatory fields, the \uicontrol Next and/or \uicontrol Finish buttons are
enabled only when all mandatory fields are filled.
To consider a field "filled", QWizard simply checks that the
@@ -1987,7 +1987,7 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
QWizardPage::completeChanged() signal whenever the page becomes
complete or incomplete.
- The enabled/disabled state of the \gui Next and/or \gui Finish
+ The enabled/disabled state of the \uicontrol Next and/or \uicontrol Finish
buttons is one way to perform validation on the user input.
Another way is to reimplement validateCurrentPage() (or
QWizardPage::validatePage()) to perform some last-minute
@@ -2005,9 +2005,9 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
them using addPage(). By default, the pages are shown in the
order in which they were added. For example:
- \snippet examples/dialogs/classwizard/classwizard.cpp 0
+ \snippet dialogs/classwizard/classwizard.cpp 0
\dots
- \snippet examples/dialogs/classwizard/classwizard.cpp 2
+ \snippet dialogs/classwizard/classwizard.cpp 2
When a page is about to be shown, QWizard calls initializePage()
(which in turn calls QWizardPage::initializePage()) to fill the
@@ -2016,11 +2016,11 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
based on other pages' fields (see the \l{initialize page}{example
above}).
- If the user presses \gui Back, cleanupPage() is called (which in
+ If the user presses \uicontrol Back, cleanupPage() is called (which in
turn calls QWizardPage::cleanupPage()). The default
implementation resets the page's fields to their original values
(the values they had before initializePage() was called). If you
- want the \gui Back button to be non-destructive and keep the
+ want the \uicontrol Back button to be non-destructive and keep the
values entered by the user, simply enable the IndependentPages
option.
@@ -2037,37 +2037,37 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
In complex wizards, pages are identified by IDs. These IDs are
typically defined using an enum. For example:
- \snippet examples/dialogs/licensewizard/licensewizard.h 0
+ \snippet dialogs/licensewizard/licensewizard.h 0
\dots
- \snippet examples/dialogs/licensewizard/licensewizard.h 2
+ \snippet dialogs/licensewizard/licensewizard.h 2
\dots
- \snippet examples/dialogs/licensewizard/licensewizard.h 3
+ \snippet dialogs/licensewizard/licensewizard.h 3
The pages are inserted using setPage(), which takes an ID and an
instance of QWizardPage (or of a subclass):
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 1
+ \snippet dialogs/licensewizard/licensewizard.cpp 1
\dots
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 8
+ \snippet dialogs/licensewizard/licensewizard.cpp 8
By default, the pages are shown in increasing ID order. To
provide a dynamic order that depends on the options chosen by the
user, we must reimplement QWizardPage::nextId(). For example:
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 18
+ \snippet dialogs/licensewizard/licensewizard.cpp 18
\codeline
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 23
+ \snippet dialogs/licensewizard/licensewizard.cpp 23
\codeline
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 24
+ \snippet dialogs/licensewizard/licensewizard.cpp 24
\codeline
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 25
+ \snippet dialogs/licensewizard/licensewizard.cpp 25
\codeline
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 26
+ \snippet dialogs/licensewizard/licensewizard.cpp 26
It would also be possible to put all the logic in one place, in a
QWizard::nextId() reimplementation. For example:
- \snippet doc/src/snippets/code/src_gui_dialogs_qwizard.cpp 0
+ \snippet code/src_gui_dialogs_qwizard.cpp 0
To start at another page than the page with the lowest ID, call
setStartId().
@@ -2075,7 +2075,7 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
To test whether a page has been visited or not, call
hasVisitedPage(). For example:
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 27
+ \snippet dialogs/licensewizard/licensewizard.cpp 27
\sa QWizardPage, {Class Wizard Example}, {License Wizard Example}
*/
@@ -2085,12 +2085,12 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
This enum specifies the buttons in a wizard.
- \value BackButton The \gui Back button (\gui {Go Back} on Mac OS X)
- \value NextButton The \gui Next button (\gui Continue on Mac OS X)
- \value CommitButton The \gui Commit button
- \value FinishButton The \gui Finish button (\gui Done on Mac OS X)
- \value CancelButton The \gui Cancel button (see also NoCancelButton)
- \value HelpButton The \gui Help button (see also HaveHelpButton)
+ \value BackButton The \uicontrol Back button (\uicontrol {Go Back} on Mac OS X)
+ \value NextButton The \uicontrol Next button (\uicontrol Continue on Mac OS X)
+ \value CommitButton The \uicontrol Commit button
+ \value FinishButton The \uicontrol Finish button (\uicontrol Done on Mac OS X)
+ \value CancelButton The \uicontrol Cancel button (see also NoCancelButton)
+ \value HelpButton The \uicontrol Help button (see also HaveHelpButton)
\value CustomButton1 The first user-defined button (see also HaveCustomButton1)
\value CustomButton2 The second user-defined button (see also HaveCustomButton2)
\value CustomButton3 The third user-defined button (see also HaveCustomButton3)
@@ -2148,18 +2148,18 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
\value IgnoreSubTitles Don't show any subtitles, even if they are set.
\value ExtendedWatermarkPixmap Extend any WatermarkPixmap all the
way down to the window's edge.
- \value NoDefaultButton Don't make the \gui Next or \gui Finish button the
+ \value NoDefaultButton Don't make the \uicontrol Next or \uicontrol Finish button the
dialog's \l{QPushButton::setDefault()}{default button}.
- \value NoBackButtonOnStartPage Don't show the \gui Back button on the start page.
- \value NoBackButtonOnLastPage Don't show the \gui Back button on the last page.
- \value DisabledBackButtonOnLastPage Disable the \gui Back button on the last page.
- \value HaveNextButtonOnLastPage Show the (disabled) \gui Next button on the last page.
- \value HaveFinishButtonOnEarlyPages Show the (disabled) \gui Finish button on non-final pages.
- \value NoCancelButton Don't show the \gui Cancel button.
- \value CancelButtonOnLeft Put the \gui Cancel button on the left of \gui Back (rather than on
- the right of \gui Finish or \gui Next).
- \value HaveHelpButton Show the \gui Help button.
- \value HelpButtonOnRight Put the \gui Help button on the far right of the button layout
+ \value NoBackButtonOnStartPage Don't show the \uicontrol Back button on the start page.
+ \value NoBackButtonOnLastPage Don't show the \uicontrol Back button on the last page.
+ \value DisabledBackButtonOnLastPage Disable the \uicontrol Back button on the last page.
+ \value HaveNextButtonOnLastPage Show the (disabled) \uicontrol Next button on the last page.
+ \value HaveFinishButtonOnEarlyPages Show the (disabled) \uicontrol Finish button on non-final pages.
+ \value NoCancelButton Don't show the \uicontrol Cancel button.
+ \value CancelButtonOnLeft Put the \uicontrol Cancel button on the left of \uicontrol Back (rather than on
+ the right of \uicontrol Finish or \uicontrol Next).
+ \value HaveHelpButton Show the \uicontrol Help button.
+ \value HelpButtonOnRight Put the \uicontrol Help button on the far right of the button layout
(rather than on the far left).
\value HaveCustomButton1 Show the first user-defined button (CustomButton1).
\value HaveCustomButton2 Show the second user-defined button (CustomButton2).
@@ -2363,7 +2363,7 @@ QWizardPage *QWizard::page(int theid) const
Returns true if the page history contains page \a id; otherwise,
returns false.
- Pressing \gui Back marks the current page as "unvisited" again.
+ Pressing \uicontrol Back marks the current page as "unvisited" again.
\sa visitedPages()
*/
@@ -2377,7 +2377,7 @@ bool QWizard::hasVisitedPage(int theid) const
Returns the list of IDs of visited pages, in the order in which the pages
were visited.
- Pressing \gui Back marks the current page as "unvisited" again.
+ Pressing \uicontrol Back marks the current page as "unvisited" again.
\sa hasVisitedPage()
*/
@@ -2635,10 +2635,10 @@ QWizard::WizardOptions QWizard::options() const
Sets the text on button \a which to be \a text.
By default, the text on buttons depends on the wizardStyle. For
- example, on Mac OS X, the \gui Next button is called \gui
+ example, on Mac OS X, the \uicontrol Next button is called \uicontrol
Continue.
- To add extra buttons to the wizard (e.g., a \gui Print button),
+ To add extra buttons to the wizard (e.g., a \uicontrol Print button),
one way is to call setButtonText() with CustomButton1,
CustomButton2, or CustomButton3 to set their text, and make the
buttons visible using the HaveCustomButton1, HaveCustomButton2,
@@ -2667,7 +2667,7 @@ void QWizard::setButtonText(WizardButton which, const QString &text)
If a text has ben set using setButtonText(), this text is returned.
By default, the text on buttons depends on the wizardStyle. For
- example, on Mac OS X, the \gui Next button is called \gui
+ example, on Mac OS X, the \uicontrol Next button is called \uicontrol
Continue.
\sa button(), setButton(), setButtonText(), QWizardPage::buttonText(),
@@ -2704,7 +2704,7 @@ QString QWizard::buttonText(WizardButton which) const
Example:
- \snippet doc/src/snippets/code/src_gui_dialogs_qwizard.cpp 1
+ \snippet code/src_gui_dialogs_qwizard.cpp 1
\sa setButton(), setButtonText(), setOptions()
*/
@@ -2738,7 +2738,7 @@ void QWizard::setButtonLayout(const QList<WizardButton> &layout)
/*!
Sets the button corresponding to role \a which to \a button.
- To add extra buttons to the wizard (e.g., a \gui Print button),
+ To add extra buttons to the wizard (e.g., a \uicontrol Print button),
one way is to call setButton() with CustomButton1 to
CustomButton3, and make the buttons visible using the
HaveCustomButton1 to HaveCustomButton3 options.
@@ -3029,27 +3029,27 @@ QSize QWizard::sizeHint() const
/*!
\fn void QWizard::helpRequested()
- This signal is emitted when the user clicks the \gui Help button.
+ This signal is emitted when the user clicks the \uicontrol Help button.
- By default, no \gui Help button is shown. Call
+ By default, no \uicontrol Help button is shown. Call
setOption(HaveHelpButton, true) to have one.
Example:
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 0
+ \snippet dialogs/licensewizard/licensewizard.cpp 0
\dots
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 5
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 7
+ \snippet dialogs/licensewizard/licensewizard.cpp 5
+ \snippet dialogs/licensewizard/licensewizard.cpp 7
\dots
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 8
+ \snippet dialogs/licensewizard/licensewizard.cpp 8
\codeline
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 10
+ \snippet dialogs/licensewizard/licensewizard.cpp 10
\dots
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 12
+ \snippet dialogs/licensewizard/licensewizard.cpp 12
\codeline
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 14
+ \snippet dialogs/licensewizard/licensewizard.cpp 14
\codeline
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 15
+ \snippet dialogs/licensewizard/licensewizard.cpp 15
\sa customButtonClicked()
*/
@@ -3070,7 +3070,7 @@ QSize QWizard::sizeHint() const
/*!
Goes back to the previous page.
- This is equivalent to pressing the \gui Back button.
+ This is equivalent to pressing the \uicontrol Back button.
\sa next(), accept(), reject(), restart()
*/
@@ -3086,7 +3086,7 @@ void QWizard::back()
/*!
Advances to the next page.
- This is equivalent to pressing the \gui Next or \gui Commit button.
+ This is equivalent to pressing the \uicontrol Next or \uicontrol Commit button.
\sa nextId(), back(), accept(), reject(), restart()
*/
@@ -3253,7 +3253,7 @@ void QWizard::done(int result)
This virtual function is called by QWizard to prepare page \a id
just before it is shown either as a result of QWizard::restart()
- being called, or as a result of the user clicking \gui Next. (However, if the \l
+ being called, or as a result of the user clicking \uicontrol Next. (However, if the \l
QWizard::IndependentPages option is set, this function is only
called the first time the page is shown.)
@@ -3277,7 +3277,7 @@ void QWizard::initializePage(int theid)
\fn void QWizard::cleanupPage(int id)
This virtual function is called by QWizard to clean up page \a id just before the
- user leaves it by clicking \gui Back (unless the \l QWizard::IndependentPages option is set).
+ user leaves it by clicking \uicontrol Back (unless the \l QWizard::IndependentPages option is set).
The default implementation calls QWizardPage::cleanupPage() on
page(\a id).
@@ -3293,15 +3293,15 @@ void QWizard::cleanupPage(int theid)
/*!
This virtual function is called by QWizard when the user clicks
- \gui Next or \gui Finish to perform some last-minute validation.
+ \uicontrol Next or \uicontrol Finish to perform some last-minute validation.
If it returns true, the next page is shown (or the wizard
finishes); otherwise, the current page stays up.
The default implementation calls QWizardPage::validatePage() on
the currentPage().
- When possible, it is usually better style to disable the \gui
- Next or \gui Finish button (by specifying \l{mandatory fields} or
+ When possible, it is usually better style to disable the \uicontrol
+ Next or \uicontrol Finish button (by specifying \l{mandatory fields} or
by reimplementing QWizardPage::isComplete()) than to reimplement
validateCurrentPage().
@@ -3318,7 +3318,7 @@ bool QWizard::validateCurrentPage()
/*!
This virtual function is called by QWizard to find out which page
- to show when the user clicks the \gui Next button.
+ to show when the user clicks the \uicontrol Next button.
The return value is the ID of the next page, or -1 if no page follows.
@@ -3362,29 +3362,29 @@ int QWizard::nextId() const
\list
\li initializePage() is called to initialize the page's contents
- when the user clicks the wizard's \gui Next button. If you
+ when the user clicks the wizard's \uicontrol Next button. If you
want to derive the page's default from what the user entered
on previous pages, this is the function to reimplement.
\li cleanupPage() is called to reset the page's contents when the
- user clicks the wizard's \gui Back button.
- \li validatePage() validates the page when the user clicks \gui
- Next or \gui Finish. It is often used to show an error message
+ user clicks the wizard's \uicontrol Back button.
+ \li validatePage() validates the page when the user clicks \uicontrol
+ Next or \uicontrol Finish. It is often used to show an error message
if the user has entered incomplete or invalid information.
\li nextId() returns the ID of the next page. It is useful when
\l{creating non-linear wizards}, which allow different
traversal paths based on the information provided by the user.
- \li isComplete() is called to determine whether the \gui Next
- and/or \gui Finish button should be enabled or disabled. If
+ \li isComplete() is called to determine whether the \uicontrol Next
+ and/or \uicontrol Finish button should be enabled or disabled. If
you reimplement isComplete(), also make sure that
completeChanged() is emitted whenever the complete state
changes.
\endlist
- Normally, the \gui Next button and the \gui Finish button of a
- wizard are mutually exclusive. If isFinalPage() returns true, \gui
- Finish is available; otherwise, \gui Next is available. By
+ Normally, the \uicontrol Next button and the \uicontrol Finish button of a
+ wizard are mutually exclusive. If isFinalPage() returns true, \uicontrol
+ Finish is available; otherwise, \uicontrol Next is available. By
default, isFinalPage() is true only when nextId() returns -1. If
- you want to show \gui Next and \gui Final simultaneously for a
+ you want to show \uicontrol Next and \uicontrol Final simultaneously for a
page (letting the user perform an "early finish"), call
setFinalPage(true) on that page. For wizards that support early
finishes, you might also want to set the
@@ -3532,7 +3532,7 @@ QPixmap QWizardPage::pixmap(QWizard::WizardPixmap which) const
/*!
This virtual function is called by QWizard::initializePage() to
prepare the page just before it is shown either as a result of QWizard::restart()
- being called, or as a result of the user clicking \gui Next.
+ being called, or as a result of the user clicking \uicontrol Next.
(However, if the \l QWizard::IndependentPages option is set, this function is only
called the first time the page is shown.)
@@ -3540,7 +3540,7 @@ QPixmap QWizardPage::pixmap(QWizard::WizardPixmap which) const
fields are properly initialized based on fields from previous
pages. For example:
- \snippet examples/dialogs/classwizard/classwizard.cpp 17
+ \snippet dialogs/classwizard/classwizard.cpp 17
The default implementation does nothing.
@@ -3552,7 +3552,7 @@ void QWizardPage::initializePage()
/*!
This virtual function is called by QWizard::cleanupPage() when
- the user leaves the page by clicking \gui Back (unless the \l QWizard::IndependentPages
+ the user leaves the page by clicking \uicontrol Back (unless the \l QWizard::IndependentPages
option is set).
The default implementation resets the page's fields to their
@@ -3576,14 +3576,14 @@ void QWizardPage::cleanupPage()
/*!
This virtual function is called by QWizard::validateCurrentPage()
- when the user clicks \gui Next or \gui Finish to perform some
+ when the user clicks \uicontrol Next or \uicontrol Finish to perform some
last-minute validation. If it returns true, the next page is shown
(or the wizard finishes); otherwise, the current page stays up.
The default implementation returns true.
- When possible, it is usually better style to disable the \gui
- Next or \gui Finish button (by specifying \l{mandatory fields} or
+ When possible, it is usually better style to disable the \uicontrol
+ Next or \uicontrol Finish button (by specifying \l{mandatory fields} or
reimplementing isComplete()) than to reimplement validatePage().
\sa QWizard::validateCurrentPage(), isComplete()
@@ -3595,7 +3595,7 @@ bool QWizardPage::validatePage()
/*!
This virtual function is called by QWizard to determine whether
- the \gui Next or \gui Finish button should be enabled or
+ the \uicontrol Next or \uicontrol Finish button should be enabled or
disabled.
The default implementation returns true if all \l{mandatory
@@ -3645,7 +3645,7 @@ bool QWizardPage::isComplete() const
/*!
Explicitly sets this page to be final if \a finalPage is true.
- After calling setFinalPage(true), isFinalPage() returns true and the \gui
+ After calling setFinalPage(true), isFinalPage() returns true and the \uicontrol
Finish button is visible (and enabled if isComplete() returns
true).
@@ -3664,7 +3664,7 @@ void QWizardPage::setFinalPage(bool finalPage)
}
/*!
- This function is called by QWizard to determine whether the \gui
+ This function is called by QWizard to determine whether the \uicontrol
Finish button should be shown for this page or not.
By default, it returns true if there is no next page
@@ -3695,12 +3695,12 @@ bool QWizardPage::isFinalPage() const
sets it to be a normal page.
A commit page is a page that represents an action which cannot be undone
- by clicking \gui Back or \gui Cancel.
+ by clicking \uicontrol Back or \uicontrol Cancel.
- A \gui Commit button replaces the \gui Next button on a commit page. Clicking this
- button simply calls QWizard::next() just like clicking \gui Next does.
+ A \uicontrol Commit button replaces the \uicontrol Next button on a commit page. Clicking this
+ button simply calls QWizard::next() just like clicking \uicontrol Next does.
- A page entered directly from a commit page has its \gui Back button disabled.
+ A page entered directly from a commit page has its \uicontrol Back button disabled.
\sa isCommitPage()
*/
@@ -3748,7 +3748,7 @@ void QWizardPage::setButtonText(QWizard::WizardButton which, const QString &text
this text is returned.
By default, the text on buttons depends on the QWizard::wizardStyle.
- For example, on Mac OS X, the \gui Next button is called \gui
+ For example, on Mac OS X, the \uicontrol Next button is called \uicontrol
Continue.
\sa setButtonText(), QWizard::buttonText(), QWizard::setButtonText()
@@ -3768,7 +3768,7 @@ QString QWizardPage::buttonText(QWizard::WizardButton which) const
/*!
This virtual function is called by QWizard::nextId() to find
- out which page to show when the user clicks the \gui Next button.
+ out which page to show when the user clicks the \uicontrol Next button.
The return value is the ID of the next page, or -1 if no page follows.
@@ -3778,7 +3778,7 @@ QString QWizardPage::buttonText(QWizard::WizardButton which) const
By reimplementing this function, you can specify a dynamic page
order. For example:
- \snippet examples/dialogs/licensewizard/licensewizard.cpp 18
+ \snippet dialogs/licensewizard/licensewizard.cpp 18
\sa QWizard::nextId()
*/
@@ -3845,7 +3845,7 @@ void QWizardPage::setField(const QString &name, const QVariant &value)
Example:
- \snippet examples/dialogs/classwizard/classwizard.cpp 17
+ \snippet dialogs/classwizard/classwizard.cpp 17
\sa QWizard::field(), setField(), registerField()
*/
@@ -3868,8 +3868,8 @@ QVariant QWizardPage::field(const QString &name) const
explicitly about each other.
If \a name ends with an asterisk (\c *), the field is a mandatory
- field. When a page has mandatory fields, the \gui Next and/or
- \gui Finish buttons are enabled only when all mandatory fields
+ field. When a page has mandatory fields, the \uicontrol Next and/or
+ \uicontrol Finish buttons are enabled only when all mandatory fields
are filled. This requires a \a changedSignal to be specified, to
tell QWizard to recheck the value stored by the mandatory field.
diff --git a/src/widgets/doc/images/addressbook-tutorial-part1-labeled-layout.png b/src/widgets/doc/images/addressbook-tutorial-part1-labeled-layout.png
new file mode 100644
index 0000000000..b19cb360a1
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part1-labeled-layout.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part1-labeled-screenshot.png b/src/widgets/doc/images/addressbook-tutorial-part1-labeled-screenshot.png
new file mode 100644
index 0000000000..f9b91eebe6
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part1-labeled-screenshot.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part1-screenshot.png b/src/widgets/doc/images/addressbook-tutorial-part1-screenshot.png
new file mode 100644
index 0000000000..454b0959e6
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part1-screenshot.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part2-add-contact.png b/src/widgets/doc/images/addressbook-tutorial-part2-add-contact.png
new file mode 100644
index 0000000000..6f2b947b21
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part2-add-contact.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part2-add-flowchart.png b/src/widgets/doc/images/addressbook-tutorial-part2-add-flowchart.png
new file mode 100644
index 0000000000..ca9af3720d
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part2-add-flowchart.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part2-add-successful.png b/src/widgets/doc/images/addressbook-tutorial-part2-add-successful.png
new file mode 100644
index 0000000000..99a2154007
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part2-add-successful.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part2-labeled-layout.png b/src/widgets/doc/images/addressbook-tutorial-part2-labeled-layout.png
new file mode 100644
index 0000000000..1e000c8f31
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part2-labeled-layout.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part2-signals-and-slots.png b/src/widgets/doc/images/addressbook-tutorial-part2-signals-and-slots.png
new file mode 100644
index 0000000000..e49f8dc262
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part2-signals-and-slots.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part2-stretch-effects.png b/src/widgets/doc/images/addressbook-tutorial-part2-stretch-effects.png
new file mode 100644
index 0000000000..d9f7f31227
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part2-stretch-effects.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part3-labeled-layout.png b/src/widgets/doc/images/addressbook-tutorial-part3-labeled-layout.png
new file mode 100644
index 0000000000..1981ba8cb6
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part3-labeled-layout.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part3-linkedlist.png b/src/widgets/doc/images/addressbook-tutorial-part3-linkedlist.png
new file mode 100644
index 0000000000..e7f4725dce
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part3-linkedlist.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part3-screenshot.png b/src/widgets/doc/images/addressbook-tutorial-part3-screenshot.png
new file mode 100644
index 0000000000..75159b4045
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part3-screenshot.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part4-remove.png b/src/widgets/doc/images/addressbook-tutorial-part4-remove.png
new file mode 100644
index 0000000000..8eb259ef02
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part4-remove.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part5-finddialog.png b/src/widgets/doc/images/addressbook-tutorial-part5-finddialog.png
new file mode 100644
index 0000000000..743d92ef6f
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part5-finddialog.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part5-notfound.png b/src/widgets/doc/images/addressbook-tutorial-part5-notfound.png
new file mode 100644
index 0000000000..2d35766ab5
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part5-notfound.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part5-screenshot.png b/src/widgets/doc/images/addressbook-tutorial-part5-screenshot.png
new file mode 100644
index 0000000000..3abe2775c2
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part5-screenshot.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part5-signals-and-slots.png b/src/widgets/doc/images/addressbook-tutorial-part5-signals-and-slots.png
new file mode 100644
index 0000000000..1771e7bbbf
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part5-signals-and-slots.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part6-load.png b/src/widgets/doc/images/addressbook-tutorial-part6-load.png
new file mode 100644
index 0000000000..a027a1decb
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part6-load.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part6-save.png b/src/widgets/doc/images/addressbook-tutorial-part6-save.png
new file mode 100644
index 0000000000..757feeb9ac
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part6-save.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part6-screenshot.png b/src/widgets/doc/images/addressbook-tutorial-part6-screenshot.png
new file mode 100644
index 0000000000..7bb2f749bf
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part6-screenshot.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-part7-screenshot.png b/src/widgets/doc/images/addressbook-tutorial-part7-screenshot.png
new file mode 100644
index 0000000000..3e7b3ca522
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-part7-screenshot.png
Binary files differ
diff --git a/src/widgets/doc/images/addressbook-tutorial-screenshot.png b/src/widgets/doc/images/addressbook-tutorial-screenshot.png
new file mode 100644
index 0000000000..3fba6e849e
--- /dev/null
+++ b/src/widgets/doc/images/addressbook-tutorial-screenshot.png
Binary files differ
diff --git a/src/widgets/doc/images/assistant-toolbar.png b/src/widgets/doc/images/assistant-toolbar.png
new file mode 100644
index 0000000000..1b41825c64
--- /dev/null
+++ b/src/widgets/doc/images/assistant-toolbar.png
Binary files differ
diff --git a/src/widgets/doc/images/buttonbox-gnomelayout-horizontal.png b/src/widgets/doc/images/buttonbox-gnomelayout-horizontal.png
new file mode 100644
index 0000000000..b2f74bb6c6
--- /dev/null
+++ b/src/widgets/doc/images/buttonbox-gnomelayout-horizontal.png
Binary files differ
diff --git a/src/widgets/doc/images/buttonbox-gnomelayout-vertical.png b/src/widgets/doc/images/buttonbox-gnomelayout-vertical.png
new file mode 100644
index 0000000000..e7843dc22d
--- /dev/null
+++ b/src/widgets/doc/images/buttonbox-gnomelayout-vertical.png
Binary files differ
diff --git a/src/widgets/doc/images/buttonbox-kdelayout-horizontal.png b/src/widgets/doc/images/buttonbox-kdelayout-horizontal.png
new file mode 100644
index 0000000000..5da11f4d7a
--- /dev/null
+++ b/src/widgets/doc/images/buttonbox-kdelayout-horizontal.png
Binary files differ
diff --git a/src/widgets/doc/images/buttonbox-kdelayout-vertical.png b/src/widgets/doc/images/buttonbox-kdelayout-vertical.png
new file mode 100644
index 0000000000..6f5dfc6b65
--- /dev/null
+++ b/src/widgets/doc/images/buttonbox-kdelayout-vertical.png
Binary files differ
diff --git a/src/widgets/doc/images/buttonbox-mac-modeless-horizontal.png b/src/widgets/doc/images/buttonbox-mac-modeless-horizontal.png
new file mode 100644
index 0000000000..2e853d34fb
--- /dev/null
+++ b/src/widgets/doc/images/buttonbox-mac-modeless-horizontal.png
Binary files differ
diff --git a/src/widgets/doc/images/buttonbox-mac-modeless-vertical.png b/src/widgets/doc/images/buttonbox-mac-modeless-vertical.png
new file mode 100644
index 0000000000..f59bd8ddaf
--- /dev/null
+++ b/src/widgets/doc/images/buttonbox-mac-modeless-vertical.png
Binary files differ
diff --git a/src/widgets/doc/images/buttonbox-maclayout-horizontal.png b/src/widgets/doc/images/buttonbox-maclayout-horizontal.png
new file mode 100644
index 0000000000..89ae84dea0
--- /dev/null
+++ b/src/widgets/doc/images/buttonbox-maclayout-horizontal.png
Binary files differ
diff --git a/src/widgets/doc/images/buttonbox-maclayout-vertical.png b/src/widgets/doc/images/buttonbox-maclayout-vertical.png
new file mode 100644
index 0000000000..728760029f
--- /dev/null
+++ b/src/widgets/doc/images/buttonbox-maclayout-vertical.png
Binary files differ
diff --git a/src/widgets/doc/images/buttonbox-winlayout-horizontal.png b/src/widgets/doc/images/buttonbox-winlayout-horizontal.png
new file mode 100644
index 0000000000..dd4ce1c313
--- /dev/null
+++ b/src/widgets/doc/images/buttonbox-winlayout-horizontal.png
Binary files differ
diff --git a/src/widgets/doc/images/buttonbox-winlayout-vertical.png b/src/widgets/doc/images/buttonbox-winlayout-vertical.png
new file mode 100644
index 0000000000..539de1aa1a
--- /dev/null
+++ b/src/widgets/doc/images/buttonbox-winlayout-vertical.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-calendarwidget.png b/src/widgets/doc/images/cde-calendarwidget.png
new file mode 100644
index 0000000000..9615eaeab8
--- /dev/null
+++ b/src/widgets/doc/images/cde-calendarwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-checkbox.png b/src/widgets/doc/images/cde-checkbox.png
new file mode 100644
index 0000000000..b2528dc5de
--- /dev/null
+++ b/src/widgets/doc/images/cde-checkbox.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-combobox.png b/src/widgets/doc/images/cde-combobox.png
new file mode 100644
index 0000000000..74586433eb
--- /dev/null
+++ b/src/widgets/doc/images/cde-combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-dateedit.png b/src/widgets/doc/images/cde-dateedit.png
new file mode 100644
index 0000000000..ebb24d59cf
--- /dev/null
+++ b/src/widgets/doc/images/cde-dateedit.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-datetimeedit.png b/src/widgets/doc/images/cde-datetimeedit.png
new file mode 100644
index 0000000000..9ac659a3f3
--- /dev/null
+++ b/src/widgets/doc/images/cde-datetimeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-dial.png b/src/widgets/doc/images/cde-dial.png
new file mode 100644
index 0000000000..956d19cb6c
--- /dev/null
+++ b/src/widgets/doc/images/cde-dial.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-doublespinbox.png b/src/widgets/doc/images/cde-doublespinbox.png
new file mode 100644
index 0000000000..30a9af66fa
--- /dev/null
+++ b/src/widgets/doc/images/cde-doublespinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-fontcombobox.png b/src/widgets/doc/images/cde-fontcombobox.png
new file mode 100644
index 0000000000..043ca1d20f
--- /dev/null
+++ b/src/widgets/doc/images/cde-fontcombobox.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-frame.png b/src/widgets/doc/images/cde-frame.png
new file mode 100644
index 0000000000..221576e849
--- /dev/null
+++ b/src/widgets/doc/images/cde-frame.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-groupbox.png b/src/widgets/doc/images/cde-groupbox.png
new file mode 100644
index 0000000000..8bad69be4e
--- /dev/null
+++ b/src/widgets/doc/images/cde-groupbox.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-horizontalscrollbar.png b/src/widgets/doc/images/cde-horizontalscrollbar.png
new file mode 100644
index 0000000000..6e7cde8da1
--- /dev/null
+++ b/src/widgets/doc/images/cde-horizontalscrollbar.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-label.png b/src/widgets/doc/images/cde-label.png
new file mode 100644
index 0000000000..4e906eaa00
--- /dev/null
+++ b/src/widgets/doc/images/cde-label.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-lcdnumber.png b/src/widgets/doc/images/cde-lcdnumber.png
new file mode 100644
index 0000000000..97324c1a6c
--- /dev/null
+++ b/src/widgets/doc/images/cde-lcdnumber.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-lineedit.png b/src/widgets/doc/images/cde-lineedit.png
new file mode 100644
index 0000000000..6c1527ba19
--- /dev/null
+++ b/src/widgets/doc/images/cde-lineedit.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-listview.png b/src/widgets/doc/images/cde-listview.png
new file mode 100644
index 0000000000..2e58140880
--- /dev/null
+++ b/src/widgets/doc/images/cde-listview.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-progressbar.png b/src/widgets/doc/images/cde-progressbar.png
new file mode 100644
index 0000000000..41715deb48
--- /dev/null
+++ b/src/widgets/doc/images/cde-progressbar.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-pushbutton.png b/src/widgets/doc/images/cde-pushbutton.png
new file mode 100644
index 0000000000..2d9bdd25a4
--- /dev/null
+++ b/src/widgets/doc/images/cde-pushbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-radiobutton.png b/src/widgets/doc/images/cde-radiobutton.png
new file mode 100644
index 0000000000..e053665f5a
--- /dev/null
+++ b/src/widgets/doc/images/cde-radiobutton.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-slider.png b/src/widgets/doc/images/cde-slider.png
new file mode 100644
index 0000000000..bd84371898
--- /dev/null
+++ b/src/widgets/doc/images/cde-slider.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-spinbox.png b/src/widgets/doc/images/cde-spinbox.png
new file mode 100644
index 0000000000..5f53c8e902
--- /dev/null
+++ b/src/widgets/doc/images/cde-spinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-tableview.png b/src/widgets/doc/images/cde-tableview.png
new file mode 100644
index 0000000000..7a99217560
--- /dev/null
+++ b/src/widgets/doc/images/cde-tableview.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-tabwidget.png b/src/widgets/doc/images/cde-tabwidget.png
new file mode 100644
index 0000000000..8cf5473fc2
--- /dev/null
+++ b/src/widgets/doc/images/cde-tabwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-textedit.png b/src/widgets/doc/images/cde-textedit.png
new file mode 100644
index 0000000000..c65b8da8f4
--- /dev/null
+++ b/src/widgets/doc/images/cde-textedit.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-timeedit.png b/src/widgets/doc/images/cde-timeedit.png
new file mode 100644
index 0000000000..6a5a4b953f
--- /dev/null
+++ b/src/widgets/doc/images/cde-timeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-toolbox.png b/src/widgets/doc/images/cde-toolbox.png
new file mode 100644
index 0000000000..c0dd4e9400
--- /dev/null
+++ b/src/widgets/doc/images/cde-toolbox.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-toolbutton.png b/src/widgets/doc/images/cde-toolbutton.png
new file mode 100644
index 0000000000..baff25c25b
--- /dev/null
+++ b/src/widgets/doc/images/cde-toolbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/cde-treeview.png b/src/widgets/doc/images/cde-treeview.png
new file mode 100644
index 0000000000..df3184b31b
--- /dev/null
+++ b/src/widgets/doc/images/cde-treeview.png
Binary files differ
diff --git a/src/widgets/doc/images/checkboxes-exclusive.png b/src/widgets/doc/images/checkboxes-exclusive.png
new file mode 100644
index 0000000000..0ada3a046a
--- /dev/null
+++ b/src/widgets/doc/images/checkboxes-exclusive.png
Binary files differ
diff --git a/src/widgets/doc/images/checkboxes-non-exclusive.png b/src/widgets/doc/images/checkboxes-non-exclusive.png
new file mode 100644
index 0000000000..4211aaedfb
--- /dev/null
+++ b/src/widgets/doc/images/checkboxes-non-exclusive.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-calendarwidget.png b/src/widgets/doc/images/cleanlooks-calendarwidget.png
new file mode 100644
index 0000000000..99c57b61ee
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-calendarwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-checkbox.png b/src/widgets/doc/images/cleanlooks-checkbox.png
new file mode 100644
index 0000000000..aaf2daae4e
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-checkbox.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-combobox.png b/src/widgets/doc/images/cleanlooks-combobox.png
new file mode 100644
index 0000000000..5fff4c87f6
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-dateedit.png b/src/widgets/doc/images/cleanlooks-dateedit.png
new file mode 100644
index 0000000000..384136a162
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-dateedit.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-datetimeedit.png b/src/widgets/doc/images/cleanlooks-datetimeedit.png
new file mode 100644
index 0000000000..7a62cebfb4
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-datetimeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-dial.png b/src/widgets/doc/images/cleanlooks-dial.png
new file mode 100644
index 0000000000..259a0888b6
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-dial.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-doublespinbox.png b/src/widgets/doc/images/cleanlooks-doublespinbox.png
new file mode 100644
index 0000000000..93b11f919a
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-doublespinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-fontcombobox.png b/src/widgets/doc/images/cleanlooks-fontcombobox.png
new file mode 100644
index 0000000000..47a5907f56
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-fontcombobox.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-frame.png b/src/widgets/doc/images/cleanlooks-frame.png
new file mode 100644
index 0000000000..2427b08d8f
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-frame.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-groupbox.png b/src/widgets/doc/images/cleanlooks-groupbox.png
new file mode 100644
index 0000000000..89c6eb2f39
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-groupbox.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-horizontalscrollbar.png b/src/widgets/doc/images/cleanlooks-horizontalscrollbar.png
new file mode 100644
index 0000000000..ca1c806c91
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-horizontalscrollbar.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-label.png b/src/widgets/doc/images/cleanlooks-label.png
new file mode 100644
index 0000000000..199758fd69
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-label.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-lcdnumber.png b/src/widgets/doc/images/cleanlooks-lcdnumber.png
new file mode 100644
index 0000000000..c6e34127cf
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-lcdnumber.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-lineedit.png b/src/widgets/doc/images/cleanlooks-lineedit.png
new file mode 100644
index 0000000000..3e9f1a4be3
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-lineedit.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-listview.png b/src/widgets/doc/images/cleanlooks-listview.png
new file mode 100644
index 0000000000..95f836c66b
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-listview.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-progressbar.png b/src/widgets/doc/images/cleanlooks-progressbar.png
new file mode 100644
index 0000000000..53fc6c1faa
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-progressbar.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-pushbutton-menu.png b/src/widgets/doc/images/cleanlooks-pushbutton-menu.png
new file mode 100644
index 0000000000..0d5cb59ec0
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-pushbutton-menu.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-pushbutton.png b/src/widgets/doc/images/cleanlooks-pushbutton.png
new file mode 100644
index 0000000000..7b3b3357c1
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-pushbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-radiobutton.png b/src/widgets/doc/images/cleanlooks-radiobutton.png
new file mode 100644
index 0000000000..4e077688c2
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-radiobutton.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-slider.png b/src/widgets/doc/images/cleanlooks-slider.png
new file mode 100644
index 0000000000..8dfaa01092
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-slider.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-spinbox.png b/src/widgets/doc/images/cleanlooks-spinbox.png
new file mode 100644
index 0000000000..ad5b5a01b6
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-spinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-tableview.png b/src/widgets/doc/images/cleanlooks-tableview.png
new file mode 100644
index 0000000000..d89fecc5ad
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-tableview.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-tabwidget.png b/src/widgets/doc/images/cleanlooks-tabwidget.png
new file mode 100644
index 0000000000..bcff2967aa
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-tabwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-textedit.png b/src/widgets/doc/images/cleanlooks-textedit.png
new file mode 100644
index 0000000000..0c825a1e04
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-textedit.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-timeedit.png b/src/widgets/doc/images/cleanlooks-timeedit.png
new file mode 100644
index 0000000000..00420a2f18
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-timeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-toolbox.png b/src/widgets/doc/images/cleanlooks-toolbox.png
new file mode 100644
index 0000000000..63366e5422
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-toolbox.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-toolbutton.png b/src/widgets/doc/images/cleanlooks-toolbutton.png
new file mode 100644
index 0000000000..bcf86ea26f
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-toolbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/cleanlooks-treeview.png b/src/widgets/doc/images/cleanlooks-treeview.png
new file mode 100644
index 0000000000..5bc4a06a3c
--- /dev/null
+++ b/src/widgets/doc/images/cleanlooks-treeview.png
Binary files differ
diff --git a/src/widgets/doc/images/clock.png b/src/widgets/doc/images/clock.png
new file mode 100644
index 0000000000..c7f6a1b296
--- /dev/null
+++ b/src/widgets/doc/images/clock.png
Binary files differ
diff --git a/src/widgets/doc/images/columnview.png b/src/widgets/doc/images/columnview.png
new file mode 100644
index 0000000000..127b79531f
--- /dev/null
+++ b/src/widgets/doc/images/columnview.png
Binary files differ
diff --git a/src/widgets/doc/images/designer-stylesheet-options.png b/src/widgets/doc/images/designer-stylesheet-options.png
new file mode 100644
index 0000000000..a6893e770b
--- /dev/null
+++ b/src/widgets/doc/images/designer-stylesheet-options.png
Binary files differ
diff --git a/src/widgets/doc/images/designer-stylesheet-usage.png b/src/widgets/doc/images/designer-stylesheet-usage.png
new file mode 100644
index 0000000000..f6875900de
--- /dev/null
+++ b/src/widgets/doc/images/designer-stylesheet-usage.png
Binary files differ
diff --git a/src/widgets/doc/images/designer-validator-highlighter.png b/src/widgets/doc/images/designer-validator-highlighter.png
new file mode 100644
index 0000000000..a6661d5c95
--- /dev/null
+++ b/src/widgets/doc/images/designer-validator-highlighter.png
Binary files differ
diff --git a/src/widgets/doc/images/dummy_tree.png b/src/widgets/doc/images/dummy_tree.png
new file mode 100644
index 0000000000..7373ea60f6
--- /dev/null
+++ b/src/widgets/doc/images/dummy_tree.png
Binary files differ
diff --git a/src/widgets/doc/images/example_model.png b/src/widgets/doc/images/example_model.png
new file mode 100644
index 0000000000..4261261c7e
--- /dev/null
+++ b/src/widgets/doc/images/example_model.png
Binary files differ
diff --git a/src/widgets/doc/images/filedialogurls.png b/src/widgets/doc/images/filedialogurls.png
new file mode 100644
index 0000000000..7d22ef33ae
--- /dev/null
+++ b/src/widgets/doc/images/filedialogurls.png
Binary files differ
diff --git a/src/widgets/doc/images/frames.png b/src/widgets/doc/images/frames.png
new file mode 100644
index 0000000000..13c08508a2
--- /dev/null
+++ b/src/widgets/doc/images/frames.png
Binary files differ
diff --git a/src/widgets/doc/images/graphicsview-ellipseitem-pie.png b/src/widgets/doc/images/graphicsview-ellipseitem-pie.png
new file mode 100644
index 0000000000..136175abc2
--- /dev/null
+++ b/src/widgets/doc/images/graphicsview-ellipseitem-pie.png
Binary files differ
diff --git a/src/widgets/doc/images/graphicsview-ellipseitem.png b/src/widgets/doc/images/graphicsview-ellipseitem.png
new file mode 100644
index 0000000000..7c7a8e58d0
--- /dev/null
+++ b/src/widgets/doc/images/graphicsview-ellipseitem.png
Binary files differ
diff --git a/src/widgets/doc/images/graphicsview-items.png b/src/widgets/doc/images/graphicsview-items.png
new file mode 100644
index 0000000000..73be2ddaee
--- /dev/null
+++ b/src/widgets/doc/images/graphicsview-items.png
Binary files differ
diff --git a/src/widgets/doc/images/graphicsview-pathitem.png b/src/widgets/doc/images/graphicsview-pathitem.png
new file mode 100644
index 0000000000..c1ddd5620a
--- /dev/null
+++ b/src/widgets/doc/images/graphicsview-pathitem.png
Binary files differ
diff --git a/src/widgets/doc/images/graphicsview-pixmapitem.png b/src/widgets/doc/images/graphicsview-pixmapitem.png
new file mode 100644
index 0000000000..d14fac55e0
--- /dev/null
+++ b/src/widgets/doc/images/graphicsview-pixmapitem.png
Binary files differ
diff --git a/src/widgets/doc/images/graphicsview-polygonitem.png b/src/widgets/doc/images/graphicsview-polygonitem.png
new file mode 100644
index 0000000000..3cd2232574
--- /dev/null
+++ b/src/widgets/doc/images/graphicsview-polygonitem.png
Binary files differ
diff --git a/src/widgets/doc/images/graphicsview-rectitem.png b/src/widgets/doc/images/graphicsview-rectitem.png
new file mode 100644
index 0000000000..a5917e55dd
--- /dev/null
+++ b/src/widgets/doc/images/graphicsview-rectitem.png
Binary files differ
diff --git a/src/widgets/doc/images/graphicsview-zorder.png b/src/widgets/doc/images/graphicsview-zorder.png
new file mode 100644
index 0000000000..a1cc3d0168
--- /dev/null
+++ b/src/widgets/doc/images/graphicsview-zorder.png
Binary files differ
diff --git a/src/widgets/doc/images/gridlayout.png b/src/widgets/doc/images/gridlayout.png
new file mode 100644
index 0000000000..ae76c0487b
--- /dev/null
+++ b/src/widgets/doc/images/gridlayout.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-calendarwidget.png b/src/widgets/doc/images/gtk-calendarwidget.png
new file mode 100644
index 0000000000..568cd1a5da
--- /dev/null
+++ b/src/widgets/doc/images/gtk-calendarwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-checkbox.png b/src/widgets/doc/images/gtk-checkbox.png
new file mode 100644
index 0000000000..1fd5fc77bf
--- /dev/null
+++ b/src/widgets/doc/images/gtk-checkbox.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-combobox.png b/src/widgets/doc/images/gtk-combobox.png
new file mode 100644
index 0000000000..3b4544df13
--- /dev/null
+++ b/src/widgets/doc/images/gtk-combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-dateedit.png b/src/widgets/doc/images/gtk-dateedit.png
new file mode 100644
index 0000000000..25229f0b3b
--- /dev/null
+++ b/src/widgets/doc/images/gtk-dateedit.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-datetimeedit.png b/src/widgets/doc/images/gtk-datetimeedit.png
new file mode 100644
index 0000000000..0c934a4d0d
--- /dev/null
+++ b/src/widgets/doc/images/gtk-datetimeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-dial.png b/src/widgets/doc/images/gtk-dial.png
new file mode 100644
index 0000000000..18e14b3650
--- /dev/null
+++ b/src/widgets/doc/images/gtk-dial.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-doublespinbox.png b/src/widgets/doc/images/gtk-doublespinbox.png
new file mode 100644
index 0000000000..3a69043c0b
--- /dev/null
+++ b/src/widgets/doc/images/gtk-doublespinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-fontcombobox.png b/src/widgets/doc/images/gtk-fontcombobox.png
new file mode 100644
index 0000000000..4cb1bc1343
--- /dev/null
+++ b/src/widgets/doc/images/gtk-fontcombobox.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-frame.png b/src/widgets/doc/images/gtk-frame.png
new file mode 100644
index 0000000000..c1bf52f6a6
--- /dev/null
+++ b/src/widgets/doc/images/gtk-frame.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-groupbox.png b/src/widgets/doc/images/gtk-groupbox.png
new file mode 100644
index 0000000000..6d217c89f9
--- /dev/null
+++ b/src/widgets/doc/images/gtk-groupbox.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-horizontalscrollbar.png b/src/widgets/doc/images/gtk-horizontalscrollbar.png
new file mode 100644
index 0000000000..2887730c13
--- /dev/null
+++ b/src/widgets/doc/images/gtk-horizontalscrollbar.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-label.png b/src/widgets/doc/images/gtk-label.png
new file mode 100644
index 0000000000..006d0133d8
--- /dev/null
+++ b/src/widgets/doc/images/gtk-label.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-lcdnumber.png b/src/widgets/doc/images/gtk-lcdnumber.png
new file mode 100644
index 0000000000..142d298ffc
--- /dev/null
+++ b/src/widgets/doc/images/gtk-lcdnumber.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-lineedit.png b/src/widgets/doc/images/gtk-lineedit.png
new file mode 100644
index 0000000000..8fb513c39f
--- /dev/null
+++ b/src/widgets/doc/images/gtk-lineedit.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-listview.png b/src/widgets/doc/images/gtk-listview.png
new file mode 100644
index 0000000000..d32f8e8aee
--- /dev/null
+++ b/src/widgets/doc/images/gtk-listview.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-progressbar.png b/src/widgets/doc/images/gtk-progressbar.png
new file mode 100644
index 0000000000..6162484bf3
--- /dev/null
+++ b/src/widgets/doc/images/gtk-progressbar.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-pushbutton.png b/src/widgets/doc/images/gtk-pushbutton.png
new file mode 100644
index 0000000000..f4f4d7c1e4
--- /dev/null
+++ b/src/widgets/doc/images/gtk-pushbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-radiobutton.png b/src/widgets/doc/images/gtk-radiobutton.png
new file mode 100644
index 0000000000..b3620fa054
--- /dev/null
+++ b/src/widgets/doc/images/gtk-radiobutton.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-slider.png b/src/widgets/doc/images/gtk-slider.png
new file mode 100644
index 0000000000..3d8e0ee89e
--- /dev/null
+++ b/src/widgets/doc/images/gtk-slider.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-spinbox.png b/src/widgets/doc/images/gtk-spinbox.png
new file mode 100644
index 0000000000..a39eb3aa93
--- /dev/null
+++ b/src/widgets/doc/images/gtk-spinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-tableview.png b/src/widgets/doc/images/gtk-tableview.png
new file mode 100644
index 0000000000..a025193188
--- /dev/null
+++ b/src/widgets/doc/images/gtk-tableview.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-tabwidget.png b/src/widgets/doc/images/gtk-tabwidget.png
new file mode 100644
index 0000000000..089c76dad2
--- /dev/null
+++ b/src/widgets/doc/images/gtk-tabwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-textedit.png b/src/widgets/doc/images/gtk-textedit.png
new file mode 100644
index 0000000000..e4b91c01c9
--- /dev/null
+++ b/src/widgets/doc/images/gtk-textedit.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-timeedit.png b/src/widgets/doc/images/gtk-timeedit.png
new file mode 100644
index 0000000000..acf6730a86
--- /dev/null
+++ b/src/widgets/doc/images/gtk-timeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-toolbox.png b/src/widgets/doc/images/gtk-toolbox.png
new file mode 100644
index 0000000000..25e6137699
--- /dev/null
+++ b/src/widgets/doc/images/gtk-toolbox.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-toolbutton.png b/src/widgets/doc/images/gtk-toolbutton.png
new file mode 100644
index 0000000000..f0eb86efc5
--- /dev/null
+++ b/src/widgets/doc/images/gtk-toolbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/gtk-treeview.png b/src/widgets/doc/images/gtk-treeview.png
new file mode 100644
index 0000000000..7b4e3044be
--- /dev/null
+++ b/src/widgets/doc/images/gtk-treeview.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/branchindicatorimage.png b/src/widgets/doc/images/javastyle/branchindicatorimage.png
new file mode 100644
index 0000000000..f2cfc4b2e9
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/branchindicatorimage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/button.png b/src/widgets/doc/images/javastyle/button.png
new file mode 100644
index 0000000000..c3a97425b1
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/button.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/checkbox.png b/src/widgets/doc/images/javastyle/checkbox.png
new file mode 100644
index 0000000000..bc841a6a6d
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/checkbox.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/checkboxexample.png b/src/widgets/doc/images/javastyle/checkboxexample.png
new file mode 100644
index 0000000000..69217fb2e5
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/checkboxexample.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/combobox.png b/src/widgets/doc/images/javastyle/combobox.png
new file mode 100644
index 0000000000..de9745a218
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/comboboximage.png b/src/widgets/doc/images/javastyle/comboboximage.png
new file mode 100644
index 0000000000..1f05e5fe86
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/comboboximage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/conceptualpushbuttontree.png b/src/widgets/doc/images/javastyle/conceptualpushbuttontree.png
new file mode 100644
index 0000000000..910000a6e8
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/conceptualpushbuttontree.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/dockwidget.png b/src/widgets/doc/images/javastyle/dockwidget.png
new file mode 100644
index 0000000000..4bfec142bf
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/dockwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/dockwidgetimage.png b/src/widgets/doc/images/javastyle/dockwidgetimage.png
new file mode 100644
index 0000000000..eefe171e3e
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/dockwidgetimage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/groupbox.png b/src/widgets/doc/images/javastyle/groupbox.png
new file mode 100644
index 0000000000..a39cd42c9f
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/groupbox.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/groupboximage.png b/src/widgets/doc/images/javastyle/groupboximage.png
new file mode 100644
index 0000000000..5baf6092d4
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/groupboximage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/header.png b/src/widgets/doc/images/javastyle/header.png
new file mode 100644
index 0000000000..b4546d840e
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/header.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/headerimage.png b/src/widgets/doc/images/javastyle/headerimage.png
new file mode 100644
index 0000000000..41171497d5
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/headerimage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/menu.png b/src/widgets/doc/images/javastyle/menu.png
new file mode 100644
index 0000000000..8d44da4054
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/menu.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/menubar.png b/src/widgets/doc/images/javastyle/menubar.png
new file mode 100644
index 0000000000..e68e4a3a55
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/menubar.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/menubarimage.png b/src/widgets/doc/images/javastyle/menubarimage.png
new file mode 100644
index 0000000000..b0cf28edcc
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/menubarimage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/menuimage.png b/src/widgets/doc/images/javastyle/menuimage.png
new file mode 100644
index 0000000000..282dde7159
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/menuimage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/progressbar.png b/src/widgets/doc/images/javastyle/progressbar.png
new file mode 100644
index 0000000000..de3a838c38
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/progressbar.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/progressbarimage.png b/src/widgets/doc/images/javastyle/progressbarimage.png
new file mode 100644
index 0000000000..433b900ab5
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/progressbarimage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/pushbutton.png b/src/widgets/doc/images/javastyle/pushbutton.png
new file mode 100644
index 0000000000..e5f92bea12
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/pushbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/rubberband.png b/src/widgets/doc/images/javastyle/rubberband.png
new file mode 100644
index 0000000000..087424a3f0
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/rubberband.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/rubberbandimage.png b/src/widgets/doc/images/javastyle/rubberbandimage.png
new file mode 100644
index 0000000000..2794638dbc
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/rubberbandimage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/scrollbar.png b/src/widgets/doc/images/javastyle/scrollbar.png
new file mode 100644
index 0000000000..c1ecb5d655
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/scrollbar.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/scrollbarimage.png b/src/widgets/doc/images/javastyle/scrollbarimage.png
new file mode 100644
index 0000000000..6d3e29d8dd
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/scrollbarimage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/sizegrip.png b/src/widgets/doc/images/javastyle/sizegrip.png
new file mode 100644
index 0000000000..667e6fb465
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/sizegrip.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/sizegripimage.png b/src/widgets/doc/images/javastyle/sizegripimage.png
new file mode 100644
index 0000000000..ccbf5254d3
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/sizegripimage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/slider.png b/src/widgets/doc/images/javastyle/slider.png
new file mode 100644
index 0000000000..a382233f58
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/slider.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/sliderimage.png b/src/widgets/doc/images/javastyle/sliderimage.png
new file mode 100644
index 0000000000..df700dd712
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/sliderimage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/spinbox.png b/src/widgets/doc/images/javastyle/spinbox.png
new file mode 100644
index 0000000000..ec9d6e0d75
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/spinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/spinboximage.png b/src/widgets/doc/images/javastyle/spinboximage.png
new file mode 100644
index 0000000000..d0d57c8ffb
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/spinboximage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/tab.png b/src/widgets/doc/images/javastyle/tab.png
new file mode 100644
index 0000000000..616580c839
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/tab.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/tabwidget.png b/src/widgets/doc/images/javastyle/tabwidget.png
new file mode 100644
index 0000000000..737155ccb9
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/tabwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/titlebar.png b/src/widgets/doc/images/javastyle/titlebar.png
new file mode 100644
index 0000000000..5d7ecc481d
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/titlebar.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/titlebarimage.png b/src/widgets/doc/images/javastyle/titlebarimage.png
new file mode 100644
index 0000000000..50287aeb1d
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/titlebarimage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/toolbar.png b/src/widgets/doc/images/javastyle/toolbar.png
new file mode 100644
index 0000000000..e69e8df4c8
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/toolbar.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/toolbarimage.png b/src/widgets/doc/images/javastyle/toolbarimage.png
new file mode 100644
index 0000000000..b9025f582a
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/toolbarimage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/toolbox.png b/src/widgets/doc/images/javastyle/toolbox.png
new file mode 100644
index 0000000000..c5f61ecec8
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/toolbox.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/toolboximage.png b/src/widgets/doc/images/javastyle/toolboximage.png
new file mode 100644
index 0000000000..7bcbd26432
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/toolboximage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/toolbutton.png b/src/widgets/doc/images/javastyle/toolbutton.png
new file mode 100644
index 0000000000..9167e83f75
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/toolbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/toolbuttonimage.png b/src/widgets/doc/images/javastyle/toolbuttonimage.png
new file mode 100644
index 0000000000..3217172fca
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/toolbuttonimage.png
Binary files differ
diff --git a/src/widgets/doc/images/javastyle/windowstabimage.png b/src/widgets/doc/images/javastyle/windowstabimage.png
new file mode 100644
index 0000000000..485e847844
--- /dev/null
+++ b/src/widgets/doc/images/javastyle/windowstabimage.png
Binary files differ
diff --git a/src/widgets/doc/images/licensewizard-flow.png b/src/widgets/doc/images/licensewizard-flow.png
new file mode 100644
index 0000000000..76df63a98f
--- /dev/null
+++ b/src/widgets/doc/images/licensewizard-flow.png
Binary files differ
diff --git a/src/widgets/doc/images/list_table_tree.png b/src/widgets/doc/images/list_table_tree.png
new file mode 100644
index 0000000000..b2daf1f3a5
--- /dev/null
+++ b/src/widgets/doc/images/list_table_tree.png
Binary files differ
diff --git a/src/widgets/doc/images/listview.png b/src/widgets/doc/images/listview.png
new file mode 100755
index 0000000000..fa49c52c62
--- /dev/null
+++ b/src/widgets/doc/images/listview.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-calendarwidget.png b/src/widgets/doc/images/macintosh-calendarwidget.png
new file mode 100644
index 0000000000..2f743501a9
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-calendarwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-checkbox.png b/src/widgets/doc/images/macintosh-checkbox.png
new file mode 100644
index 0000000000..d0130e3f22
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-checkbox.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-combobox.png b/src/widgets/doc/images/macintosh-combobox.png
new file mode 100644
index 0000000000..c1dc3c0c96
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-dateedit.png b/src/widgets/doc/images/macintosh-dateedit.png
new file mode 100644
index 0000000000..45aee90a9b
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-dateedit.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-datetimeedit.png b/src/widgets/doc/images/macintosh-datetimeedit.png
new file mode 100644
index 0000000000..62af02d64e
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-datetimeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-dial.png b/src/widgets/doc/images/macintosh-dial.png
new file mode 100644
index 0000000000..df0ffe23a1
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-dial.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-doublespinbox.png b/src/widgets/doc/images/macintosh-doublespinbox.png
new file mode 100644
index 0000000000..a0695ff278
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-doublespinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-fontcombobox.png b/src/widgets/doc/images/macintosh-fontcombobox.png
new file mode 100644
index 0000000000..8a5a3c78a3
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-fontcombobox.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-frame.png b/src/widgets/doc/images/macintosh-frame.png
new file mode 100644
index 0000000000..fee61a3643
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-frame.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-groupbox.png b/src/widgets/doc/images/macintosh-groupbox.png
new file mode 100644
index 0000000000..f6c7bce580
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-groupbox.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-horizontalscrollbar.png b/src/widgets/doc/images/macintosh-horizontalscrollbar.png
new file mode 100644
index 0000000000..8b63572a9e
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-horizontalscrollbar.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-label.png b/src/widgets/doc/images/macintosh-label.png
new file mode 100644
index 0000000000..753aa4d138
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-label.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-lcdnumber.png b/src/widgets/doc/images/macintosh-lcdnumber.png
new file mode 100644
index 0000000000..2ea9ea0713
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-lcdnumber.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-lineedit.png b/src/widgets/doc/images/macintosh-lineedit.png
new file mode 100644
index 0000000000..0e992c7ffe
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-lineedit.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-listview.png b/src/widgets/doc/images/macintosh-listview.png
new file mode 100644
index 0000000000..346e6427ff
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-listview.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-menu.png b/src/widgets/doc/images/macintosh-menu.png
new file mode 100644
index 0000000000..59bdceaab6
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-menu.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-progressbar.png b/src/widgets/doc/images/macintosh-progressbar.png
new file mode 100644
index 0000000000..2dfc8aba81
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-progressbar.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-pushbutton.png b/src/widgets/doc/images/macintosh-pushbutton.png
new file mode 100644
index 0000000000..7ec14910d8
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-pushbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-radiobutton.png b/src/widgets/doc/images/macintosh-radiobutton.png
new file mode 100644
index 0000000000..8b02f509ff
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-radiobutton.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-slider.png b/src/widgets/doc/images/macintosh-slider.png
new file mode 100644
index 0000000000..bf0c5464e9
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-slider.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-spinbox.png b/src/widgets/doc/images/macintosh-spinbox.png
new file mode 100644
index 0000000000..4196c37246
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-spinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-tableview.png b/src/widgets/doc/images/macintosh-tableview.png
new file mode 100644
index 0000000000..e6512494de
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-tableview.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-tabwidget.png b/src/widgets/doc/images/macintosh-tabwidget.png
new file mode 100644
index 0000000000..1d174a47e6
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-tabwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-textedit.png b/src/widgets/doc/images/macintosh-textedit.png
new file mode 100644
index 0000000000..4f0ce36baf
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-textedit.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-timeedit.png b/src/widgets/doc/images/macintosh-timeedit.png
new file mode 100644
index 0000000000..4bcfce33f8
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-timeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-toolbox.png b/src/widgets/doc/images/macintosh-toolbox.png
new file mode 100644
index 0000000000..18d41ea595
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-toolbox.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-toolbutton.png b/src/widgets/doc/images/macintosh-toolbutton.png
new file mode 100644
index 0000000000..f91331cc51
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-toolbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/macintosh-treeview.png b/src/widgets/doc/images/macintosh-treeview.png
new file mode 100644
index 0000000000..afda6d8372
--- /dev/null
+++ b/src/widgets/doc/images/macintosh-treeview.png
Binary files differ
diff --git a/src/widgets/doc/images/mainwindow-docks-example.png b/src/widgets/doc/images/mainwindow-docks-example.png
new file mode 100644
index 0000000000..a5641fd9cd
--- /dev/null
+++ b/src/widgets/doc/images/mainwindow-docks-example.png
Binary files differ
diff --git a/src/widgets/doc/images/mainwindow-docks.png b/src/widgets/doc/images/mainwindow-docks.png
new file mode 100644
index 0000000000..24f42a28ea
--- /dev/null
+++ b/src/widgets/doc/images/mainwindow-docks.png
Binary files differ
diff --git a/src/widgets/doc/images/mainwindowlayout.png b/src/widgets/doc/images/mainwindowlayout.png
new file mode 100644
index 0000000000..4776ce4f1b
--- /dev/null
+++ b/src/widgets/doc/images/mainwindowlayout.png
Binary files differ
diff --git a/src/widgets/doc/images/mdi-cascade.png b/src/widgets/doc/images/mdi-cascade.png
new file mode 100644
index 0000000000..ca55a5b894
--- /dev/null
+++ b/src/widgets/doc/images/mdi-cascade.png
Binary files differ
diff --git a/src/widgets/doc/images/mdi-tile.png b/src/widgets/doc/images/mdi-tile.png
new file mode 100644
index 0000000000..1486d9654e
--- /dev/null
+++ b/src/widgets/doc/images/mdi-tile.png
Binary files differ
diff --git a/src/widgets/doc/images/modelview-combobox.png b/src/widgets/doc/images/modelview-combobox.png
new file mode 100755
index 0000000000..d172b413eb
--- /dev/null
+++ b/src/widgets/doc/images/modelview-combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/modelview-header.png b/src/widgets/doc/images/modelview-header.png
new file mode 100644
index 0000000000..2597635b9f
--- /dev/null
+++ b/src/widgets/doc/images/modelview-header.png
Binary files differ
diff --git a/src/widgets/doc/images/modelview-models.png b/src/widgets/doc/images/modelview-models.png
new file mode 100644
index 0000000000..183a7cffd5
--- /dev/null
+++ b/src/widgets/doc/images/modelview-models.png
Binary files differ
diff --git a/src/widgets/doc/images/modelview-overview.png b/src/widgets/doc/images/modelview-overview.png
new file mode 100644
index 0000000000..41e3a6827f
--- /dev/null
+++ b/src/widgets/doc/images/modelview-overview.png
Binary files differ
diff --git a/src/widgets/doc/images/modelview-roles.png b/src/widgets/doc/images/modelview-roles.png
new file mode 100644
index 0000000000..2a60ce7190
--- /dev/null
+++ b/src/widgets/doc/images/modelview-roles.png
Binary files differ
diff --git a/src/widgets/doc/images/modelview-tablemodel.png b/src/widgets/doc/images/modelview-tablemodel.png
new file mode 100644
index 0000000000..9a9ea2f1b0
--- /dev/null
+++ b/src/widgets/doc/images/modelview-tablemodel.png
Binary files differ
diff --git a/src/widgets/doc/images/modelview-treemodel.png b/src/widgets/doc/images/modelview-treemodel.png
new file mode 100644
index 0000000000..f7b02eb150
--- /dev/null
+++ b/src/widgets/doc/images/modelview-treemodel.png
Binary files differ
diff --git a/src/widgets/doc/images/modelview.png b/src/widgets/doc/images/modelview.png
new file mode 100644
index 0000000000..7b042af8a4
--- /dev/null
+++ b/src/widgets/doc/images/modelview.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-calendarwidget.png b/src/widgets/doc/images/motif-calendarwidget.png
new file mode 100644
index 0000000000..4ce6aebc21
--- /dev/null
+++ b/src/widgets/doc/images/motif-calendarwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-checkbox.png b/src/widgets/doc/images/motif-checkbox.png
new file mode 100644
index 0000000000..2a263273a6
--- /dev/null
+++ b/src/widgets/doc/images/motif-checkbox.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-combobox.png b/src/widgets/doc/images/motif-combobox.png
new file mode 100644
index 0000000000..2a288d9f40
--- /dev/null
+++ b/src/widgets/doc/images/motif-combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-dateedit.png b/src/widgets/doc/images/motif-dateedit.png
new file mode 100644
index 0000000000..d00c45ff65
--- /dev/null
+++ b/src/widgets/doc/images/motif-dateedit.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-datetimeedit.png b/src/widgets/doc/images/motif-datetimeedit.png
new file mode 100644
index 0000000000..cc43ef888d
--- /dev/null
+++ b/src/widgets/doc/images/motif-datetimeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-dial.png b/src/widgets/doc/images/motif-dial.png
new file mode 100644
index 0000000000..36b3ff7be0
--- /dev/null
+++ b/src/widgets/doc/images/motif-dial.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-doublespinbox.png b/src/widgets/doc/images/motif-doublespinbox.png
new file mode 100644
index 0000000000..6092913ab0
--- /dev/null
+++ b/src/widgets/doc/images/motif-doublespinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-fontcombobox.png b/src/widgets/doc/images/motif-fontcombobox.png
new file mode 100644
index 0000000000..c07452d85e
--- /dev/null
+++ b/src/widgets/doc/images/motif-fontcombobox.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-frame.png b/src/widgets/doc/images/motif-frame.png
new file mode 100644
index 0000000000..55dcc32227
--- /dev/null
+++ b/src/widgets/doc/images/motif-frame.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-groupbox.png b/src/widgets/doc/images/motif-groupbox.png
new file mode 100644
index 0000000000..13742b116e
--- /dev/null
+++ b/src/widgets/doc/images/motif-groupbox.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-horizontalscrollbar.png b/src/widgets/doc/images/motif-horizontalscrollbar.png
new file mode 100644
index 0000000000..dab1d3f6f6
--- /dev/null
+++ b/src/widgets/doc/images/motif-horizontalscrollbar.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-label.png b/src/widgets/doc/images/motif-label.png
new file mode 100644
index 0000000000..7ae6674f50
--- /dev/null
+++ b/src/widgets/doc/images/motif-label.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-lcdnumber.png b/src/widgets/doc/images/motif-lcdnumber.png
new file mode 100644
index 0000000000..e2cc9a8058
--- /dev/null
+++ b/src/widgets/doc/images/motif-lcdnumber.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-lineedit.png b/src/widgets/doc/images/motif-lineedit.png
new file mode 100644
index 0000000000..a335c8c107
--- /dev/null
+++ b/src/widgets/doc/images/motif-lineedit.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-listview.png b/src/widgets/doc/images/motif-listview.png
new file mode 100644
index 0000000000..47bd3eae6d
--- /dev/null
+++ b/src/widgets/doc/images/motif-listview.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-menubar.png b/src/widgets/doc/images/motif-menubar.png
new file mode 100644
index 0000000000..f1d9f4bb3d
--- /dev/null
+++ b/src/widgets/doc/images/motif-menubar.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-progressbar.png b/src/widgets/doc/images/motif-progressbar.png
new file mode 100644
index 0000000000..f6d6979b86
--- /dev/null
+++ b/src/widgets/doc/images/motif-progressbar.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-pushbutton.png b/src/widgets/doc/images/motif-pushbutton.png
new file mode 100644
index 0000000000..9dc6a9db78
--- /dev/null
+++ b/src/widgets/doc/images/motif-pushbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-radiobutton.png b/src/widgets/doc/images/motif-radiobutton.png
new file mode 100644
index 0000000000..468e54cfcf
--- /dev/null
+++ b/src/widgets/doc/images/motif-radiobutton.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-slider.png b/src/widgets/doc/images/motif-slider.png
new file mode 100644
index 0000000000..6301e2b26d
--- /dev/null
+++ b/src/widgets/doc/images/motif-slider.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-spinbox.png b/src/widgets/doc/images/motif-spinbox.png
new file mode 100644
index 0000000000..9acc2821c8
--- /dev/null
+++ b/src/widgets/doc/images/motif-spinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-tableview.png b/src/widgets/doc/images/motif-tableview.png
new file mode 100644
index 0000000000..a1d205aaed
--- /dev/null
+++ b/src/widgets/doc/images/motif-tableview.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-tabwidget.png b/src/widgets/doc/images/motif-tabwidget.png
new file mode 100644
index 0000000000..19da66a76c
--- /dev/null
+++ b/src/widgets/doc/images/motif-tabwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-textedit.png b/src/widgets/doc/images/motif-textedit.png
new file mode 100644
index 0000000000..205bc19cfa
--- /dev/null
+++ b/src/widgets/doc/images/motif-textedit.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-timeedit.png b/src/widgets/doc/images/motif-timeedit.png
new file mode 100644
index 0000000000..1ad459b886
--- /dev/null
+++ b/src/widgets/doc/images/motif-timeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-toolbox.png b/src/widgets/doc/images/motif-toolbox.png
new file mode 100644
index 0000000000..4bc3c37bb2
--- /dev/null
+++ b/src/widgets/doc/images/motif-toolbox.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-toolbutton.png b/src/widgets/doc/images/motif-toolbutton.png
new file mode 100644
index 0000000000..8ef51ddd8d
--- /dev/null
+++ b/src/widgets/doc/images/motif-toolbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/motif-treeview.png b/src/widgets/doc/images/motif-treeview.png
new file mode 100644
index 0000000000..a7dd0f2466
--- /dev/null
+++ b/src/widgets/doc/images/motif-treeview.png
Binary files differ
diff --git a/src/widgets/doc/images/msgbox1.png b/src/widgets/doc/images/msgbox1.png
new file mode 100644
index 0000000000..1380e20a5f
--- /dev/null
+++ b/src/widgets/doc/images/msgbox1.png
Binary files differ
diff --git a/src/widgets/doc/images/msgbox2.png b/src/widgets/doc/images/msgbox2.png
new file mode 100644
index 0000000000..e7946996e4
--- /dev/null
+++ b/src/widgets/doc/images/msgbox2.png
Binary files differ
diff --git a/src/widgets/doc/images/msgbox3.png b/src/widgets/doc/images/msgbox3.png
new file mode 100644
index 0000000000..bd81f4d4da
--- /dev/null
+++ b/src/widgets/doc/images/msgbox3.png
Binary files differ
diff --git a/src/widgets/doc/images/msgbox4.png b/src/widgets/doc/images/msgbox4.png
new file mode 100644
index 0000000000..dbe6701cdd
--- /dev/null
+++ b/src/widgets/doc/images/msgbox4.png
Binary files differ
diff --git a/src/widgets/doc/images/pangesture.png b/src/widgets/doc/images/pangesture.png
new file mode 100644
index 0000000000..24caf91d3b
--- /dev/null
+++ b/src/widgets/doc/images/pangesture.png
Binary files differ
diff --git a/src/widgets/doc/images/parent-child-widgets.png b/src/widgets/doc/images/parent-child-widgets.png
new file mode 100644
index 0000000000..094e2e96b6
--- /dev/null
+++ b/src/widgets/doc/images/parent-child-widgets.png
Binary files differ
diff --git a/src/widgets/doc/images/pinchgesture.png b/src/widgets/doc/images/pinchgesture.png
new file mode 100644
index 0000000000..95614c4052
--- /dev/null
+++ b/src/widgets/doc/images/pinchgesture.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-calendarwidget.png b/src/widgets/doc/images/plastique-calendarwidget.png
new file mode 100644
index 0000000000..5e65945c72
--- /dev/null
+++ b/src/widgets/doc/images/plastique-calendarwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-checkbox.png b/src/widgets/doc/images/plastique-checkbox.png
new file mode 100644
index 0000000000..91a5109d65
--- /dev/null
+++ b/src/widgets/doc/images/plastique-checkbox.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-colordialog.png b/src/widgets/doc/images/plastique-colordialog.png
new file mode 100644
index 0000000000..68bf4d0b4b
--- /dev/null
+++ b/src/widgets/doc/images/plastique-colordialog.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-combobox.png b/src/widgets/doc/images/plastique-combobox.png
new file mode 100644
index 0000000000..e3bf8a321f
--- /dev/null
+++ b/src/widgets/doc/images/plastique-combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-dateedit.png b/src/widgets/doc/images/plastique-dateedit.png
new file mode 100644
index 0000000000..2e28a40f01
--- /dev/null
+++ b/src/widgets/doc/images/plastique-dateedit.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-datetimeedit.png b/src/widgets/doc/images/plastique-datetimeedit.png
new file mode 100644
index 0000000000..810bf1660a
--- /dev/null
+++ b/src/widgets/doc/images/plastique-datetimeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-dial.png b/src/widgets/doc/images/plastique-dial.png
new file mode 100644
index 0000000000..b65e7c78cd
--- /dev/null
+++ b/src/widgets/doc/images/plastique-dial.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-doublespinbox.png b/src/widgets/doc/images/plastique-doublespinbox.png
new file mode 100644
index 0000000000..627c4a20fe
--- /dev/null
+++ b/src/widgets/doc/images/plastique-doublespinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-fontcombobox.png b/src/widgets/doc/images/plastique-fontcombobox.png
new file mode 100644
index 0000000000..d3823081d8
--- /dev/null
+++ b/src/widgets/doc/images/plastique-fontcombobox.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-fontdialog.png b/src/widgets/doc/images/plastique-fontdialog.png
new file mode 100644
index 0000000000..7e799a8815
--- /dev/null
+++ b/src/widgets/doc/images/plastique-fontdialog.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-frame.png b/src/widgets/doc/images/plastique-frame.png
new file mode 100644
index 0000000000..9f81f6cba4
--- /dev/null
+++ b/src/widgets/doc/images/plastique-frame.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-groupbox.png b/src/widgets/doc/images/plastique-groupbox.png
new file mode 100644
index 0000000000..d353c40071
--- /dev/null
+++ b/src/widgets/doc/images/plastique-groupbox.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-horizontalscrollbar.png b/src/widgets/doc/images/plastique-horizontalscrollbar.png
new file mode 100644
index 0000000000..d20300c23f
--- /dev/null
+++ b/src/widgets/doc/images/plastique-horizontalscrollbar.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-label.png b/src/widgets/doc/images/plastique-label.png
new file mode 100644
index 0000000000..d2a55a862c
--- /dev/null
+++ b/src/widgets/doc/images/plastique-label.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-lcdnumber.png b/src/widgets/doc/images/plastique-lcdnumber.png
new file mode 100644
index 0000000000..74149ee158
--- /dev/null
+++ b/src/widgets/doc/images/plastique-lcdnumber.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-lineedit.png b/src/widgets/doc/images/plastique-lineedit.png
new file mode 100644
index 0000000000..f455383520
--- /dev/null
+++ b/src/widgets/doc/images/plastique-lineedit.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-listview.png b/src/widgets/doc/images/plastique-listview.png
new file mode 100644
index 0000000000..64bd00fe1f
--- /dev/null
+++ b/src/widgets/doc/images/plastique-listview.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-menu.png b/src/widgets/doc/images/plastique-menu.png
new file mode 100644
index 0000000000..88df2493af
--- /dev/null
+++ b/src/widgets/doc/images/plastique-menu.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-menubar.png b/src/widgets/doc/images/plastique-menubar.png
new file mode 100644
index 0000000000..642f95d6cf
--- /dev/null
+++ b/src/widgets/doc/images/plastique-menubar.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-progressbar.png b/src/widgets/doc/images/plastique-progressbar.png
new file mode 100644
index 0000000000..fe8dd90274
--- /dev/null
+++ b/src/widgets/doc/images/plastique-progressbar.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-progressdialog.png b/src/widgets/doc/images/plastique-progressdialog.png
new file mode 100644
index 0000000000..4373bcac16
--- /dev/null
+++ b/src/widgets/doc/images/plastique-progressdialog.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-pushbutton-menu.png b/src/widgets/doc/images/plastique-pushbutton-menu.png
new file mode 100644
index 0000000000..d090033aa7
--- /dev/null
+++ b/src/widgets/doc/images/plastique-pushbutton-menu.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-pushbutton.png b/src/widgets/doc/images/plastique-pushbutton.png
new file mode 100644
index 0000000000..83c44fd38d
--- /dev/null
+++ b/src/widgets/doc/images/plastique-pushbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-radiobutton.png b/src/widgets/doc/images/plastique-radiobutton.png
new file mode 100644
index 0000000000..a2c820d7d1
--- /dev/null
+++ b/src/widgets/doc/images/plastique-radiobutton.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-sizegrip.png b/src/widgets/doc/images/plastique-sizegrip.png
new file mode 100644
index 0000000000..09a551efab
--- /dev/null
+++ b/src/widgets/doc/images/plastique-sizegrip.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-slider.png b/src/widgets/doc/images/plastique-slider.png
new file mode 100644
index 0000000000..492f0fdfbd
--- /dev/null
+++ b/src/widgets/doc/images/plastique-slider.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-spinbox.png b/src/widgets/doc/images/plastique-spinbox.png
new file mode 100644
index 0000000000..af15db3c23
--- /dev/null
+++ b/src/widgets/doc/images/plastique-spinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-statusbar.png b/src/widgets/doc/images/plastique-statusbar.png
new file mode 100644
index 0000000000..c8f9792ab9
--- /dev/null
+++ b/src/widgets/doc/images/plastique-statusbar.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-tabbar-truncated.png b/src/widgets/doc/images/plastique-tabbar-truncated.png
new file mode 100644
index 0000000000..8e906d9928
--- /dev/null
+++ b/src/widgets/doc/images/plastique-tabbar-truncated.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-tabbar.png b/src/widgets/doc/images/plastique-tabbar.png
new file mode 100644
index 0000000000..3371dda1b6
--- /dev/null
+++ b/src/widgets/doc/images/plastique-tabbar.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-tableview.png b/src/widgets/doc/images/plastique-tableview.png
new file mode 100644
index 0000000000..b20c1cce7f
--- /dev/null
+++ b/src/widgets/doc/images/plastique-tableview.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-tabwidget.png b/src/widgets/doc/images/plastique-tabwidget.png
new file mode 100644
index 0000000000..92ae398844
--- /dev/null
+++ b/src/widgets/doc/images/plastique-tabwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-textedit.png b/src/widgets/doc/images/plastique-textedit.png
new file mode 100644
index 0000000000..a802d75fcc
--- /dev/null
+++ b/src/widgets/doc/images/plastique-textedit.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-timeedit.png b/src/widgets/doc/images/plastique-timeedit.png
new file mode 100644
index 0000000000..2d70b84c4c
--- /dev/null
+++ b/src/widgets/doc/images/plastique-timeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-toolbox.png b/src/widgets/doc/images/plastique-toolbox.png
new file mode 100644
index 0000000000..10bcd7af62
--- /dev/null
+++ b/src/widgets/doc/images/plastique-toolbox.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-toolbutton.png b/src/widgets/doc/images/plastique-toolbutton.png
new file mode 100644
index 0000000000..4e51831408
--- /dev/null
+++ b/src/widgets/doc/images/plastique-toolbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/plastique-treeview.png b/src/widgets/doc/images/plastique-treeview.png
new file mode 100644
index 0000000000..db0bc01a25
--- /dev/null
+++ b/src/widgets/doc/images/plastique-treeview.png
Binary files differ
diff --git a/src/widgets/doc/images/progressBar-stylesheet.png b/src/widgets/doc/images/progressBar-stylesheet.png
new file mode 100644
index 0000000000..b4bf755b6c
--- /dev/null
+++ b/src/widgets/doc/images/progressBar-stylesheet.png
Binary files differ
diff --git a/src/widgets/doc/images/progressBar2-stylesheet.png b/src/widgets/doc/images/progressBar2-stylesheet.png
new file mode 100644
index 0000000000..8b5ecc0a66
--- /dev/null
+++ b/src/widgets/doc/images/progressBar2-stylesheet.png
Binary files differ
diff --git a/src/widgets/doc/images/propagation-custom.png b/src/widgets/doc/images/propagation-custom.png
new file mode 100644
index 0000000000..866b44d677
--- /dev/null
+++ b/src/widgets/doc/images/propagation-custom.png
Binary files differ
diff --git a/src/widgets/doc/images/propagation-standard.png b/src/widgets/doc/images/propagation-standard.png
new file mode 100644
index 0000000000..b010fccc95
--- /dev/null
+++ b/src/widgets/doc/images/propagation-standard.png
Binary files differ
diff --git a/src/widgets/doc/images/qcalendarwidget-grid.png b/src/widgets/doc/images/qcalendarwidget-grid.png
new file mode 100644
index 0000000000..3df4dd99e2
--- /dev/null
+++ b/src/widgets/doc/images/qcalendarwidget-grid.png
Binary files differ
diff --git a/src/widgets/doc/images/qcalendarwidget-maximum.png b/src/widgets/doc/images/qcalendarwidget-maximum.png
new file mode 100644
index 0000000000..1e78d20e85
--- /dev/null
+++ b/src/widgets/doc/images/qcalendarwidget-maximum.png
Binary files differ
diff --git a/src/widgets/doc/images/qcalendarwidget-minimum.png b/src/widgets/doc/images/qcalendarwidget-minimum.png
new file mode 100644
index 0000000000..f860429309
--- /dev/null
+++ b/src/widgets/doc/images/qcalendarwidget-minimum.png
Binary files differ
diff --git a/src/widgets/doc/images/qcolumnview.png b/src/widgets/doc/images/qcolumnview.png
new file mode 100644
index 0000000000..1d312bf953
--- /dev/null
+++ b/src/widgets/doc/images/qcolumnview.png
Binary files differ
diff --git a/src/widgets/doc/images/qcompleter.png b/src/widgets/doc/images/qcompleter.png
new file mode 100644
index 0000000000..d25caacc72
--- /dev/null
+++ b/src/widgets/doc/images/qcompleter.png
Binary files differ
diff --git a/src/widgets/doc/images/qdesktopwidget.png b/src/widgets/doc/images/qdesktopwidget.png
new file mode 100644
index 0000000000..02f8e8b5ad
--- /dev/null
+++ b/src/widgets/doc/images/qdesktopwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/qformlayout-kde.png b/src/widgets/doc/images/qformlayout-kde.png
new file mode 100644
index 0000000000..c32bb12499
--- /dev/null
+++ b/src/widgets/doc/images/qformlayout-kde.png
Binary files differ
diff --git a/src/widgets/doc/images/qformlayout-mac.png b/src/widgets/doc/images/qformlayout-mac.png
new file mode 100644
index 0000000000..0a0824efb6
--- /dev/null
+++ b/src/widgets/doc/images/qformlayout-mac.png
Binary files differ
diff --git a/src/widgets/doc/images/qformlayout-qpe.png b/src/widgets/doc/images/qformlayout-qpe.png
new file mode 100644
index 0000000000..3abecc5716
--- /dev/null
+++ b/src/widgets/doc/images/qformlayout-qpe.png
Binary files differ
diff --git a/src/widgets/doc/images/qformlayout-win.png b/src/widgets/doc/images/qformlayout-win.png
new file mode 100644
index 0000000000..1ed44bdd3b
--- /dev/null
+++ b/src/widgets/doc/images/qformlayout-win.png
Binary files differ
diff --git a/src/widgets/doc/images/qformlayout-with-6-children.png b/src/widgets/doc/images/qformlayout-with-6-children.png
new file mode 100644
index 0000000000..f743599702
--- /dev/null
+++ b/src/widgets/doc/images/qformlayout-with-6-children.png
Binary files differ
diff --git a/src/widgets/doc/images/qgraphicsproxywidget-embed.png b/src/widgets/doc/images/qgraphicsproxywidget-embed.png
new file mode 100644
index 0000000000..10d8f6fddd
--- /dev/null
+++ b/src/widgets/doc/images/qgraphicsproxywidget-embed.png
Binary files differ
diff --git a/src/widgets/doc/images/qgridlayout-with-5-children.png b/src/widgets/doc/images/qgridlayout-with-5-children.png
new file mode 100644
index 0000000000..8d0c2962e4
--- /dev/null
+++ b/src/widgets/doc/images/qgridlayout-with-5-children.png
Binary files differ
diff --git a/src/widgets/doc/images/qhboxlayout-with-5-children.png b/src/widgets/doc/images/qhboxlayout-with-5-children.png
new file mode 100644
index 0000000000..9b48dc5c47
--- /dev/null
+++ b/src/widgets/doc/images/qhboxlayout-with-5-children.png
Binary files differ
diff --git a/src/widgets/doc/images/qmdisubwindowlayout.png b/src/widgets/doc/images/qmdisubwindowlayout.png
new file mode 100644
index 0000000000..ffe5cc3949
--- /dev/null
+++ b/src/widgets/doc/images/qmdisubwindowlayout.png
Binary files differ
diff --git a/src/widgets/doc/images/qscrollarea-noscrollbars.png b/src/widgets/doc/images/qscrollarea-noscrollbars.png
new file mode 100644
index 0000000000..a1520f3e21
--- /dev/null
+++ b/src/widgets/doc/images/qscrollarea-noscrollbars.png
Binary files differ
diff --git a/src/widgets/doc/images/qscrollarea-onescrollbar.png b/src/widgets/doc/images/qscrollarea-onescrollbar.png
new file mode 100644
index 0000000000..b4f7976bc4
--- /dev/null
+++ b/src/widgets/doc/images/qscrollarea-onescrollbar.png
Binary files differ
diff --git a/src/widgets/doc/images/qscrollarea-twoscrollbars.png b/src/widgets/doc/images/qscrollarea-twoscrollbars.png
new file mode 100644
index 0000000000..bf720e498c
--- /dev/null
+++ b/src/widgets/doc/images/qscrollarea-twoscrollbars.png
Binary files differ
diff --git a/src/widgets/doc/images/qscrollbar-picture.png b/src/widgets/doc/images/qscrollbar-picture.png
new file mode 100644
index 0000000000..898e014c40
--- /dev/null
+++ b/src/widgets/doc/images/qscrollbar-picture.png
Binary files differ
diff --git a/src/widgets/doc/images/qscrollbar-values.png b/src/widgets/doc/images/qscrollbar-values.png
new file mode 100644
index 0000000000..cea744b3be
--- /dev/null
+++ b/src/widgets/doc/images/qscrollbar-values.png
Binary files differ
diff --git a/src/widgets/doc/images/qspinbox-plusminus.png b/src/widgets/doc/images/qspinbox-plusminus.png
new file mode 100644
index 0000000000..3b35a408a0
--- /dev/null
+++ b/src/widgets/doc/images/qspinbox-plusminus.png
Binary files differ
diff --git a/src/widgets/doc/images/qspinbox-updown.png b/src/widgets/doc/images/qspinbox-updown.png
new file mode 100644
index 0000000000..a6caa4419b
--- /dev/null
+++ b/src/widgets/doc/images/qspinbox-updown.png
Binary files differ
diff --git a/src/widgets/doc/images/qstyle-comboboxes.png b/src/widgets/doc/images/qstyle-comboboxes.png
new file mode 100644
index 0000000000..aecec914a0
--- /dev/null
+++ b/src/widgets/doc/images/qstyle-comboboxes.png
Binary files differ
diff --git a/src/widgets/doc/images/qstyleoptiontoolbar-position.png b/src/widgets/doc/images/qstyleoptiontoolbar-position.png
new file mode 100644
index 0000000000..5eaae7e4cd
--- /dev/null
+++ b/src/widgets/doc/images/qstyleoptiontoolbar-position.png
Binary files differ
diff --git a/src/widgets/doc/images/qtableview-resized.png b/src/widgets/doc/images/qtableview-resized.png
new file mode 100644
index 0000000000..813256ee9e
--- /dev/null
+++ b/src/widgets/doc/images/qtableview-resized.png
Binary files differ
diff --git a/src/widgets/doc/images/qtwizard-aero1.png b/src/widgets/doc/images/qtwizard-aero1.png
new file mode 100644
index 0000000000..fe9e9bc21c
--- /dev/null
+++ b/src/widgets/doc/images/qtwizard-aero1.png
Binary files differ
diff --git a/src/widgets/doc/images/qtwizard-aero2.png b/src/widgets/doc/images/qtwizard-aero2.png
new file mode 100644
index 0000000000..261c0651fe
--- /dev/null
+++ b/src/widgets/doc/images/qtwizard-aero2.png
Binary files differ
diff --git a/src/widgets/doc/images/qtwizard-classic1.png b/src/widgets/doc/images/qtwizard-classic1.png
new file mode 100644
index 0000000000..be3edbecaf
--- /dev/null
+++ b/src/widgets/doc/images/qtwizard-classic1.png
Binary files differ
diff --git a/src/widgets/doc/images/qtwizard-classic2.png b/src/widgets/doc/images/qtwizard-classic2.png
new file mode 100644
index 0000000000..165f569d1d
--- /dev/null
+++ b/src/widgets/doc/images/qtwizard-classic2.png
Binary files differ
diff --git a/src/widgets/doc/images/qtwizard-mac1.png b/src/widgets/doc/images/qtwizard-mac1.png
new file mode 100644
index 0000000000..bc8cd9b715
--- /dev/null
+++ b/src/widgets/doc/images/qtwizard-mac1.png
Binary files differ
diff --git a/src/widgets/doc/images/qtwizard-mac2.png b/src/widgets/doc/images/qtwizard-mac2.png
new file mode 100644
index 0000000000..850f6b85a5
--- /dev/null
+++ b/src/widgets/doc/images/qtwizard-mac2.png
Binary files differ
diff --git a/src/widgets/doc/images/qtwizard-macpage.png b/src/widgets/doc/images/qtwizard-macpage.png
new file mode 100644
index 0000000000..1ba3122f91
--- /dev/null
+++ b/src/widgets/doc/images/qtwizard-macpage.png
Binary files differ
diff --git a/src/widgets/doc/images/qtwizard-modern1.png b/src/widgets/doc/images/qtwizard-modern1.png
new file mode 100644
index 0000000000..223e3ddec3
--- /dev/null
+++ b/src/widgets/doc/images/qtwizard-modern1.png
Binary files differ
diff --git a/src/widgets/doc/images/qtwizard-modern2.png b/src/widgets/doc/images/qtwizard-modern2.png
new file mode 100644
index 0000000000..d66c374a4c
--- /dev/null
+++ b/src/widgets/doc/images/qtwizard-modern2.png
Binary files differ
diff --git a/src/widgets/doc/images/qtwizard-nonmacpage.png b/src/widgets/doc/images/qtwizard-nonmacpage.png
new file mode 100644
index 0000000000..cbe464d57f
--- /dev/null
+++ b/src/widgets/doc/images/qtwizard-nonmacpage.png
Binary files differ
diff --git a/src/widgets/doc/images/qundoview.png b/src/widgets/doc/images/qundoview.png
new file mode 100644
index 0000000000..3bdb1cf2ed
--- /dev/null
+++ b/src/widgets/doc/images/qundoview.png
Binary files differ
diff --git a/src/widgets/doc/images/qvboxlayout-with-5-children.png b/src/widgets/doc/images/qvboxlayout-with-5-children.png
new file mode 100644
index 0000000000..57c37d7247
--- /dev/null
+++ b/src/widgets/doc/images/qvboxlayout-with-5-children.png
Binary files differ
diff --git a/src/widgets/doc/images/readonlytable_role.png b/src/widgets/doc/images/readonlytable_role.png
new file mode 100644
index 0000000000..7d2d416a53
--- /dev/null
+++ b/src/widgets/doc/images/readonlytable_role.png
Binary files differ
diff --git a/src/widgets/doc/images/selected-items1.png b/src/widgets/doc/images/selected-items1.png
new file mode 100644
index 0000000000..12b572d4d8
--- /dev/null
+++ b/src/widgets/doc/images/selected-items1.png
Binary files differ
diff --git a/src/widgets/doc/images/selected-items2.png b/src/widgets/doc/images/selected-items2.png
new file mode 100644
index 0000000000..ad247d90a9
--- /dev/null
+++ b/src/widgets/doc/images/selected-items2.png
Binary files differ
diff --git a/src/widgets/doc/images/selected-items3.png b/src/widgets/doc/images/selected-items3.png
new file mode 100644
index 0000000000..d7aa7be46b
--- /dev/null
+++ b/src/widgets/doc/images/selected-items3.png
Binary files differ
diff --git a/src/widgets/doc/images/selection-extended.png b/src/widgets/doc/images/selection-extended.png
new file mode 100644
index 0000000000..8ca488d812
--- /dev/null
+++ b/src/widgets/doc/images/selection-extended.png
Binary files differ
diff --git a/src/widgets/doc/images/selection-multi.png b/src/widgets/doc/images/selection-multi.png
new file mode 100644
index 0000000000..766e4a18bc
--- /dev/null
+++ b/src/widgets/doc/images/selection-multi.png
Binary files differ
diff --git a/src/widgets/doc/images/selection-single.png b/src/widgets/doc/images/selection-single.png
new file mode 100644
index 0000000000..d9d0655864
--- /dev/null
+++ b/src/widgets/doc/images/selection-single.png
Binary files differ
diff --git a/src/widgets/doc/images/selection2.png b/src/widgets/doc/images/selection2.png
new file mode 100644
index 0000000000..66c757f88e
--- /dev/null
+++ b/src/widgets/doc/images/selection2.png
Binary files differ
diff --git a/src/widgets/doc/images/shareddirmodel.png b/src/widgets/doc/images/shareddirmodel.png
new file mode 100644
index 0000000000..7b9fdeda04
--- /dev/null
+++ b/src/widgets/doc/images/shareddirmodel.png
Binary files differ
diff --git a/src/widgets/doc/images/sharedmodel-tableviews.png b/src/widgets/doc/images/sharedmodel-tableviews.png
new file mode 100644
index 0000000000..d241e4ca1a
--- /dev/null
+++ b/src/widgets/doc/images/sharedmodel-tableviews.png
Binary files differ
diff --git a/src/widgets/doc/images/sharedselection-tableviews.png b/src/widgets/doc/images/sharedselection-tableviews.png
new file mode 100644
index 0000000000..ccbda2578f
--- /dev/null
+++ b/src/widgets/doc/images/sharedselection-tableviews.png
Binary files differ
diff --git a/src/widgets/doc/images/simpleanchorlayout-example.png b/src/widgets/doc/images/simpleanchorlayout-example.png
new file mode 100644
index 0000000000..1d5c8ac048
--- /dev/null
+++ b/src/widgets/doc/images/simpleanchorlayout-example.png
Binary files differ
diff --git a/src/widgets/doc/images/spinboxdelegate-example.png b/src/widgets/doc/images/spinboxdelegate-example.png
new file mode 100644
index 0000000000..5e57a9c12b
--- /dev/null
+++ b/src/widgets/doc/images/spinboxdelegate-example.png
Binary files differ
diff --git a/src/widgets/doc/images/standard-views.png b/src/widgets/doc/images/standard-views.png
new file mode 100644
index 0000000000..c804551622
--- /dev/null
+++ b/src/widgets/doc/images/standard-views.png
Binary files differ
diff --git a/src/widgets/doc/images/standardwidget.png b/src/widgets/doc/images/standardwidget.png
new file mode 100644
index 0000000000..3ccccf14a3
--- /dev/null
+++ b/src/widgets/doc/images/standardwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/stardelegate.png b/src/widgets/doc/images/stardelegate.png
new file mode 100644
index 0000000000..24fa9fb0d7
--- /dev/null
+++ b/src/widgets/doc/images/stardelegate.png
Binary files differ
diff --git a/src/widgets/doc/images/stringlistmodel.png b/src/widgets/doc/images/stringlistmodel.png
new file mode 100644
index 0000000000..eedbff3585
--- /dev/null
+++ b/src/widgets/doc/images/stringlistmodel.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-border-image-normal.png b/src/widgets/doc/images/stylesheet-border-image-normal.png
new file mode 100644
index 0000000000..8afe3c9a67
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-border-image-normal.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-border-image-stretched.png b/src/widgets/doc/images/stylesheet-border-image-stretched.png
new file mode 100644
index 0000000000..3f9ca92dd3
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-border-image-stretched.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-border-image-wrong.png b/src/widgets/doc/images/stylesheet-border-image-wrong.png
new file mode 100644
index 0000000000..19d6e449f4
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-border-image-wrong.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-boxmodel.png b/src/widgets/doc/images/stylesheet-boxmodel.png
new file mode 100644
index 0000000000..a0249d77b7
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-boxmodel.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-branch-closed.png b/src/widgets/doc/images/stylesheet-branch-closed.png
new file mode 100644
index 0000000000..213ffdd88f
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-branch-closed.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-branch-end.png b/src/widgets/doc/images/stylesheet-branch-end.png
new file mode 100644
index 0000000000..54915b3b01
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-branch-end.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-branch-more.png b/src/widgets/doc/images/stylesheet-branch-more.png
new file mode 100644
index 0000000000..664ad44740
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-branch-more.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-branch-open.png b/src/widgets/doc/images/stylesheet-branch-open.png
new file mode 100644
index 0000000000..e8cad95ccf
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-branch-open.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-coffee-cleanlooks.png b/src/widgets/doc/images/stylesheet-coffee-cleanlooks.png
new file mode 100644
index 0000000000..e75df0d80a
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-coffee-cleanlooks.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-coffee-xp.png b/src/widgets/doc/images/stylesheet-coffee-xp.png
new file mode 100644
index 0000000000..8bedd80ee9
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-coffee-xp.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-pagefold-mac.png b/src/widgets/doc/images/stylesheet-pagefold-mac.png
new file mode 100644
index 0000000000..5c061b9cfd
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-pagefold-mac.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-pagefold.png b/src/widgets/doc/images/stylesheet-pagefold.png
new file mode 100644
index 0000000000..5ccb4edbc9
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-pagefold.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-redbutton1.png b/src/widgets/doc/images/stylesheet-redbutton1.png
new file mode 100644
index 0000000000..cb03375e12
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-redbutton1.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-redbutton2.png b/src/widgets/doc/images/stylesheet-redbutton2.png
new file mode 100644
index 0000000000..5325708942
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-redbutton2.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-redbutton3.png b/src/widgets/doc/images/stylesheet-redbutton3.png
new file mode 100644
index 0000000000..dd976f0760
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-redbutton3.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-scrollbar1.png b/src/widgets/doc/images/stylesheet-scrollbar1.png
new file mode 100644
index 0000000000..666ff1119a
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-scrollbar1.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-scrollbar2.png b/src/widgets/doc/images/stylesheet-scrollbar2.png
new file mode 100644
index 0000000000..439cf8035d
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-scrollbar2.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-treeview.png b/src/widgets/doc/images/stylesheet-treeview.png
new file mode 100644
index 0000000000..883d190f36
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-treeview.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-vline.png b/src/widgets/doc/images/stylesheet-vline.png
new file mode 100644
index 0000000000..8f0c336fd8
--- /dev/null
+++ b/src/widgets/doc/images/stylesheet-vline.png
Binary files differ
diff --git a/src/widgets/doc/images/swipegesture.png b/src/widgets/doc/images/swipegesture.png
new file mode 100644
index 0000000000..0b7d35af3a
--- /dev/null
+++ b/src/widgets/doc/images/swipegesture.png
Binary files differ
diff --git a/src/widgets/doc/images/system-tray.png b/src/widgets/doc/images/system-tray.png
new file mode 100644
index 0000000000..298b193cf7
--- /dev/null
+++ b/src/widgets/doc/images/system-tray.png
Binary files differ
diff --git a/src/widgets/doc/images/tabWidget-stylesheet1.png b/src/widgets/doc/images/tabWidget-stylesheet1.png
new file mode 100644
index 0000000000..fc8fc19e74
--- /dev/null
+++ b/src/widgets/doc/images/tabWidget-stylesheet1.png
Binary files differ
diff --git a/src/widgets/doc/images/tabWidget-stylesheet2.png b/src/widgets/doc/images/tabWidget-stylesheet2.png
new file mode 100644
index 0000000000..2cbf2bf36d
--- /dev/null
+++ b/src/widgets/doc/images/tabWidget-stylesheet2.png
Binary files differ
diff --git a/src/widgets/doc/images/tabWidget-stylesheet3.png b/src/widgets/doc/images/tabWidget-stylesheet3.png
new file mode 100644
index 0000000000..f57a9c9f9c
--- /dev/null
+++ b/src/widgets/doc/images/tabWidget-stylesheet3.png
Binary files differ
diff --git a/src/widgets/doc/images/tableWidget-stylesheet.png b/src/widgets/doc/images/tableWidget-stylesheet.png
new file mode 100644
index 0000000000..e99e7a97c8
--- /dev/null
+++ b/src/widgets/doc/images/tableWidget-stylesheet.png
Binary files differ
diff --git a/src/widgets/doc/images/tableview.png b/src/widgets/doc/images/tableview.png
new file mode 100755
index 0000000000..8be1b6ce62
--- /dev/null
+++ b/src/widgets/doc/images/tableview.png
Binary files differ
diff --git a/src/widgets/doc/images/tree_2_with_algorithm.png b/src/widgets/doc/images/tree_2_with_algorithm.png
new file mode 100644
index 0000000000..ecf91012bf
--- /dev/null
+++ b/src/widgets/doc/images/tree_2_with_algorithm.png
Binary files differ
diff --git a/src/widgets/doc/images/treeview.png b/src/widgets/doc/images/treeview.png
new file mode 100644
index 0000000000..af31fe9bf1
--- /dev/null
+++ b/src/widgets/doc/images/treeview.png
Binary files differ
diff --git a/src/widgets/doc/images/widgetdelegate.png b/src/widgets/doc/images/widgetdelegate.png
new file mode 100644
index 0000000000..3df4c4b6a5
--- /dev/null
+++ b/src/widgets/doc/images/widgetdelegate.png
Binary files differ
diff --git a/src/widgets/doc/images/widgetmapper.png b/src/widgets/doc/images/widgetmapper.png
new file mode 100644
index 0000000000..9627088077
--- /dev/null
+++ b/src/widgets/doc/images/widgetmapper.png
Binary files differ
diff --git a/src/widgets/doc/images/widgets-tutorial-childwidget.png b/src/widgets/doc/images/widgets-tutorial-childwidget.png
new file mode 100644
index 0000000000..0d42d701fc
--- /dev/null
+++ b/src/widgets/doc/images/widgets-tutorial-childwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/widgets-tutorial-nestedlayouts.png b/src/widgets/doc/images/widgets-tutorial-nestedlayouts.png
new file mode 100644
index 0000000000..1e2a9f4a1d
--- /dev/null
+++ b/src/widgets/doc/images/widgets-tutorial-nestedlayouts.png
Binary files differ
diff --git a/src/widgets/doc/images/widgets-tutorial-toplevel.png b/src/widgets/doc/images/widgets-tutorial-toplevel.png
new file mode 100644
index 0000000000..a80d13c50d
--- /dev/null
+++ b/src/widgets/doc/images/widgets-tutorial-toplevel.png
Binary files differ
diff --git a/src/widgets/doc/images/widgets-tutorial-windowlayout.png b/src/widgets/doc/images/widgets-tutorial-windowlayout.png
new file mode 100644
index 0000000000..fce52cdcd9
--- /dev/null
+++ b/src/widgets/doc/images/widgets-tutorial-windowlayout.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-calendarwidget.png b/src/widgets/doc/images/windows-calendarwidget.png
new file mode 100644
index 0000000000..ad016238ad
--- /dev/null
+++ b/src/widgets/doc/images/windows-calendarwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-checkbox.png b/src/widgets/doc/images/windows-checkbox.png
new file mode 100644
index 0000000000..eb1be4b736
--- /dev/null
+++ b/src/widgets/doc/images/windows-checkbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-combobox.png b/src/widgets/doc/images/windows-combobox.png
new file mode 100644
index 0000000000..d6bc483494
--- /dev/null
+++ b/src/widgets/doc/images/windows-combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-dateedit.png b/src/widgets/doc/images/windows-dateedit.png
new file mode 100644
index 0000000000..95587ec62e
--- /dev/null
+++ b/src/widgets/doc/images/windows-dateedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-datetimeedit.png b/src/widgets/doc/images/windows-datetimeedit.png
new file mode 100644
index 0000000000..6aa1766146
--- /dev/null
+++ b/src/widgets/doc/images/windows-datetimeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-dial.png b/src/widgets/doc/images/windows-dial.png
new file mode 100644
index 0000000000..0aa3a26159
--- /dev/null
+++ b/src/widgets/doc/images/windows-dial.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-doublespinbox.png b/src/widgets/doc/images/windows-doublespinbox.png
new file mode 100644
index 0000000000..244b5f66cd
--- /dev/null
+++ b/src/widgets/doc/images/windows-doublespinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-fontcombobox.png b/src/widgets/doc/images/windows-fontcombobox.png
new file mode 100644
index 0000000000..bf98cad922
--- /dev/null
+++ b/src/widgets/doc/images/windows-fontcombobox.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-frame.png b/src/widgets/doc/images/windows-frame.png
new file mode 100644
index 0000000000..5979b31b25
--- /dev/null
+++ b/src/widgets/doc/images/windows-frame.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-groupbox.png b/src/widgets/doc/images/windows-groupbox.png
new file mode 100644
index 0000000000..88f46a3832
--- /dev/null
+++ b/src/widgets/doc/images/windows-groupbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-horizontalscrollbar.png b/src/widgets/doc/images/windows-horizontalscrollbar.png
new file mode 100644
index 0000000000..1f36b9a352
--- /dev/null
+++ b/src/widgets/doc/images/windows-horizontalscrollbar.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-label.png b/src/widgets/doc/images/windows-label.png
new file mode 100644
index 0000000000..a1c3a396a9
--- /dev/null
+++ b/src/widgets/doc/images/windows-label.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-lcdnumber.png b/src/widgets/doc/images/windows-lcdnumber.png
new file mode 100644
index 0000000000..b463511aab
--- /dev/null
+++ b/src/widgets/doc/images/windows-lcdnumber.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-lineedit.png b/src/widgets/doc/images/windows-lineedit.png
new file mode 100644
index 0000000000..270e4517ff
--- /dev/null
+++ b/src/widgets/doc/images/windows-lineedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-listview.png b/src/widgets/doc/images/windows-listview.png
new file mode 100644
index 0000000000..2884fae1b1
--- /dev/null
+++ b/src/widgets/doc/images/windows-listview.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-progressbar.png b/src/widgets/doc/images/windows-progressbar.png
new file mode 100644
index 0000000000..361799a70e
--- /dev/null
+++ b/src/widgets/doc/images/windows-progressbar.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-pushbutton.png b/src/widgets/doc/images/windows-pushbutton.png
new file mode 100644
index 0000000000..14528d6808
--- /dev/null
+++ b/src/widgets/doc/images/windows-pushbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-radiobutton.png b/src/widgets/doc/images/windows-radiobutton.png
new file mode 100644
index 0000000000..db328cb563
--- /dev/null
+++ b/src/widgets/doc/images/windows-radiobutton.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-slider.png b/src/widgets/doc/images/windows-slider.png
new file mode 100644
index 0000000000..fde85024b6
--- /dev/null
+++ b/src/widgets/doc/images/windows-slider.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-spinbox.png b/src/widgets/doc/images/windows-spinbox.png
new file mode 100644
index 0000000000..d4e93c584a
--- /dev/null
+++ b/src/widgets/doc/images/windows-spinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-tableview.png b/src/widgets/doc/images/windows-tableview.png
new file mode 100644
index 0000000000..89da89fb5f
--- /dev/null
+++ b/src/widgets/doc/images/windows-tableview.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-tabwidget.png b/src/widgets/doc/images/windows-tabwidget.png
new file mode 100644
index 0000000000..8622f7ec6a
--- /dev/null
+++ b/src/widgets/doc/images/windows-tabwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-textedit.png b/src/widgets/doc/images/windows-textedit.png
new file mode 100644
index 0000000000..fd21ade02f
--- /dev/null
+++ b/src/widgets/doc/images/windows-textedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-timeedit.png b/src/widgets/doc/images/windows-timeedit.png
new file mode 100644
index 0000000000..6ae0e406bc
--- /dev/null
+++ b/src/widgets/doc/images/windows-timeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-toolbox.png b/src/widgets/doc/images/windows-toolbox.png
new file mode 100644
index 0000000000..99b471e6df
--- /dev/null
+++ b/src/widgets/doc/images/windows-toolbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-toolbutton.png b/src/widgets/doc/images/windows-toolbutton.png
new file mode 100644
index 0000000000..9ceb846ed4
--- /dev/null
+++ b/src/widgets/doc/images/windows-toolbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/windows-treeview.png b/src/widgets/doc/images/windows-treeview.png
new file mode 100644
index 0000000000..f55cd69c79
--- /dev/null
+++ b/src/widgets/doc/images/windows-treeview.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-calendarwidget.png b/src/widgets/doc/images/windowsvista-calendarwidget.png
new file mode 100644
index 0000000000..3cb1ab78dc
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-calendarwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-checkbox.png b/src/widgets/doc/images/windowsvista-checkbox.png
new file mode 100644
index 0000000000..b9bc909988
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-checkbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-combobox.png b/src/widgets/doc/images/windowsvista-combobox.png
new file mode 100644
index 0000000000..f53192f45a
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-dateedit.png b/src/widgets/doc/images/windowsvista-dateedit.png
new file mode 100644
index 0000000000..bb79482849
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-dateedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-datetimeedit.png b/src/widgets/doc/images/windowsvista-datetimeedit.png
new file mode 100644
index 0000000000..0a104de084
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-datetimeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-dial.png b/src/widgets/doc/images/windowsvista-dial.png
new file mode 100644
index 0000000000..7081269c31
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-dial.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-doublespinbox.png b/src/widgets/doc/images/windowsvista-doublespinbox.png
new file mode 100644
index 0000000000..6efa9379fd
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-doublespinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-fontcombobox.png b/src/widgets/doc/images/windowsvista-fontcombobox.png
new file mode 100644
index 0000000000..3771e84bd4
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-fontcombobox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-frame.png b/src/widgets/doc/images/windowsvista-frame.png
new file mode 100644
index 0000000000..63b8422d2b
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-frame.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-groupbox.png b/src/widgets/doc/images/windowsvista-groupbox.png
new file mode 100644
index 0000000000..967d8878a7
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-groupbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-horizontalscrollbar.png b/src/widgets/doc/images/windowsvista-horizontalscrollbar.png
new file mode 100644
index 0000000000..996865d66c
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-horizontalscrollbar.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-label.png b/src/widgets/doc/images/windowsvista-label.png
new file mode 100644
index 0000000000..caef8d8361
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-label.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-lcdnumber.png b/src/widgets/doc/images/windowsvista-lcdnumber.png
new file mode 100644
index 0000000000..911438e2b1
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-lcdnumber.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-lineedit.png b/src/widgets/doc/images/windowsvista-lineedit.png
new file mode 100644
index 0000000000..9fcde3a851
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-lineedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-listview.png b/src/widgets/doc/images/windowsvista-listview.png
new file mode 100644
index 0000000000..36a03438ab
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-listview.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-progressbar.png b/src/widgets/doc/images/windowsvista-progressbar.png
new file mode 100644
index 0000000000..0bda010811
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-progressbar.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-pushbutton.png b/src/widgets/doc/images/windowsvista-pushbutton.png
new file mode 100644
index 0000000000..3bc438dc10
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-pushbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-radiobutton.png b/src/widgets/doc/images/windowsvista-radiobutton.png
new file mode 100644
index 0000000000..fdfd2d66dd
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-radiobutton.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-slider.png b/src/widgets/doc/images/windowsvista-slider.png
new file mode 100644
index 0000000000..be2fffb7b5
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-slider.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-spinbox.png b/src/widgets/doc/images/windowsvista-spinbox.png
new file mode 100644
index 0000000000..4a2293e724
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-spinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-tableview.png b/src/widgets/doc/images/windowsvista-tableview.png
new file mode 100644
index 0000000000..96f4937bc1
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-tableview.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-tabwidget.png b/src/widgets/doc/images/windowsvista-tabwidget.png
new file mode 100644
index 0000000000..259c4f1a89
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-tabwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-textedit.png b/src/widgets/doc/images/windowsvista-textedit.png
new file mode 100644
index 0000000000..5e5696623e
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-textedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-timeedit.png b/src/widgets/doc/images/windowsvista-timeedit.png
new file mode 100644
index 0000000000..e24fdd268a
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-timeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-toolbox.png b/src/widgets/doc/images/windowsvista-toolbox.png
new file mode 100644
index 0000000000..8cfe5f9cab
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-toolbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-toolbutton.png b/src/widgets/doc/images/windowsvista-toolbutton.png
new file mode 100644
index 0000000000..0baa9809c1
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-toolbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsvista-treeview.png b/src/widgets/doc/images/windowsvista-treeview.png
new file mode 100644
index 0000000000..db211e4b5f
--- /dev/null
+++ b/src/widgets/doc/images/windowsvista-treeview.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-calendarwidget.png b/src/widgets/doc/images/windowsxp-calendarwidget.png
new file mode 100644
index 0000000000..9a5fa6ebcd
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-calendarwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-checkbox.png b/src/widgets/doc/images/windowsxp-checkbox.png
new file mode 100644
index 0000000000..505d3a3641
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-checkbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-combobox.png b/src/widgets/doc/images/windowsxp-combobox.png
new file mode 100644
index 0000000000..2363c8401c
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-dateedit.png b/src/widgets/doc/images/windowsxp-dateedit.png
new file mode 100644
index 0000000000..060ba07b2c
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-dateedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-datetimeedit.png b/src/widgets/doc/images/windowsxp-datetimeedit.png
new file mode 100644
index 0000000000..4e41f0fc14
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-datetimeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-dial.png b/src/widgets/doc/images/windowsxp-dial.png
new file mode 100644
index 0000000000..0aa3a26159
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-dial.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-doublespinbox.png b/src/widgets/doc/images/windowsxp-doublespinbox.png
new file mode 100644
index 0000000000..3165a61b93
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-doublespinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-fontcombobox.png b/src/widgets/doc/images/windowsxp-fontcombobox.png
new file mode 100644
index 0000000000..96292b84ef
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-fontcombobox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-frame.png b/src/widgets/doc/images/windowsxp-frame.png
new file mode 100644
index 0000000000..5979b31b25
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-frame.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-groupbox.png b/src/widgets/doc/images/windowsxp-groupbox.png
new file mode 100644
index 0000000000..0b6f7e21ad
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-groupbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-horizontalscrollbar.png b/src/widgets/doc/images/windowsxp-horizontalscrollbar.png
new file mode 100644
index 0000000000..38812ec107
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-horizontalscrollbar.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-label.png b/src/widgets/doc/images/windowsxp-label.png
new file mode 100644
index 0000000000..a1c3a396a9
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-label.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-lcdnumber.png b/src/widgets/doc/images/windowsxp-lcdnumber.png
new file mode 100644
index 0000000000..102023c8ed
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-lcdnumber.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-lineedit.png b/src/widgets/doc/images/windowsxp-lineedit.png
new file mode 100644
index 0000000000..9102b53ca4
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-lineedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-listview.png b/src/widgets/doc/images/windowsxp-listview.png
new file mode 100644
index 0000000000..b0fc9bd3a7
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-listview.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-menu.png b/src/widgets/doc/images/windowsxp-menu.png
new file mode 100644
index 0000000000..b8ca947e73
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-menu.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-progressbar.png b/src/widgets/doc/images/windowsxp-progressbar.png
new file mode 100644
index 0000000000..c8a73d6754
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-progressbar.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-pushbutton.png b/src/widgets/doc/images/windowsxp-pushbutton.png
new file mode 100644
index 0000000000..bf6b7bf15d
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-pushbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-radiobutton.png b/src/widgets/doc/images/windowsxp-radiobutton.png
new file mode 100644
index 0000000000..ad8a908fb2
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-radiobutton.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-slider.png b/src/widgets/doc/images/windowsxp-slider.png
new file mode 100644
index 0000000000..9e2fca7c40
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-slider.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-spinbox.png b/src/widgets/doc/images/windowsxp-spinbox.png
new file mode 100644
index 0000000000..e42073cd6b
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-spinbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-tableview.png b/src/widgets/doc/images/windowsxp-tableview.png
new file mode 100644
index 0000000000..5d12137ad5
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-tableview.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-tabwidget.png b/src/widgets/doc/images/windowsxp-tabwidget.png
new file mode 100644
index 0000000000..3c8e777a0b
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-tabwidget.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-textedit.png b/src/widgets/doc/images/windowsxp-textedit.png
new file mode 100644
index 0000000000..d89c75c71b
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-textedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-timeedit.png b/src/widgets/doc/images/windowsxp-timeedit.png
new file mode 100644
index 0000000000..751cca9e6a
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-timeedit.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-toolbox.png b/src/widgets/doc/images/windowsxp-toolbox.png
new file mode 100644
index 0000000000..99b471e6df
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-toolbox.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-toolbutton.png b/src/widgets/doc/images/windowsxp-toolbutton.png
new file mode 100644
index 0000000000..ea63e16aae
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-toolbutton.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-treeview.png b/src/widgets/doc/images/windowsxp-treeview.png
new file mode 100644
index 0000000000..050cc2f4d6
--- /dev/null
+++ b/src/widgets/doc/images/windowsxp-treeview.png
Binary files differ
diff --git a/src/widgets/doc/qtwidgets.qdocconf b/src/widgets/doc/qtwidgets.qdocconf
new file mode 100644
index 0000000000..c90f25338e
--- /dev/null
+++ b/src/widgets/doc/qtwidgets.qdocconf
@@ -0,0 +1,92 @@
+include(../../../doc/global/qt-cpp-ignore.qdocconf)
+
+project = QtWidgets
+description = Qt Widgets Reference Documentation
+url = http://qt-project.org/doc/qt-5.0/qtwidgets
+version = 5.0.0
+
+sourceencoding = UTF-8
+outputencoding = UTF-8
+naturallanguage = en_US
+qhp.projects = QtWidgets
+
+qhp.QtWidgets.file = qtwidgets.qhp
+qhp.QtWidgets.namespace = org.qt-project.qtwidgets.500
+qhp.QtWidgets.virtualFolder = qdoc
+qhp.QtWidgets.indexTitle = Qt Widgets Reference Documentation
+qhp.QtWidgets.indexRoot =
+
+qhp.QtWidgets.filterAttributes = qtwidgets 5.0.0 qtrefdoc
+qhp.QtWidgets.customFilters.Qt.name = QtWidgets 5.0.0
+qhp.QtWidgets.customFilters.Qt.filterAttributes = qtwidgets 5.0.0
+qhp.QtWidgets.subprojects = classes overviews examples
+qhp.QtWidgets.subprojects.classes.title = Classes
+qhp.QtWidgets.subprojects.classes.indexTitle = Qt Widgets' Classes
+qhp.QtWidgets.subprojects.classes.selectors = class fake:headerfile
+qhp.QtWidgets.subprojects.classes.sortPages = true
+qhp.QtWidgets.subprojects.overviews.title = Overviews
+qhp.QtWidgets.subprojects.overviews.indexTitle = All Overviews and HOWTOs
+qhp.QtWidgets.subprojects.overviews.selectors = fake:page,group,module
+qhp.QtWidgets.subprojects.examples.title = Qt Widgets Examples
+qhp.QtWidgets.subprojects.examples.indexTitle = Qt Widgets Examples
+qhp.QtWidgets.subprojects.examples.selectors = fake:example
+
+dita.metadata.default.author = Qt Project
+dita.metadata.default.permissions = all
+dita.metadata.default.publisher = Qt Project
+dita.metadata.default.copyryear = 2012
+dita.metadata.default.copyrholder = Nokia
+dita.metadata.default.audience = programmer
+
+sources.fileextensions = "*.c++ *.cc *.cpp *.cxx *.mm *.qml *.qdoc"
+headers.fileextensions = "*.ch *.h *.h++ *.hh *.hpp *.hxx"
+
+examples.fileextensions = "*.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp *.qml *.css"
+examples.imageextensions = "*.png"
+
+outputdir = ../../../doc/qtwidgets
+tagfile = ../../../doc/qtwidgets/qtwidgets.tags
+
+HTML.generatemacrefs = "true"
+HTML.nobreadcrumbs = "true"
+
+HTML.templatedir = .
+
+HTML.stylesheets = ../../../doc/global/style/offline.css
+
+HTML.headerstyles = \
+ " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/offline.css\" />\n"
+
+HTML.endheader = \
+ "</head>\n" \
+
+defines = Q_QDOC \
+ QT_.*_SUPPORT \
+ QT_.*_LIB \
+ QT_COMPAT \
+ QT_KEYPAD_NAVIGATION \
+ QT_NO_EGL \
+ Q_WS_.* \
+ Q_OS_.* \
+ Q_BYTE_ORDER \
+ QT_DEPRECATED \
+ QT_DEPRECATED_* \
+ Q_NO_USING_KEYWORD \
+ __cplusplus \
+ Q_COMPILER_INITIALIZER_LISTS
+
+versionsym = QT_VERSION_STR
+
+codeindent = 1
+
+depends += qtcore qtgui
+
+headerdirs += ..
+
+sourcedirs += ..
+
+exampledirs += ../../../examples \
+ ../ \
+ snippets
+
+imagedirs += images
diff --git a/src/widgets/doc/snippets/code/doc_src_layout.cpp b/src/widgets/doc/snippets/code/doc_src_layout.cpp
new file mode 100644
index 0000000000..b6abab61d3
--- /dev/null
+++ b/src/widgets/doc/snippets/code/doc_src_layout.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#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/src/widgets/doc/snippets/code/doc_src_model-view-programming.cpp b/src/widgets/doc/snippets/code/doc_src_model-view-programming.cpp
new file mode 100644
index 0000000000..ca9aa606f7
--- /dev/null
+++ b/src/widgets/doc/snippets/code/doc_src_model-view-programming.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+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/src/widgets/doc/snippets/code/doc_src_qt4-mainwindow.cpp b/src/widgets/doc/snippets/code/doc_src_qt4-mainwindow.cpp
new file mode 100644
index 0000000000..ecbb5f5220
--- /dev/null
+++ b/src/widgets/doc/snippets/code/doc_src_qt4-mainwindow.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [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/src/widgets/doc/snippets/code/doc_src_qt4-styles.cpp b/src/widgets/doc/snippets/code/doc_src_qt4-styles.cpp
new file mode 100644
index 0000000000..9bebb825e4
--- /dev/null
+++ b/src/widgets/doc/snippets/code/doc_src_qt4-styles.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+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/src/widgets/doc/snippets/code/doc_src_qtwidgets.cpp b/src/widgets/doc/snippets/code/doc_src_qtwidgets.cpp
new file mode 100644
index 0000000000..74888e3891
--- /dev/null
+++ b/src/widgets/doc/snippets/code/doc_src_qtwidgets.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [1]
+#include <QtWidgets>
+//! [1]
diff --git a/src/widgets/doc/snippets/code/doc_src_qtwidgets.pro b/src/widgets/doc/snippets/code/doc_src_qtwidgets.pro
new file mode 100644
index 0000000000..2fee715c24
--- /dev/null
+++ b/src/widgets/doc/snippets/code/doc_src_qtwidgets.pro
@@ -0,0 +1,3 @@
+#! [0]
+QT += widgets
+#! [0]
diff --git a/src/widgets/doc/snippets/code/doc_src_styles.cpp b/src/widgets/doc/snippets/code/doc_src_styles.cpp
new file mode 100644
index 0000000000..6c079c6637
--- /dev/null
+++ b/src/widgets/doc/snippets/code/doc_src_styles.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+ opt.initFrom(q);
+ if (down)
+ opt.state |= QStyle::State_Sunken;
+ if (tristate && noChange)
+ opt.state |= QStyle::State_NoChange;
+ else
+ opt.state |= checked ? QStyle::State_On :
+ QStyle::State_Off;
+ if (q->testAttribute(Qt::WA_Hover) && q->underMouse()) {
+ if (hovering)
+ opt.state |= QStyle::State_MouseOver;
+ else
+ opt.state &= ~QStyle::State_MouseOver;
+ }
+ opt.text = text;
+ opt.icon = icon;
+ opt.iconSize = q->iconSize();
+//! [0]
+
+
+//! [1]
+ state = QStyle::State_None;
+ if (widget->isEnabled())
+ state |= QStyle::State_Enabled;
+ if (widget->hasFocus())
+ state |= QStyle::State_HasFocus;
+ if (widget->window()->testAttribute(Qt::WA_KeyboardFocusChange))
+ state |= QStyle::State_KeyboardFocusChange;
+ if (widget->underMouse())
+ state |= QStyle::State_MouseOver;
+ if (widget->window()->isActiveWindow())
+ state |= QStyle::State_Active;
+#ifdef Q_WS_MAC
+ extern bool qt_mac_can_clickThrough(const QWidget *w); //qwidget_mac.cpp
+ if (!(state & QStyle::State_Active) && !qt_mac_can_clickThrough(widget))
+ state &= ~QStyle::State_Enabled;
+#endif
+#ifdef QT_KEYPAD_NAVIGATION
+ if (widget->hasEditFocus())
+ state |= QStyle::State_HasEditFocus;
+#endif
+
+ direction = widget->layoutDirection();
+ rect = widget->rect();
+ palette = widget->palette();
+ fontMetrics = widget->fontMetrics();
+//! [1]
+
+
+//! [2]
+ QStylePainter p(this);
+ QStyleOptionButton opt = d->getStyleOption();
+ p.drawControl(QStyle::CE_CheckBox, opt);
+//! [2]
+
+
+//! [3]
+ QStyleOptionButton subopt = *btn;
+ subopt.rect = subElementRect(SE_CheckBoxIndicator, btn, widget);
+ drawPrimitive(PE_IndicatorCheckBox, &subopt, p, widget);
+ subopt.rect = subElementRect(SE_CheckBoxContents, btn, widget);
+ drawControl(CE_CheckBoxLabel, &subopt, p, widget);
+
+ if (btn->state & State_HasFocus) {
+ QStyleOptionFocusRect fropt;
+ fropt.QStyleOption::operator=(*btn);
+ fropt.rect = subElementRect(SE_CheckBoxFocusRect, btn, widget);
+ drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
+ }
+//! [3]
+
+
+//! [4]
+ const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt);
+ uint alignment = visualAlignment(btn->direction, Qt::AlignLeft | Qt::AlignVCenter);
+
+ if (!styleHint(SH_UnderlineShortcut, btn, widget))
+ alignment |= Qt::TextHideMnemonic;
+ QPixmap pix;
+ QRect textRect = btn->rect;
+ if (!btn->icon.isNull()) {
+ pix = btn->icon.pixmap(btn->iconSize, btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled);
+ drawItemPixmap(p, btn->rect, alignment, pix);
+ if (btn->direction == Qt::RightToLeft)
+ textRect.setRight(textRect.right() - btn->iconSize.width() - 4);
+ else
+ textRect.setLeft(textRect.left() + btn->iconSize.width() + 4);
+ }
+ if (!btn->text.isEmpty()){
+ drawItemText(p, textRect, alignment | Qt::TextShowMnemonic,
+ btn->palette, btn->state & State_Enabled, btn->text, QPalette::WindowText);
+ }
+//! [4]
diff --git a/src/widgets/doc/snippets/code/doc_src_stylesheet.cpp b/src/widgets/doc/snippets/code/doc_src_stylesheet.cpp
new file mode 100644
index 0000000000..eb02634c6d
--- /dev/null
+++ b/src/widgets/doc/snippets/code/doc_src_stylesheet.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [21]
+qApp->setStyleSheet("QPushButton { color: white }");
+//! [21]
+
+
+//! [22]
+myPushButton->setStyleSheet("* { color: blue }");
+//! [22]
+
+
+//! [23]
+myPushButton->setStyleSheet("color: blue");
+//! [23]
+
+
+//! [24]
+qApp->setStyleSheet("QGroupBox { color: red; } ");
+//! [24]
+
+//! [25]
+qApp->setStyleSheet("QGroupBox, QGroupBox * { color: red; }");
+//! [25]
+
+
+//! [26]
+class MyPushButton : public QPushButton {
+ // ...
+}
+
+// ...
+qApp->setStyleSheet("MyPushButton { background: yellow; }");
+//! [26]
+
+
+//! [27]
+namespace ns {
+ class MyPushButton : public QPushButton {
+ // ...
+ }
+}
+
+// ...
+qApp->setStyleSheet("ns--MyPushButton { background: yellow; }");
+//! [27]
+
+
+//! [32]
+void CustomWidget::paintEvent(QPaintEvent *)
+{
+ QStyleOption opt;
+ opt.init(this);
+ QPainter p(this);
+ style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
+}
+//! [32]
+
+
+//! [88]
+qApp->setStyleSheet("QLineEdit { background-color: yellow }");
+//! [88]
+
+
+//! [89]
+myDialog->setStyleSheet("QLineEdit { background-color: yellow }");
+//! [89]
+
+
+//! [90]
+myDialog->setStyleSheet("QLineEdit#nameEdit { background-color: yellow }");
+//! [90]
+
+
+//! [91]
+nameEdit->setStyleSheet("background-color: yellow");
+//! [91]
+
+
+//! [92]
+nameEdit->setStyleSheet("color: blue; background-color: yellow");
+//! [92]
+
+
+//! [93]
+nameEdit->setStyleSheet("color: blue;"
+ "background-color: yellow;"
+ "selection-color: yellow;"
+ "selection-background-color: blue;");
+//! [93]
+
+
+//! [95]
+QLineEdit *nameEdit = new QLineEdit(this);
+nameEdit->setProperty("mandatoryField", true);
+
+QLineEdit *emailEdit = new QLineEdit(this);
+emailEdit->setProperty("mandatoryField", true);
+
+QSpinBox *ageSpinBox = new QSpinBox(this);
+ageSpinBox->setProperty("mandatoryField", true);
+//! [95]
diff --git a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
new file mode 100644
index 0000000000..9acba09c67
--- /dev/null
+++ b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
@@ -0,0 +1,1866 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QLineEdit { background: yellow }
+QCheckBox { color: red }
+//! [0]
+
+
+//! [1]
+QPushButton { color: red }
+//! [1]
+
+
+//! [2]
+QPushButton, QLineEdit, QComboBox { color: red }
+//! [2]
+
+
+//! [3]
+QPushButton { color: red }
+QLineEdit { color: red }
+QComboBox { color: red }
+//! [3]
+
+
+//! [4]
+QPushButton { color: red; background-color: white }
+//! [4]
+
+
+//! [5]
+QComboBox::drop-down { image: url(dropdown.png) }
+//! [5]
+
+
+//! [6]
+QComboBox {
+ margin-right: 20px;
+}
+QComboBox::drop-down {
+ subcontrol-origin: margin;
+}
+//! [6]
+
+
+//! [7]
+QComboBox::down-arrow {
+ image: url(down_arrow.png);
+}
+QComboBox::down-arrow:pressed {
+ position: relative;
+ top: 1px; left: 1px;
+}
+//! [7]
+
+
+//! [8]
+QPushButton:hover { color: white }
+//! [8]
+
+
+//! [9]
+QRadioButton:!hover { color: red }
+//! [9]
+
+
+//! [10]
+QCheckBox:hover:checked { color: white }
+//! [10]
+
+
+//! [11]
+QPushButton:hover:!pressed { color: blue; }
+//! [11]
+
+
+//! [12]
+QCheckBox:hover, QCheckBox:checked { color: white }
+//! [12]
+
+
+//! [13]
+QComboBox::drop-down:hover { image: url(dropdown_bright.png) }
+//! [13]
+
+
+//! [14]
+QPushButton#okButton { color: gray }
+QPushButton { color: red }
+//! [14]
+
+
+//! [15]
+QPushButton:hover { color: white }
+QPushButton { color: red }
+//! [15]
+
+
+//! [16]
+QPushButton:hover { color: white }
+QPushButton:enabled { color: red }
+//! [16]
+
+
+//! [17]
+QPushButton:enabled { color: red }
+QPushButton:hover { color: white }
+//! [17]
+
+
+//! [18]
+QPushButton:hover:enabled { color: white }
+QPushButton:enabled { color: red }
+//! [18]
+
+
+//! [19]
+QPushButton { color: red }
+QAbstractButton { color: gray }
+//! [19]
+
+
+//! [20]
+* {} /* a=0 b=0 c=0 -> specificity = 0 */
+LI {} /* a=0 b=0 c=1 -> specificity = 1 */
+UL LI {} /* a=0 b=0 c=2 -> specificity = 2 */
+UL OL+LI {} /* a=0 b=0 c=3 -> specificity = 3 */
+H1 + *[REL=up]{} /* a=0 b=1 c=1 -> specificity = 11 */
+UL OL LI.red {} /* a=0 b=1 c=3 -> specificity = 13 */
+LI.red.level {} /* a=0 b=2 c=1 -> specificity = 21 */
+#x34y {} /* a=1 b=0 c=0 -> specificity = 100 */
+//! [20]
+
+
+//! [28]
+MyLabel { qproperty-pixmap: url(pixmap.png); }
+MyGroupBox { qproperty-titleColor: rgb(100, 200, 100); }
+QPushButton { qproperty-iconSize: 20px 20px; }
+//! [28]
+
+
+//! [30]
+QPushButton { background-color: red; border: none; }
+//! [30]
+
+
+//! [31]
+QToolButton { background-color: red; border: none; }
+//! [31]
+
+
+//! [33]
+QTreeView {
+ alternate-background-color: blue;
+ background: yellow;
+}
+//! [33]
+
+
+//! [34]
+QTextEdit { background: yellow }
+//! [34]
+
+
+//! [35]
+QLabel {
+ background-image: url(dense6pattern.png);
+ background-repeat: repeat-xy;
+}
+//! [35]
+
+
+//! [36]
+QLabel { background-color: yellow }
+QLineEdit { background-color: rgb(255, 0, 0) }
+//! [36]
+
+
+//! [37]
+QFrame { background-image: url(:/images/hydro.png) }
+//! [37]
+
+
+//! [38]
+QFrame {
+ background: white url(:/images/ring.png);
+ background-repeat: repeat-y;
+ background-position: left;
+}
+//! [38]
+
+
+//! [39]
+QFrame {
+ background: url(:/images/footer.png);
+ background-position: bottom left;
+}
+//! [39]
+
+
+//! [40]
+QTextEdit {
+ background-image: url("leaves.png");
+ background-attachment: fixed;
+}
+//! [40]
+
+
+//! [41]
+QFrame {
+ background-image: url(:/images/header.png);
+ background-position: top left;
+ background-origin: content;
+ background-clip: padding;
+}
+//! [41]
+
+
+//! [42]
+QFrame {
+ background-image: url(:/images/header.png);
+ background-position: top left;
+ background-origin: content;
+}
+//! [42]
+
+
+//! [43]
+QLineEdit { border: 1px solid white }
+//! [43]
+
+
+//! [44]
+QLineEdit {
+ border-width: 1px;
+ border-style: solid;
+ border-color: white;
+}
+//! [44]
+
+
+//! [45]
+QLineEdit {
+ border-width: 1px;
+ border-style: solid;
+ border-radius: 4px;
+}
+//! [45]
+
+
+//! [46]
+QLineEdit {
+ border-width: 1px;
+ border-style: solid;
+ border-color: blue;
+}
+//! [46]
+
+
+//! [47]
+QLineEdit {
+ border-width: 2px;
+ border-style: solid;
+ border-color: darkblue;
+}
+//! [47]
+
+
+//! [48]
+QSpinBox::down-button { bottom: 2px }
+//! [48]
+
+
+//! [49]
+* { button-layout: 2 }
+//! [49]
+
+
+//! [50]
+QPushButton { color: red }
+//! [50]
+
+
+//! [51]
+QDialogButtonBox { dialogbuttonbox-buttons-have-icons: 1; }
+//! [51]
+
+
+//! [52]
+* { etch-disabled-text: 1 }
+//! [52]
+
+
+//! [53]
+QCheckBox { font: bold italic large "Times New Roman" }
+//! [53]
+
+
+//! [54]
+QCheckBox { font-family: "New Century Schoolbook" }
+//! [54]
+
+
+//! [55]
+QTextEdit { font-size: 12px }
+//! [55]
+
+
+//! [56]
+QTextEdit { font-style: italic }
+//! [56]
+
+
+//! [57]
+* { gridline-color: gray }
+//! [57]
+
+
+//! [58]
+QSpinBox::down-button { height: 10px }
+//! [58]
+
+
+//! [59]
+/* implicitly sets the size of down-button to the size of spindown.png */
+QSpinBox::down-button { image: url(:/images/spindown.png) }
+//! [59]
+
+
+//! [60]
+QSpinBox::down-button { left: 2px }
+//! [60]
+
+
+//! [61]
+* { lineedit-password-character: 9679 }
+//! [61]
+
+
+//! [62]
+QLineEdit { margin: 2px }
+//! [62]
+
+
+//! [63]
+QSpinBox { max-height: 24px }
+//! [63]
+
+
+//! [64]
+QComboBox { max-width: 72px }
+//! [64]
+
+
+//! [65]
+QMessageBox { messagebox-text-interaction-flags: 5 }
+//! [65]
+
+
+//! [66]
+QComboBox { min-height: 24px }
+//! [66]
+
+
+//! [67]
+QComboBox { min-width: 72px }
+//! [67]
+
+
+//! [68]
+QToolTip { opacity: 223 }
+//! [68]
+
+
+//! [69]
+QLineEdit { padding: 3px }
+//! [69]
+
+
+//! [70]
+QSpinBox::down-button { right: 2px }
+//! [70]
+
+
+//! [71]
+QTextEdit { selection-background-color: darkblue }
+//! [71]
+
+
+//! [72]
+QTextEdit { selection-color: white }
+//! [72]
+
+
+//! [73]
+* { show-decoration-selected: 1 }
+//! [73]
+
+
+//! [74]
+QMenuBar { spacing: 10 }
+//! [74]
+
+
+//! [75]
+QSpinBox::up-button {
+ image: url(:/images/spinup.png);
+ subcontrol-origin: content;
+ subcontrol-position: right top;
+}
+//! [75]
+
+
+//! [76]
+QSpinBox::down-button {
+ image: url(:/images/spindown.png);
+ subcontrol-origin: padding;
+ subcontrol-position: right bottom;
+}
+//! [76]
+
+
+//! [77]
+QPushButton {
+ text-align: left;
+}
+//! [77]
+
+
+//! [78]
+QSpinBox::up-button { top: 2px }
+//! [78]
+
+
+//! [79]
+QSpinBox::up-button { width: 12px }
+//! [79]
+
+
+//! [80]
+QTextEdit { background-position: bottom center }
+//! [80]
+
+
+//! [81]
+QDialog { etch-disabled-text: 1 }
+//! [81]
+
+
+//! [82]
+QLabel { border-color: red } /* red red red red */
+QLabel { border-color: red blue } /* red blue red blue */
+QLabel { border-color: red blue green } /* red blue green blue */
+QLabel { border-color: red blue green yellow } /* red blue green yellow */
+//! [82]
+
+
+//! [83]
+QLabel { border-width: 1px } /* 1px 1px 1px 1px */
+QLabel { border-width: 1px 2px } /* 1px 2px 1px 2px */
+QLabel { border-width: 1px 2px 3px } /* 1px 2px 3px 2px */
+QLabel { border-width: 1px 2px 3px 4px } /* 1px 2px 3px 4px */
+//! [83]
+
+
+//! [84]
+QLabel { border-color: red } /* opaque red */
+QLabel { border-color: #FF0000 } /* opaque red */
+QLabel { border-color: rgba(255, 0, 0, 75%) } /* 75% opaque red */
+QLabel { border-color: rgb(255, 0, 0) } /* opaque red */
+QLabel { border-color: rgb(100%, 0%, 0%) } /* opaque red */
+QLabel { border-color: hsv(60, 255, 255) } /* opaque yellow */
+QLabel { border-color: hsva(240, 255, 255, 75%) } /* 75% blue */
+//! [84]
+
+
+//! [85]
+/* linear gradient from white to green */
+QTextEdit {
+ background: qlineargradient(x1:0, y1:0, x2:1, y2:1,
+ stop:0 white, stop: 0.4 gray, stop:1 green)
+}
+
+/* linear gradient from white to green */
+QTextEdit {
+ background: qlineargradient(x1:0, y1:0, x2:1, y2:1,
+ stop:0 white, stop: 0.4 rgba(10, 20, 30, 40), stop:1 rgb(0, 200, 230, 200))
+}
+
+
+/* conical gradient from white to green */
+QTextEdit {
+ background: qconicalgradient(cx:0.5, cy:0.5, angle:30,
+ stop:0 white, stop:1 #00FF00)
+}
+
+/* radial gradient from white to green */
+QTextEdit {
+ background: qradialgradient(cx:0, cy:0, radius: 1,
+ fx:0.5, fy:0.5, stop:0 white, stop:1 green)
+}
+//! [85]
+
+
+//! [86]
+* {
+ file-icon: url(file.png),
+ url(file_selected.png) selected;
+ }
+
+QMessageBox {
+ dialogbuttonbox-buttons-have-icons: true;
+ dialog-ok-icon: url(ok.svg);
+ dialog-cancel-icon: url(cancel.png), url(grayed_cancel.png) disabled;
+}
+//! [86]
+
+
+//! [87]
+QPushButton { color: palette(dark); }
+//! [87]
+
+
+//! [94]
+*[mandatoryField="true"] { background-color: yellow }
+//! [94]
+
+
+//! [96]
+QPushButton#evilButton { background-color: red }
+//! [96]
+
+
+//! [97]
+QPushButton#evilButton {
+ background-color: red;
+ border-style: outset;
+ border-width: 2px;
+ border-color: beige;
+}
+//! [97]
+
+
+//! [98]
+QPushButton#evilButton {
+ background-color: red;
+ border-style: outset;
+ border-width: 2px;
+ border-radius: 10px;
+ border-color: beige;
+ font: bold 14px;
+ min-width: 10em;
+ padding: 6px;
+}
+//! [98]
+
+
+//! [99]
+QPushButton#evilButton {
+ background-color: red;
+ border-style: outset;
+ border-width: 2px;
+ border-radius: 10px;
+ border-color: beige;
+ font: bold 14px;
+ min-width: 10em;
+ padding: 6px;
+}
+QPushButton#evilButton:pressed {
+ background-color: rgb(224, 0, 0);
+ border-style: inset;
+}
+//! [99]
+
+
+//! [100]
+QPushButton#evilButton::menu-indicator {
+ image: url(myindicator.png);
+}
+//! [100]
+
+
+//! [101]
+QPushButton::menu-indicator {
+ image: url(myindicator.png);
+ subcontrol-position: right center;
+ subcontrol-origin: padding;
+ left: -2px;
+}
+//! [101]
+
+
+//! [102]
+QLineEdit { color: red }
+//! [102]
+
+
+//! [103]
+QLineEdit { color: red }
+QLineEdit[readOnly="true"] { color: gray }
+//! [103]
+
+
+//! [104]
+QLineEdit { color: red }
+QLineEdit[readOnly="true"] { color: gray }
+#registrationDialog QLineEdit { color: brown }
+//! [104]
+
+
+//! [105]
+QLineEdit { color: red }
+QLineEdit[readOnly="true"] { color: gray }
+QDialog QLineEdit { color: brown }
+//! [105]
+
+
+//! [106]
+QTextEdit, QListView {
+ background-color: white;
+ background-image: url(draft.png);
+ background-attachment: scroll;
+}
+//! [106]
+
+
+//! [107]
+QTextEdit, QListView {
+ background-color: white;
+ background-image: url(draft.png);
+ background-attachment: fixed;
+}
+//! [107]
+
+
+//! [108]
+QCheckBox {
+ spacing: 5px;
+}
+
+QCheckBox::indicator {
+ width: 13px;
+ height: 13px;
+}
+
+QCheckBox::indicator:unchecked {
+ image: url(:/images/checkbox_unchecked.png);
+}
+
+QCheckBox::indicator:unchecked:hover {
+ image: url(:/images/checkbox_unchecked_hover.png);
+}
+
+QCheckBox::indicator:unchecked:pressed {
+ image: url(:/images/checkbox_unchecked_pressed.png);
+}
+
+QCheckBox::indicator:checked {
+ image: url(:/images/checkbox_checked.png);
+}
+
+QCheckBox::indicator:checked:hover {
+ image: url(:/images/checkbox_checked_hover.png);
+}
+
+QCheckBox::indicator:checked:pressed {
+ image: url(:/images/checkbox_checked_pressed.png);
+}
+
+QCheckBox::indicator:indeterminate:hover {
+ image: url(:/images/checkbox_indeterminate_hover.png);
+}
+
+QCheckBox::indicator:indeterminate:pressed {
+ image: url(:/images/checkbox_indeterminate_pressed.png);
+}
+//! [108]
+
+
+//! [109]
+QComboBox {
+ border: 1px solid gray;
+ border-radius: 3px;
+ padding: 1px 18px 1px 3px;
+ min-width: 6em;
+}
+
+QComboBox:editable {
+ background: white;
+}
+
+QComboBox:!editable, QComboBox::drop-down:editable {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
+ stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
+}
+
+/* QComboBox gets the "on" state when the popup is open */
+QComboBox:!editable:on, QComboBox::drop-down:editable:on {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #D3D3D3, stop: 0.4 #D8D8D8,
+ stop: 0.5 #DDDDDD, stop: 1.0 #E1E1E1);
+}
+
+QComboBox:on { /* shift the text when the popup opens */
+ padding-top: 3px;
+ padding-left: 4px;
+}
+
+QComboBox::drop-down {
+ subcontrol-origin: padding;
+ subcontrol-position: top right;
+ width: 15px;
+
+ border-left-width: 1px;
+ border-left-color: darkgray;
+ border-left-style: solid; /* just a single line */
+ border-top-right-radius: 3px; /* same radius as the QComboBox */
+ border-bottom-right-radius: 3px;
+}
+
+QComboBox::down-arrow {
+ image: url(/usr/share/icons/crystalsvg/16x16/actions/1downarrow.png);
+}
+
+QComboBox::down-arrow:on { /* shift the arrow when popup is open */
+ top: 1px;
+ left: 1px;
+}
+//! [109]
+
+
+//! [110]
+QComboBox QAbstractItemView {
+ border: 2px solid darkgray;
+ selection-background-color: lightgray;
+}
+//! [110]
+
+
+//! [111]
+QDockWidget {
+ border: 1px solid lightgray;
+ titlebar-close-icon: url(close.png);
+ titlebar-normal-icon: url(undock.png);
+}
+
+QDockWidget::title {
+ text-align: left; /* align the text to the left */
+ background: lightgray;
+ padding-left: 5px;
+}
+
+QDockWidget::close-button, QDockWidget::float-button {
+ border: 1px solid transparent;
+ background: darkgray;
+ padding: 0px;
+}
+
+QDockWidget::close-button:hover, QDockWidget::float-button:hover {
+ background: gray;
+}
+
+QDockWidget::close-button:pressed, QDockWidget::float-button:pressed {
+ padding: 1px -1px -1px 1px;
+}
+//! [111]
+
+
+//! [112]
+QDockWidget {
+ border: 1px solid lightgray;
+ titlebar-close-icon: url(close.png);
+ titlebar-normal-icon: url(float.png);
+}
+
+QDockWidget::title {
+ text-align: left;
+ background: lightgray;
+ padding-left: 35px;
+}
+
+QDockWidget::close-button, QDockWidget::float-button {
+ background: darkgray;
+ padding: 0px;
+ icon-size: 14px; /* maximum icon size */
+}
+
+QDockWidget::close-button:hover, QDockWidget::float-button:hover {
+ background: gray;
+}
+
+QDockWidget::close-button:pressed, QDockWidget::float-button:pressed {
+ padding: 1px -1px -1px 1px;
+}
+
+QDockWidget::close-button {
+ subcontrol-position: top left;
+ subcontrol-origin: margin;
+ position: absolute;
+ top: 0px; left: 0px; bottom: 0px;
+ width: 14px;
+}
+
+QDockWidget::float-button {
+ subcontrol-position: top left;
+ subcontrol-origin: margin;
+ position: absolute;
+ top: 0px; left: 16px; bottom: 0px;
+ width: 14px;
+}
+//! [112]
+
+
+//! [113]
+QFrame, QLabel, QToolTip {
+ border: 2px solid green;
+ border-radius: 4px;
+ padding: 2px;
+ background-image: url(images/welcome.png);
+}
+//! [113]
+
+
+//! [114]
+QGroupBox {
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #E0E0E0, stop: 1 #FFFFFF);
+ border: 2px solid gray;
+ border-radius: 5px;
+ margin-top: 1ex; /* leave space at the top for the title */
+}
+
+QGroupBox::title {
+ subcontrol-origin: margin;
+ subcontrol-position: top center; /* position at the top center */
+ padding: 0 3px;
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #FFOECE, stop: 1 #FFFFFF);
+}
+//! [114]
+
+
+//! [115]
+QGroupBox::indicator {
+ width: 13px;
+ height: 13px;
+}
+
+QGroupBox::indicator:unchecked {
+ image: url(:/images/checkbox_unchecked.png);
+}
+
+/* proceed with styling just like QCheckBox */
+//! [115]
+
+
+//! [116]
+QHeaderView::section {
+ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
+ stop:0 #616161, stop: 0.5 #505050,
+ stop: 0.6 #434343, stop:1 #656565);
+ color: white;
+ padding-left: 4px;
+ border: 1px solid #6c6c6c;
+}
+
+QHeaderView::section:checked
+{
+ background-color: red;
+}
+
+/* style the sort indicator */
+QHeaderView::down-arrow {
+ image: url(down_arrow.png);
+}
+
+QHeaderView::up-arrow {
+ image: url(up_arrow.png);
+}
+//! [116]
+
+
+//! [117]
+QLineEdit {
+ border: 2px solid gray;
+ border-radius: 10px;
+ padding: 0 8px;
+ background: yellow;
+ selection-background-color: darkgray;
+}
+//! [117]
+
+
+//! [118]
+QLineEdit[echoMode="2"] {
+ lineedit-password-character: 9679;
+}
+//! [118]
+
+
+//! [119]
+QLineEdit:read-only {
+ background: lightblue;
+//! [119]
+
+
+//! [120]
+QListView {
+ alternate-background-color: yellow;
+}
+//! [120]
+
+
+//! [121]
+QListView {
+ show-decoration-selected: 1; /* make the selection span the entire width of the view */
+}
+
+QListView::item:alternate {
+ background: #EEEEEE;
+}
+
+QListView::item:selected {
+ border: 1px solid #6a6ea9;
+}
+
+QListView::item:selected:!active {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #ABAFE5, stop: 1 #8588B2);
+}
+
+QListView::item:selected:active {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #6a6ea9, stop: 1 #888dd9);
+}
+
+QListView::item:hover {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #FAFBFE, stop: 1 #DCDEF1);
+}
+//! [121]
+
+
+//! [122]
+QMainWindow::separator {
+ background: yellow;
+ width: 10px; /* when vertical */
+ height: 10px; /* when horizontal */
+}
+
+QMainWindow::separator:hover {
+ background: red;
+}
+//! [122]
+
+
+//! [123]
+QMenu {
+ background-color: #ABABAB; /* sets background of the menu */
+ border: 1px solid black;
+}
+
+QMenu::item {
+ /* sets background of menu item. set this to something non-transparent
+ if you want menu color and menu item color to be different */
+ background-color: transparent;
+}
+
+QMenu::item:selected { /* when user selects item using mouse or keyboard */
+ background-color: #654321;
+}
+//! [123]
+
+
+//! [124]
+QMenu {
+ background-color: white;
+ margin: 2px; /* some spacing around the menu */
+}
+
+QMenu::item {
+ padding: 2px 25px 2px 20px;
+ border: 1px solid transparent; /* reserve space for selection border */
+}
+
+QMenu::item:selected {
+ border-color: darkblue;
+ background: rgba(100, 100, 100, 150);
+}
+
+QMenu::icon:checked { /* appearance of a 'checked' icon */
+ background: gray;
+ border: 1px inset gray;
+ position: absolute;
+ top: 1px;
+ right: 1px;
+ bottom: 1px;
+ left: 1px;
+}
+
+QMenu::separator {
+ height: 2px;
+ background: lightblue;
+ margin-left: 10px;
+ margin-right: 5px;
+}
+
+QMenu::indicator {
+ width: 13px;
+ height: 13px;
+}
+
+/* non-exclusive indicator = check box style indicator (see QActionGroup::setExclusive) */
+QMenu::indicator:non-exclusive:unchecked {
+ image: url(:/images/checkbox_unchecked.png);
+}
+
+QMenu::indicator:non-exclusive:unchecked:selected {
+ image: url(:/images/checkbox_unchecked_hover.png);
+}
+
+QMenu::indicator:non-exclusive:checked {
+ image: url(:/images/checkbox_checked.png);
+}
+
+QMenu::indicator:non-exclusive:checked:selected {
+ image: url(:/images/checkbox_checked_hover.png);
+}
+
+/* exclusive indicator = radio button style indicator (see QActionGroup::setExclusive) */
+QMenu::indicator:exclusive:unchecked {
+ image: url(:/images/radiobutton_unchecked.png);
+}
+
+QMenu::indicator:exclusive:unchecked:selected {
+ image: url(:/images/radiobutton_unchecked_hover.png);
+}
+
+QMenu::indicator:exclusive:checked {
+ image: url(:/images/radiobutton_checked.png);
+}
+
+QMenu::indicator:exclusive:checked:selected {
+ image: url(:/images/radiobutton_checked_hover.png);
+}
+
+//! [124]
+
+
+//! [125]
+QMenuBar {
+ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
+ stop:0 lightgray, stop:1 darkgray);
+}
+
+QMenuBar::item {
+ spacing: 3px; /* spacing between menu bar items */
+ padding: 1px 4px;
+ background: transparent;
+ border-radius: 4px;
+}
+
+QMenuBar::item:selected { /* when selected using mouse or keyboard */
+ background: #a8a8a8;
+}
+
+QMenuBar::item:pressed {
+ background: #888888;
+}
+//! [125]
+
+
+//! [126]
+QProgressBar {
+ border: 2px solid grey;
+ border-radius: 5px;
+}
+
+QProgressBar::chunk {
+ background-color: #05B8CC;
+ width: 20px;
+}
+//! [126]
+
+
+//! [127]
+QProgressBar {
+ border: 2px solid grey;
+ border-radius: 5px;
+ text-align: center;
+}
+//! [127]
+
+
+//! [128]
+QProgressBar::chunk {
+ background-color: #CD96CD;
+ width: 10px;
+ margin: 0.5px;
+}
+//! [128]
+
+
+//! [129]
+QPushButton {
+ border: 2px solid #8f8f91;
+ border-radius: 6px;
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #f6f7fa, stop: 1 #dadbde);
+ min-width: 80px;
+}
+
+QPushButton:pressed {
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #dadbde, stop: 1 #f6f7fa);
+}
+
+QPushButton:flat {
+ border: none; /* no border for a flat push button */
+}
+
+QPushButton:default {
+ border-color: navy; /* make the default button prominent */
+}
+//! [129]
+
+
+//! [130]
+QPushButton:open { /* when the button has its menu open */
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #dadbde, stop: 1 #f6f7fa);
+}
+
+QPushButton::menu-indicator {
+ image: url(menu_indicator.png);
+ subcontrol-origin: padding;
+ subcontrol-position: bottom right;
+}
+
+QPushButton::menu-indicator:pressed, QPushButton::menu-indicator:open {
+ position: relative;
+ top: 2px; left: 2px; /* shift the arrow by 2 px */
+}
+//! [130]
+
+
+//! [131]
+QRadioButton::indicator {
+ width: 13px;
+ height: 13px;
+}
+
+QRadioButton::indicator::unchecked {
+ image: url(:/images/radiobutton_unchecked.png);
+}
+
+QRadioButton::indicator:unchecked:hover {
+ image: url(:/images/radiobutton_unchecked_hover.png);
+}
+
+QRadioButton::indicator:unchecked:pressed {
+ image: url(:/images/radiobutton_unchecked_pressed.png);
+}
+
+QRadioButton::indicator::checked {
+ image: url(:/images/radiobutton_checked.png);
+}
+
+QRadioButton::indicator:checked:hover {
+ image: url(:/images/radiobutton_checked_hover.png);
+}
+
+QRadioButton::indicator:checked:pressed {
+ image: url(:/images/radiobutton_checked_pressed.png);
+}
+//! [131]
+
+
+//! [132]
+QScrollBar:horizontal {
+ border: 2px solid grey;
+ background: #32CC99;
+ height: 15px;
+ margin: 0px 20px 0 20px;
+}
+//! [132]
+
+
+//! [133]
+QScrollBar::handle:horizontal {
+ background: white;
+ min-width: 20px;
+}
+//! [133]
+
+
+//! [134]
+QScrollBar::add-line:horizontal {
+ border: 2px solid grey;
+ background: #32CC99;
+ width: 20px;
+ subcontrol-position: right;
+ subcontrol-origin: margin;
+}
+
+QScrollBar::sub-line:horizontal {
+ border: 2px solid grey;
+ background: #32CC99;
+ width: 20px;
+ subcontrol-position: left;
+ subcontrol-origin: margin;
+}
+//! [134]
+
+
+//! [135]
+QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal {
+ border: 2px solid grey;
+ width: 3px;
+ height: 3px;
+ background: white;
+}
+
+QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
+ background: none;
+}
+//! [135]
+
+
+//! [136]
+QScrollBar:horizontal {
+ border: 2px solid green;
+ background: cyan;
+ height: 15px;
+ margin: 0px 40px 0 0px;
+}
+
+QScrollBar::handle:horizontal {
+ background: gray;
+ min-width: 20px;
+}
+
+QScrollBar::add-line:horizontal {
+ background: blue;
+ width: 16px;
+ subcontrol-position: right;
+ subcontrol-origin: margin;
+ border: 2px solid black;
+}
+
+QScrollBar::sub-line:horizontal {
+ background: magenta;
+ width: 16px;
+ subcontrol-position: top right;
+ subcontrol-origin: margin;
+ border: 2px solid black;
+ position: absolute;
+ right: 20px;
+}
+
+QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal {
+ width: 3px;
+ height: 3px;
+ background: pink;
+}
+
+QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
+ background: none;
+}
+
+//! [136]
+
+
+//! [137]
+ QScrollBar:vertical {
+ border: 2px solid grey;
+ background: #32CC99;
+ width: 15px;
+ margin: 22px 0 22px 0;
+ }
+ QScrollBar::handle:vertical {
+ background: white;
+ min-height: 20px;
+ }
+ QScrollBar::add-line:vertical {
+ border: 2px solid grey;
+ background: #32CC99;
+ height: 20px;
+ subcontrol-position: bottom;
+ subcontrol-origin: margin;
+ }
+
+ QScrollBar::sub-line:vertical {
+ border: 2px solid grey;
+ background: #32CC99;
+ height: 20px;
+ subcontrol-position: top;
+ subcontrol-origin: margin;
+ }
+ QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
+ border: 2px solid grey;
+ width: 3px;
+ height: 3px;
+ background: white;
+ }
+
+ QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
+ background: none;
+ }
+//! [137]
+
+
+//! [138]
+QSizeGrip {
+ image: url(:/images/sizegrip.png);
+ width: 16px;
+ height: 16px;
+}
+//! [138]
+
+
+//! [139]
+QSlider::groove:horizontal {
+ border: 1px solid #999999;
+ height: 8px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4);
+ margin: 2px 0;
+}
+
+QSlider::handle:horizontal {
+ background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);
+ border: 1px solid #5c5c5c;
+ width: 18px;
+ margin: -2px 0; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */
+ border-radius: 3px;
+}
+//! [139]
+
+
+//! [140]
+QSlider::groove:vertical {
+ background: red;
+ position: absolute; /* absolutely position 4px from the left and right of the widget. setting margins on the widget should work too... */
+ left: 4px; right: 4px;
+}
+
+QSlider::handle:vertical {
+ height: 10px;
+ background: green;
+ margin: 0 -4px; /* expand outside the groove */
+}
+
+QSlider::add-page:vertical {
+ background: white;
+}
+
+QSlider::sub-page:vertical {
+ background: pink;
+}
+//! [140]
+
+
+//! [141]
+QSpinBox {
+ padding-right: 15px; /* make room for the arrows */
+ border-image: url(:/images/frame.png) 4;
+ border-width: 3;
+}
+
+QSpinBox::up-button {
+ subcontrol-origin: border;
+ subcontrol-position: top right; /* position at the top right corner */
+
+ width: 16px; /* 16 + 2*1px border-width = 15px padding + 3px parent border */
+ border-image: url(:/images/spinup.png) 1;
+ border-width: 1px;
+}
+
+QSpinBox::up-button:hover {
+ border-image: url(:/images/spinup_hover.png) 1;
+}
+
+QSpinBox::up-button:pressed {
+ border-image: url(:/images/spinup_pressed.png) 1;
+}
+
+QSpinBox::up-arrow {
+ image: url(:/images/up_arrow.png);
+ width: 7px;
+ height: 7px;
+}
+
+QSpinBox::up-arrow:disabled, QSpinBox::up-arrow:off { /* off state when value is max */
+ image: url(:/images/up_arrow_disabled.png);
+}
+
+QSpinBox::down-button {
+ subcontrol-origin: border;
+ subcontrol-position: bottom right; /* position at bottom right corner */
+
+ width: 16px;
+ border-image: url(:/images/spindown.png) 1;
+ border-width: 1px;
+ border-top-width: 0;
+}
+
+QSpinBox::down-button:hover {
+ border-image: url(:/images/spindown_hover.png) 1;
+}
+
+QSpinBox::down-button:pressed {
+ border-image: url(:/images/spindown_pressed.png) 1;
+}
+
+QSpinBox::down-arrow {
+ image: url(:/images/down_arrow.png);
+ width: 7px;
+ height: 7px;
+}
+
+QSpinBox::down-arrow:disabled,
+QSpinBox::down-arrow:off { /* off state when value in min */
+ image: url(:/images/down_arrow_disabled.png);
+}
+
+//! [141]
+
+
+//! [142]
+QSplitter::handle {
+ image: url(images/splitter.png);
+}
+
+QSplitter::handle:horizontal {
+ width: 2px;
+}
+
+QSplitter::handle:vertical {
+ height: 2px;
+}
+
+QSplitter::handle:pressed {
+ url(images/splitter_pressed.png);
+}
+
+//! [142]
+
+
+//! [143]
+QStatusBar {
+ background: brown;
+}
+
+QStatusBar::item {
+ border: 1px solid red;
+ border-radius: 3px;
+}
+//! [143]
+
+
+//! [144]
+QStatusBar QLabel {
+ border: 3px solid white;
+}
+//! [144]
+
+
+//! [145]
+QTabWidget::pane { /* The tab widget frame */
+ border-top: 2px solid #C2C7CB;
+}
+
+QTabWidget::tab-bar {
+ left: 5px; /* move to the right by 5px */
+}
+
+/* Style the tab using the tab sub-control. Note that
+ it reads QTabBar _not_ QTabWidget */
+QTabBar::tab {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
+ stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
+ border: 2px solid #C4C4C3;
+ border-bottom-color: #C2C7CB; /* same as the pane color */
+ border-top-left-radius: 4px;
+ border-top-right-radius: 4px;
+ min-width: 8ex;
+ padding: 2px;
+}
+
+QTabBar::tab:selected, QTabBar::tab:hover {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #fafafa, stop: 0.4 #f4f4f4,
+ stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
+}
+
+QTabBar::tab:selected {
+ border-color: #9B9B9B;
+ border-bottom-color: #C2C7CB; /* same as pane color */
+}
+
+QTabBar::tab:!selected {
+ margin-top: 2px; /* make non-selected tabs look smaller */
+}
+//! [145]
+
+
+//! [146]
+QTabWidget::pane { /* The tab widget frame */
+ border-top: 2px solid #C2C7CB;
+}
+
+QTabWidget::tab-bar {
+ left: 5px; /* move to the right by 5px */
+}
+
+/* Style the tab using the tab sub-control. Note that
+ it reads QTabBar _not_ QTabWidget */
+QTabBar::tab {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
+ stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
+ border: 2px solid #C4C4C3;
+ border-bottom-color: #C2C7CB; /* same as the pane color */
+ border-top-left-radius: 4px;
+ border-top-right-radius: 4px;
+ min-width: 8ex;
+ padding: 2px;
+}
+
+QTabBar::tab:selected, QTabBar::tab:hover {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #fafafa, stop: 0.4 #f4f4f4,
+ stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
+}
+
+QTabBar::tab:selected {
+ border-color: #9B9B9B;
+ border-bottom-color: #C2C7CB; /* same as pane color */
+}
+
+QTabBar::tab:!selected {
+ margin-top: 2px; /* make non-selected tabs look smaller */
+}
+
+/* make use of negative margins for overlapping tabs */
+QTabBar::tab:selected {
+ /* expand/overlap to the left and right by 4px */
+ margin-left: -4px;
+ margin-right: -4px;
+}
+
+QTabBar::tab:first:selected {
+ margin-left: 0; /* the first selected tab has nothing to overlap with on the left */
+}
+
+QTabBar::tab:last:selected {
+ margin-right: 0; /* the last selected tab has nothing to overlap with on the right */
+}
+
+QTabBar::tab:only-one {
+ margin: 0; /* if there is only one tab, we don't want overlapping margins */
+}
+//! [146]
+
+
+//! [147]
+QTabWidget::pane { /* The tab widget frame */
+ border-top: 2px solid #C2C7CB;
+ position: absolute;
+ top: -0.5em;
+}
+
+QTabWidget::tab-bar {
+ alignment: center;
+}
+
+/* Style the tab using the tab sub-control. Note that
+ it reads QTabBar _not_ QTabWidget */
+QTabBar::tab {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
+ stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
+ border: 2px solid #C4C4C3;
+ border-bottom-color: #C2C7CB; /* same as the pane color */
+ border-top-left-radius: 4px;
+ border-top-right-radius: 4px;
+ min-width: 8ex;
+ padding: 2px;
+}
+
+QTabBar::tab:selected, QTabBar::tab:hover {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #fafafa, stop: 0.4 #f4f4f4,
+ stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
+}
+
+QTabBar::tab:selected {
+ border-color: #9B9B9B;
+ border-bottom-color: #C2C7CB; /* same as pane color */
+}
+//! [147]
+
+
+//! [148]
+QTabBar::tear {
+ image: url(tear_indicator.png);
+}
+
+QTabBar::scroller { /* the width of the scroll buttons */
+ width: 20px;
+}
+
+QTabBar QToolButton { /* the scroll buttons are tool buttons */
+ border-image: url(scrollbutton.png) 2;
+ border-width: 2px;
+}
+
+QTabBar QToolButton::right-arrow { /* the arrow mark in the tool buttons */
+ image: url(rightarrow.png);
+}
+
+QTabBar QToolButton::left-arrow {
+ image: url(leftarrow.png);
+}
+//! [148]
+
+
+//! [149]
+QTableView {
+ selection-background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5,
+ stop: 0 #FF92BB, stop: 1 white);
+}
+//! [149]
+
+
+//! [150]
+QTableView QTableCornerButton::section {
+ background: red;
+ border: 2px outset red;
+}
+//! [150]
+
+
+//! [151]
+QToolBar {
+ background: red;
+ spacing: 3px; /* spacing between items in the tool bar */
+}
+
+QToolBar::handle {
+ image: url(handle.png);
+}
+//! [151]
+
+
+//! [152]
+QToolBox::tab {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
+ stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
+ border-radius: 5px;
+ color: darkgray;
+}
+
+QToolBox::tab:selected { /* italicize selected tabs */
+ font: italic;
+ color: white;
+}
+//! [152]
+
+
+//! [153]
+QToolButton { /* all types of tool button */
+ border: 2px solid #8f8f91;
+ border-radius: 6px;
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #f6f7fa, stop: 1 #dadbde);
+}
+
+QToolButton[popupMode="1"] { /* only for MenuButtonPopup */
+ padding-right: 20px; /* make way for the popup button */
+}
+
+QToolButton:pressed {
+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #dadbde, stop: 1 #f6f7fa);
+}
+
+/* the subcontrols below are used only in the MenuButtonPopup mode */
+QToolButton::menu-button {
+ border: 2px solid gray;
+ border-top-right-radius: 6px;
+ border-bottom-right-radius: 6px;
+ /* 16px width + 4px for border = 20px allocated above */
+ width: 16px;
+}
+
+QToolButton::menu-arrow {
+ image: url(downarrow.png);
+}
+
+QToolButton::menu-arrow:open {
+ top: 1px; left: 1px; /* shift it a bit */
+}
+//! [153]
+
+
+//! [154]
+QToolTip {
+ border: 2px solid darkkhaki;
+ padding: 5px;
+ border-radius: 3px;
+ opacity: 200;
+}
+//! [154]
+
+
+//! [155]
+QTreeView {
+ alternate-background-color: yellow;
+}
+//! [155]
+
+
+//! [156]
+QTreeView {
+ show-decoration-selected: 1;
+}
+
+QTreeView::item {
+ border: 1px solid #d9d9d9;
+ border-top-color: transparent;
+ border-bottom-color: transparent;
+}
+
+QTreeView::item:hover {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
+ border: 1px solid #bfcde4;
+}
+
+QTreeView::item:selected {
+ border: 1px solid #567dbc;
+}
+
+QTreeView::item:selected:active{
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc);
+}
+
+QTreeView::item:selected:!active {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf);
+}
+//! [156]
+
+
+//! [157]
+QTreeView::branch {
+ background: palette(base);
+}
+
+QTreeView::branch:has-siblings:!adjoins-item {
+ background: cyan;
+}
+
+QTreeView::branch:has-siblings:adjoins-item {
+ background: red;
+}
+
+QTreeView::branch:!has-children:!has-siblings:adjoins-item {
+ background: blue;
+}
+
+QTreeView::branch:closed:has-children:has-siblings {
+ background: pink;
+}
+
+QTreeView::branch:has-children:!has-siblings:closed {
+ background: gray;
+}
+
+QTreeView::branch:open:has-children:has-siblings {
+ background: magenta;
+}
+
+QTreeView::branch:open:has-children:!has-siblings {
+ background: green;
+}
+
+//! [157]
+
+
+//! [158]
+QTreeView::branch:has-siblings:!adjoins-item {
+ border-image: url(vline.png) 0;
+}
+
+QTreeView::branch:has-siblings:adjoins-item {
+ border-image: url(branch-more.png) 0;
+}
+
+QTreeView::branch:!has-children:!has-siblings:adjoins-item {
+ border-image: url(branch-end.png) 0;
+}
+
+QTreeView::branch:has-children:!has-siblings:closed,
+QTreeView::branch:closed:has-children:has-siblings {
+ border-image: none;
+ image: url(branch-closed.png);
+}
+
+QTreeView::branch:open:has-children:!has-siblings,
+QTreeView::branch:open:has-children:has-siblings {
+ border-image: none;
+ image: url(branch-open.png);
+}
+//! [158]
+
+//! [159]
+QTabBar::close-button {
+ image: url(close.png)
+ subcontrol-position: left;
+}
+QTabBar::close-button:hover {
+ image: url(close-hover.png)
+}
+
+//! [159]
diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp
new file mode 100644
index 0000000000..1a89ff327f
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+fileName = QFileDialog::getOpenFileName(this,
+ tr("Open Image"), "/home/jana", tr("Image Files (*.png *.jpg *.bmp)"));
+//! [0]
+
+
+//! [1]
+"Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
+//! [1]
+
+
+//! [2]
+QFileDialog dialog(this);
+dialog.setFileMode(QFileDialog::AnyFile);
+//! [2]
+
+
+//! [3]
+dialog.setNameFilter(tr("Images (*.png *.xpm *.jpg)"));
+//! [3]
+
+
+//! [4]
+dialog.setViewMode(QFileDialog::Detail);
+//! [4]
+
+
+//! [5]
+QStringList fileNames;
+if (dialog.exec())
+ fileNames = dialog.selectedFiles();
+//! [5]
+
+
+//! [6]
+dialog.setNameFilter("All C++ files (*.cpp *.cc *.C *.cxx *.c++)");
+dialog.setNameFilter("*.cpp *.cc *.C *.cxx *.c++");
+//! [6]
+
+
+//! [7]
+QStringList filters;
+filters << "Image files (*.png *.xpm *.jpg)"
+ << "Text files (*.txt)"
+ << "Any files (*)";
+
+QFileDialog dialog(this);
+dialog.setNameFilters(filters);
+dialog.exec();
+//! [7]
+
+
+//! [8]
+QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
+ "/home",
+ tr("Images (*.png *.xpm *.jpg)"));
+//! [8]
+
+
+//! [9]
+QStringList files = QFileDialog::getOpenFileNames(
+ this,
+ "Select one or more files to open",
+ "/home",
+ "Images (*.png *.xpm *.jpg)");
+//! [9]
+
+
+//! [10]
+QStringList list = files;
+QStringList::Iterator it = list.begin();
+while(it != list.end()) {
+ myProcessing(*it);
+ ++it;
+}
+//! [10]
+
+
+//! [11]
+QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
+ "/home/jana/untitled.png",
+ tr("Images (*.png *.xpm *.jpg)"));
+//! [11]
+
+
+//! [12]
+QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
+ "/home",
+ QFileDialog::ShowDirsOnly
+ | QFileDialog::DontResolveSymlinks);
+//! [12]
diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qfontdialog.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qfontdialog.cpp
new file mode 100644
index 0000000000..e07ecbca3e
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qfontdialog.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+bool ok;
+QFont font = QFontDialog::getFont(
+ &ok, QFont("Helvetica [Cronyx]", 10), this);
+if (ok) {
+ // the user clicked OK and font is set to the font the user selected
+} else {
+ // the user canceled the dialog; font is set to the initial
+ // value, in this case Helvetica [Cronyx], 10
+}
+//! [0]
+
+
+//! [1]
+myWidget.setFont(QFontDialog::getFont(0, myWidget.font()));
+//! [1]
+
+
+//! [2]
+bool ok;
+QFont font = QFontDialog::getFont(&ok, QFont("Times", 12), this);
+if (ok) {
+ // font is set to the font the user selected
+} else {
+ // the user canceled the dialog; font is set to the initial
+ // value, in this case Times, 12.
+}
+//! [2]
+
+
+//! [3]
+myWidget.setFont(QFontDialog::getFont(0, myWidget.font()));
+//! [3]
+
+
+//! [4]
+bool ok;
+QFont font = QFontDialog::getFont(&ok, this);
+if (ok) {
+ // font is set to the font the user selected
+} else {
+ // the user canceled the dialog; font is set to the default
+ // application font, QApplication::font()
+}
+//! [4]
diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp
new file mode 100644
index 0000000000..90bc2e9b0a
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+int ret = QMessageBox::warning(this, tr("My Application"),
+ tr("The document has been modified.\n"
+ "Do you want to save your changes?"),
+ QMessageBox::Save | QMessageBox::Discard
+ | QMessageBox::Cancel,
+ QMessageBox::Save);
+//! [0]
+
+
+//! [1]
+QMessageBox msgBox;
+msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+switch (msgBox.exec()) {
+case QMessageBox::Yes:
+ // yes was clicked
+ break;
+case QMessageBox::No:
+ // no was clicked
+ break;
+default:
+ // should never be reached
+ break;
+}
+//! [1]
+
+
+//! [2]
+QMessageBox msgBox;
+QPushButton *connectButton = msgBox.addButton(tr("Connect"), QMessageBox::ActionRole);
+QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);
+
+msgBox.exec();
+
+if (msgBox.clickedButton() == connectButton) {
+ // connect
+} else if (msgBox.clickedButton() == abortButton) {
+ // abort
+}
+//! [2]
+
+
+//! [3]
+QMessageBox messageBox(this);
+QAbstractButton *disconnectButton =
+ messageBox.addButton(tr("Disconnect"), QMessageBox::ActionRole);
+...
+messageBox.exec();
+if (messageBox.clickedButton() == disconnectButton) {
+ ...
+}
+//! [3]
+
+
+//! [4]
+#include <QApplication>
+#include <QMessageBox>
+
+int main(int argc, char *argv[])
+{
+ QT_REQUIRE_VERSION(argc, argv, "4.0.2")
+
+ QApplication app(argc, argv);
+ ...
+ return app.exec();
+}
+//! [4]
+
+//! [5]
+QMessageBox msgBox;
+msgBox.setText("The document has been modified.");
+msgBox.exec();
+//! [5]
+
+//! [6]
+QMessageBox msgBox;
+msgBox.setText("The document has been modified.");
+msgBox.setInformativeText("Do you want to save your changes?");
+msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+msgBox.setDefaultButton(QMessageBox::Save);
+int ret = msgBox.exec();
+//! [6]
+
+//! [7]
+switch (ret) {
+ case QMessageBox::Save:
+ // Save was clicked
+ break;
+ case QMessageBox::Discard:
+ // Don't Save was clicked
+ break;
+ case QMessageBox::Cancel:
+ // Cancel was clicked
+ break;
+ default:
+ // should never be reached
+ break;
+}
+//! [7]
+
+//! [9]
+QMessageBox msgBox(this);
+msgBox.setText(tr("The document has been modified.\n"
+ "Do you want to save your changes?"));
+msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard
+ | QMessageBox::Cancel);
+msgBox.setDefaultButton(QMessageBox::Save);
+//! [9]
diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qwizard.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qwizard.cpp
new file mode 100644
index 0000000000..47db20da99
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qwizard.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+int LicenseWizard::nextId() const
+{
+ switch (currentId()) {
+ case Page_Intro:
+ if (field("intro.evaluate").toBool()) {
+ return Page_Evaluate;
+ } else {
+ return Page_Register;
+ }
+ case Page_Evaluate:
+ return Page_Conclusion;
+ case Page_Register:
+ if (field("register.upgradeKey").toString().isEmpty()) {
+ return Page_Details;
+ } else {
+ return Page_Conclusion;
+ }
+ case Page_Details:
+ return Page_Conclusion;
+ case Page_Conclusion:
+ default:
+ return -1;
+ }
+}
+//! [0]
+
+
+//! [1]
+MyWizard::MyWizard(QWidget *parent)
+ : QWizard(parent)
+{
+ ...
+ QList<QWizard::WizardButton> layout;
+ layout << QWizard::Stretch << QWizard::BackButton << QWizard::CancelButton
+ << QWizard::NextButton << QWizard::FinishButton;
+ setButtonLayout(layout);
+ ...
+}
+//! [1]
diff --git a/src/widgets/doc/snippets/code/src_gui_effects_qgraphicseffect.cpp b/src/widgets/doc/snippets/code/src_gui_effects_qgraphicseffect.cpp
new file mode 100644
index 0000000000..3e0b0b64ee
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_effects_qgraphicseffect.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+MyGraphicsOpacityEffect::draw(QPainter *painter)
+{
+ // Fully opaque; draw directly without going through a pixmap.
+ if (qFuzzyCompare(m_opacity, 1)) {
+ drawSource(painter);
+ return;
+ }
+ ...
+}
+//! [0]
+
+//! [1]
+MyGraphicsEffect::draw(QPainter *painter)
+{
+ ...
+ QPoint offset;
+ if (sourceIsPixmap()) {
+ // No point in drawing in device coordinates (pixmap will be scaled anyways).
+ const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset);
+ ...
+ painter->drawPixmap(offset, pixmap);
+ } else {
+ // Draw pixmap in device coordinates to avoid pixmap scaling;
+ const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset);
+ painter->setWorldTransform(QTransform());
+ ...
+ painter->drawPixmap(offset, pixmap);
+ }
+ ...
+}
+//! [1]
+
+//! [2]
+...
+QLinearGradient alphaGradient(rect.topLeft(), rect.bottomLeft());
+alphaGradient.setColorAt(0.0, Qt::transparent);
+alphaGradient.setColorAt(0.5, Qt::black);
+alphaGradient.setColorAt(1.0, Qt::transparent);
+QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect;
+effect->setOpacityMask(alphaGradient);
+...
+//! [2]
diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp
new file mode 100644
index 0000000000..9a974de016
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QGraphicsScene scene;
+QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit);
+QGraphicsWidget *pushButton = scene.addWidget(new QPushButton);
+
+QGraphicsGridLayout *layout = new QGraphicsGridLayout;
+layout->addItem(textEdit, 0, 0);
+layout->addItem(pushButton, 0, 1);
+
+QGraphicsWidget *form = new QGraphicsWidget;
+form->setLayout(layout);
+scene.addItem(form);
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp
new file mode 100644
index 0000000000..01df05c084
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp
@@ -0,0 +1,278 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+class SimpleItem : public QGraphicsItem
+{
+public:
+ QRectF boundingRect() const
+ {
+ qreal penWidth = 1;
+ return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,
+ 20 + penWidth, 20 + penWidth);
+ }
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+ {
+ painter->drawRoundedRect(-10, -10, 20, 20, 5, 5);
+ }
+};
+//! [0]
+
+
+//! [1]
+class CustomItem : public QGraphicsItem
+{
+ ...
+ enum { Type = UserType + 1 };
+
+ int type() const
+ {
+ // Enable the use of qgraphicsitem_cast with this item.
+ return Type;
+ }
+ ...
+};
+//! [1]
+
+
+//! [2]
+item->setCursor(Qt::IBeamCursor);
+//! [2]
+
+
+//! [3]
+item->setCursor(Qt::IBeamCursor);
+//! [3]
+
+
+//! [4]
+QGraphicsRectItem rect;
+rect.setPos(100, 100);
+
+rect.sceneTransform().map(QPointF(0, 0));
+// returns QPointF(100, 100);
+
+rect.sceneTransform().inverted().map(QPointF(100, 100));
+// returns QPointF(0, 0);
+//! [4]
+
+
+//! [5]
+QGraphicsRectItem rect;
+rect.setPos(100, 100);
+
+rect.deviceTransform(view->viewportTransform()).map(QPointF(0, 0));
+// returns the item's (0, 0) point in view's viewport coordinates
+
+rect.deviceTransform(view->viewportTransform()).inverted().map(QPointF(100, 100));
+// returns view's viewport's (100, 100) coordinate in item coordinates
+//! [5]
+
+
+//! [6]
+// Rotate an item 45 degrees around (0, 0).
+item->rotate(45);
+
+// Rotate an item 45 degrees around (x, y).
+item->setTransform(QTransform().translate(x, y).rotate(45).translate(-x, -y));
+//! [6]
+
+
+//! [7]
+// Scale an item by 3x2 from its origin
+item->scale(3, 2);
+
+// Scale an item by 3x2 from (x, y)
+item->setTransform(QTransform().translate(x, y).scale(3, 2).translate(-x, -y));
+//! [7]
+
+
+//! [8]
+QRectF CircleItem::boundingRect() const
+{
+ qreal penWidth = 1;
+ return QRectF(-radius - penWidth / 2, -radius - penWidth / 2,
+ diameter + penWidth, diameter + penWidth);
+}
+//! [8]
+
+
+//! [9]
+QPainterPath RoundItem::shape() const
+{
+ QPainterPath path;
+ path.addEllipse(boundingRect());
+ return path;
+}
+//! [9]
+
+
+//! [10]
+void RoundRectItem::paint(QPainter *painter,
+ const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+{
+ painter->drawRoundedRect(-10, -10, 20, 20, 5, 5);
+}
+//! [10]
+
+
+//! [11]
+static const int ObjectName = 0;
+
+QGraphicsItem *item = scene.itemAt(100, 50);
+if (item->data(ObjectName).toString().isEmpty()) {
+ if (qgraphicsitem_cast<ButtonItem *>(item))
+ item->setData(ObjectName, "Button");
+}
+//! [11]
+
+
+//! [12]
+QGraphicsScene scene;
+QGraphicsEllipseItem *ellipse = scene.addEllipse(QRectF(-10, -10, 20, 20));
+QGraphicsLineItem *line = scene.addLine(QLineF(-10, -10, 20, 20));
+
+line->installSceneEventFilter(ellipse);
+// line's events are filtered by ellipse's sceneEventFilter() function.
+
+ellipse->installSceneEventFilter(line);
+// ellipse's events are filtered by line's sceneEventFilter() function.
+//! [12]
+
+
+//! [13]
+void CustomItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
+{
+ QMenu menu;
+ QAction *removeAction = menu.addAction("Remove");
+ QAction *markAction = menu.addAction("Mark");
+ QAction *selectedAction = menu.exec(event->screenPos());
+ // ...
+}
+//! [13]
+
+
+//! [14]
+CustomItem::CustomItem()
+{
+ setAcceptDrops(true);
+ ...
+}
+
+void CustomItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
+{
+ event->setAccepted(event->mimeData()->hasFormat("text/plain"));
+}
+//! [14]
+
+
+//! [15]
+QVariant Component::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ if (change == ItemPositionChange && scene()) {
+ // value is the new position.
+ QPointF newPos = value.toPointF();
+ QRectF rect = scene()->sceneRect();
+ if (!rect.contains(newPos)) {
+ // Keep the item inside the scene rect.
+ newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
+ newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
+ return newPos;
+ }
+ }
+ return QGraphicsItem::itemChange(change, value);
+}
+//! [15]
+
+
+//! [16]
+void CircleItem::setRadius(qreal newRadius)
+{
+ if (radius != newRadius) {
+ prepareGeometryChange();
+ radius = newRadius;
+ }
+}
+//! [16]
+
+
+//! [17]
+// Group all selected items together
+QGraphicsItemGroup *group = scene->createItemGroup(scene->selecteditems());
+
+// Destroy the group, and delete the group item
+scene->destroyItemGroup(group);
+//! [17]
+
+
+//! [QGraphicsItem type]
+class CustomItem : public QGraphicsItem
+{
+ ...
+ enum { Type = UserType + 1 };
+
+ int type() const
+ {
+ // Enable the use of qgraphicsitem_cast with this item.
+ return Type;
+ }
+ ...
+};
+//! [QGraphicsItem type]
+
+//! [18]
+class QGraphicsPathItem : public QAbstractGraphicsShapeItem
+{
+ public:
+ enum { Type = 2 };
+ int type() const { return Type; }
+ ...
+};
+//! [18]
+
+//! [19]
+QTransform xform = item->deviceTransform(view->viewportTransform());
+QRect deviceRect = xform.mapRect(rect).toAlignedRect();
+view->viewport()->scroll(dx, dy, deviceRect);
+//! [19]
+
diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp
new file mode 100644
index 0000000000..e3998201af
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QGraphicsScene scene;
+QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit);
+QGraphicsWidget *pushButton = scene.addWidget(new QPushButton);
+
+QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
+layout->addItem(textEdit);
+layout->addItem(pushButton);
+
+QGraphicsWidget *form = new QGraphicsWidget;
+form->setLayout(layout);
+scene.addItem(form);
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp
new file mode 100644
index 0000000000..e508dbfb2b
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QTabWidget *tabWidget = new QTabWidget;
+
+ QGraphicsScene scene;
+ QGraphicsProxyWidget *proxy = scene.addWidget(tabWidget);
+
+ QGraphicsView view(&scene);
+ view.show();
+
+ return app.exec();
+}
+//! [0]
+
+//! [1]
+QGroupBox *groupBox = new QGroupBox("Contact Details");
+QLabel *numberLabel = new QLabel("Telephone number");
+QLineEdit *numberEdit = new QLineEdit;
+
+QFormLayout *layout = new QFormLayout;
+layout->addRow(numberLabel, numberEdit);
+groupBox->setLayout(layout);
+
+QGraphicsScene scene;
+QGraphicsProxyWidget *proxy = scene.addWidget(groupBox);
+
+QGraphicsView view(&scene);
+view.show();
+//! [1]
+
+//! [2]
+QGraphicsScene scene;
+
+QLineEdit *edit = new QLineEdit;
+QGraphicsProxyWidget *proxy = scene.addWidget(edit);
+
+edit->isVisible(); // returns true
+proxy->isVisible(); // also returns true
+
+edit->hide();
+
+edit->isVisible(); // returns false
+proxy->isVisible(); // also returns false
+//! [2]
diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp
new file mode 100644
index 0000000000..40b240c56f
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QGraphicsScene scene;
+scene.addText("Hello, world!");
+
+QGraphicsView view(&scene);
+view.show();
+//! [0]
+
+
+//! [1]
+QGraphicsScene scene;
+scene.addItem(...
+...
+QPrinter printer(QPrinter::HighResolution);
+printer.setPaperSize(QPrinter::A4);
+
+QPainter painter(&printer);
+scene.render(&painter);
+//! [1]
+
+
+//! [2]
+QSizeF segmentSize = sceneRect().size() / pow(2, depth - 1);
+//! [2]
+
+
+//! [3]
+QGraphicsScene scene;
+QGraphicsView view(&scene);
+view.show();
+
+// a blue background
+scene.setBackgroundBrush(Qt::blue);
+
+// a gradient background
+QRadialGradient gradient(0, 0, 10);
+gradient.setSpread(QGradient::RepeatSpread);
+scene.setBackgroundBrush(gradient);
+//! [3]
+
+
+//! [4]
+QGraphicsScene scene;
+QGraphicsView view(&scene);
+view.show();
+
+// a white semi-transparent foreground
+scene.setForegroundBrush(QColor(255, 255, 255, 127));
+
+// a grid foreground
+scene.setForegroundBrush(QBrush(Qt::lightGray, Qt::CrossPattern));
+//! [4]
+
+
+//! [5]
+QRectF TileScene::rectForTile(int x, int y) const
+{
+ // Return the rectangle for the tile at position (x, y).
+ return QRectF(x * tileWidth, y * tileHeight, tileWidth, tileHeight);
+}
+
+void TileScene::setTile(int x, int y, const QPixmap &pixmap)
+{
+ // Sets or replaces the tile at position (x, y) with pixmap.
+ if (x >= 0 && x < numTilesH && y >= 0 && y < numTilesV) {
+ tiles[y][x] = pixmap;
+ invalidate(rectForTile(x, y), BackgroundLayer);
+ }
+}
+
+void TileScene::drawBackground(QPainter *painter, const QRectF &exposed)
+{
+ // Draws all tiles that intersect the exposed area.
+ for (int y = 0; y < numTilesV; ++y) {
+ for (int x = 0; x < numTilesH; ++x) {
+ QRectF rect = rectForTile(x, y);
+ if (exposed.intersects(rect))
+ painter->drawPixmap(rect.topLeft(), tiles[y][x]);
+ }
+ }
+}
+//! [5]
diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp
new file mode 100644
index 0000000000..0e9ceea6a0
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+
+setDropAction(proposedAction());
+
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
new file mode 100644
index 0000000000..d07b5f7cf6
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QGraphicsScene scene;
+scene.addText("Hello, world!");
+
+QGraphicsView view(&scene);
+view.show();
+//! [0]
+
+
+//! [1]
+QGraphicsScene scene;
+scene.addRect(QRectF(-10, -10, 20, 20));
+
+QGraphicsView view(&scene);
+view.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
+view.show();
+//! [1]
+
+
+//! [2]
+QGraphicsView view;
+view.setBackgroundBrush(QImage(":/images/backgroundtile.png"));
+view.setCacheMode(QGraphicsView::CacheBackground);
+//! [2]
+
+
+//! [3]
+QGraphicsScene scene;
+scene.addText("GraphicsView rotated clockwise");
+
+QGraphicsView view(&scene);
+view.rotate(90); // the text is rendered with a 90 degree clockwise rotation
+view.show();
+//! [3]
+
+
+//! [4]
+QGraphicsScene scene;
+scene.addItem(...
+...
+
+QGraphicsView view(&scene);
+view.show();
+...
+
+QPrinter printer(QPrinter::HighResolution);
+printer.setPageSize(QPrinter::A4);
+QPainter painter(&printer);
+
+// print, fitting the viewport contents into a full page
+view.render(&painter);
+
+// print the upper half of the viewport into the lower.
+// half of the page.
+QRect viewport = view.viewport()->rect();
+view.render(&painter,
+ QRectF(0, printer.height() / 2,
+ printer.width(), printer.height() / 2),
+ viewport.adjusted(0, 0, 0, -viewport.height() / 2));
+
+//! [4]
+
+
+//! [5]
+void CustomView::mousePressEvent(QMouseEvent *event)
+{
+ qDebug() << "There are" << items(event->pos()).size()
+ << "items at position" << mapToScene(event->pos());
+}
+//! [5]
+
+
+//! [6]
+void CustomView::mousePressEvent(QMouseEvent *event)
+{
+ if (QGraphicsItem *item = itemAt(event->pos())) {
+ qDebug() << "You clicked on item" << item;
+ } else {
+ qDebug() << "You didn't click on an item.";
+ }
+}
+//! [6]
+
+
+//! [7]
+QGraphicsScene scene;
+scene.addText("GraphicsView rotated clockwise");
+
+QGraphicsView view(&scene);
+view.rotate(90); // the text is rendered with a 90 degree clockwise rotation
+view.show();
+//! [7]
diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp
new file mode 100644
index 0000000000..da92f2d2e1
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+void MyGroupBoxWidget::initStyleOption(QStyleOption *option) const
+{
+ QGraphicsWidget::initStyleOption(option);
+ if (QStyleOptionGroupBox *box = qstyleoption_cast<QStyleOptionGroupBox *>(option)) {
+ // Add group box specific state.
+ box->flat = isFlat();
+ ...
+ }
+}
+//! [0]
+
+
+//! [1]
+setTabOrder(a, b); // a to b
+setTabOrder(b, c); // a to b to c
+setTabOrder(c, d); // a to b to c to d
+//! [1]
+
+
+//! [2]
+// WRONG
+setTabOrder(c, d); // c to d
+setTabOrder(a, b); // a to b AND c to d
+setTabOrder(b, c); // a to b to c, but not c to d
+//! [2]
diff --git a/src/widgets/doc/snippets/code/src_gui_image_qicon.cpp b/src/widgets/doc/snippets/code/src_gui_image_qicon.cpp
new file mode 100644
index 0000000000..28ebea8f65
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_image_qicon.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QToolButton *button = new QToolButton;
+button->setIcon(QIcon("open.xpm"));
+//! [0]
+
+
+//! [1]
+button->setIcon(QIcon());
+//! [1]
+
+
+//! [2]
+void MyWidget::drawIcon(QPainter *painter, QPoint pos)
+{
+ QPixmap pixmap = icon.pixmap(QSize(22, 22),
+ isEnabled() ? QIcon::Normal
+ : QIcon::Disabled,
+ isChecked() ? QIcon::On
+ : QIcon::Off);
+ painter->drawPixmap(pos, pixmap);
+}
+//! [2]
+
+//! [3]
+ QIcon undoicon = QIcon::fromTheme("edit-undo");
+//! [3]
+
+//! [4]
+ QIcon undoicon = QIcon::fromTheme("edit-undo", QIcon(":/undo.png"));
+//! [4]
+
diff --git a/src/widgets/doc/snippets/code/src_gui_image_qpixmapfilter.cpp b/src/widgets/doc/snippets/code/src_gui_image_qpixmapfilter.cpp
new file mode 100644
index 0000000000..55d5aa4897
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_image_qpixmapfilter.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QPixmapColorizeFilter *myFilter = new QPixmapColorFilter;
+myFilter->setColor(QColor(128, 0, 0));
+myFilter->draw(painter, QPoint(0, 0), originalPixmap);
+//! [0]
+
+//! [1]
+QPixmapConvolutionFilter *myFilter = new QPixmapConvolutionFilter;
+qreal kernel[] = {
+ 0.0,-1.0, 0.0,
+ -1.0, 5.0,-1.0,
+ 0.0,-1.0, 0.0
+ };
+myFilter->setConvolutionKernel(kernel, 3, 3);
+myFilter->draw(painter, QPoint(0, 0), originalPixmap);
+//! [1]
+
+//! [2]
+QPixmapDropShadowFilter *myFilter = new QPixmapDropShadowFilter;
+myFilter->draw(painter, QPoint(0, 0), originalPixmap);
+//! [2]
+
diff --git a/src/widgets/doc/snippets/code/src_gui_itemviews_qabstractitemview.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qabstractitemview.cpp
new file mode 100644
index 0000000000..2a497ff37c
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qabstractitemview.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+void MyView::resizeEvent(QResizeEvent *event) {
+ horizontalScrollBar()->setRange(0, realWidth - width());
+ ...
+}
+//! [0]
+
+//! [1]
+setIndexWidget(index, new QLineEdit);
+...
+setIndexWidget(index, new QTextEdit);
+//! [1]
+
+//! [2]
+QItemSelectionModel *m = view->selectionModel();
+view->setModel(new model);
+delete m;
+//! [2]
diff --git a/src/widgets/doc/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp
new file mode 100644
index 0000000000..d968260d39
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QDataWidgetMapper *mapper = new QDataWidgetMapper;
+mapper->setModel(model);
+mapper->addMapping(mySpinBox, 0);
+mapper->addMapping(myLineEdit, 1);
+mapper->addMapping(myCountryChooser, 2);
+mapper->toFirst();
+//! [0]
+
+
+//! [1]
+QDataWidgetMapper *mapper = new QDataWidgetMapper();
+mapper->setModel(myModel);
+mapper->addMapping(nameLineEdit, 0);
+mapper->addMapping(ageSpinBox, 1);
+//! [1]
+
+
+//! [2]
+QDataWidgetMapper *mapper = new QDataWidgetMapper();
+connect(myTableView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
+ mapper, SLOT(setCurrentModelIndex(QModelIndex)));
+//! [2]
diff --git a/src/widgets/doc/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp
new file mode 100644
index 0000000000..3f1e11c04c
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+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/src/widgets/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
new file mode 100644
index 0000000000..ae91339867
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QStandardItemModel model(4, 4);
+for (int row = 0; row < 4; ++row) {
+ for (int column = 0; column < 4; ++column) {
+ QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
+ model.setItem(row, column, item);
+ }
+}
+//! [0]
+
+
+//! [1]
+QStandardItemModel model;
+QStandardItem *parentItem = model.invisibleRootItem();
+for (int i = 0; i < 4; ++i) {
+ QStandardItem *item = new QStandardItem(QString("item %0").arg(i));
+ parentItem->appendRow(item);
+ parentItem = item;
+}
+//! [1]
+
+
+//! [2]
+QTreeView *treeView = new QTreeView(this);
+treeView->setModel(myStandardItemModel);
+connect(treeView, SIGNAL(clicked(QModelIndex)),
+ this, SLOT(clicked(QModelIndex)));
+//! [2]
+
+
+//! [3]
+void MyWidget::clicked(const QModelIndex &index)
+{
+ QStandardItem *item = myStandardItemModel->itemFromIndex(index);
+ // Do stuff with the item ...
+}
+//! [3]
+
+
+//! [4]
+treeView->scrollTo(item->index());
+//! [4]
diff --git a/src/widgets/doc/snippets/code/src_gui_itemviews_qtablewidget.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qtablewidget.cpp
new file mode 100644
index 0000000000..169fff57b9
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qtablewidget.cpp
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+setCellWidget(index, new QLineEdit);
+...
+setCellWidget(index, new QTextEdit);
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp
new file mode 100644
index 0000000000..b299d765f3
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QTreeWidget *treeWidget = new QTreeWidget();
+treeWidget->setColumnCount(1);
+QList<QTreeWidgetItem *> items;
+for (int i = 0; i < 10; ++i)
+ items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("item: %1").arg(i))));
+treeWidget->insertTopLevelItems(0, items);
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qaction.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qaction.cpp
new file mode 100644
index 0000000000..af876cd872
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qaction.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QApplication app(argc, argv);
+app.setAttribute(Qt::AA_DontShowIconsInMenus); // Icons are *no longer shown* in menus
+// ...
+QAction *myAction = new QAction();
+// ...
+myAction->setIcon(SomeIcon);
+myAction->setIconVisibleInMenu(true); // Icon *will* be shown in menus for *this* action.
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp
new file mode 100644
index 0000000000..b32e8c3f39
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+int main(int argc, char **argv)
+{
+#ifdef Q_WS_X11
+ bool useGUI = getenv("DISPLAY") != 0;
+#else
+ bool useGUI = true;
+#endif
+ QApplication app(argc, argv, useGUI);
+
+ if (useGUI) {
+ // start GUI version
+ ...
+ } else {
+ // start non-GUI version
+ ...
+ }
+ return app.exec();
+}
+//! [0]
+
+
+//! [1]
+QApplication::setStyle(new QWindowsStyle);
+//! [1]
+
+
+//! [2]
+int main(int argc, char *argv[])
+{
+ QApplication::setColorSpec(QApplication::ManyColor);
+ QApplication app(argc, argv);
+ ...
+ return app.exec();
+}
+//! [2]
+
+
+//! [3]
+QSize MyWidget::sizeHint() const
+{
+ return QSize(80, 25).expandedTo(QApplication::globalStrut());
+}
+//! [3]
+
+
+//! [4]
+void showAllHiddenTopLevelWidgets()
+{
+ foreach (QWidget *widget, QApplication::topLevelWidgets()) {
+ if (widget->isHidden())
+ widget->show();
+ }
+}
+//! [4]
+
+
+//! [5]
+void updateAllWidgets()
+{
+ foreach (QWidget *widget, QApplication::allWidgets())
+ widget->update();
+}
+//! [5]
+
+
+//! [6]
+int main(int argc, char *argv[])
+{
+ QApplication::setDesktopSettingsAware(false);
+ QApplication app(argc, argv);
+ ...
+ return app.exec();
+}
+//! [6]
+
+
+//! [7]
+if ((startPos - currentPos).manhattanLength() >=
+ QApplication::startDragDistance())
+ startTheDrag();
+//! [7]
+
+
+//! [8]
+void MyApplication::commitData(QSessionManager& manager)
+{
+ if (manager.allowsInteraction()) {
+ int ret = QMessageBox::warning(
+ mainWindow,
+ tr("My Application"),
+ tr("Save changes to document?"),
+ QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+
+ switch (ret) {
+ case QMessageBox::Save:
+ manager.release();
+ if (!saveDocument())
+ manager.cancel();
+ break;
+ case QMessageBox::Discard:
+ break;
+ case QMessageBox::Cancel:
+ default:
+ manager.cancel();
+ }
+ } else {
+ // we did not get permission to interact, then
+ // do something reasonable instead
+ }
+}
+//! [8]
+
+
+//! [9]
+appname -session id
+//! [9]
+
+
+//! [10]
+foreach (const QString &command, mySession.restartCommand())
+ do_something(command);
+//! [10]
+
+
+//! [11]
+foreach (const QString &command, mySession.discardCommand())
+ do_something(command);
+//! [11]
+
+
+//! [12]
+QWidget *widget = qApp->widgetAt(x, y);
+if (widget)
+ widget = widget->window();
+//! [12]
+
+
+//! [13]
+QWidget *widget = qApp->widgetAt(point);
+if (widget)
+ widget = widget->window();
+//! [13]
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp
new file mode 100644
index 0000000000..1f7517b613
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QFormLayout *formLayout = new QFormLayout;
+formLayout->addRow(tr("&Name:"), nameLineEdit);
+formLayout->addRow(tr("&Email:"), emailLineEdit);
+formLayout->addRow(tr("&Age:"), ageSpinBox);
+setLayout(formLayout);
+//! [0]
+
+
+//! [1]
+nameLabel = new QLabel(tr("&Name:"));
+nameLabel->setBuddy(nameLineEdit);
+
+emailLabel = new QLabel(tr("&Name:"));
+emailLabel->setBuddy(emailLineEdit);
+
+ageLabel = new QLabel(tr("&Name:"));
+ageLabel->setBuddy(ageSpinBox);
+
+QGridLayout *gridLayout = new QGridLayout;
+gridLayout->addWidget(nameLabel, 0, 0);
+gridLayout->addWidget(nameLineEdit, 0, 1);
+gridLayout->addWidget(emailLabel, 1, 0);
+gridLayout->addWidget(emailLineEdit, 1, 1);
+gridLayout->addWidget(ageLabel, 2, 0);
+gridLayout->addWidget(ageSpinBox, 2, 1);
+setLayout(gridLayout);
+//! [1]
+
+
+//! [2]
+formLayout->setRowWrapPolicy(QFormLayout::DontWrapRows);
+formLayout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
+formLayout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
+formLayout->setLabelAlignment(Qt::AlignLeft);
+//! [2]
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp
new file mode 100644
index 0000000000..cabd753b5d
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+static void paintLayout(QPainter *painter, QLayoutItem *item)
+{
+ QLayout *layout = item->layout();
+ if (layout) {
+ for (int i = 0; i < layout->count(); ++i)
+ paintLayout(painter, layout->itemAt(i));
+ }
+ painter->drawRect(item->geometry());
+}
+
+void MyWidget::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ if (layout())
+ paintLayout(&painter, layout());
+}
+//! [0]
+
+
+//! [1]
+QLayoutItem *child;
+while ((child = layout->takeAt(0)) != 0) {
+ ...
+ delete child;
+}
+//! [1]
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp
new file mode 100644
index 0000000000..378253c605
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+int MyLayout::heightForWidth(int w) const
+{
+ if (cache_dirty || cached_width != w) {
+ // not all C++ compilers support "mutable"
+ MyLayout *that = (MyLayout*)this;
+ int h = calculateHeightForWidth(w);
+ that->cached_hfw = h;
+ return h;
+ }
+ return cached_hfw;
+}
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qshortcut.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qshortcut.cpp
new file mode 100644
index 0000000000..31e3e3291e
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qshortcut.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+shortcut = new QShortcut(QKeySequence(tr("Ctrl+O", "File|Open")),
+ parent);
+//! [0]
+
+
+//! [1]
+setKey(0); // no signal emitted
+setKey(QKeySequence()); // no signal emitted
+setKey(0x3b1); // Greek letter alpha
+setKey(Qt::Key_D); // 'd', e.g. to delete
+setKey('q'); // 'q', e.g. to quit
+setKey(Qt::CTRL + Qt::Key_P); // Ctrl+P, e.g. to print document
+setKey("Ctrl+P"); // Ctrl+P, e.g. to print document
+//! [1]
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp
new file mode 100644
index 0000000000..3e94519073
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+w->setWindowState(w->windowState() ^ Qt::WindowFullScreen);
+//! [0]
+
+
+//! [1]
+w->setWindowState(w->windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
+//! [1]
+
+
+//! [2]
+width = baseSize().width() + i * sizeIncrement().width();
+height = baseSize().height() + j * sizeIncrement().height();
+//! [2]
+
+
+//! [3]
+aWidget->window()->setWindowTitle("New Window Title");
+//! [3]
+
+
+//! [4]
+QFont font("Helvetica", 12, QFont::Bold);
+setFont(font);
+//! [4]
+
+
+//! [5]
+QFont font;
+font.setBold(false);
+setFont(font);
+//! [5]
+
+
+//! [6]
+setCursor(Qt::IBeamCursor);
+//! [6]
+
+
+//! [7]
+QPixmap pixmap(widget->size());
+widget->render(&pixmap);
+//! [7]
+
+
+//! [8]
+QPainter painter(this);
+...
+painter.end();
+myWidget->render(this);
+//! [8]
+
+
+//! [9]
+setTabOrder(a, b); // a to b
+setTabOrder(b, c); // a to b to c
+setTabOrder(c, d); // a to b to c to d
+//! [9]
+
+
+//! [10]
+// WRONG
+setTabOrder(c, d); // c to d
+setTabOrder(a, b); // a to b AND c to d
+setTabOrder(b, c); // a to b to c, but not c to d
+//! [10]
+
+
+//! [11]
+void MyWidget::closeEvent(QCloseEvent *event)
+{
+ QSettings settings("MyCompany", "MyApp");
+ settings.setValue("geometry", saveGeometry());
+ QWidget::closeEvent(event);
+}
+//! [11]
+
+
+//! [12]
+QSettings settings("MyCompany", "MyApp");
+myWidget->restoreGeometry(settings.value("myWidget/geometry").toByteArray());
+//! [12]
+
+
+//! [13]
+setUpdatesEnabled(false);
+bigVisualChanges();
+setUpdatesEnabled(true);
+//! [13]
+
+
+//! [14]
+...
+extern void qt_x11_set_global_double_buffer(bool);
+qt_x11_set_global_double_buffer(false);
+...
+//! [14]
diff --git a/src/widgets/doc/snippets/code/src_gui_painting_qdrawutil.cpp b/src/widgets/doc/snippets/code/src_gui_painting_qdrawutil.cpp
new file mode 100644
index 0000000000..0f70fce8ef
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_painting_qdrawutil.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QFrame frame:
+frame.setFrameStyle(QFrame::HLine | QFrame::Sunken);
+//! [0]
+
+
+//! [1]
+QFrame frame:
+frame.setFrameStyle(QFrame::Box | QFrame::Raised);
+//! [1]
+
+
+//! [2]
+QFrame frame:
+frame.setFrameStyle( QFrame::Panel | QFrame::Sunken);
+//! [2]
+
+
+//! [3]
+QFrame frame:
+frame.setFrameStyle(QFrame::WinPanel | QFrame::Raised);
+//! [3]
+
+
+//! [4]
+QFrame frame:
+frame.setFrameStyle(QFrame::Box | QFrame::Plain);
+//! [4]
+
+
+//! [5]
+QFrame frame:
+frame.setFrameStyle(QFrame::HLine | QFrame::Sunken);
+//! [5]
+
+
+//! [6]
+QFrame frame:
+frame.setFrameStyle(QFrame::Box | QFrame::Raised);
+//! [6]
+
+
+//! [7]
+QFrame frame:
+frame.setFrameStyle( QFrame::Panel | QFrame::Sunken);
+//! [7]
+
+
+//! [8]
+QFrame frame:
+frame.setFrameStyle(QFrame::WinPanel | QFrame::Raised);
+//! [8]
+
+
+//! [9]
+QFrame frame:
+frame.setFrameStyle(QFrame::Box | QFrame::Plain);
+//! [9]
diff --git a/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp b/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp
new file mode 100644
index 0000000000..ae9ff131aa
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+class MyProxyStyle : public QProxyStyle
+{
+public:
+
+ int styleHint(StyleHint hint, const QStyleOption *option = 0,
+ const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
+ {
+ if (hint == QStyle::SH_UnderlineShortcut)
+ return 1;
+ return QProxyStyle::styleHint(hint, option, widget, returnData);
+ }
+};
+
+//! [0]
+
+//! [1]
+#include "textedit.h"
+#include <QApplication>
+#include <QProxyStyle>
+
+class MyProxyStyle : public QProxyStyle
+{
+ public:
+ int styleHint(StyleHint hint, const QStyleOption *option = 0,
+ const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
+ {
+ if (hint == QStyle::SH_UnderlineShortcut)
+ return 0;
+ return QProxyStyle::styleHint(hint, option, widget, returnData);
+ }
+};
+
+int main(int argc, char **argv)
+{
+ Q_INIT_RESOURCE(textedit);
+
+ QApplication a(argc, argv);
+ a.setStyle(new MyProxyStyle);
+ TextEdit mw;
+ mw.resize(700, 800);
+ mw.show();
+ //...
+}
+//! [1]
diff --git a/src/widgets/doc/snippets/code/src_gui_styles_qstyle.cpp b/src/widgets/doc/snippets/code/src_gui_styles_qstyle.cpp
new file mode 100644
index 0000000000..ed4ebb60a4
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_styles_qstyle.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+./myapplication -style motif
+//! [0]
+
+
+//! [1]
+./myapplication -style custom
+//! [1]
diff --git a/src/widgets/doc/snippets/code/src_gui_styles_qstyleoption.cpp b/src/widgets/doc/snippets/code/src_gui_styles_qstyleoption.cpp
new file mode 100644
index 0000000000..962212388f
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_styles_qstyleoption.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+int MyStyle::styleHint(StyleHint stylehint, const QStyleOption *opt,
+ const QWidget *widget, QStyleHintReturn* returnData) const;
+{
+ if (stylehint == SH_RubberBand_Mask) {
+ const QStyleHintReturnMask *maskReturn =
+ qstyleoption_cast<const QStyleHintReturnMask *>(hint);
+ if (maskReturn) {
+ ...
+ }
+ }
+ ...
+}
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp b/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp
new file mode 100644
index 0000000000..2e8eac17ad
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QStringList wordList;
+wordList << "alpha" << "omega" << "omicron" << "zeta";
+
+QLineEdit *lineEdit = new QLineEdit(this);
+
+QCompleter *completer = new QCompleter(wordList, this);
+completer->setCaseSensitivity(Qt::CaseInsensitive);
+lineEdit->setCompleter(completer);
+//! [0]
+
+
+//! [1]
+QCompleter *completer = new QCompleter(this);
+completer->setModel(new QDirModel(completer));
+lineEdit->setCompleter(completer);
+//! [1]
+
+
+//! [2]
+for (int i = 0; completer->setCurrentRow(i); i++)
+ qDebug() << completer->currentCompletion() << " is match number " << i;
+//! [2]
diff --git a/src/widgets/doc/snippets/code/src_gui_util_qundostack.cpp b/src/widgets/doc/snippets/code/src_gui_util_qundostack.cpp
new file mode 100644
index 0000000000..7e06a8ef6f
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_util_qundostack.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+class AppendText : public QUndoCommand
+{
+public:
+ AppendText(QString *doc, const QString &text)
+ : m_document(doc), m_text(text) { setText("append text"); }
+ virtual void undo()
+ { m_document->chop(m_text.length()); }
+ virtual void redo()
+ { m_document->append(m_text); }
+private:
+ QString *m_document;
+ QString m_text;
+};
+//! [0]
+
+
+//! [1]
+MyCommand *command1 = new MyCommand();
+stack->push(command1);
+MyCommand *command2 = new MyCommand();
+stack->push(command2);
+
+stack->undo();
+
+MyCommand *command3 = new MyCommand();
+stack->push(command3); // command2 gets deleted
+//! [1]
+
+
+//! [2]
+QUndoCommand *insertRed = new QUndoCommand(); // an empty command
+insertRed->setText("insert red text");
+
+new InsertText(document, idx, text, insertRed); // becomes child of insertRed
+new SetColor(document, idx, text.length(), Qt::red, insertRed);
+
+stack.push(insertRed);
+//! [2]
+
+
+//! [3]
+bool AppendText::mergeWith(const QUndoCommand *other)
+{
+ if (other->id() != id()) // make sure other is also an AppendText command
+ return false;
+ m_text += static_cast<const AppendText*>(other)->m_text;
+ return true;
+}
+//! [3]
+
+
+//! [4]
+stack.beginMacro("insert red text");
+stack.push(new InsertText(document, idx, text));
+stack.push(new SetColor(document, idx, text.length(), Qt::red));
+stack.endMacro(); // indexChanged() is emitted
+//! [4]
+
+
+//! [5]
+QUndoCommand *insertRed = new QUndoCommand(); // an empty command
+insertRed->setText("insert red text");
+
+new InsertText(document, idx, text, insertRed); // becomes child of insertRed
+new SetColor(document, idx, text.length(), Qt::red, insertRed);
+
+stack.push(insertRed);
+//! [5]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qabstractbutton.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qabstractbutton.cpp
new file mode 100644
index 0000000000..948ed0e958
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qabstractbutton.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QPushButton *button = new QPushButton(tr("Ro&ck && Roll"), this);
+//! [0]
+
+
+//! [1]
+button->setIcon(QIcon(":/images/print.png"));
+button->setShortcut(tr("Alt+F7"));
+//! [1]
+
+
+//! [2]
+void MyWidget::reactToToggle(bool checked)
+{
+ if (checked) {
+ // Examine the new button states.
+ ...
+ }
+}
+//! [2]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qabstractspinbox.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qabstractspinbox.cpp
new file mode 100644
index 0000000000..66f3449760
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qabstractspinbox.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QSpinBox *spinBox = new QSpinBox(this);
+spinBox->setRange(0, 100);
+spinBox->setWrapping(true);
+spinBox->setValue(100);
+spinBox->stepBy(1);
+// value is 0
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qcalendarwidget.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qcalendarwidget.cpp
new file mode 100644
index 0000000000..6f99bdf0ce
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qcalendarwidget.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QCalendarWidget *calendar;
+calendar->setGridVisible(true);
+//! [0]
+
+
+//! [1]
+QCalendarWidget *calendar;
+calendar->setGridVisible(true);
+calendar->setMinimumDate(QDate(2006, 6, 19));
+//! [1]
+
+
+//! [2]
+QCalendarWidget *calendar;
+calendar->setGridVisible(true);
+calendar->setMaximumDate(QDate(2006, 7, 3));
+//! [2]
+
+
+//! [3]
+QCalendarWidget *calendar;
+
+calendar->setDateRange(min, max);
+//! [3]
+
+
+//! [4]
+QCalendarWidget *calendar;
+
+calendar->setMinimumDate(min);
+calendar->setMaximumDate(max);
+//! [4]
+
+
+//! [5]
+QCalendarWidget *calendar;
+calendar->setGridVisible(true);
+//! [5]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qcheckbox.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qcheckbox.cpp
new file mode 100644
index 0000000000..71ee59bc85
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qcheckbox.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QCheckBox *checkbox = new QCheckBox("C&ase sensitive", this);
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qdatetimeedit.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qdatetimeedit.cpp
new file mode 100644
index 0000000000..5eb9e739ea
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qdatetimeedit.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QDateTimeEdit *dateEdit = new QDateTimeEdit(QDate::currentDate());
+dateEdit->setMinimumDate(QDate::currentDate().addDays(-365));
+dateEdit->setMaximumDate(QDate::currentDate().addDays(365));
+dateEdit->setDisplayFormat("yyyy.MM.dd");
+//! [0]
+
+
+//! [1]
+setDateTimeRange(min, max);
+//! [1]
+
+
+//! [2]
+setMinimumDateTime(min);
+setMaximumDateTime(max);
+//! [2]
+
+
+//! [3]
+setDateRange(min, max);
+//! [3]
+
+
+//! [4]
+setMinimumDate(min);
+setMaximumDate(max);
+//! [4]
+
+
+//! [5]
+setTimeRange(min, max);
+//! [5]
+
+
+//! [6]
+setMinimumTime(min);
+setMaximumTime(max);
+//! [6]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qdockwidget.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qdockwidget.cpp
new file mode 100644
index 0000000000..690e3d5f33
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qdockwidget.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QDockWidget *dockWidget = qobject_cast<QDockWidget*>(parentWidget());
+if (dockWidget->features() & QDockWidget::DockWidgetVerticalTitleBar) {
+ // I need to be vertical
+} else {
+ // I need to be horizontal
+}
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qframe.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qframe.cpp
new file mode 100644
index 0000000000..6e3afcd8cf
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qframe.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QLabel label(...);
+label.setFrameStyle(QFrame::Panel | QFrame::Raised);
+label.setLineWidth(2);
+
+QProgressBar pbar(...);
+label.setFrameStyle(QFrame::NoFrame);
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qgroupbox.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qgroupbox.cpp
new file mode 100644
index 0000000000..fc0339f690
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qgroupbox.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+g->setTitle("&User information");
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qlabel.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qlabel.cpp
new file mode 100644
index 0000000000..83b02a2f22
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qlabel.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QLabel *label = new QLabel(this);
+label->setFrameStyle(QFrame::Panel | QFrame::Sunken);
+label->setText("first line\nsecond line");
+label->setAlignment(Qt::AlignBottom | Qt::AlignRight);
+//! [0]
+
+
+//! [1]
+QLineEdit* phoneEdit = new QLineEdit(this);
+QLabel* phoneLabel = new QLabel("&Phone:", this);
+phoneLabel->setBuddy(phoneEdit);
+//! [1]
+
+
+//! [2]
+QLineEdit *nameEd = new QLineEdit(this);
+QLabel *nameLb = new QLabel("&Name:", this);
+nameLb->setBuddy(nameEd);
+QLineEdit *phoneEd = new QLineEdit(this);
+QLabel *phoneLb = new QLabel("&Phone:", this);
+phoneLb->setBuddy(phoneEd);
+// (layout setup not shown)
+//! [2]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qlineedit.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qlineedit.cpp
new file mode 100644
index 0000000000..12ed38ad65
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qlineedit.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+void LineEdit::contextMenuEvent(QContextMenuEvent *event)
+{
+ QMenu *menu = createStandardContextMenu();
+ menu->addAction(tr("My Menu Item"));
+ //...
+ menu->exec(event->globalPos());
+ delete menu;
+}
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qmainwindow.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qmainwindow.cpp
new file mode 100644
index 0000000000..3558922ec9
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qmainwindow.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+void MyMainWindow::closeEvent(QCloseEvent *event)
+{
+ QSettings settings("MyCompany", "MyApp");
+ settings.setValue("geometry", saveGeometry());
+ settings.setValue("windowState", saveState());
+ QMainWindow::closeEvent(event);
+}
+//! [0]
+
+
+//! [1]
+void MainWindow::readSettings()
+{
+ QSettings settings("MyCompany", "MyApp");
+ restoreGeometry(settings.value("myWidget/geometry").toByteArray());
+ restoreState(settings.value("myWidget/windowState").toByteArray());
+}
+//! [1]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qmenu.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qmenu.cpp
new file mode 100644
index 0000000000..5799248bf4
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qmenu.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+exec(QCursor::pos());
+//! [0]
+
+
+//! [1]
+exec(somewidget.mapToGlobal(QPoint(0,0)));
+//! [1]
+
+
+//! [2]
+exec(e->globalPos());
+//! [2]
+
+
+//! [3]
+exec(QCursor::pos());
+//! [3]
+
+
+//! [4]
+exec(somewidget.mapToGlobal(QPoint(0, 0)));
+//! [4]
+
+
+//! [5]
+exec(e->globalPos());
+//! [5]
+
+
+//! [6]
+QMenu menu;
+QAction *at = actions[0]; // Assumes actions is not empty
+foreach (QAction *a, actions)
+ menu.addAction(a);
+menu.exec(pos, at);
+//! [6]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp
new file mode 100644
index 0000000000..412bc2d5eb
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+menubar->addMenu(fileMenu);
+//! [0]
+
+
+//! [1]
+QMenuBar *menuBar = new QMenuBar(0);
+//! [1]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qplaintextedit.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qplaintextedit.cpp
new file mode 100644
index 0000000000..931c6c69a6
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qplaintextedit.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+void MyQPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
+{
+ QMenu *menu = createStandardContextMenu();
+ menu->addAction(tr("My Menu Item"));
+ //...
+ menu->exec(event->globalPos());
+ delete menu;
+}
+//! [0]
+
+
+//! [1]
+edit->textCursor().insertText(text);
+//! [1]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qpushbutton.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qpushbutton.cpp
new file mode 100644
index 0000000000..e0ae945620
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qpushbutton.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QPushButton *button = new QPushButton("&Download", this);
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qradiobutton.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qradiobutton.cpp
new file mode 100644
index 0000000000..a93809fa5d
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qradiobutton.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QRadioButton *button = new QRadioButton("Search from the &cursor", this);
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qrubberband.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qrubberband.cpp
new file mode 100644
index 0000000000..b8d6a14d1c
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qrubberband.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+void Widget::mousePressEvent(QMouseEvent *event)
+{
+ origin = event->pos();
+ if (!rubberBand)
+ rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
+ rubberBand->setGeometry(QRect(origin, QSize()));
+ rubberBand->show();
+}
+
+void Widget::mouseMoveEvent(QMouseEvent *event)
+{
+ rubberBand->setGeometry(QRect(origin, event->pos()).normalized());
+}
+
+void Widget::mouseReleaseEvent(QMouseEvent *event)
+{
+ rubberBand->hide();
+ // determine selection, for example using QRect::intersects()
+ // and QRect::contains().
+}
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qscrollarea.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qscrollarea.cpp
new file mode 100644
index 0000000000..9c90a0c53d
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qscrollarea.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QLabel *imageLabel = new QLabel;
+QImage image("happyguy.png");
+imageLabel->setPixmap(QPixmap::fromImage(image));
+
+scrollArea = new QScrollArea;
+scrollArea->setBackgroundRole(QPalette::Dark);
+scrollArea->setWidget(imageLabel);
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qspinbox.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qspinbox.cpp
new file mode 100644
index 0000000000..fc1f5b7e47
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qspinbox.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+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/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp
new file mode 100644
index 0000000000..48f1051e2c
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QPixmap pixmap(":/splash.png");
+QSplashScreen *splash = new QSplashScreen(pixmap);
+splash->show();
+
+... // Loading some items
+splash->showMessage("Loaded modules");
+
+qApp->processEvents();
+
+... // Establishing connections
+splash->showMessage("Established connections");
+
+qApp->processEvents();
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qsplitter.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qsplitter.cpp
new file mode 100644
index 0000000000..18007a4cdf
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qsplitter.cpp
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QWidget *widget = splitter->widget(index);
+QSizePolicy policy = widget->sizePolicy();
+policy.setHorizontalStretch(stretch);
+policy.setVerticalStretch(stretch);
+widget->setSizePolicy(policy);
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qstatusbar.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qstatusbar.cpp
new file mode 100644
index 0000000000..6ea752b237
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qstatusbar.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+statusBar()->addWidget(new MyReadWriteIndication);
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qtextbrowser.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qtextbrowser.cpp
new file mode 100644
index 0000000000..ed30c2d80a
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qtextbrowser.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+backaction.setToolTip(browser.historyTitle(-1));
+forwardaction.setToolTip(browser.historyTitle(+1));
+//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qtextedit.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qtextedit.cpp
new file mode 100644
index 0000000000..cd1ae62c84
--- /dev/null
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qtextedit.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+void MyTextEdit::contextMenuEvent(QContextMenuEvent *event)
+{
+ QMenu *menu = createStandardContextMenu();
+ menu->addAction(tr("My Menu Item"));
+ //...
+ menu->exec(event->globalPos());
+ delete menu;
+}
+//! [0]
+
+
+//! [1]
+edit->textCursor().insertText(text);
+//! [1]
+
+
+//! [2]
+edit->textCursor().insertHtml(fragment);
+//! [2]
diff --git a/src/widgets/doc/snippets/customstyle/customstyle.cpp b/src/widgets/doc/snippets/customstyle/customstyle.cpp
new file mode 100644
index 0000000000..2e0843c49c
--- /dev/null
+++ b/src/widgets/doc/snippets/customstyle/customstyle.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "customstyle.h"
+
+CustomStyle::CustomStyle()
+{
+//! [0]
+ QSpinBox *spinBox = qobject_cast<QSpinBox *>(widget);
+ if (spinBox) {
+//! [0] //! [1]
+ }
+//! [1]
+}
+
+//! [2]
+void CustomStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const
+{
+ if (element == PE_IndicatorSpinUp || element == PE_IndicatorSpinDown) {
+ QPolygon points(3);
+ int x = option->rect.x();
+ int y = option->rect.y();
+ int w = option->rect.width() / 2;
+ int h = option->rect.height() / 2;
+ x += (option->rect.width() - w) / 2;
+ y += (option->rect.height() - h) / 2;
+
+ if (element == PE_IndicatorSpinUp) {
+ points[0] = QPoint(x, y + h);
+ points[1] = QPoint(x + w, y + h);
+ points[2] = QPoint(x + w / 2, y);
+ } else { // PE_SpinBoxDown
+ points[0] = QPoint(x, y);
+ points[1] = QPoint(x + w, y);
+ points[2] = QPoint(x + w / 2, y + h);
+ }
+
+ if (option->state & State_Enabled) {
+ painter->setPen(option->palette.mid().color());
+ painter->setBrush(option->palette.buttonText());
+ } else {
+ painter->setPen(option->palette.buttonText().color());
+ painter->setBrush(option->palette.mid());
+ }
+ painter->drawPolygon(points);
+ } else {
+ QWindowsStyle::drawPrimitive(element, option, painter, widget);
+//! [2] //! [3]
+ }
+//! [3] //! [4]
+}
+//! [4]
diff --git a/src/widgets/doc/snippets/customstyle/customstyle.h b/src/widgets/doc/snippets/customstyle/customstyle.h
new file mode 100644
index 0000000000..437994d2e2
--- /dev/null
+++ b/src/widgets/doc/snippets/customstyle/customstyle.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CUSTOMSTYLE_H
+#define CUSTOMSTYLE_H
+
+#include <QWindowsStyle>
+
+//! [0]
+class CustomStyle : public QWindowsStyle
+{
+ Q_OBJECT
+
+public:
+ CustomStyle()
+ ~CustomStyle() {}
+
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+};
+//! [0]
+
+#endif
diff --git a/src/widgets/doc/snippets/customstyle/customstyle.pro b/src/widgets/doc/snippets/customstyle/customstyle.pro
new file mode 100644
index 0000000000..af0ee4e141
--- /dev/null
+++ b/src/widgets/doc/snippets/customstyle/customstyle.pro
@@ -0,0 +1,2 @@
+HEADERS += customstyle.h
+SOURCES += customstyle.cpp main.cpp
diff --git a/src/widgets/doc/snippets/customstyle/main.cpp b/src/widgets/doc/snippets/customstyle/main.cpp
new file mode 100644
index 0000000000..b3bea3bd7b
--- /dev/null
+++ b/src/widgets/doc/snippets/customstyle/main.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [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/src/widgets/doc/snippets/customviewstyle.cpp b/src/widgets/doc/snippets/customviewstyle.cpp
new file mode 100644
index 0000000000..55a766d17d
--- /dev/null
+++ b/src/widgets/doc/snippets/customviewstyle.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <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/src/widgets/doc/snippets/dialogs/dialogs.cpp b/src/widgets/doc/snippets/dialogs/dialogs.cpp
new file mode 100644
index 0000000000..78916f862c
--- /dev/null
+++ b/src/widgets/doc/snippets/dialogs/dialogs.cpp
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+typedef QDialog WordCountDialog;
+typedef QDialog FindDialog;
+
+#define this 0
+#define setWordCount(x) isVisible()
+
+QString tr(const char *text)
+{
+ return QApplication::translate(text, text);
+}
+
+class EditorWindow : public QMainWindow
+{
+public:
+ void find();
+ void countWords();
+
+private:
+ FindDialog *findDialog;
+};
+
+//! [0]
+void EditorWindow::find()
+{
+ if (!findDialog) {
+ findDialog = new FindDialog(this);
+ connect(findDialog, SIGNAL(findNext()), this, SLOT(findNext()));
+ }
+
+ findDialog->show();
+ findDialog->raise();
+ findDialog->activateWindow();
+}
+//! [0]
+
+//! [1]
+void EditorWindow::countWords()
+{
+ WordCountDialog dialog(this);
+ dialog.setWordCount(document().wordCount());
+ dialog.exec();
+}
+//! [1]
+
+inline bool boo()
+{
+ QMessageBox::information(this, "Application name",
+ "Unable to find the user preferences file.\n"
+ "The factory default will be used instead.");
+
+ QString filename;
+ if (QFile::exists(filename) &&
+ QMessageBox::question(
+ this,
+ tr("Overwrite File? -- Application Name"),
+ tr("A file called %1 already exists."
+ "Do you want to overwrite it?")
+ .arg(filename),
+ tr("&Yes"), tr("&No"),
+ QString(), 0, 1))
+ return false;
+
+ switch(QMessageBox::warning(this, "Application name",
+ "Could not connect to the <mumble> server.\n"
+ "This program can't function correctly "
+ "without the server.\n\n",
+ "Retry",
+ "Quit", 0, 0, 1)) {
+ case 0: // The user clicked the Retry again button or pressed Enter
+ // try again
+ break;
+ case 1: // The user clicked the Quit or pressed Escape
+ // exit
+ break;
+ }
+
+ switch(QMessageBox::information(this, "Application name here",
+ "The document contains unsaved changes\n"
+ "Do you want to save the changes before exiting?",
+ "&Save", "&Discard", "Cancel",
+ 0, // Enter == button 0
+ 2)) { // Escape == button 2
+ case 0: // Save clicked or Alt+S pressed or Enter pressed.
+ // save
+ break;
+ case 1: // Discard clicked or Alt+D pressed
+ // don't save but exit
+ break;
+ case 2: // Cancel clicked or Escape pressed
+ // don't exit
+ break;
+ }
+
+ switch(QMessageBox::warning(this, "Application name here",
+ "Could not save the user preferences,\n"
+ "because the disk is full. You can delete\n"
+ "some files and press Retry, or you can\n"
+ "abort the Save Preferences operation.",
+ QMessageBox::Retry | QMessageBox::Default,
+ QMessageBox::Abort | QMessageBox::Escape)) {
+ case QMessageBox::Retry: // Retry clicked or Enter pressed
+ // try again
+ break;
+ case QMessageBox::Abort: // Abort clicked or Escape pressed
+ // abort
+ break;
+ }
+
+ QString errorDetails;
+ QMessageBox::critical(0, "Application name here",
+ QString("An internal error occurred. Please ") +
+ "call technical support at 1234-56789 and report\n"+
+ "these numbers:\n\n" + errorDetails +
+ "\n\nApplication will now exit.");
+
+ QMessageBox::about(this, "About <Application>",
+ "<Application> is a <one-paragraph blurb>\n\n"
+ "Copyright 1991-2003 Such-and-such. "
+ "<License words here.>\n\n"
+ "For technical support, call 1234-56789 or see\n"
+ "http://www.such-and-such.com/Application/\n");
+
+ {
+ // saving the file
+ QMessageBox mb("Application name here",
+ "Saving the file will overwrite the original file on the disk.\n"
+ "Do you really want to save?",
+ QMessageBox::Information,
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::No,
+ QMessageBox::Cancel | QMessageBox::Escape);
+ mb.setButtonText(QMessageBox::Yes, "Save");
+ mb.setButtonText(QMessageBox::No, "Discard");
+ switch(mb.exec()) {
+ case QMessageBox::Yes:
+ // save and exit
+ break;
+ case QMessageBox::No:
+ // exit without saving
+ break;
+ case QMessageBox::Cancel:
+ // don't save and don't exit
+ break;
+ }
+ }
+
+ {
+ // hardware failure
+//! [2]
+ QMessageBox mb("Application Name",
+ "Hardware failure.\n\nDisk error detected\nDo you want to stop?",
+ QMessageBox::Question,
+ QMessageBox::Yes | QMessageBox::Default,
+ QMessageBox::No | QMessageBox::Escape,
+ QMessageBox::NoButton);
+ if (mb.exec() == QMessageBox::No) {
+ // try again
+//! [2]
+ }
+ }
+}
+
+inline void moo()
+{
+ int numFiles;
+//! [3]
+ QProgressDialog progress("Copying files...", "Abort Copy", 0, numFiles, this);
+ progress.setWindowModality(Qt::WindowModal);
+
+ for (int i = 0; i < numFiles; i++) {
+ progress.setValue(i);
+
+ if (progress.wasCanceled())
+ break;
+ //... copy one file
+ }
+ progress.setValue(numFiles);
+//! [3]
+}
+
+class Operation : public QObject
+{
+public:
+ Operation(QObject *parent);
+ void perform();
+ void cancel();
+
+private:
+ int steps;
+ QProgressDialog *pd;
+ QTimer *t;
+};
+
+//! [4]
+// Operation constructor
+Operation::Operation(QObject *parent)
+ : QObject(parent), steps(0)
+{
+ pd = new QProgressDialog("Operation in progress.", "Cancel", 0, 100);
+ connect(pd, SIGNAL(canceled()), this, SLOT(cancel()));
+ t = new QTimer(this);
+ connect(t, SIGNAL(timeout()), this, SLOT(perform()));
+ t->start(0);
+}
+//! [4] //! [5]
+
+void Operation::perform()
+{
+ pd->setValue(steps);
+ //... perform one percent of the operation
+ steps++;
+ if (steps > pd->maximum())
+ t->stop();
+}
+//! [5] //! [6]
+
+void Operation::cancel()
+{
+ t->stop();
+ //... cleanup
+}
+//! [6]
+
+int main()
+{
+}
diff --git a/src/widgets/doc/snippets/dockwidgets/mainwindow.cpp b/src/widgets/doc/snippets/dockwidgets/mainwindow.cpp
new file mode 100644
index 0000000000..882af70b64
--- /dev/null
+++ b/src/widgets/doc/snippets/dockwidgets/mainwindow.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <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/src/widgets/doc/snippets/filedialogurls.cpp b/src/widgets/doc/snippets/filedialogurls.cpp
new file mode 100644
index 0000000000..b1e41cbcad
--- /dev/null
+++ b/src/widgets/doc/snippets/filedialogurls.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/graphicssceneadditemsnippet.cpp b/src/widgets/doc/snippets/graphicssceneadditemsnippet.cpp
new file mode 100644
index 0000000000..1130a59217
--- /dev/null
+++ b/src/widgets/doc/snippets/graphicssceneadditemsnippet.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/itemselection/itemselection.pro b/src/widgets/doc/snippets/itemselection/itemselection.pro
new file mode 100644
index 0000000000..b1126bfe73
--- /dev/null
+++ b/src/widgets/doc/snippets/itemselection/itemselection.pro
@@ -0,0 +1,3 @@
+HEADERS = model.h
+SOURCES = main.cpp \
+ model.cpp
diff --git a/src/widgets/doc/snippets/itemselection/main.cpp b/src/widgets/doc/snippets/itemselection/main.cpp
new file mode 100644
index 0000000000..f39fb68b32
--- /dev/null
+++ b/src/widgets/doc/snippets/itemselection/main.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ 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/src/widgets/doc/snippets/itemselection/model.cpp b/src/widgets/doc/snippets/itemselection/model.cpp
new file mode 100644
index 0000000000..6c9c5bad82
--- /dev/null
+++ b/src/widgets/doc/snippets/itemselection/model.cpp
@@ -0,0 +1,238 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ 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/src/widgets/doc/snippets/itemselection/model.h b/src/widgets/doc/snippets/itemselection/model.h
new file mode 100644
index 0000000000..ef63e45ce0
--- /dev/null
+++ b/src/widgets/doc/snippets/itemselection/model.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/javastyle.cpp b/src/widgets/doc/snippets/javastyle.cpp
new file mode 100644
index 0000000000..a00df57e82
--- /dev/null
+++ b/src/widgets/doc/snippets/javastyle.cpp
@@ -0,0 +1,2745 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <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/src/widgets/doc/snippets/layouts/layouts.cpp b/src/widgets/doc/snippets/layouts/layouts.cpp
new file mode 100644
index 0000000000..49c341c048
--- /dev/null
+++ b/src/widgets/doc/snippets/layouts/layouts.cpp
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ {
+//! [0]
+ QWidget *window = new QWidget;
+//! [0] //! [1]
+ QPushButton *button1 = new QPushButton("One");
+//! [1] //! [2]
+ QPushButton *button2 = new QPushButton("Two");
+ QPushButton *button3 = new QPushButton("Three");
+ QPushButton *button4 = new QPushButton("Four");
+ QPushButton *button5 = new QPushButton("Five");
+//! [2]
+
+//! [3]
+ QHBoxLayout *layout = new QHBoxLayout;
+//! [3] //! [4]
+ layout->addWidget(button1);
+ layout->addWidget(button2);
+ layout->addWidget(button3);
+ layout->addWidget(button4);
+ layout->addWidget(button5);
+
+ window->setLayout(layout);
+//! [4]
+ window->setWindowTitle("QHBoxLayout");
+//! [5]
+ window->show();
+//! [5]
+ }
+
+ {
+//! [6]
+ QWidget *window = new QWidget;
+//! [6] //! [7]
+ QPushButton *button1 = new QPushButton("One");
+//! [7] //! [8]
+ QPushButton *button2 = new QPushButton("Two");
+ QPushButton *button3 = new QPushButton("Three");
+ QPushButton *button4 = new QPushButton("Four");
+ QPushButton *button5 = new QPushButton("Five");
+//! [8]
+
+//! [9]
+ QVBoxLayout *layout = new QVBoxLayout;
+//! [9] //! [10]
+ layout->addWidget(button1);
+ layout->addWidget(button2);
+ layout->addWidget(button3);
+ layout->addWidget(button4);
+ layout->addWidget(button5);
+
+ window->setLayout(layout);
+//! [10]
+ window->setWindowTitle("QVBoxLayout");
+//! [11]
+ window->show();
+//! [11]
+ }
+
+ {
+//! [12]
+ QWidget *window = new QWidget;
+//! [12] //! [13]
+ QPushButton *button1 = new QPushButton("One");
+//! [13] //! [14]
+ QPushButton *button2 = new QPushButton("Two");
+ QPushButton *button3 = new QPushButton("Three");
+ QPushButton *button4 = new QPushButton("Four");
+ QPushButton *button5 = new QPushButton("Five");
+//! [14]
+
+//! [15]
+ QGridLayout *layout = new QGridLayout;
+//! [15] //! [16]
+ layout->addWidget(button1, 0, 0);
+ layout->addWidget(button2, 0, 1);
+ layout->addWidget(button3, 1, 0, 1, 2);
+ layout->addWidget(button4, 2, 0);
+ layout->addWidget(button5, 2, 1);
+
+ window->setLayout(layout);
+//! [16]
+ window->setWindowTitle("QGridLayout");
+//! [17]
+ window->show();
+//! [17]
+ }
+
+ {
+//! [18]
+ QWidget *window = new QWidget;
+//! [18]
+//! [19]
+ QPushButton *button1 = new QPushButton("One");
+ QLineEdit *lineEdit1 = new QLineEdit();
+//! [19]
+//! [20]
+ QPushButton *button2 = new QPushButton("Two");
+ QLineEdit *lineEdit2 = new QLineEdit();
+ QPushButton *button3 = new QPushButton("Three");
+ QLineEdit *lineEdit3 = new QLineEdit();
+//! [20]
+//! [21]
+ QFormLayout *layout = new QFormLayout;
+//! [21]
+//! [22]
+ layout->addRow(button1, lineEdit1);
+ layout->addRow(button2, lineEdit2);
+ layout->addRow(button3, lineEdit3);
+
+ window->setLayout(layout);
+//! [22]
+ window->setWindowTitle("QFormLayout");
+//! [23]
+ window->show();
+//! [23]
+ }
+
+ return app.exec();
+}
diff --git a/src/widgets/doc/snippets/mainwindowsnippet.cpp b/src/widgets/doc/snippets/mainwindowsnippet.cpp
new file mode 100644
index 0000000000..76305e9ce2
--- /dev/null
+++ b/src/widgets/doc/snippets/mainwindowsnippet.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ createMenus();
+ createToolBars();
+ createDockWidgets();
+ //setMenuWidget(new QPushButton("Hello"));
+}
+
+void MainWindow::createMenus()
+{
+ //setMenuWidget(new QPushButton("Hello"));
+ QMenu *menu = new QMenu("File");
+ menu->addAction("Save &As");
+
+ QMenuBar *bar = new QMenuBar;
+ bar->addMenu(menu);
+
+ setMenuWidget(new QWidget());
+}
+
+void MainWindow::createToolBars()
+{
+ setToolButtonStyle(Qt::ToolButtonTextOnly);
+ QToolBar *t1 = new QToolBar;
+ t1->addAction(new QAction("t1", this));
+
+ QToolBar *t2 = new QToolBar;
+ t2->addAction(new QAction("t2", this));
+
+ addToolBar(Qt::LeftToolBarArea, t1);
+ addToolBar(Qt::LeftToolBarArea, t2);
+}
+
+void MainWindow::createDockWidgets()
+{
+ QWidget *dockWidgetContents = new QWidget;
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(new QPushButton("My Button."));
+ dockWidgetContents->setLayout(layout);
+
+//! [0]
+ QDockWidget *dockWidget = new QDockWidget(tr("Dock Widget"), this);
+ dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea |
+ Qt::RightDockWidgetArea);
+ dockWidget->setWidget(dockWidgetContents);
+ addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
+//! [0]
+}
diff --git a/src/widgets/doc/snippets/mdiareasnippets.cpp b/src/widgets/doc/snippets/mdiareasnippets.cpp
new file mode 100644
index 0000000000..711f25bd83
--- /dev/null
+++ b/src/widgets/doc/snippets/mdiareasnippets.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+void mainWindowExample()
+{
+ QMdiArea *mdiArea = new QMdiArea;
+//! [0]
+ QMainWindow *mainWindow = new QMainWindow;
+ mainWindow->setCentralWidget(mdiArea);
+//! [0]
+
+ mdiArea->addSubWindow(new QPushButton("Push Me Now!"));
+
+ mainWindow->show();
+}
+
+void addingSubWindowsExample()
+{
+ QWidget *internalWidget1 = new QWidget;
+ QWidget *internalWidget2 = new QWidget;
+
+//! [1]
+ QMdiArea mdiArea;
+ QMdiSubWindow *subWindow1 = new QMdiSubWindow;
+ subWindow1->setWidget(internalWidget1);
+ subWindow1->setAttribute(Qt::WA_DeleteOnClose);
+ mdiArea.addSubWindow(subWindow1);
+
+ QMdiSubWindow *subWindow2 =
+ mdiArea.addSubWindow(internalWidget2);
+
+//! [1]
+ subWindow1->show();
+ subWindow2->show();
+
+ mdiArea.show();
+}
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ mainWindowExample();
+ //addingSubWindowsExample();
+
+ QAction *act = new QAction(qApp);
+ act->setShortcut(Qt::ALT + Qt::Key_S);
+ act->setShortcutContext( Qt::ApplicationShortcut );
+ QObject::connect(act, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+
+ QWidget widget5;
+ widget5.show();
+ widget5.addAction(act);
+
+ return app.exec();
+}
+
+
diff --git a/src/widgets/doc/snippets/myscrollarea.cpp b/src/widgets/doc/snippets/myscrollarea.cpp
new file mode 100644
index 0000000000..a6a575f922
--- /dev/null
+++ b/src/widgets/doc/snippets/myscrollarea.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+class MyScrollArea : public QAbstractScrollArea
+{
+public:
+ MyScrollArea(QWidget *w);
+ void setWidget(QWidget *w);
+
+protected:
+ void scrollContentsBy(int dx, int dy);
+ void resizeEvent(QResizeEvent *event);
+
+private:
+ void updateWidgetPosition();
+ void updateArea();
+
+ QWidget *widget;
+};
+
+MyScrollArea::MyScrollArea(QWidget *widget)
+ : QAbstractScrollArea()
+{
+ setWidget(widget);
+}
+
+void MyScrollArea::setWidget(QWidget *w)
+{
+ widget = w;
+ widget->setParent(viewport());
+ if (!widget->testAttribute(Qt::WA_Resized))
+ widget->resize(widget->sizeHint());
+
+ verticalScrollBar()->setValue(0);
+ verticalScrollBar()->setValue(0);
+
+ updateArea();
+}
+
+void MyScrollArea::updateWidgetPosition()
+{
+//! [0]
+ int hvalue = horizontalScrollBar()->value();
+ int vvalue = verticalScrollBar()->value();
+ QPoint topLeft = viewport()->rect().topLeft();
+
+ widget->move(topLeft.x() - hvalue, topLeft.y() - vvalue);
+//! [0]
+}
+
+void MyScrollArea::scrollContentsBy(int /*dx*/, int /*dy*/)
+{
+ updateWidgetPosition();
+}
+
+void MyScrollArea::updateArea()
+{
+//! [1]
+ QSize areaSize = viewport()->size();
+ QSize widgetSize = widget->size();
+
+ verticalScrollBar()->setPageStep(areaSize.height());
+ horizontalScrollBar()->setPageStep(areaSize.width());
+ verticalScrollBar()->setRange(0, widgetSize.height() - areaSize.height());
+ horizontalScrollBar()->setRange(0, widgetSize.width() - areaSize.width());
+ updateWidgetPosition();
+//! [1]
+}
+
+void MyScrollArea::resizeEvent(QResizeEvent *event)
+{
+ updateArea();
+}
+
+int main(int argv, char **args)
+{
+ QApplication app(argv, args);
+
+ QPixmap pixmap("mypixmap.png");
+ QLabel label;
+ label.setPixmap(pixmap);
+ MyScrollArea area(&label);
+ area.resize(300, 300);
+ area.show();
+
+ area.setWidget(&label);
+
+ return app.exec();
+}
diff --git a/src/widgets/doc/snippets/qlistview-dnd/main.cpp b/src/widgets/doc/snippets/qlistview-dnd/main.cpp
new file mode 100644
index 0000000000..56bff2a612
--- /dev/null
+++ b/src/widgets/doc/snippets/qlistview-dnd/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/qlistview-dnd/mainwindow.cpp b/src/widgets/doc/snippets/qlistview-dnd/mainwindow.cpp
new file mode 100644
index 0000000000..ff35c5e25d
--- /dev/null
+++ b/src/widgets/doc/snippets/qlistview-dnd/mainwindow.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <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/src/widgets/doc/snippets/qlistview-dnd/mainwindow.h b/src/widgets/doc/snippets/qlistview-dnd/mainwindow.h
new file mode 100644
index 0000000000..daac61260e
--- /dev/null
+++ b/src/widgets/doc/snippets/qlistview-dnd/mainwindow.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/qlistview-dnd/model.cpp b/src/widgets/doc/snippets/qlistview-dnd/model.cpp
new file mode 100644
index 0000000000..190ac968c0
--- /dev/null
+++ b/src/widgets/doc/snippets/qlistview-dnd/model.cpp
@@ -0,0 +1,167 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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 (const 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 (const 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/src/widgets/doc/snippets/qlistview-dnd/model.h b/src/widgets/doc/snippets/qlistview-dnd/model.h
new file mode 100644
index 0000000000..9d1ff904e1
--- /dev/null
+++ b/src/widgets/doc/snippets/qlistview-dnd/model.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** 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/src/widgets/doc/snippets/qlistview-dnd/qlistview-dnd.pro b/src/widgets/doc/snippets/qlistview-dnd/qlistview-dnd.pro
new file mode 100644
index 0000000000..71fa273a69
--- /dev/null
+++ b/src/widgets/doc/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/src/widgets/doc/snippets/qlistwidget-dnd/main.cpp b/src/widgets/doc/snippets/qlistwidget-dnd/main.cpp
new file mode 100644
index 0000000000..56bff2a612
--- /dev/null
+++ b/src/widgets/doc/snippets/qlistwidget-dnd/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/qlistwidget-dnd/mainwindow.cpp b/src/widgets/doc/snippets/qlistwidget-dnd/mainwindow.cpp
new file mode 100644
index 0000000000..8d93f823f4
--- /dev/null
+++ b/src/widgets/doc/snippets/qlistwidget-dnd/mainwindow.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <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/src/widgets/doc/snippets/qlistwidget-dnd/mainwindow.h b/src/widgets/doc/snippets/qlistwidget-dnd/mainwindow.h
new file mode 100644
index 0000000000..50cac647d1
--- /dev/null
+++ b/src/widgets/doc/snippets/qlistwidget-dnd/mainwindow.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/qlistwidget-dnd/qlistwidget-dnd.pro b/src/widgets/doc/snippets/qlistwidget-dnd/qlistwidget-dnd.pro
new file mode 100644
index 0000000000..12a900a7c6
--- /dev/null
+++ b/src/widgets/doc/snippets/qlistwidget-dnd/qlistwidget-dnd.pro
@@ -0,0 +1,3 @@
+SOURCES = main.cpp \
+ mainwindow.cpp
+HEADERS = mainwindow.h
diff --git a/src/widgets/doc/snippets/qlistwidget-using/mainwindow.cpp b/src/widgets/doc/snippets/qlistwidget-using/mainwindow.cpp
new file mode 100644
index 0000000000..8e30f7979b
--- /dev/null
+++ b/src/widgets/doc/snippets/qlistwidget-using/mainwindow.cpp
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *itemsMenu = new QMenu(tr("&Items"));
+
+ insertAction = itemsMenu->addAction(tr("&Insert Item"));
+ removeAction = itemsMenu->addAction(tr("&Remove Item"));
+ QAction *ascendingAction = itemsMenu->addAction(tr("Sort in &Ascending Order"));
+ QAction *descendingAction = itemsMenu->addAction(tr("Sort in &Descending Order"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+/* For convenient quoting:
+//! [0]
+ QListWidget *listWidget = new QListWidget(this);
+//! [0]
+*/
+ listWidget = new QListWidget(this);
+ listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(ascendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
+ connect(descendingAction, SIGNAL(triggered()), this, SLOT(sortDescending()));
+ connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
+ connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
+ connect(listWidget,
+ SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
+ this, SLOT(updateMenus(QListWidgetItem *)));
+
+ setupListItems();
+ updateMenus(listWidget->currentItem());
+
+ setCentralWidget(listWidget);
+ setWindowTitle(tr("List Widget"));
+}
+
+void MainWindow::setupListItems()
+{
+//! [1]
+ new QListWidgetItem(tr("Oak"), listWidget);
+ new QListWidgetItem(tr("Fir"), listWidget);
+ new QListWidgetItem(tr("Pine"), listWidget);
+//! [1]
+ new QListWidgetItem(tr("Birch"), listWidget);
+//! [2]
+ new QListWidgetItem(tr("Hazel"), listWidget);
+//! [2]
+ new QListWidgetItem(tr("Redwood"), listWidget);
+//! [3]
+ new QListWidgetItem(tr("Sycamore"), listWidget);
+ new QListWidgetItem(tr("Chestnut"), listWidget);
+ new QListWidgetItem(tr("Mahogany"), listWidget);
+//! [3]
+}
+
+void MainWindow::sortAscending()
+{
+//! [4]
+ listWidget->sortItems(Qt::AscendingOrder);
+//! [4]
+}
+
+void MainWindow::sortDescending()
+{
+//! [5]
+ listWidget->sortItems(Qt::DescendingOrder);
+//! [5]
+}
+
+void MainWindow::insertItem()
+{
+ if (!listWidget->currentItem())
+ return;
+
+ QString itemText = QInputDialog::getText(this, tr("Insert Item"),
+ tr("Input text for the new item:"));
+
+ if (itemText.isNull())
+ return;
+
+//! [6]
+ QListWidgetItem *newItem = new QListWidgetItem;
+ newItem->setText(itemText);
+//! [6]
+ int row = listWidget->row(listWidget->currentItem());
+//! [7]
+ listWidget->insertItem(row, newItem);
+//! [7]
+
+ QString toolTipText = tr("Tooltip:") + itemText;
+ QString statusTipText = tr("Status tip:") + itemText;
+ QString whatsThisText = tr("What's This?:") + itemText;
+//! [8]
+ newItem->setToolTip(toolTipText);
+ newItem->setStatusTip(toolTipText);
+ newItem->setWhatsThis(whatsThisText);
+//! [8]
+}
+
+void MainWindow::removeItem()
+{
+ listWidget->takeItem(listWidget->row(listWidget->currentItem()));
+}
+
+void MainWindow::updateMenus(QListWidgetItem *current)
+{
+ insertAction->setEnabled(current != 0);
+ removeAction->setEnabled(current != 0);
+}
diff --git a/src/widgets/doc/snippets/qmacnativewidget/main.mm b/src/widgets/doc/snippets/qmacnativewidget/main.mm
new file mode 100644
index 0000000000..2c5c49769a
--- /dev/null
+++ b/src/widgets/doc/snippets/qmacnativewidget/main.mm
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QtGui>
+#include <QtGui/qmacnativewidget_mac.h>
+#import <Cocoa/Cocoa.h>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+//![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]
+ return app.exec(); // gives us the same behavior in both
+}
diff --git a/src/widgets/doc/snippets/qsortfilterproxymodel/main.cpp b/src/widgets/doc/snippets/qsortfilterproxymodel/main.cpp
new file mode 100644
index 0000000000..0d78ae3f10
--- /dev/null
+++ b/src/widgets/doc/snippets/qsortfilterproxymodel/main.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <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/src/widgets/doc/snippets/qsortfilterproxymodel/qsortfilterproxymodel.pro b/src/widgets/doc/snippets/qsortfilterproxymodel/qsortfilterproxymodel.pro
new file mode 100644
index 0000000000..16181f21cf
--- /dev/null
+++ b/src/widgets/doc/snippets/qsortfilterproxymodel/qsortfilterproxymodel.pro
@@ -0,0 +1 @@
+SOURCES = main.cpp
diff --git a/src/widgets/doc/snippets/qsplashscreen/main.cpp b/src/widgets/doc/snippets/qsplashscreen/main.cpp
new file mode 100644
index 0000000000..49bc084412
--- /dev/null
+++ b/src/widgets/doc/snippets/qsplashscreen/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <stdlib.h>
+
+#include "mainwindow.h"
+
+//! [0]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QPixmap pixmap(":/splash.png");
+ QSplashScreen splash(pixmap);
+ splash.show();
+ app.processEvents();
+//! [0]
+
+ sleep(5);
+//! [1]
+ QMainWindow window;
+ window.show();
+ splash.finish(&window);
+ return app.exec();
+}
+//! [1]
diff --git a/src/widgets/doc/snippets/qstackedlayout/main.cpp b/src/widgets/doc/snippets/qstackedlayout/main.cpp
new file mode 100644
index 0000000000..771c36c721
--- /dev/null
+++ b/src/widgets/doc/snippets/qstackedlayout/main.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <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/src/widgets/doc/snippets/qstackedwidget/main.cpp b/src/widgets/doc/snippets/qstackedwidget/main.cpp
new file mode 100644
index 0000000000..9a29d773e6
--- /dev/null
+++ b/src/widgets/doc/snippets/qstackedwidget/main.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QApplication>
+
+class Widget : public QWidget
+{
+public:
+ Widget(QWidget *parent = 0);
+};
+
+Widget::Widget(QWidget *parent)
+ : QWidget(parent)
+{
+//! [0]
+ QWidget *firstPageWidget = new QWidget;
+ QWidget *secondPageWidget = new QWidget;
+ QWidget *thirdPageWidget = new QWidget;
+
+ QStackedWidget *stackedWidget = new QStackedWidget;
+ stackedWidget->addWidget(firstPageWidget);
+ stackedWidget->addWidget(secondPageWidget);
+ stackedWidget->addWidget(thirdPageWidget);
+
+//! [0] //! [1]
+ QComboBox *pageComboBox = new QComboBox;
+ pageComboBox->addItem(tr("Page 1"));
+ pageComboBox->addItem(tr("Page 2"));
+ pageComboBox->addItem(tr("Page 3"));
+ connect(pageComboBox, SIGNAL(activated(int)),
+ stackedWidget, SLOT(setCurrentIndex(int)));
+
+//! [1] //! [2]
+ QVBoxLayout *layout = new QVBoxLayout;
+//! [2]
+ layout->addWidget(pageComboBox);
+//! [3]
+ layout->addWidget(stackedWidget);
+ setLayout(layout);
+//! [3]
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Widget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/src/widgets/doc/snippets/qstyleoption/main.cpp b/src/widgets/doc/snippets/qstyleoption/main.cpp
new file mode 100644
index 0000000000..78f663012c
--- /dev/null
+++ b/src/widgets/doc/snippets/qstyleoption/main.cpp
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QApplication>
+
+class MyPushButton : public QPushButton
+{
+public:
+ MyPushButton(QWidget *parent = 0);
+
+ void paintEvent(QPaintEvent *);
+};
+
+MyPushButton::MyPushButton(QWidget *parent)
+ : QPushButton(parent)
+{
+}
+
+//! [0]
+void MyPushButton::paintEvent(QPaintEvent *)
+{
+ QStyleOptionButton option;
+ option.initFrom(this);
+ option.state = isDown() ? QStyle::State_Sunken : QStyle::State_Raised;
+ if (isDefault())
+ option.features |= QStyleOptionButton::DefaultButton;
+ option.text = text();
+ option.icon = icon();
+
+ QPainter painter(this);
+ style()->drawControl(QStyle::CE_PushButton, &option, &painter, this);
+}
+//! [0]
+
+
+
+class MyStyle : public QStyle
+{
+public:
+ MyStyle();
+
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget);
+};
+
+MyStyle::MyStyle()
+{
+//! [1]
+ QStyleOptionFrame *option;
+
+ if (const QStyleOptionFrame *frameOption =
+ qstyleoption_cast<const QStyleOptionFrame *>(option)) {
+ QStyleOptionFrameV2 frameOptionV2(*frameOption);
+
+ // draw the frame using frameOptionV2
+ }
+//! [1]
+
+//! [2]
+ if (const QStyleOptionProgressBar *progressBarOption =
+ qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
+ QStyleOptionProgressBarV2 progressBarV2(*progressBarOption);
+
+ // draw the progress bar using progressBarV2
+ }
+//! [2]
+
+//! [3]
+ if (const QStyleOptionTab *tabOption =
+ qstyleoption_cast<const QStyleOptionTab *>(option)) {
+ QStyleOptionTabV2 tabV2(*tabOption);
+
+ // draw the tab using tabV2
+ }
+//! [3]
+}
+
+//! [4]
+void MyStyle::drawPrimitive(PrimitiveElement element,
+ const QStyleOption *option,
+ QPainter *painter,
+ const QWidget *widget)
+{
+ if (element == PE_FrameFocusRect) {
+ const QStyleOptionFocusRect *focusRectOption =
+ qstyleoption_cast<const QStyleOptionFocusRect *>(option);
+ if (focusRectOption) {
+ // ...
+ }
+ }
+ // ...
+}
+//! [4]
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MyPushButton button;
+ button.show();
+ return app.exec();
+}
diff --git a/src/widgets/doc/snippets/qstyleplugin/main.cpp b/src/widgets/doc/snippets/qstyleplugin/main.cpp
new file mode 100644
index 0000000000..10a122016f
--- /dev/null
+++ b/src/widgets/doc/snippets/qstyleplugin/main.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <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/src/widgets/doc/snippets/qtablewidget-resizing/mainwindow.cpp b/src/widgets/doc/snippets/qtablewidget-resizing/mainwindow.cpp
new file mode 100644
index 0000000000..f3ab01784e
--- /dev/null
+++ b/src/widgets/doc/snippets/qtablewidget-resizing/mainwindow.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *tableMenu = new QMenu(tr("&Table"));
+
+ QAction *tableWidthAction = tableMenu->addAction(tr("Change Table &Width"));
+ QAction *tableHeightAction = tableMenu->addAction(tr("Change Table &Height"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(tableMenu);
+
+//! [0]
+ tableWidget = new QTableWidget(this);
+//! [0]
+ tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(tableWidthAction, SIGNAL(triggered()), this, SLOT(changeWidth()));
+ connect(tableHeightAction, SIGNAL(triggered()), this, SLOT(changeHeight()));
+
+ setupTableItems();
+
+ setCentralWidget(tableWidget);
+ setWindowTitle(tr("Table Widget Resizing"));
+}
+
+void MainWindow::setupTableItems()
+{
+//! [1]
+ tableWidget->setRowCount(10);
+ tableWidget->setColumnCount(5);
+//! [1]
+
+ for (int row = 0; row < tableWidget->rowCount(); ++row) {
+ for (int column = 0; column < tableWidget->columnCount(); ++column) {
+//! [2]
+ QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(
+ (row+1)*(column+1)));
+ tableWidget->setItem(row, column, newItem);
+//! [2]
+ }
+ }
+}
+
+void MainWindow::changeWidth()
+{
+ bool ok;
+
+ int newWidth = QInputDialog::getInteger(this, tr("Change table width"),
+ tr("Input the number of columns required (1-20):"),
+ tableWidget->columnCount(), 1, 20, 1, &ok);
+
+ if (ok)
+ tableWidget->setColumnCount(newWidth);
+}
+
+void MainWindow::changeHeight()
+{
+ bool ok;
+
+ int newHeight = QInputDialog::getInteger(this, tr("Change table height"),
+ tr("Input the number of rows required (1-20):"),
+ tableWidget->rowCount(), 1, 20, 1, &ok);
+
+ if (ok)
+ tableWidget->setRowCount(newHeight);
+}
diff --git a/src/widgets/doc/snippets/qtablewidget-using/Images/cubed.png b/src/widgets/doc/snippets/qtablewidget-using/Images/cubed.png
new file mode 100644
index 0000000000..2cd9048ca6
--- /dev/null
+++ b/src/widgets/doc/snippets/qtablewidget-using/Images/cubed.png
Binary files differ
diff --git a/src/widgets/doc/snippets/qtablewidget-using/Images/squared.png b/src/widgets/doc/snippets/qtablewidget-using/Images/squared.png
new file mode 100644
index 0000000000..bfdf993289
--- /dev/null
+++ b/src/widgets/doc/snippets/qtablewidget-using/Images/squared.png
Binary files differ
diff --git a/src/widgets/doc/snippets/qtablewidget-using/images.qrc b/src/widgets/doc/snippets/qtablewidget-using/images.qrc
new file mode 100644
index 0000000000..1d49b52866
--- /dev/null
+++ b/src/widgets/doc/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/src/widgets/doc/snippets/qtablewidget-using/main.cpp b/src/widgets/doc/snippets/qtablewidget-using/main.cpp
new file mode 100644
index 0000000000..56bff2a612
--- /dev/null
+++ b/src/widgets/doc/snippets/qtablewidget-using/main.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/qtablewidget-using/mainwindow.cpp b/src/widgets/doc/snippets/qtablewidget-using/mainwindow.cpp
new file mode 100644
index 0000000000..b03a5e4999
--- /dev/null
+++ b/src/widgets/doc/snippets/qtablewidget-using/mainwindow.cpp
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "math.h"
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *itemsMenu = new QMenu(tr("&Items"));
+
+ QAction *sumItemsAction = itemsMenu->addAction(tr("&Sum Items"));
+ QAction *averageItemsAction = itemsMenu->addAction(tr("&Average Items"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+//! [0]
+ tableWidget = new QTableWidget(12, 3, this);
+//! [0]
+ tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+//! [1]
+ QTableWidgetItem *valuesHeaderItem = new QTableWidgetItem(tr("Values"));
+ tableWidget->setHorizontalHeaderItem(0, valuesHeaderItem);
+//! [1]
+ valuesHeaderItem->setTextAlignment(Qt::AlignVCenter);
+ QTableWidgetItem *squaresHeaderItem = new QTableWidgetItem(tr("Squares"));
+ squaresHeaderItem->setIcon(QIcon(QPixmap(":/Images/squared.png")));
+ squaresHeaderItem->setTextAlignment(Qt::AlignVCenter);
+//! [2]
+ QTableWidgetItem *cubesHeaderItem = new QTableWidgetItem(tr("Cubes"));
+ cubesHeaderItem->setIcon(QIcon(QPixmap(":/Images/cubed.png")));
+ cubesHeaderItem->setTextAlignment(Qt::AlignVCenter);
+//! [2]
+ tableWidget->setHorizontalHeaderItem(1, squaresHeaderItem);
+ tableWidget->setHorizontalHeaderItem(2, cubesHeaderItem);
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(sumItemsAction, SIGNAL(triggered()), this, SLOT(sumItems()));
+ connect(averageItemsAction, SIGNAL(triggered()), this, SLOT(averageItems()));
+
+ setupTableItems();
+
+ setCentralWidget(tableWidget);
+ setWindowTitle(tr("Table Widget"));
+}
+
+void MainWindow::setupTableItems()
+{
+ for (int row = 0; row < tableWidget->rowCount()-1; ++row) {
+ for (int column = 0; column < tableWidget->columnCount(); ++column) {
+//! [3]
+ QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(
+ pow(row, column+1)));
+ tableWidget->setItem(row, column, newItem);
+//! [3]
+ }
+ }
+ for (int column = 0; column < tableWidget->columnCount(); ++column) {
+ QTableWidgetItem *newItem = new QTableWidgetItem;
+ newItem->setFlags(Qt::ItemIsEnabled);
+ tableWidget->setItem(tableWidget->rowCount()-1, column, newItem);
+ }
+}
+
+void MainWindow::averageItems()
+{
+ QList<QTableWidgetItem *> selected = tableWidget->selectedItems();
+ QTableWidgetItem *item;
+ int number = 0;
+ double total = 0;
+
+ foreach (item, selected) {
+ bool ok;
+ double value = item->text().toDouble(&ok);
+
+ if (ok && !item->text().isEmpty()) {
+ total += value;
+ number++;
+ }
+ }
+ if (number > 0)
+ tableWidget->currentItem()->setText(QString::number(total/number));
+}
+
+void MainWindow::sumItems()
+{
+//! [4]
+ QList<QTableWidgetItem *> selected = tableWidget->selectedItems();
+ QTableWidgetItem *item;
+ int number = 0;
+ double total = 0;
+
+ foreach (item, selected) {
+ bool ok;
+ double value = item->text().toDouble(&ok);
+
+ if (ok && !item->text().isEmpty()) {
+ total += value;
+ number++;
+ }
+ }
+//! [4]
+ if (number > 0)
+ tableWidget->currentItem()->setText(QString::number(total));
+}
diff --git a/src/widgets/doc/snippets/qtablewidget-using/mainwindow.h b/src/widgets/doc/snippets/qtablewidget-using/mainwindow.h
new file mode 100644
index 0000000000..5c8c997762
--- /dev/null
+++ b/src/widgets/doc/snippets/qtablewidget-using/mainwindow.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <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/src/widgets/doc/snippets/qtablewidget-using/qtablewidget-using.pro b/src/widgets/doc/snippets/qtablewidget-using/qtablewidget-using.pro
new file mode 100644
index 0000000000..ffe134cbb6
--- /dev/null
+++ b/src/widgets/doc/snippets/qtablewidget-using/qtablewidget-using.pro
@@ -0,0 +1,4 @@
+SOURCES = main.cpp \
+ mainwindow.cpp
+HEADERS = mainwindow.h
+RESOURCES += images.qrc
diff --git a/src/widgets/doc/snippets/qtreewidget-using/mainwindow.cpp b/src/widgets/doc/snippets/qtreewidget-using/mainwindow.cpp
new file mode 100644
index 0000000000..2a62c3e5f8
--- /dev/null
+++ b/src/widgets/doc/snippets/qtreewidget-using/mainwindow.cpp
@@ -0,0 +1,230 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *itemsMenu = new QMenu(tr("&Items"));
+
+ insertAction = itemsMenu->addAction(tr("&Insert Item"));
+ removeAction = itemsMenu->addAction(tr("&Remove Item"));
+ removeAction->setEnabled(false);
+ itemsMenu->addSeparator();
+ ascendingAction = itemsMenu->addAction(tr("Sort in &Ascending Order"));
+ descendingAction = itemsMenu->addAction(tr("Sort in &Descending Order"));
+ autoSortAction = itemsMenu->addAction(tr("&Automatically Sort Items"));
+ autoSortAction->setCheckable(true);
+ itemsMenu->addSeparator();
+ QAction *findItemsAction = itemsMenu->addAction(tr("&Find Items"));
+ findItemsAction->setShortcut(tr("Ctrl+F"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+/* For convenient quoting:
+//! [0]
+ QTreeWidget *treeWidget = new QTreeWidget(this);
+//! [0]
+*/
+ treeWidget = new QTreeWidget(this);
+//! [1]
+ treeWidget->setColumnCount(2);
+//! [1] //! [2]
+ QStringList headers;
+ headers << tr("Subject") << tr("Default");
+ treeWidget->setHeaderLabels(headers);
+//! [2]
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(ascendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
+ connect(autoSortAction, SIGNAL(triggered()), this, SLOT(updateSortItems()));
+ connect(descendingAction, SIGNAL(triggered()), this, SLOT(sortDescending()));
+ connect(findItemsAction, SIGNAL(triggered()), this, SLOT(findItems()));
+ connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
+ connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
+ connect(treeWidget,
+ SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
+ this, SLOT(updateMenus(QTreeWidgetItem *)));
+
+ setupTreeItems();
+ updateMenus(treeWidget->currentItem());
+
+ setCentralWidget(treeWidget);
+ setWindowTitle(tr("Tree Widget"));
+}
+
+void MainWindow::setupTreeItems()
+{
+//! [3]
+ QTreeWidgetItem *cities = new QTreeWidgetItem(treeWidget);
+ cities->setText(0, tr("Cities"));
+ QTreeWidgetItem *osloItem = new QTreeWidgetItem(cities);
+ osloItem->setText(0, tr("Oslo"));
+ osloItem->setText(1, tr("Yes"));
+//! [3]
+
+ (new QTreeWidgetItem(cities))->setText(0, tr("Stockholm"));
+ (new QTreeWidgetItem(cities))->setText(0, tr("Helsinki"));
+ (new QTreeWidgetItem(cities))->setText(0, tr("Copenhagen"));
+
+//! [4] //! [5]
+ QTreeWidgetItem *planets = new QTreeWidgetItem(treeWidget, cities);
+//! [4]
+ planets->setText(0, tr("Planets"));
+//! [5]
+ (new QTreeWidgetItem(planets))->setText(0, tr("Mercury"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Venus"));
+
+ QTreeWidgetItem *earthItem = new QTreeWidgetItem(planets);
+ earthItem->setText(0, tr("Earth"));
+ earthItem->setText(1, tr("Yes"));
+
+ (new QTreeWidgetItem(planets))->setText(0, tr("Mars"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Jupiter"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Saturn"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Uranus"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Neptune"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Pluto"));
+}
+
+void MainWindow::findItems()
+{
+ QString itemText = QInputDialog::getText(this, tr("Find Items"),
+ tr("Text to find (including wildcards):"));
+
+ if (itemText.isEmpty())
+ return;
+
+//! [6]
+ QTreeWidgetItem *item;
+//! [6]
+ foreach (item, treeWidget->selectedItems())
+ treeWidget->setItemSelected(item, false);
+
+//! [7]
+ QList<QTreeWidgetItem *> found = treeWidget->findItems(
+ itemText, Qt::MatchWildcard);
+
+ foreach (item, found) {
+ treeWidget->setItemSelected(item, true);
+ // Show the item->text(0) for each item.
+ }
+//! [7]
+}
+
+void MainWindow::insertItem()
+{
+ QTreeWidgetItem *currentItem = treeWidget->currentItem();
+
+ if (!currentItem)
+ return;
+
+ QString itemText = QInputDialog::getText(this, tr("Insert Item"),
+ tr("Input text for the new item:"));
+
+ if (itemText.isEmpty())
+ return;
+
+//! [8]
+ QTreeWidgetItem *parent = currentItem->parent();
+ QTreeWidgetItem *newItem;
+ if (parent)
+ newItem = new QTreeWidgetItem(parent, treeWidget->currentItem());
+ else
+//! [8] //! [9]
+ newItem = new QTreeWidgetItem(treeWidget, treeWidget->currentItem());
+//! [9]
+
+ newItem->setText(0, itemText);
+}
+
+void MainWindow::removeItem()
+{
+ QTreeWidgetItem *currentItem = treeWidget->currentItem();
+
+ if (!currentItem)
+ return;
+
+//! [10]
+ QTreeWidgetItem *parent = currentItem->parent();
+ int index;
+
+ if (parent) {
+ index = parent->indexOfChild(treeWidget->currentItem());
+ delete parent->takeChild(index);
+ } else {
+ index = treeWidget->indexOfTopLevelItem(treeWidget->currentItem());
+ delete treeWidget->takeTopLevelItem(index);
+//! [10] //! [11]
+ }
+//! [11]
+}
+
+void MainWindow::sortAscending()
+{
+ treeWidget->sortItems(0, Qt::AscendingOrder);
+}
+
+void MainWindow::sortDescending()
+{
+ treeWidget->sortItems(0, Qt::DescendingOrder);
+}
+
+void MainWindow::updateMenus(QTreeWidgetItem *current)
+{
+ insertAction->setEnabled(current != 0);
+ removeAction->setEnabled(current != 0);
+}
+
+void MainWindow::updateSortItems()
+{
+ ascendingAction->setEnabled(!autoSortAction->isChecked());
+ descendingAction->setEnabled(!autoSortAction->isChecked());
+
+ treeWidget->setSortingEnabled(autoSortAction->isChecked());
+}
diff --git a/src/widgets/doc/snippets/qtreewidgetitemiterator-using/mainwindow.cpp b/src/widgets/doc/snippets/qtreewidgetitemiterator-using/mainwindow.cpp
new file mode 100644
index 0000000000..a0648b18c5
--- /dev/null
+++ b/src/widgets/doc/snippets/qtreewidgetitemiterator-using/mainwindow.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *itemsMenu = new QMenu(tr("&Items"));
+
+ insertAction = itemsMenu->addAction(tr("&Insert Item"));
+ removeAction = itemsMenu->addAction(tr("&Remove Item"));
+ removeAction->setEnabled(false);
+ itemsMenu->addSeparator();
+ ascendingAction = itemsMenu->addAction(tr("Sort in &Ascending Order"));
+ descendingAction = itemsMenu->addAction(tr("Sort in &Descending Order"));
+ autoSortAction = itemsMenu->addAction(tr("&Automatically Sort Items"));
+ autoSortAction->setCheckable(true);
+ itemsMenu->addSeparator();
+ QAction *findItemsAction = itemsMenu->addAction(tr("&Find Items"));
+ findItemsAction->setShortcut(tr("Ctrl+F"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(itemsMenu);
+
+/* For convenient quoting:
+ QTreeWidget *treeWidget = new QTreeWidget(this);
+*/
+ treeWidget = new QTreeWidget(this);
+ treeWidget->setColumnCount(2);
+ QStringList headers;
+ headers << tr("Subject") << tr("Default");
+ treeWidget->setHeaderLabels(headers);
+
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(ascendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
+ connect(autoSortAction, SIGNAL(triggered()), this, SLOT(updateSortItems()));
+ connect(descendingAction, SIGNAL(triggered()), this, SLOT(sortDescending()));
+ connect(findItemsAction, SIGNAL(triggered()), this, SLOT(findItems()));
+ connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
+ connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
+ connect(treeWidget,
+ SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
+ this, SLOT(updateMenus(QTreeWidgetItem *)));
+
+ setupTreeItems();
+ updateMenus(treeWidget->currentItem());
+
+ setCentralWidget(treeWidget);
+ setWindowTitle(tr("Tree Widget"));
+}
+
+void MainWindow::setupTreeItems()
+{
+ QTreeWidgetItem *planets = new QTreeWidgetItem(treeWidget);
+ planets->setText(0, tr("Planets"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Mercury"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Venus"));
+
+ QTreeWidgetItem *earthItem = new QTreeWidgetItem(planets);
+ earthItem->setText(0, tr("Earth"));
+ earthItem->setText(1, tr("Yes"));
+
+ (new QTreeWidgetItem(planets))->setText(0, tr("Mars"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Jupiter"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Saturn"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Uranus"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Neptune"));
+ (new QTreeWidgetItem(planets))->setText(0, tr("Pluto"));
+}
+
+void MainWindow::findItems()
+{
+ QString itemText = QInputDialog::getText(this, tr("Find Items"),
+ tr("Text to find:"));
+
+ if (itemText.isEmpty())
+ return;
+
+//! [0]
+ QTreeWidgetItemIterator it(treeWidget);
+ while (*it) {
+ if ((*it)->text(0) == itemText)
+ (*it)->setSelected(true);
+ ++it;
+ }
+//! [0]
+}
+
+void MainWindow::insertItem()
+{
+ QTreeWidgetItem *currentItem = treeWidget->currentItem();
+
+ if (!currentItem)
+ return;
+
+ QString itemText = QInputDialog::getText(this, tr("Insert Item"),
+ tr("Input text for the new item:"));
+
+ if (itemText.isEmpty())
+ return;
+
+ QTreeWidgetItem *parent = currentItem->parent();
+ QTreeWidgetItem *newItem;
+ if (parent)
+ newItem = new QTreeWidgetItem(parent, treeWidget->currentItem());
+ else
+ newItem = new QTreeWidgetItem(treeWidget, treeWidget->currentItem());
+
+ newItem->setText(0, itemText);
+}
+
+void MainWindow::removeItem()
+{
+ QTreeWidgetItem *currentItem = treeWidget->currentItem();
+
+ if (!currentItem)
+ return;
+
+ QTreeWidgetItem *parent = currentItem->parent();
+ int index;
+
+ if (parent) {
+ index = parent->indexOfChild(treeWidget->currentItem());
+ delete parent->takeChild(index);
+ } else {
+ index = treeWidget->indexOfTopLevelItem(treeWidget->currentItem());
+ delete treeWidget->takeTopLevelItem(index);
+ }
+}
+
+void MainWindow::sortAscending()
+{
+ treeWidget->sortItems(0, Qt::AscendingOrder);
+}
+
+void MainWindow::sortDescending()
+{
+ treeWidget->sortItems(0, Qt::DescendingOrder);
+}
+
+void MainWindow::updateMenus(QTreeWidgetItem *current)
+{
+ insertAction->setEnabled(current != 0);
+ removeAction->setEnabled(current != 0);
+}
+
+void MainWindow::updateSortItems()
+{
+ ascendingAction->setEnabled(!autoSortAction->isChecked());
+ descendingAction->setEnabled(!autoSortAction->isChecked());
+
+ treeWidget->setSortingEnabled(autoSortAction->isChecked());
+}
diff --git a/src/widgets/doc/snippets/reading-selections/main.cpp b/src/widgets/doc/snippets/reading-selections/main.cpp
new file mode 100644
index 0000000000..3356ffc8ab
--- /dev/null
+++ b/src/widgets/doc/snippets/reading-selections/main.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ 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/src/widgets/doc/snippets/reading-selections/model.cpp b/src/widgets/doc/snippets/reading-selections/model.cpp
new file mode 100644
index 0000000000..ca4b9f84dd
--- /dev/null
+++ b/src/widgets/doc/snippets/reading-selections/model.cpp
@@ -0,0 +1,238 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ 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/src/widgets/doc/snippets/reading-selections/model.h b/src/widgets/doc/snippets/reading-selections/model.h
new file mode 100644
index 0000000000..ef63e45ce0
--- /dev/null
+++ b/src/widgets/doc/snippets/reading-selections/model.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/reading-selections/reading-selections.pro b/src/widgets/doc/snippets/reading-selections/reading-selections.pro
new file mode 100644
index 0000000000..91ebd3e84f
--- /dev/null
+++ b/src/widgets/doc/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/src/widgets/doc/snippets/reading-selections/window.cpp b/src/widgets/doc/snippets/reading-selections/window.cpp
new file mode 100644
index 0000000000..dd9970374f
--- /dev/null
+++ b/src/widgets/doc/snippets/reading-selections/window.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ 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/src/widgets/doc/snippets/reading-selections/window.h b/src/widgets/doc/snippets/reading-selections/window.h
new file mode 100644
index 0000000000..6d2537c22d
--- /dev/null
+++ b/src/widgets/doc/snippets/reading-selections/window.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/shareddirmodel/main.cpp b/src/widgets/doc/snippets/shareddirmodel/main.cpp
new file mode 100644
index 0000000000..78d439b752
--- /dev/null
+++ b/src/widgets/doc/snippets/shareddirmodel/main.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ A simple example of how to view a model in several views, and share a
+ selection model.
+*/
+
+#include <QtGui>
+
+//! [0] //! [1]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QSplitter *splitter = new QSplitter;
+
+//! [2] //! [3]
+ QFileSystemModel *model = new QFileSystemModel;
+ model->setRootPath(QDir::currentPath());
+//! [0] //! [2] //! [4] //! [5]
+ QTreeView *tree = new QTreeView(splitter);
+//! [3] //! [6]
+ tree->setModel(model);
+//! [4] //! [6] //! [7]
+ tree->setRootIndex(model->index(QDir::currentPath()));
+//! [7]
+
+ QListView *list = new QListView(splitter);
+ list->setModel(model);
+ list->setRootIndex(model->index(QDir::currentPath()));
+
+//! [5]
+ QItemSelectionModel *selection = new QItemSelectionModel(model);
+ tree->setSelectionModel(selection);
+ list->setSelectionModel(selection);
+
+//! [8]
+ splitter->setWindowTitle("Two views onto the same file system model");
+ splitter->show();
+ return app.exec();
+}
+//! [1] //! [8]
diff --git a/src/widgets/doc/snippets/sharedtablemodel/main.cpp b/src/widgets/doc/snippets/sharedtablemodel/main.cpp
new file mode 100644
index 0000000000..f031a02aca
--- /dev/null
+++ b/src/widgets/doc/snippets/sharedtablemodel/main.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ 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/src/widgets/doc/snippets/sharedtablemodel/model.cpp b/src/widgets/doc/snippets/sharedtablemodel/model.cpp
new file mode 100644
index 0000000000..ec56f84adb
--- /dev/null
+++ b/src/widgets/doc/snippets/sharedtablemodel/model.cpp
@@ -0,0 +1,236 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ 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/src/widgets/doc/snippets/sharedtablemodel/model.h b/src/widgets/doc/snippets/sharedtablemodel/model.h
new file mode 100644
index 0000000000..ef63e45ce0
--- /dev/null
+++ b/src/widgets/doc/snippets/sharedtablemodel/model.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/sharedtablemodel/sharedtablemodel.pro b/src/widgets/doc/snippets/sharedtablemodel/sharedtablemodel.pro
new file mode 100644
index 0000000000..10671e6e25
--- /dev/null
+++ b/src/widgets/doc/snippets/sharedtablemodel/sharedtablemodel.pro
@@ -0,0 +1,2 @@
+HEADERS += model.h
+SOURCES += main.cpp model.cpp
diff --git a/src/widgets/doc/snippets/simplemodel-use/main.cpp b/src/widgets/doc/snippets/simplemodel-use/main.cpp
new file mode 100644
index 0000000000..d8188b14e6
--- /dev/null
+++ b/src/widgets/doc/snippets/simplemodel-use/main.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ 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]
+ QFileSystemModel *model = new QFileSystemModel;
+ 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/src/widgets/doc/snippets/simplemodel-use/simplemodel-use.pro b/src/widgets/doc/snippets/simplemodel-use/simplemodel-use.pro
new file mode 100644
index 0000000000..28dcadcbfa
--- /dev/null
+++ b/src/widgets/doc/snippets/simplemodel-use/simplemodel-use.pro
@@ -0,0 +1 @@
+SOURCES += main.cpp
diff --git a/src/widgets/doc/snippets/splitter/splitter.cpp b/src/widgets/doc/snippets/splitter/splitter.cpp
new file mode 100644
index 0000000000..3908f1b0e3
--- /dev/null
+++ b/src/widgets/doc/snippets/splitter/splitter.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+void processSize(int)
+{
+}
+
+int main()
+{
+ QWidget *parent = 0;
+
+//! [0]
+ QSplitter *splitter = new QSplitter(parent);
+ QListView *listview = new QListView;
+ QTreeView *treeview = new QTreeView;
+ QTextEdit *textedit = new QTextEdit;
+ splitter->addWidget(listview);
+ splitter->addWidget(treeview);
+ splitter->addWidget(textedit);
+//! [0]
+
+ {
+ // SAVE STATE
+//! [1]
+ QSettings settings;
+ settings.setValue("splitterSizes", splitter->saveState());
+//! [1]
+ }
+
+ {
+ // RESTORE STATE
+//! [2]
+ QSettings settings;
+ splitter->restoreState(settings.value("splitterSizes").toByteArray());
+//! [2]
+ }
+
+//! [3]
+ QListIterator<int> it(splitter->sizes());
+ while (it.hasNext())
+ processSize(it.next());
+//! [3]
+
+ return 0;
+}
diff --git a/src/widgets/doc/snippets/splitterhandle/splitter.cpp b/src/widgets/doc/snippets/splitterhandle/splitter.cpp
new file mode 100644
index 0000000000..b8b729bb91
--- /dev/null
+++ b/src/widgets/doc/snippets/splitterhandle/splitter.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <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/src/widgets/doc/snippets/splitterhandle/splitter.h b/src/widgets/doc/snippets/splitterhandle/splitter.h
new file mode 100644
index 0000000000..ba310b9e8d
--- /dev/null
+++ b/src/widgets/doc/snippets/splitterhandle/splitter.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SPLITTER_H
+#define SPLITTER_H
+
+#include <QLinearGradient>
+#include <QSplitter>
+#include <QSplitterHandle>
+
+class QPaintEvent;
+
+//! [0]
+class Splitter : public QSplitter
+{
+public:
+ Splitter(Qt::Orientation orientation, QWidget *parent = 0);
+
+protected:
+ QSplitterHandle *createHandle();
+};
+//! [0]
+
+class SplitterHandle : public QSplitterHandle
+{
+public:
+ SplitterHandle(Qt::Orientation orientation, QSplitter *parent);
+
+protected:
+ void paintEvent(QPaintEvent *event);
+
+private:
+ QLinearGradient gradient;
+};
+
+#endif
diff --git a/src/widgets/doc/snippets/stringlistmodel/main.cpp b/src/widgets/doc/snippets/stringlistmodel/main.cpp
new file mode 100644
index 0000000000..d4f0efdc22
--- /dev/null
+++ b/src/widgets/doc/snippets/stringlistmodel/main.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ 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/src/widgets/doc/snippets/stringlistmodel/model.cpp b/src/widgets/doc/snippets/stringlistmodel/model.cpp
new file mode 100644
index 0000000000..6795345d36
--- /dev/null
+++ b/src/widgets/doc/snippets/stringlistmodel/model.cpp
@@ -0,0 +1,211 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ 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]
+
+
+#ifdef 0
+// This represents a read-only version of data(), an early stage in the
+// development of the example leading to an editable StringListModel.
+
+/*!
+ 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-data-read-only]
+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-data-read-only]
+#endif
+
+
+/*!
+ 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 || role == Qt::EditRole)
+ 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/src/widgets/doc/snippets/stringlistmodel/model.h b/src/widgets/doc/snippets/stringlistmodel/model.h
new file mode 100644
index 0000000000..1dceccb8a8
--- /dev/null
+++ b/src/widgets/doc/snippets/stringlistmodel/model.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/stringlistmodel/stringlistmodel.pro b/src/widgets/doc/snippets/stringlistmodel/stringlistmodel.pro
new file mode 100644
index 0000000000..b1126bfe73
--- /dev/null
+++ b/src/widgets/doc/snippets/stringlistmodel/stringlistmodel.pro
@@ -0,0 +1,3 @@
+HEADERS = model.h
+SOURCES = main.cpp \
+ model.cpp
diff --git a/src/widgets/doc/snippets/styles/styles.cpp b/src/widgets/doc/snippets/styles/styles.cpp
new file mode 100644
index 0000000000..1109669bcb
--- /dev/null
+++ b/src/widgets/doc/snippets/styles/styles.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QStyleOption>
+#include <QStylePainter>
+#include <QWidget>
+
+class MyWidget : public QWidget
+{
+protected:
+ void paintEvent(QPaintEvent *event);
+ void paintEvent2(QPaintEvent *event);
+
+};
+
+//! [0] //! [1]
+void MyWidget::paintEvent(QPaintEvent * /* event */)
+//! [0]
+{
+//! [2]
+ QPainter painter(this);
+//! [2]
+
+ QStyleOptionFocusRect option;
+ option.initFrom(this);
+ option.backgroundColor = palette().color(QPalette::Background);
+
+//! [3]
+ style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this);
+//! [3]
+}
+//! [1]
+
+void MyWidget::paintEvent2(QPaintEvent * /* event */)
+//! [4]
+{
+//! [4] //! [5] //! [6]
+ QStylePainter painter(this);
+//! [5]
+
+ QStyleOptionFocusRect option;
+ option.initFrom(this);
+ option.backgroundColor = palette().color(QPalette::Background);
+
+//! [7]
+ painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
+//! [7]
+}
+//! [6]
+
+int main()
+{
+ return 0;
+}
diff --git a/src/widgets/doc/snippets/stylesheet/common-mistakes.cpp b/src/widgets/doc/snippets/stylesheet/common-mistakes.cpp
new file mode 100644
index 0000000000..d4552fcf1d
--- /dev/null
+++ b/src/widgets/doc/snippets/stylesheet/common-mistakes.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [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/src/widgets/doc/snippets/textdocument-imagedrop/textedit.cpp b/src/widgets/doc/snippets/textdocument-imagedrop/textedit.cpp
new file mode 100644
index 0000000000..fbb6f73ddc
--- /dev/null
+++ b/src/widgets/doc/snippets/textdocument-imagedrop/textedit.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "textedit.h"
+#include <QtGui>
+
+TextEdit::TextEdit(QWidget *parent)
+ : QTextEdit(parent)
+{
+}
+
+//! [0]
+bool TextEdit::canInsertFromMimeData( const QMimeData *source ) const
+{
+ if (source->hasImage())
+ return true;
+ else
+ return QTextEdit::canInsertFromMimeData(source);
+}
+//! [0]
+
+//! [1]
+void TextEdit::insertFromMimeData( const QMimeData *source )
+{
+ if (source->hasImage())
+ {
+ QImage image = qvariant_cast<QImage>(source->imageData());
+ QTextCursor cursor = this->textCursor();
+ QTextDocument *document = this->document();
+ document->addResource(QTextDocument::ImageResource, QUrl("image"), image);
+ cursor.insertImage("image");
+ }
+}
+//! [1]
diff --git a/src/widgets/doc/snippets/timeline/main.cpp b/src/widgets/doc/snippets/timeline/main.cpp
new file mode 100644
index 0000000000..f4be7f3c5b
--- /dev/null
+++ b/src/widgets/doc/snippets/timeline/main.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <math.h>
+
+int main(int argv, char *args[])
+{
+ QApplication app(argv, args);
+
+//! [0]
+ QGraphicsItem *ball = new QGraphicsEllipseItem(0, 0, 20, 20);
+
+ QTimeLine *timer = new QTimeLine(5000);
+ timer->setFrameRange(0, 100);
+
+ QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
+ animation->setItem(ball);
+ animation->setTimeLine(timer);
+
+ for (int i = 0; i < 200; ++i)
+ animation->setPosAt(i / 200.0, QPointF(i, i));
+
+ QGraphicsScene *scene = new QGraphicsScene();
+ scene->setSceneRect(0, 0, 250, 250);
+ scene->addItem(ball);
+
+ QGraphicsView *view = new QGraphicsView(scene);
+ view->show();
+
+ timer->start();
+//! [0]
+
+ return app.exec();
+}
diff --git a/src/widgets/doc/snippets/updating-selections/main.cpp b/src/widgets/doc/snippets/updating-selections/main.cpp
new file mode 100644
index 0000000000..3356ffc8ab
--- /dev/null
+++ b/src/widgets/doc/snippets/updating-selections/main.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ 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/src/widgets/doc/snippets/updating-selections/model.cpp b/src/widgets/doc/snippets/updating-selections/model.cpp
new file mode 100644
index 0000000000..ec56f84adb
--- /dev/null
+++ b/src/widgets/doc/snippets/updating-selections/model.cpp
@@ -0,0 +1,236 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ 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/src/widgets/doc/snippets/updating-selections/model.h b/src/widgets/doc/snippets/updating-selections/model.h
new file mode 100644
index 0000000000..ef63e45ce0
--- /dev/null
+++ b/src/widgets/doc/snippets/updating-selections/model.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/updating-selections/updating-selections.pro b/src/widgets/doc/snippets/updating-selections/updating-selections.pro
new file mode 100644
index 0000000000..91ebd3e84f
--- /dev/null
+++ b/src/widgets/doc/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/src/widgets/doc/snippets/updating-selections/window.cpp b/src/widgets/doc/snippets/updating-selections/window.cpp
new file mode 100644
index 0000000000..eaa37b8c87
--- /dev/null
+++ b/src/widgets/doc/snippets/updating-selections/window.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ 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/src/widgets/doc/snippets/updating-selections/window.h b/src/widgets/doc/snippets/updating-selections/window.h
new file mode 100644
index 0000000000..0d87ced010
--- /dev/null
+++ b/src/widgets/doc/snippets/updating-selections/window.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/whatsthis/whatsthis.cpp b/src/widgets/doc/snippets/whatsthis/whatsthis.cpp
new file mode 100644
index 0000000000..3d3f65d317
--- /dev/null
+++ b/src/widgets/doc/snippets/whatsthis/whatsthis.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+class MainWindow : public QMainWindow
+{
+public:
+ MainWindow();
+
+ QAction *newAct;
+};
+
+MainWindow()
+{
+//! [0]
+ newAct = new QAction(tr("&New"), this);
+ newAct->setShortcut(tr("Ctrl+N"));
+ newAct->setStatusTip(tr("Create a new file"));
+ newAct->setWhatsThis(tr("Click this option to create a new file."));
+//! [0]
+}
+
+int main()
+{
+ return 0;
+}
diff --git a/src/widgets/doc/snippets/widget-mask/main.cpp b/src/widgets/doc/snippets/widget-mask/main.cpp
new file mode 100644
index 0000000000..18653deb4c
--- /dev/null
+++ b/src/widgets/doc/snippets/widget-mask/main.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#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/src/widgets/doc/snippets/widgetdelegate.cpp b/src/widgets/doc/snippets/widgetdelegate.cpp
new file mode 100644
index 0000000000..4d2a6559a5
--- /dev/null
+++ b/src/widgets/doc/snippets/widgetdelegate.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "widgetdelegate.h"
+
+//![0]
+void WidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+{
+ if (index.column() == 1) {
+ int progress = index.data().toInt();
+
+ QStyleOptionProgressBar progressBarOption;
+ progressBarOption.rect = option.rect;
+ progressBarOption.minimum = 0;
+ progressBarOption.maximum = 100;
+ progressBarOption.progress = progress;
+ progressBarOption.text = QString::number(progress) + "%";
+ progressBarOption.textVisible = true;
+
+ QApplication::style()->drawControl(QStyle::CE_ProgressBar,
+ &progressBarOption, painter);
+ } else
+ QStyledItemDelegate::paint(painter, option, index);
+
+//![0]
+}
diff --git a/src/widgets/doc/snippets/widgets-tutorial/template.cpp b/src/widgets/doc/snippets/widgets-tutorial/template.cpp
new file mode 100644
index 0000000000..187952d44d
--- /dev/null
+++ b/src/widgets/doc/snippets/widgets-tutorial/template.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [main.cpp body]
+#include <QtGui>
+
+// Include header files for application components.
+// ...
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ // Set up and show widgets.
+ // ...
+
+ return app.exec();
+}
+//! [main.cpp body]
diff --git a/src/widgets/doc/src/addressbook-fr.qdoc b/src/widgets/doc/src/addressbook-fr.qdoc
new file mode 100644
index 0000000000..edd53239d0
--- /dev/null
+++ b/src/widgets/doc/src/addressbook-fr.qdoc
@@ -0,0 +1,1036 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page tutorials-addressbook-fr.html
+
+ \title Tutoriel "Carnet d'adresses"
+ \brief Une introduction à la programation d'interface graphique montrant comment construire une application simple avec Qt.
+
+ Ce tutoriel est une introduction à la programmation de GUI (interface utilisateur)
+ à l'aide des outils fournis par la plateforme multiplate-forme Qt.
+
+ \image addressbook-tutorial-screenshot.png
+
+ Ce tutoriel va nous amener à découvrir quelques technologies fondamentales fournies
+ par Qt, tel que:
+
+ \list
+ \li Les Widgets et leur mise en page à l'aide des layouts
+ \li Les signaux et slots
+ \li Les structures de données de collections
+ \li Les entrées/sorties
+ \endlist
+
+ Si c'est votre premier contact avec Qt, lisez \l{How to Learn Qt}{Comment apprendre Qt}
+ si ce n'est déjà fait.
+
+ Le code source du tutoriel est distribué avec Qt dans le dossier \c examples/tutorials/addressbook
+
+ Les chapitres du tutoriel:
+
+ \list 1
+ \li \l{tutorials/addressbook-fr/part1}{Conception de l'interface utilisateur}
+ \li \l{tutorials/addressbook-fr/part2}{Ajouter des adresses}
+ \li \l{tutorials/addressbook-fr/part3}{Navigation entre les éléments}
+ \li \l{tutorials/addressbook-fr/part4}{éditer et supprimer des adresses}
+ \li \l{tutorials/addressbook-fr/part5}{Ajout d'une fonction de recherche}
+ \li \l{tutorials/addressbook-fr/part6}{Sauvegarde et chargement}
+ \li \l{tutorials/addressbook-fr/part7}{Fonctionnalités avancées}
+ \endlist
+
+ La petite application que nous développerons ici ne possède pas tous les éléments
+ des interfaces dernier cri, elle va nous permettre d'utiliser les techniques de base
+ utilisées dans les applications plus complexes.
+
+ Lorsque vous aurez terminé ce tutoriel, nous vous recommandons de poursuivre avec l'exemple
+ "\l{mainwindows/application}{Application}", qui présente une interface simple utilisant
+ les menus et barres d'outils, la barre d'état, etc.
+
+*/
+
+/*!
+ \page tutorials-addressbook-fr-part1.html
+
+ \example tutorials/addressbook-fr/part1
+ \title Carnet d'adresses 1 - Conception de l'interface utilisateur
+
+ La première partie de ce tutoriel traite de la conception d'une interface graphique
+ (GUI) basique, que l'on utilisera pour l'application Carnet d'adresses.
+
+ La première étape dans la création d'applications graphiques est la conception de
+ l'interface utilisateur. Dans ce chapitre, nous verrons comment créer les labels
+ et champs de saisie nécessaires à l'implementation d'un carnet d'adresses de base.
+ Le résultat attendu est illustré par la capture d'écran ci-dessous.
+
+ \image addressbook-tutorial-part1-screenshot.png
+
+ Nous allons avoir besoin de deux objets QLabel, \c nameLabel et \c addressLabel,
+ ainsi que deux champs de saisie: un objet QLineEdit, \c nameLine, et un objet
+ QTextEdit, \c addressText, afin de permettre à l'utilisateur d'entrer le nom d'un
+ contact et son adresse. Les widgets utilisés ainsi que leur placement sont visibles ci-dessous.
+
+ \image addressbook-tutorial-part1-labeled-screenshot.png
+
+ Trois fichiers sont nécessaires à l'implémentation de ce carnet d'adresses:
+
+ \list
+ \li \c{addressbook.h} - le fichier de définition (header) pour la classe \c AddressBook,
+ \li \c{addressbook.cpp} - le fichier source, qui comprend l'implémentation de la classe
+ \c AddressBook
+ \li \c{main.cpp} - le fichier qui contient la méthode \c main() , et
+ une instance de la classe \c AddressBook.
+ \endlist
+
+ \section1 Programmation en Qt - héritage
+
+
+ Lorsque l'on écrit des programmes avec Qt, on a généralement recours à
+ l'héritage depuis des objets Qt, afin d'y ajouter des fonctionnalités.
+ C'est l'un des concepts fondamentaux de la création de widgets personnalisés
+ ou de collections de widgets. Utiliser l'héritage afin de compléter
+ ou modifier le comportement d'un widget présente les avantages suivants:
+
+ \list
+ \li La possibilité d'implémenter des méthodes virtuelles et des méthodes
+ virtuelles pures pour obtenir exactement ce que l'on souhaite, avec la possibilité
+ d'utiliser l'implémentation de la classe mère si besoin est.
+ \li Cela permet l'encapsulation partielle de l'interface utilisateur dans une classe,
+ afin que les autres parties de l'application n'aient pas à se soucier de chacun des
+ widgets qui forment l'interface utilisateur.
+ \li La classe fille peut être utilisée pour créer de nombreux widgets personnalisés
+ dans une même application ou bibliothèque, et le code de la classe fille peut être
+ réutilisé dans d'autres projets
+ \endlist
+
+ Comme Qt ne fournit pas de widget standard pour un carnet d'adresses, nous
+ partirons d'une classe de widget Qt standard et y ajouterons des fonctionnalités.
+ La classe \c AddressBook crée dans ce tutoriel peut être réutilisée si on a besoin d'un
+ widget carnet d'adresses basique.
+
+
+ \section1 La classe AddressBook
+
+ Le fichier \l{tutorials/addressbook-fr/part1/addressbook.h}{\c addressbook.h} permet de
+ définir la classe \c AddressBook.
+
+ On commence par définir \c AddressBook comme une classe fille de QWidget et déclarer
+ un constructeur. On utilise également la macro Q_OBJECT pour indiquer que la classe
+ exploite les fonctionnalités de signaux et slots offertes par Qt ainsi que
+ l'internationalisation, bien que nous ne les utilisions pas à ce stade.
+
+ \snippet tutorials/addressbook-fr/part1/addressbook.h class definition
+
+ La classe contient les déclarations de \c nameLine et \c addressText,
+ les instances privées de QLineEdit et QTextEdit mentionnées précédemment.
+ Vous verrez, dans les chapitres à venir que les informations contenues
+ dans \c nameLine et \c addressText sont nécessaires à de nombreuses méthodes
+ du carnet d'adresses.
+
+ Il n'est pas nécessaire de déclarer les objets QLabel que nous allons utiliser
+ puisque nous n'aurons pas besoin d'y faire référence après leur création.
+ La façon dont Qt gère la parenté des objets est traitée dans la section suivante.
+
+ La macro Q_OBJECT implémente des fonctionnalités parmi les plus avancées de Qt.
+ Pour le moment, il est bon de voir la macro Q_OBJECT comme un raccourci nous
+ permettant d'utiliser les méthodes \l{QObject::}{tr()} et \l{QObject::}{connect()}.
+
+ Nous en avons maintenant terminé avec le fichier \c addressbook.h et allons
+ passer à l'implémentation du fichier \c addressbook.cpp.
+
+ \section1 Implémentation de la classe AddressBook
+
+ Le constructeur de la classe \c{AddressBook} prend en paramètre un QWidget, \e parent.
+ Par convention, on passe ce paramètre au constructeur de la classe mère.
+ Ce concept de parenté, où un parent peut avoir un ou plusieurs enfants, est utile
+ pour regrouper les Widgets avec Qt. Par exemple, si vous détruisez le parent,
+ tous ses enfants seront détruits égalament.
+
+
+ \snippet tutorials/addressbook/part1/addressbook.cpp constructor and input fields
+
+ à l'intérieur de ce constructeur, on déclare et instancie deux objets locaux
+ QLabel, \c nameLabel et \c addressLabel, de même on instancie \c nameLine et
+ \c addressText. La méthode \l{QObject::tr()}{tr()} renvoie une version traduite
+ de la chaîne de caractères, si elle existe; dans le cas contraire, elle renvoie
+ la chaîne elle même. On peut voir cette méthode comme un marqueur \tt{<insérer
+ la traduction ici>}, permettant de repérer les objets QString à considérer
+ pour traduire une application. Vous remarquerez, dans les chapitres à venir
+ comme dans les \l{Qt Examples}{exemples Qt}, qu'elle est utilisée chaque fois
+ que l'on utilise une chaîne susceptible d'être traduite.
+
+ Lorsque l'on programme avec Qt, il est utile de savoir comment fonctionnent les
+ agencements ou layouts. Qt fournit trois classes principales de layouts pour
+ contrôler le placement des widgets: QHBoxLayout, QVBoxLayout et QGridLayout.
+
+ \image addressbook-tutorial-part1-labeled-layout.png
+
+ On utilise un QGridLayout pour positionner nos labels et champs de saisie de manière
+ structurée. QGridLayout divise l'espace disponible en une grille, et place les
+ widgets dans les cellules que l'on spécifie par les numéros de ligne et de colonne.
+ Le diagramme ci-dessus présente les cellules et la position des widgets, et cette
+ organisation est obtenue à l'aide du code suivant:
+
+ \snippet tutorials/addressbook/part1/addressbook.cpp layout
+
+ On remarque que le label \c AddressLabel est positionné en utilisant Qt::AlignTop
+ comme argument optionnel. Ceci est destiné à assurer qu'il ne sera pas centré
+ verticalement dans la cellule (1,0). Pour un aperçu rapide des layouts de Qt,
+ consultez la section \l{Layout Management}.
+
+ Afin d'installer l'objet layout dans un widget, il faut appeler la méthode
+ \l{QWidget::setLayout()}{setLayout()} du widget en question:
+
+ \snippet tutorials/addressbook/part1/addressbook.cpp setting the layout
+
+ Enfin, on initialise le titre du widget à "Simple Address Book"
+
+ \section1 Exécution de l'application
+
+ Un fichier séparé, \c main.cpp, est utilisé pour la méthode \c main(). Dans cette
+ fonction, on crée une instance de QApplication, \c app. QApplication se charge de
+ des ressources communes à l'ensemble de l'application, tel que les polices de
+ caractères et le curseur par défaut, ainsi que de l'exécution de la boucle d'évènements.
+ De ce fait, il y a toujours un objet QApplication dans toute application graphique en Qt.
+
+ \snippet tutorials/addressbook/part1/main.cpp main function
+
+ On construit un nouveau widget \c AddressBook sur la pile et on invoque
+ sa méthode \l{QWidget::show()}{show()} pour l'afficher.
+ Cependant, le widget ne sera pas visible tant que la boucle d'évènements
+ n'aura pas été lancée. On démarre la boucle d'évènements en appelant la
+ méthode \l{QApplication::}{exec()} de l'application; le résultat renvoyé
+ par cette méthode est lui même utilisé comme valeur de retour pour la méthode
+ \c main().
+ On comprend maintenant pourquoi \c AddressBook a été créé sur la pile: à la fin
+ du programme, l'objet sort du scope de la fonction \c main() et tous ses widgets enfants
+ sont supprimés, assurant ainsi qu'il n'y aura pas de fuites de mémoire.
+*/
+
+/*!
+ \page tutorials-addressbook-fr-part2.html
+
+ \example tutorials/addressbook-fr/part2
+ \title Carnet d'adresses 2 - Ajouter des adresses
+
+ La prochaine étape pour créer notre carnet d'adresses est d'ajouter un soupçon
+ d'interactivité.
+
+ \image addressbook-tutorial-part2-add-contact.png
+
+ Nous allons fournir un bouton que l'utilisateur peut
+ cliquer pour ajouter un nouveau contact. Une structure de données est aussi
+ nécessaire afin de pouvoir stocker les contacts en mémoire.
+
+ \section1 Définition de la classe AddressBook
+
+ Maintenant que nous avons mis en place les labels et les champs de saisie,
+ nous ajoutons les boutons pour compléter le processus d'ajout d'un contact.
+ Cela veut dire que notre fichier \c addressbook.h a maintenant trois
+ objets QPushButton et trois slots publics correspondant.
+
+ \snippet tutorials/addressbook/part2/addressbook.h slots
+
+ Un slot est une méthode qui répond à un signal. Nous allons
+ voir ce concept en détail lorsque nous implémenterons la classe \c{AddressBook}.
+ Pour une explication détaillée du concept de signal et slot, vous pouvez
+ vous référer au document \l{Signals and Slots}.
+
+ Les trois objets QPushButton \c addButton, \c submitButton et \c cancelButton
+ sont maintenant inclus dans la déclaration des variables privées, avec
+ \c nameLine et \c addressText du chapitre précédent.
+
+ \snippet tutorials/addressbook/part2/addressbook.h pushbutton declaration
+
+ Nous avons besoin d'un conteneur pour stocker les contacts du carnet
+ d'adresses, de façon à pouvoir les énumérer et les afficher.
+ Un objet QMap, \c contacts, est utilisé pour ça, car il permet de stocker
+ des paires clé-valeur: le nom du contact est la \e{clé} et l'adresse du contact
+ est la \e{valeur}.
+
+ \snippet tutorials/addressbook/part2/addressbook.h remaining private variables
+
+ Nous déclarons aussi deux objects QString privés: \c oldName et \c oldAddress.
+ Ces objets sont nécessaires pour conserver le nom et l'adresse du dernier contact
+ affiché avant que l'utilisateur ne clique sur le bouton "Add". Grâce à ces variables
+ si l'utilisateur clique sur "Cancel", il est possible de revenir
+ à l'affichage du dernier contact.
+
+ \section1 Implémentation de la classe AddressBook
+
+ Dans le constructeur de \c AddressBook, \c nameLine et
+ \c addressText sont mis en mode lecture seule, de façon à autoriser l'affichage
+ mais pas la modification du contact courant.
+
+ \dots
+ \snippet tutorials/addressbook/part2/addressbook.cpp setting readonly 1
+ \dots
+ \snippet tutorials/addressbook/part2/addressbook.cpp setting readonly 2
+
+ Ensuite, nous instancions les boutons \c addButton, \c submitButton, et
+ \c cancelButton.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp pushbutton declaration
+
+ Le bouton \c addButton est affiché en invoquant la méthode \l{QPushButton::show()}
+ {show()}, tandis que \c submitButton et \c cancelButton sont cachés en invoquant
+ \l{QPushButton::hide()}{hide()}. Ces deux boutons ne seront affichés que lorsque
+ l'utilisateur cliquera sur "Add", et ceci est géré par la méthode \c addContact()
+ décrite plus loin.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp connecting signals and slots
+
+ Nous connectons le signal \l{QPushButton::clicked()}{clicked()} de chaque bouton
+ au slot qui gèrera l'action.
+ L'image ci-dessous illustre ceci:
+
+ \image addressbook-tutorial-part2-signals-and-slots.png
+
+ Ensuite, nous arrangeons proprement les boutons sur la droite du widget
+ AddressBook, et nous utilisons un QVBoxLayout pour les aligner verticalement.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp vertical layout
+
+ La methode \l{QBoxLayout::addStretch()}{addStretch()} est utilisée pour
+ assurer que les boutons ne sont pas répartis uniformément, mais regroupés
+ dans la partie supperieure du widget. La figure ci-dessous montre la différence
+ si \l{QBoxLayout::addStretch()}{addStretch()} est utilisé ou pas.
+
+ \image addressbook-tutorial-part2-stretch-effects.png
+
+ Ensuite nous ajoutons \c buttonLayout1 à \c mainLayout, en utilisant
+ \l{QGridLayout::addLayout()}{addLayout()}. Ceci nous permet d'imbriquer les
+ mises en page puisque \c buttonLayout1 est maintenant un enfant de \c mainLayout.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp grid layout
+
+ Les coordonnées du layout global ressemblent maintenant à ça:
+
+ \image addressbook-tutorial-part2-labeled-layout.png
+
+ Dans la méthode \c addContact(), nous stockons les détails du dernier
+ contact affiché dans \c oldName et \c oldAddress. Ensuite, nous
+ vidons ces champs de saisie et nous désactivons le mode
+ lecture seule. Le focus est placé sur \c nameLine et on affiche
+ \c submitButton et \c cancelButton.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp addContact
+
+ La méthode \c submitContact() peut être divisée en trois parties:
+
+ \list 1
+ \li Nous extrayons les détails du contact depuis \c nameLine et \c addressText
+ et les stockons dans des objets QString. Nous les validons pour s'assurer
+ que l'utilisateur n'a pas cliqué sur "Add" avec des champs de saisie
+ vides; sinon un message est affiché avec QMessageBox pour rappeller à
+ l'utilisateur que les deux champs doivent être complétés.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp submitContact part1
+
+ \li Ensuite, nous vérifions si le contact existe déjà. Si aucun contacts
+ existant n'entre en conflit avec le nouveau, nous l'ajoutons à
+ \c contacts et nous affichons un QMessageBox pour informer l'utilisateur
+ que le contact a été ajouté.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp submitContact part2
+
+ Si le contact existe déjà, nous affichons un QMessageBox pour informer
+ l'utilisateur du problème.
+ Notre objet \c contacts est basé sur des paires clé-valeur formés par
+ le nom et l'adresse, nous voulons nous assurer que la \e clé est unique.
+
+ \li Une fois que les deux vérifications précédentes ont été traitées,
+ nous restaurons les boutons à leur état normal à l'aide du code
+ suivant:
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp submitContact part3
+
+ \endlist
+
+ La capture d'écran ci-dessous montre l'affichage fournit par un objet
+ QMessageBox, utilisé ici pour afficher un message d'information
+ à l'utilisateur:
+
+ \image addressbook-tutorial-part2-add-successful.png
+
+ La méthode \c cancel() restaure les détails du dernier contact, active
+ \c addButton, et cache \c submitButton et \c cancelButton.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp cancel
+
+ L'idée générale pour augmenter la flexibilité lors de l'ajout d'un
+ contact est de donner la possiblité de cliquer sur "Add"
+ ou "Cancel" à n'importe quel moment.
+ L'organigramme ci-dessous reprend l'ensemble des interactions dévelopées
+ jusqu'ici:
+
+ \image addressbook-tutorial-part2-add-flowchart.png
+*/
+
+/*!
+ \page tutorials-addressbook-fr-part3.html
+
+ \example tutorials/addressbook-fr/part3
+ \title Carnet d'adresses 3 - Navigation entre les éléments
+
+ L'application "Carnet d'adresses" est maintenant à moitié terminée. Il
+ nous faut maintenant ajouter quelques fonctions pour naviguer entre
+ les contacts. Avant de commencer, il faut se décider sur le type de structure de
+ données le plus approprié pour stocker les contacts.
+
+ Dans le chapitre 2, nous avons utilisé un QMap utilisant des paires clé-valeur,
+ avec le nom du contact comme \e clé, et l'adresse du contact comme \e valeur.
+ Cela fonctionnait bien jusqu'ici, mais pour ajouter la navigation entre les
+ entrées, quelques améliorations sont nécessaires.
+
+ Nous améliorerons le QMap en le faisant ressembler à une structure de données
+ similaire à une liste liée, où tous les éléments sont connectés, y compris
+ le premier et le dernier élément. La figure ci-dessous illustre cette structure
+ de donnée.
+
+ \image addressbook-tutorial-part3-linkedlist.png
+
+ \section1 Définition de la classe AddressBook
+
+ Pour ajouter les fonctions de navigation au carnet d'adresses, nous avons
+ besoin de deux slots supplémentaires dans notre classe \c AddressBook:
+ \c next() et \c previous(). Ceux-ci sont ajoutés au fichier addressbook.h:
+
+ \snippet tutorials/addressbook/part3/addressbook.h navigation functions
+
+ Nous avons aussi besoin de deux nouveaux objets QPushButton, nous ajoutons
+ donc les variables privées \c nextButton et \c previousButton.
+
+ \snippet tutorials/addressbook/part3/addressbook.h navigation pushbuttons
+
+ \section1 Implémentation de la classe AddressBook
+
+ A l'intérieur du constructeur de \c AddressBook, dans \c addressbook.cpp, nous
+ instancions \c nextButton et \c previousButton et nous les désactivons
+ par défaut. Nous faisons ceci car la navigation ne doit être activée
+ que lorsqu'il y a plus d'un contact dans le carnet d'adresses.
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp navigation pushbuttons
+
+ Nous connectons alors ces boutons à leur slots respectifs:
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp connecting navigation signals
+
+ L'image ci-dessous montre l'interface utilisateur que nous allons créer.
+ Remarquez que cela ressemble de plus en plus à l'interface du programme
+ complet.
+
+ \image addressbook-tutorial-part3-screenshot.png
+
+ Nous suivons les conventions pour les fonctions \c next() et \c previous()
+ en plaçant \c nextButton à droite et \c previousButton à gauche. Pour
+ faire cette mise en page intuitive, nous utilisons un QHBoxLayout pour
+ placer les widgets côte à côte:
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp navigation layout
+
+ L'objet QHBoxLayout, \c buttonLayout2, est ensuite ajouté à \c mainLayout.
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp adding navigation layout
+
+ La figure ci-dessous montre les systèmes de coordonnées pour les widgets du
+ \c mainLayout.
+ \image addressbook-tutorial-part3-labeled-layout.png
+
+ Dans notre méthode \c addContact(), nous avons desactivé ces boutons
+ pour être sûr que l'utilisateur n'utilise pas la navigation lors de
+ l'ajout d'un contact.
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp disabling navigation
+
+ Dans notre méthode \c submitContact(), nous activons les boutons de
+ navigation, \c nextButton et \c previousButton, en fonction de la
+ taille de \c contacts. Commen mentionné plus tôt, la navigation n'est
+ activée que si il y a plus d'un contact dans le carnet d'adresses.
+ Les lignes suivantes montrent comment faire cela:
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp enabling navigation
+
+ Nous incluons aussi ces lignes de code dans le bouton \c cancel().
+
+ Souvenez vous que nous voulons émuler une liste-liée ciruculaire à
+ l'aide de l'objet QMap, \c contacts. Pour faire cela, nous obtenons un itérateur
+ sur \c contact dans la méthode \c next(), et ensuite:
+
+ \list
+ \li Si l'itérateur n'est pas à la fin de \c contacts, nous l'incrémentons
+ \li Si l'itérateur est à la fin de \c contacts, nous changeons sa position
+ jusqu'au début de \c contacts. Cela donne l'illusion que notre QMap
+ fonctionne comme une liste circulaire.
+ \endlist
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp next() function
+
+ Une fois que nous avons itéré jusqu'à l'objet recherché dans \c contacts,
+ nous affichons son contenu sur \c nameLine et \c addressText.
+
+ De la même façon, pour la méthode \c previous(), nous obtenons un
+ itérateur sur \c contacts et ensuite:
+
+ \list
+ \li Si l'itérateur est à la fin de \c contacts, on réinitialise
+ l'affichage et on retourne.
+ \li Si l'itérateur est au début de \c contacts, on change sa
+ position jusqu'à la fin
+ \li Ensuite, on décrémente l'itérateur
+ \endlist
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp previous() function
+
+ à nouveau, nous affichons le contenu de l'objet courant dans \c contacts.
+
+*/
+
+/*!
+
+ \page tutorials-addressbook-fr-part4.html
+
+ \example tutorials/addressbook-fr/part4
+ \title Carnet d'Adresses 4 - éditer et supprimer des adresses
+
+
+ Dans ce chapitre, nous verrons comment modifier les données des contacts
+ contenus dans l'application carnet d'adresses.
+
+
+ \image addressbook-tutorial-screenshot.png
+
+ Nous avons maintenant un carnet d'adresses qui ne se contente pas de
+ lister des contacts de façon ordonnée, mais permet également la
+ navigation. Il serait pratique d'inclure des fonctions telles qu'éditer et
+ supprimer, afin que les détails associés à un contact puissent être
+ modifiés lorsque c'est nécessaire. Cependant, cela requiert une légère
+ modification, sous la forme d'énumérations. Au chapitre précédent, nous avions deux
+ modes: \c {AddingMode} et \c {NavigationMode}, mais ils n'étaient pas
+ définis en tant qu'énumérations. Au lieu de ça, on activait et désactivait les
+ boutons correspondants manuellement, au prix de multiples redondances dans
+ le code.
+
+ Dans ce chapitre, on définit l'énumération \c Mode avec trois valeurs possibles.
+
+ \list
+ \li \c{NavigationMode},
+ \li \c{AddingMode}, et
+ \li \c{EditingMode}.
+ \endlist
+
+ \section1 Définition de la classe AddressBook
+
+ Le fichier \c addressbook.h est mis a jour pour contenir l'énumération \c Mode :
+
+ \snippet tutorials/addressbook/part4/addressbook.h Mode enum
+
+ On ajoute également deux nouveaux slots, \c editContact() et
+ \c removeContact(), à notre liste de slots publics.
+
+ \snippet tutorials/addressbook/part4/addressbook.h edit and remove slots
+
+ Afin de basculer d'un mode à l'autre, on introduit la méthode
+ \c updateInterface() pour contrôller l'activation et la désactivation de
+ tous les objets QPushButton. On ajoute également deux nouveaux boutons,
+ \c editButton et \c removeButton, pour les fonctions d'édition
+ et de suppression mentionnées plus haut.
+
+ \snippet tutorials/addressbook/part4/addressbook.h updateInterface() declaration
+ \dots
+ \snippet tutorials/addressbook/part4/addressbook.h buttons declaration
+ \dots
+ \snippet tutorials/addressbook/part4/addressbook.h mode declaration
+
+ Enfin, on déclare \c currentMode pour garder une trace du mode
+ actuellement utilisé.
+
+ \section1 Implémentation de la classe AddressBook
+
+ Il nous faut maintenant implémenter les fonctionnalités de changement de
+ mode de l'application carnet d'adresses. Les boutons \c editButton et
+ \c removeButton sont instanciés et désactivés par défaut, puisque le
+ carnet d'adresses démarre sans aucun contact en mémoire.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp edit and remove buttons
+
+ Ces boutons sont ensuite connectés à leurs slots respectifs,
+ \c editContact() et \c removeContact(), avant d'être ajoutés à
+ \c buttonLayout1.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp connecting edit and remove
+ \dots
+ \snippet tutorials/addressbook/part4/addressbook.cpp adding edit and remove to the layout
+
+ La methode \c editContact() place les anciens détails du contact dans
+ \c oldName et \c oldAddress, avant de basculer vers le mode
+ \c EditingMode. Dans ce mode, les boutons \c submitButton et
+ \c cancelButton sont tous deux activés, l'utilisateur peut par conséquent
+ modifier les détails du contact et cliquer sur l'un de ces deux boutons
+ par la suite.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp editContact() function
+
+ La méthode \c submitContact() a été divisée en deux avec un bloc
+ \c{if-else}. On teste \c currentMode pour voir si le mode courant est
+ \c AddingMode. Si c'est le cas, on procède à l'ajout.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp submitContact() function beginning
+ \dots
+ \snippet tutorials/addressbook/part4/addressbook.cpp submitContact() function part1
+
+ Sinon, on s'assure que \c currentMode est en \c EditingMode. Si c'est le
+ cas, on compare \c oldName et \c name. Si le nom a changé, on supprime
+ l'ancien contact de \c contacts et on insère le contact mis a jour.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp submitContact() function part2
+
+ Si seule l'adresse a changé (i.e. \c oldAddress n'est pas identique à
+ \c address), on met à jour l'adresse du contact. Enfin on règle
+ \c currentMode à \c NavigationMode. C'est une étape importante puisque
+ c'est cela qui réactive tous les boutons désactivés.
+
+ Afin de retirer un contact du carnet d'adresses, on implémente la méthode
+ \c removeContact(). Cette méthode vérifie que le contact est présent dans
+ \c contacts.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp removeContact() function
+
+ Si c'est le cas, on affiche une boîte de dialogue QMessageBox, demandant
+ confirmation de la suppression à l'utilisateur. Une fois la confirmation
+ effectuée, on appelle \c previous(), afin de s'assurer que l'interface
+ utilisateur affiche une autre entrée, et on supprime le contact en
+ utilisant le méthode \l{QMap::remove()}{remove()} de \l{QMap}. Dans un
+ souci pratique, on informe l'utilisateur de la suppression par le biais
+ d'une autre QMessageBox. Les deux boîtes de dialogue utilisées dans cette
+ méthode sont représentées ci-dessous.
+
+ \image addressbook-tutorial-part4-remove.png
+
+ \section2 Mise à jour de l'Interface utilisateur
+
+ On a évoqué plus haut la méthode \c updateInterface() comme moyen
+ d'activer et de désactiver les différents boutons de l'interface en
+ fonction du mode. Cette méthode met à jour le mode courant selon
+ l'argument \c mode qui lui est passé, en l'assignant à \c currentMode,
+ avant de tester sa valeur.
+
+ Chacun des boutons est ensuite activé ou désactivé, en fonction du mode.
+ Le code source pour les cas \c AddingMode et \c EditingMode est visible
+ ci-dessous:
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp update interface() part 1
+
+ Dans le cas de \c NavigationMode, en revanche, des tests conditionnels
+ sont passés en paramètre de QPushButton::setEnabled(). Ceci permet de
+ s'assurer que les boutons \c editButton et \c removeButton ne sont activés
+ que s'il existe au moins un contact dans le carnet d'adresses;
+ \c nextButton et \c previousButton ne sont activés que lorsqu'il existe
+ plus d'un contact dans le carnet d'adresses.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp update interface() part 2
+
+ En effectuant les opérations de réglage du mode et de mise à jour de
+ l'interface utilisateur au sein de la même méthode, on est à l'abri de
+ l'éventualité où l'interface utilisateur se "désynchronise" de l'état
+ interne de l'application.
+
+*/
+
+/*!
+ \page tutorials-addressbook-fr-part5.html
+
+ \example tutorials/addressbook-fr/part5
+ \title Carnet d'adresse 5 - Ajout d'une fonction de recherche
+
+ Dans ce chapitre, nous allons voir les possibilités pour rechercher
+ des contacts dans le carnet d'adresse.
+
+ \image addressbook-tutorial-part5-screenshot.png
+
+ Plus nous ajoutons des contacts dans l'application, plus
+ il devient difficile de naviguer avec les boutons \e Next et \e Previous.
+ Dans ce cas, une fonction de recherche serait plus efficace pour rechercher
+ les contacts.
+ La capture d'écran ci-dessus montre le bouton de recherche \e Find et sa position
+ dans le paneau de bouton.
+
+ Lorsque l'utilisateur clique sur le bouton \e Find, il est courant d'afficher
+ une boîte de dialogue qui demande à l'utilisateur d'entrer un nom de contact.
+ Qt fournit la classe QDialog, que nous sous-classons dans ce chapitre pour
+ implémenter la class \c FindDialog.
+
+ \section1 Définition de la classe FindDialog
+
+ \image addressbook-tutorial-part5-finddialog.png
+
+ Pour sous-classer QDialog, nous commençons par inclure le header de
+ QDialog dans le fichier \c finddialog.h. De plus, nous déclarons les
+ classes QLineEdit et QPushButton car nous utilisons ces widgets dans
+ notre classe dialogue.
+
+ Tout comme dans la classe \c AddressBook, la classe \c FindDialog utilise
+ la macro Q_OBJECT et son constructeur est défini de façon à accepter
+ un QWidget parent, même si cette boîte de dialogue sera affichée dans une
+ fenêtre séparée.
+
+ \snippet tutorials/addressbook/part5/finddialog.h FindDialog header
+
+ Nous définissons la méthode publique \c getFindText() pour être utilisée
+ par les classes qui instancient \c FindDialog, ce qui leur permet d'obtenir
+ le texte entré par l'utilisateur. Un slot public, \c findClicked(), est
+ défini pour prendre en charge le texte lorsque l'utilisateur clique sur
+ le bouton \gui Find.
+
+ Finalement, nous définissons les variables privées \c findButton,
+ \c lineEdit et \c findText, qui correspondent respectivement au bouton
+ \gui Find, au champ de texte dans lequel l'utilisateur tape le texte
+ à rechercher, et à une variable interne stockant le texte pour une
+ utilisation ultérieure.
+
+ \section1 Implémentation de la classe FindDialog
+
+ Dans le constructeur de \c FindDialog, nous instancions les objets des
+ variables privées \c lineEdit, \c findButton et \c findText. Nous utilisons ensuite
+ un QHBoxLayout pour positionner les widgets.
+
+ \snippet tutorials/addressbook/part5/finddialog.cpp constructor
+
+ Nous mettons en place la mise en page et le titre de la fenêtre, et
+ nous connectons les signaux aux slots. Remarquez que le signal
+ \l{QPushButton::clicked()}{clicked()} de \c{findButton} est connecté
+ à \c findClicked() et \l{QDialog::accept()}{accept()}. Le slot
+ \l{QDialog::accept()}{accept()} fourni par le QDialog ferme
+ la boîte de dialogue et lui donne le code de retour \l{QDialog::}{Accepted}.
+ Nous utilisons cette fonction pour aider la méthode \c findContact() de la classe
+ \c{AddressBook} à savoir si l'objet \c FindDialog a été fermé. Ceci sera
+ expliqué plus loin lorsque nous verrons la méthode \c findContact().
+
+ \image addressbook-tutorial-part5-signals-and-slots.png
+
+ Dans \c findClicked(), nous validons le champ de texte pour nous
+ assurer que l'utilisateur n'a pas cliqué sur le bouton \gui Find sans
+ avoir entré un nom de contact. Ensuite, nous stockons le texte du champ
+ d'entrée \c lineEdit dans \c findText. Et finalement nous vidons le
+ contenu de \c lineEdit et cachons la boîte de dialogue.
+
+ \snippet tutorials/addressbook/part5/finddialog.cpp findClicked() function
+
+ La variable \c findText a un accesseur publique associé: \c getFindText().
+ Étant donné que nous ne modifions \c findText directement que dans le
+ constructeur et la méthode \c findClicked(), nous ne créons pas
+ de manipulateurs associé à \c getFindText().
+ Puisque \c getFindText() est publique, les classes instanciant et
+ utilisant \c FindDialog peuvent toujours accéder à la chaîne de
+ caractères que l'utilisateur a entré et accepté.
+
+ \snippet tutorials/addressbook/part5/finddialog.cpp getFindText() function
+
+ \section1 Définition de la classe AddressBook
+
+ Pour utiliser \c FindDialog depuis la classe \c AddressBook, nous
+ incluons \c finddialog.h dans le fichier \c addressbook.h.
+
+ \snippet tutorials/addressbook/part5/addressbook.h include finddialog's header
+
+ Jusqu'ici, toutes les fonctionnalités du carnet d'adresses ont un
+ QPushButton et un slot correspondant. De la même façon, pour la
+ fonctionnalité \gui Find, nous avons \c findButton et \c findContact().
+
+ Le \c findButton est déclaré comme une variable privée et la
+ méthode \c findContact() est déclarée comme un slot public.
+
+ \snippet tutorials/addressbook/part5/addressbook.h findContact() declaration
+ \dots
+ \snippet tutorials/addressbook/part5/addressbook.h findButton declaration
+
+ Finalement, nous déclarons la variable privée \c dialog que nous allons
+ utiliser pour accéder à une instance de \c FindDialog.
+
+ \snippet tutorials/addressbook/part5/addressbook.h FindDialog declaration
+
+ Une fois que nous avons instancié la boîte de dialogue, nous voulons l'utiliser
+ plus qu'une fois. Utiliser une variable privée nous permet d'y référer
+ à plus d'un endroit dans la classe.
+
+ \section1 Implémentation de la classe AddressBook
+
+ Dans le constructeur de \c AddressBook, nous instancions nos objets privés,
+ \c findbutton et \c findDialog:
+
+ \snippet tutorials/addressbook/part5/addressbook.cpp instantiating findButton
+ \dots
+ \snippet tutorials/addressbook/part5/addressbook.cpp instantiating FindDialog
+
+ Ensuite, nous connectons le signal \l{QPushButton::clicked()}{clicked()} de
+ \c{findButton} à \c findContact().
+
+ \snippet tutorials/addressbook/part5/addressbook.cpp signals and slots for find
+
+ Maintenant, tout ce qui manque est le code de notre méthode \c findContact():
+
+ \snippet tutorials/addressbook/part5/addressbook.cpp findContact() function
+
+ Nous commençons par afficher l'instance de \c FindDialog, \c dialog.
+ L'utilisateur peut alors entrer le nom du contact à rechercher. Lorsque
+ l'utilisateur clique sur le bouton \c findButton, la boîte de dialogue est
+ masquée et le code de retour devient QDialog::Accepted. Ce code de retour
+ vient remplir la condition du premier if.
+
+ Ensuite, nous extrayons le texte que nous utiliserons pour la recherche,
+ il s'agit ici de \c contactName obtenu à l'aide de la méthode \c getFindText()
+ de \c FindDialog. Si le contact existe dans le carnet d'adresse, nous
+ l'affichons directement. Sinon, nous affichons le QMessageBox suivant pour
+ indiquer que la recherche à échouée.
+
+ \image addressbook-tutorial-part5-notfound.png
+*/
+
+/*!
+ \page tutorials-addressbook-part6.html
+
+ \example tutorials/addressbook-fr/part6
+ \title Carnet d'Adresses 6 - Sauvegarde et chargement
+
+ Ce chapitre couvre les fonctionnalités de gestion des fichiers de Qt que
+ l'on utilise pour écrire les procédures de sauvegarde et chargement pour
+ l'application carnet d'adresses.
+
+ \image addressbook-tutorial-part6-screenshot.png
+
+ Bien que la navigation et la recherche de contacts soient des
+ fonctionnalités importantes, notre carnet d'adresses ne sera pleinement
+ utilisable qu'une fois que l'on pourra sauvegarder les contacts existants
+ et les charger à nouveau par la suite.
+ Qt fournit de nombreuses classes pour gérer les \l{Input/Output and
+ Networking}{entrées et sorties}, mais nous avons choisi de nous contenter d'une
+ combinaison de deux classes simples à utiliser ensemble: QFile et QDataStream.
+
+ Un objet QFile représente un fichier sur le disque qui peut être lu, et
+ dans lequel on peut écrire. QFile est une classe fille de la classe plus
+ générique QIODevice, qui peut représenter différents types de
+ périphériques.
+
+ Un objet QDataStream est utilisé pour sérialiser des données binaires
+ dans le but de les passer à un QIODevice pour les récupérer dans le
+ futur. Pour lire ou écrire dans un QIODevice, il suffit d'ouvrir le
+ flux, avec le périphérique approprié en paramètre, et d'y lire ou
+ écrire.
+
+ \section1 Définition de la classe AddressBook
+
+ On déclare deux slots publics, \c saveToFile() et \c loadFromFile(),
+ ainsi que deux objets QPushButton, \c loadButton et \c saveButton.
+
+ \snippet tutorials/addressbook/part6/addressbook.h save and load functions declaration
+ \dots
+ \snippet tutorials/addressbook/part6/addressbook.h save and load buttons declaration
+
+ \section1 Implémentation de la classe AddressBook
+
+ Dans notre constructeur, on instancie \c loadButton et \c saveButton.
+ Idéalement, l'interface serait plus conviviale avec des boutons
+ affichant "Load contacts from a file" et "Save contacts to a file". Mais
+ compte tenu de la dimension des autres boutons, on initialise les labels
+ des boutons à \gui{Load...} et \gui{Save...}. Heureusement, Qt offre une
+ façon simple d'ajouter des info-bulles avec
+ \l{QWidget::setToolTip()}{setToolTip()}, et nous l'exploitons de la façon
+ suivante pour nos boutons:
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp tooltip 1
+ \dots
+ \snippet tutorials/addressbook/part6/addressbook.cpp tooltip 2
+
+ Bien qu'on ne cite pas le code correspondant ici, nous ajoutons ces deux boutons au
+ layout de droite, \c button1Layout, comme pour les fonctionnalités précédentes, et
+ nous connectons leurs signaux
+ \l{QPushButton::clicked()}{clicked()} à leurs slots respectifs.
+
+ Pour la sauvegarde, on commence par récupérer le nom de fichier
+ \c fileName, en utilisant QFileDialog::getSaveFileName(). C'est une
+ méthode pratique fournie par QFileDialog, qui ouvre une boîte de
+ dialogue modale et permet à l'utilisateur d'entrer un nom de fichier ou
+ de choisir un fichier \c{.abk} existant. Les fichiers \c{.abk}
+ correspondent à l'extension choisie pour la sauvegarde des contacts de
+ notre carnet d'adresses.
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part1
+
+ La boîte de dialogue affichée est visible sur la capture d'écran ci-
+ dessous.
+
+ \image addressbook-tutorial-part6-save.png
+
+ Si \c fileName n'est pas vide, on crée un objet QFile, \c file, à partir
+ de \c fileName. QFile fonctionne avec QDataStream puisqu'il dérive de
+ QIODevice.
+
+ Ensuite, on essaie d'ouvrir le fichier en écriture, ce qui correspond au
+ mode \l{QIODevice::}{WriteOnly}. Si cela échoue, on en informe
+ l'utilisateur avec une QMessageBox.
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part2
+
+ Dans le cas contraire, on instancie un objet QDataStream, \c out, afin
+ d'écrire dans le fichier ouvert. QDataStream nécessite que la même
+ version de flux soit utilisée pour la lecture et l'écriture. On s'assure
+ que c'est le cas en spécifiant explicitement d'utiliser la
+ \l{QDataStream::Qt_4_5}{version introduite avec Qt 4.5} avant de
+ sérialiser les données vers le fichier \c file.
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part3
+
+ Pour le chargement, on récupère également \c fileName en utilisant
+ QFileDialog::getOpenFileName(). Cette méthode est l'homologue de
+ QFileDialog::getSaveFileName() et affiche également une boîte de
+ dialogue modale permettant à l'utilisateur d'entrer un nom de fichier ou
+ de selectionner un fichier \c{.abk} existant, afin de le charger dans le
+ carnet d'adresses.
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part1
+
+ Sous Windows, par exemple, cette méthode affiche une boîte de dialogue
+ native pour la sélection de fichier, comme illustré sur la capture
+ d'écran suivante:
+
+ \image addressbook-tutorial-part6-load.png
+
+ Si \c fileName n'est pas vide, on utilise une fois de plus un objet
+ QFile, \c file, et on tente de l'ouvrir en lecture, avec le mode
+ \l{QIODevice::}{ReadOnly}. De même que précédemment dans notre
+ implémentation de \c saveToFile(), si cette tentative s'avère
+ infructueuse, on en informe l'utilisateur par le biais d'une
+ QMessageBox.
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part2
+
+ Dans le cas contraire, on instancie un objet QDataStream, \c in, en
+ spécifiant la version à utiliser comme précédemment, et on lit les
+ informations sérialisées vers la structure de données \c contacts. Notez
+ qu'on purge \c contacts avant d'y mettre les informations lues afin de
+ simplifier le processus de lecture de fichier. Une façon plus avancée de
+ procéder serait de lire les contacts dans un objet QMap temporaire, et
+ de copier uniquement les contacts n'existant pas encore dans
+ \c contacts.
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part3
+
+ Pour afficher les contacts lus depuis le fichier, on doit d'abord
+ valider les données obtenues afin de s'assurer que le fichier lu
+ contient effectivement des entrées de carnet d'adresses. Si c'est le
+ cas, on affiche le premier contact; sinon on informe l'utilisateur du
+ problème par une QMessageBox. Enfin, on met à jour l'interface afin
+ d'activer et de désactiver les boutons de façon appropriée.
+*/
+
+/*!
+ \page tutorials-addressbook-fr-part7.html
+
+ \example tutorials/addressbook-fr/part7
+ \title Carnet d'adresse 7 - Fonctionnalités avancées
+
+ Ce chapitre couvre quelques fonctionnalités additionnelles qui
+ feront de notre carnet d'adresses une application plus pratique
+ pour une utilisation quotidienne.
+
+ \image addressbook-tutorial-part7-screenshot.png
+
+ Bien que notre application carnet d'adresses soit utile en tant que telle,
+ il serait pratique de pouvoir échanger les contacts avec d'autres applications.
+ Le format vCard est un un format de fichier populaire pour échanger
+ ce type de données.
+ Dans ce chapitre, nous étendrons notre carnet d'adresses pour permettre
+ d'exporter des contacts dans des fichiers vCard \c{.vcf}.
+
+ \section1 Définition de la classe AddressBook
+
+ Nous ajoutons un objet QPushButton, \c exportButton, et un slot
+ public correspondant, \c exportAsVCard(), à notre classe \c AddressBook
+ dans le fichier \c addressbook.h.
+
+ \snippet tutorials/addressbook/part7/addressbook.h exportAsVCard() declaration
+ \dots
+ \snippet tutorials/addressbook/part7/addressbook.h exportButton declaration
+
+ \section1 Implémentation de la classe AddressBook
+
+ Dans le constructeur de \c AddressBook, nous connectons le signal
+ \l{QPushButton::clicked()}{clicked()} de \c{exportButton} au slot
+ \c exportAsVCard().
+ Nous ajoutons aussi ce bouton à \c buttonLayout1, le layout responsable
+ du groupe de boutons sur la droite.
+
+ Dans la méthode \c exportAsVCard(), nous commençons par extraire le
+ nom du contact dans \n name. Nous déclarons \c firstname, \c lastName et
+ \c nameList.
+ Ensuite, nous cherchons la position du premier espace blanc de \c name.
+ Si il y a un espace, nous séparons le nom du contact en \c firstName et
+ \c lastName. Finalement, nous remplaçons l'espace par un underscore ("_").
+ Si il n'y a pas d'espace, nous supposons que le contact ne comprend que
+ le prénom.
+
+ \snippet tutorials/addressbook/part7/addressbook.cpp export function part1
+
+ Comme pour la méthode \c saveToFile(), nous ouvrons une boîte de dialogue
+ pour donner la possibilité à l'utilisateur de choisir un emplacement pour
+ le fichier. Avec le nom de fichier choisi, nous créons une instance de QFile
+ pour y écrire.
+
+ Nous essayons d'ouvrir le fichier en mode \l{QIODevice::}{WriteOnly}. Si
+ cela échoue, nous affichons un QMessageBox pour informer l'utilisateur
+ à propos de l'origine du problème et nous quittons la méthode. Sinon, nous passons le
+ fichier comme paramètre pour créer un objet QTextStream, \c out. De la même façon que
+ QDataStream, la classe QTextStream fournit les fonctionnalités pour
+ lire et écrire des fichiers de texte. Grâce à celà, le fichier \c{.vcf}
+ généré pourra être ouvert et édité à l'aide d'un simple éditeur de texte.
+
+ \snippet tutorials/addressbook/part7/addressbook.cpp export function part2
+
+ Nous écrivons ensuite un fichier vCard avec la balise \c{BEGIN:VCARD},
+ suivit par \c{VERSION:2.1}.
+ Le nom d'un contact est écrit à l'aide de la balise \c{N:}. Pour la balise
+ \c{FN:}, qui remplit le titre du contact, nous devons vérifier si le contact
+ à un nom de famille défini ou non. Si oui, nous utilions les détails de
+ \c nameList pour remplir le champ, dans le cas contraire on écrit uniquement le contenu
+ de \c firstName.
+
+ \snippet tutorials/addressbook/part7/addressbook.cpp export function part3
+
+ Nous continuons en écrivant l'adresse du contact. Les points-virgules
+ dans l'adresse sont échappés à l'aide de "\\", les retours de ligne sont
+ remplacés par des points-virgules, et les vigules sont remplacées par des espaces.
+ Finalement nous écrivons les balises \c{ADR;HOME:;} suivies par l'adresse
+ et la balise \c{END:VCARD}.
+
+ \snippet tutorials/addressbook/part7/addressbook.cpp export function part4
+
+ À la fin de la méthode, un QMessageBox est affiché pour informer l'utilisateur
+ que la vCard a été exportée avec succès.
+
+ \e{vCard est une marque déposée de \l{http://www.imc.org}
+ {Internet Mail Consortium}}.
+*/
diff --git a/src/widgets/doc/src/addressbook.qdoc b/src/widgets/doc/src/addressbook.qdoc
new file mode 100644
index 0000000000..27bdb0fac4
--- /dev/null
+++ b/src/widgets/doc/src/addressbook.qdoc
@@ -0,0 +1,981 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page tutorials-addressbook.html
+
+ \title Address Book Tutorial
+ \brief An introduction to GUI programming, showing how to put together a
+ simple yet fully-functioning application.
+
+ This tutorial is an introduction to GUI programming with the Qt
+ cross-platform framework.
+
+ \image addressbook-tutorial-screenshot.png
+
+ \omit
+ It doesn't cover everything; the emphasis is on teaching the programming
+ philosophy of GUI programming, and Qt's features are introduced as needed.
+ Some commonly used features are never used in this tutorial.
+ \endomit
+
+ In this tutorial, you will learn about some of the basic
+ components of Qt, including:
+
+ \list
+ \li Widgets and layout managers
+ \li Container classes
+ \li Signals and slots
+ \li Input and output devices
+ \endlist
+
+ If you are new to Qt, we recommend reading \l{How to Learn Qt} first.
+
+ Tutorial contents:
+
+ \list 1
+ \li \l{tutorials/addressbook/part1}{Designing the User Interface}
+ \li \l{tutorials/addressbook/part2}{Adding Addresses}
+ \li \l{tutorials/addressbook/part3}{Navigating between Entries}
+ \li \l{tutorials/addressbook/part4}{Editing and Removing Addresses}
+ \li \l{tutorials/addressbook/part5}{Adding a Find Function}
+ \li \l{tutorials/addressbook/part6}{Loading and Saving}
+ \li \l{tutorials/addressbook/part7}{Additional Features}
+ \endlist
+
+ The tutorial source code is located in \c{examples/tutorials/addressbook}.
+
+ Although this little application does not look much like a
+ fully-fledged modern GUI application, it uses many of the basic
+ elements that are used in more complex applications. After you
+ have worked through this tutorial, we recommend reading the
+ \l{mainwindows/application}{Application} example, which presents a
+ small GUI application, with menus, toolbars, a status bar, and so
+ on.
+*/
+
+/*!
+ \page tutorials-addressbook-part1.html
+
+ \example tutorials/addressbook/part1
+ \title Part 1 - Designing the User Interface
+
+ This first part covers the design of the basic graphical user
+ interface (GUI) for our address book application.
+
+ The first step in creating a GUI program is to design the user
+ interface. Here the our goal is to set up the labels and input
+ fields to implement a basic address book. The figure below is a
+ screenshot of the expected output.
+
+ \image addressbook-tutorial-part1-screenshot.png
+
+ We require two QLabel objects, \c nameLabel and \c addressLabel, as well
+ as two input fields, a QLineEdit object, \c nameLine, and a QTextEdit
+ object, \c addressText, to enable the user to enter a contact's name and
+ address. The widgets used and their positions are shown in the figure
+ below.
+
+ \image addressbook-tutorial-part1-labeled-screenshot.png
+
+ There are three files used to implement this address book:
+
+ \list
+ \li \c{addressbook.h} - the definition file for the \c AddressBook
+ class,
+ \li \c{addressbook.cpp} - the implementation file for the
+ \c AddressBook class, and
+ \li \c{main.cpp} - the file containing a \c main() function, with
+ an instance of \c AddressBook.
+ \endlist
+
+ \section1 Qt Programming - Subclassing
+
+ When writing Qt programs, we usually subclass Qt objects to add
+ functionality. This is one of the essential concepts behind creating
+ custom widgets or collections of standard widgets. Subclassing to
+ extend or change the behavior of a widget has the following advantages:
+
+ \list
+ \li We can write implementations of virtual or pure virtual functions to
+ obtain exactly what we need, falling back on the base class's implementation
+ when necessary.
+ \li It allows us to encapsulate parts of the user interface within a class,
+ so that the other parts of the application don't need to know about the
+ individual widgets in the user interface.
+ \li The subclass can be used to create multiple custom widgets in the same
+ application or library, and the code for the subclass can be reused in other
+ projects.
+ \endlist
+
+ Since Qt does not provide a specific address book widget, we subclass a
+ standard Qt widget class and add features to it. The \c AddressBook class
+ we create in this tutorial can be reused in situations where a basic address
+ book widget is needed.
+
+ \section1 Defining the AddressBook Class
+
+ The \l{tutorials/addressbook/part1/addressbook.h}{\c addressbook.h} file is
+ used to define the \c AddressBook class.
+
+ We start by defining \c AddressBook as a QWidget subclass and declaring
+ a constructor. We also use the Q_OBJECT macro to indicate that the class
+ uses internationalization and Qt's signals and slots features, even
+ if we do not use all of these features at this stage.
+
+ \snippet tutorials/addressbook/part1/addressbook.h class definition
+
+ The class holds declarations of \c nameLine and \c addressText,
+ the private instances of QLineEdit and QTextEdit mentioned
+ earlier. The data stored in \c nameLine and \c addressText will
+ be needed for many of the address book functions.
+
+ We don't include declarations of the QLabel objects we will use
+ because we will not need to reference them once they have been
+ created. The way Qt tracks the ownership of objects is explained
+ in the next section.
+
+ The Q_OBJECT macro itself implements some of the more advanced features of Qt.
+ For now, it is useful to think of the Q_OBJECT macro as a shortcut which allows
+ us to use the \l{QObject::}{tr()} and \l{QObject::}{connect()} functions.
+
+ We have now completed the \c addressbook.h file and we move on to
+ implement the corresponding \c addressbook.cpp file.
+
+ \section1 Implementing the AddressBook Class
+
+ The constructor of \c AddressBook accepts a QWidget parameter, \a parent.
+ By convention, we pass this parameter to the base class's constructor.
+ This concept of ownership, where a parent can have one or more children,
+ is useful for grouping widgets in Qt. For example, if you delete a parent,
+ all of its children will be deleted as well.
+
+ \snippet tutorials/addressbook/part1/addressbook.cpp constructor and input fields
+
+ In this constructor, the QLabel objects \c nameLabel and \c
+ addressLabel are instantiated, as well as \c nameLine and \c
+ addressText. The \l{QObject::tr()}{tr()} function returns a
+ translated version of the string, if there is one
+ available. Otherwise it returns the string itself. This function
+ marks its QString parameter as one that should be translated into
+ other languages. It should be used wherever a translatable string
+ appears.
+
+ When programming with Qt, it is useful to know how layouts work.
+ Qt provides three main layout classes: QHBoxLayout, QVBoxLayout
+ and QGridLayout to handle the positioning of widgets.
+
+ \image addressbook-tutorial-part1-labeled-layout.png
+
+ We use a QGridLayout to position our labels and input fields in a
+ structured manner. QGridLayout divides the available space into a grid and
+ places widgets in the cells we specify with row and column numbers. The
+ diagram above shows the layout cells and the position of our widgets, and
+ we specify this arrangement using the following code:
+
+ \snippet tutorials/addressbook/part1/addressbook.cpp layout
+
+ Notice that \c addressLabel is positioned using Qt::AlignTop as an
+ additional argument. This is to make sure it is not vertically centered in
+ cell (1,0). For a basic overview on Qt Layouts, refer to the
+ \l{Layout Management} documentation.
+
+ In order to install the layout object onto the widget, we have to invoke
+ the widget's \l{QWidget::setLayout()}{setLayout()} function:
+
+ \snippet tutorials/addressbook/part1/addressbook.cpp setting the layout
+
+ Lastly, we set the widget's title to "Simple Address Book".
+
+ \section1 Running the Application
+
+ A separate file, \c main.cpp, is used for the \c main() function. Within
+ this function, we instantiate a QApplication object, \c app. QApplication
+ is responsible for various application-wide resources, such as the default
+ font and cursor, and for running an event loop. Hence, there is always one
+ QApplication object in every GUI application using Qt.
+
+ \snippet tutorials/addressbook/part1/main.cpp main function
+
+ We construct a new \c AddressBook widget on the stack and invoke
+ its \l{QWidget::show()}{show()} function to display it.
+ However, the widget will not be shown until the application's event loop
+ is started. We start the event loop by calling the application's
+ \l{QApplication::}{exec()} function; the result returned by this function
+ is used as the return value from the \c main() function. At this point,
+ it becomes apparent why we instanciated \c AddressBook on the stack: It
+ will now go out of scope. Therefore, \c AddressBook and all its child widgets
+ will be deleted, thus preventing memory leaks.
+*/
+
+/*!
+ \page tutorials-addressbook-part2.html
+
+ \example tutorials/addressbook/part2
+ \title Part 2 - Adding Addresses
+
+ The next step in creating the address book is to implement some
+ user interactions.
+
+ \image addressbook-tutorial-part2-add-contact.png
+
+ We will provide a push button that the user can click to add a new contact.
+ Also, some form of data structure is needed to store these contacts in an
+ organized way.
+
+ \section1 Defining the AddressBook Class
+
+ Now that we have the labels and input fields set up, we add push buttons to
+ complete the process of adding a contact. This means that our
+ \c addressbook.h file now has three QPushButton objects declared and three
+ corresponding public slots.
+
+ \snippet tutorials/addressbook/part2/addressbook.h slots
+
+ A slot is a function that responds to a particular signal. We will discuss
+ this concept in further detail when implementing the \c AddressBook class.
+ However, for an overview of Qt's signals and slots concept, you can refer
+ to the \l{Signals and Slots} document.
+
+ Three QPushButton objects (\c addButton, \c submitButton, and
+ \c cancelButton) are now included in our private variable declarations,
+ along with \c nameLine and \c addressText.
+
+ \snippet tutorials/addressbook/part2/addressbook.h pushbutton declaration
+
+ We need a container to store our address book contacts, so that we can
+ traverse and display them. A QMap object, \c contacts, is used for this
+ purpose as it holds a key-value pair: the contact's name as the \e key,
+ and the contact's address as the \e{value}.
+
+ \snippet tutorials/addressbook/part2/addressbook.h remaining private variables
+
+ We also declare two private QString objects, \c oldName and \c oldAddress.
+ These objects are needed to hold the name and address of the contact that
+ was last displayed, before the user clicked \gui Add. So, when the user clicks
+ \gui Cancel, we can revert to displaying the details of the last contact.
+
+ \section1 Implementing the AddressBook Class
+
+ Within the constructor of \c AddressBook, we set the \c nameLine and
+ \c addressText to read-only, so that we can only display but not edit
+ existing contact details.
+
+ \dots
+ \snippet tutorials/addressbook/part2/addressbook.cpp setting readonly 1
+ \dots
+ \snippet tutorials/addressbook/part2/addressbook.cpp setting readonly 2
+
+ Then, we instantiate our push buttons: \c addButton, \c submitButton, and
+ \c cancelButton.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp pushbutton declaration
+
+ The \c addButton is displayed by invoking the \l{QPushButton::show()}
+ {show()} function, while the \c submitButton and \c cancelButton are
+ hidden by invoking \l{QPushButton::hide()}{hide()}. These two push
+ buttons will only be displayed when the user clicks \gui Add and this is
+ handled by the \c addContact() function discussed below.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp connecting signals and slots
+
+ We connect the push buttons' \l{QPushButton::clicked()}{clicked()} signal
+ to their respective slots. The figure below illustrates this.
+
+ \image addressbook-tutorial-part2-signals-and-slots.png
+
+ Next, we arrange our push buttons neatly to the right of our address book
+ widget, using a QVBoxLayout to line them up vertically.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp vertical layout
+
+ The \l{QBoxLayout::addStretch()}{addStretch()} function is used to ensure
+ the push buttons are not evenly spaced, but arranged closer to the top of
+ the widget. The figure below shows the difference between using
+ \l{QBoxLayout::addStretch()}{addStretch()} and not using it.
+
+ \image addressbook-tutorial-part2-stretch-effects.png
+
+ We then add \c buttonLayout1 to \c mainLayout, using
+ \l{QGridLayout::addLayout()}{addLayout()}. This gives us nested layouts
+ as \c buttonLayout1 is now a child of \c mainLayout.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp grid layout
+
+ Our layout coordinates now look like this:
+
+ \image addressbook-tutorial-part2-labeled-layout.png
+
+ In the \c addContact() function, we store the last displayed contact
+ details in \c oldName and \c oldAddress. Then we clear these input
+ fields and turn off the read-only mode. The focus is set on \c nameLine
+ and we display \c submitButton and \c cancelButton.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp addContact
+
+ The \c submitContact() function can be divided into three parts:
+
+ \list 1
+ \li We extract the contact's details from \c nameLine and \c addressText
+ and store them in QString objects. We also validate to make sure that the
+ user did not click \gui Submit with empty input fields; otherwise, a
+ QMessageBox is displayed to remind the user for a name and address.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp submitContact part1
+
+ \li We then proceed to check if the contact already exists. If it does not
+ exist, we add the contact to \c contacts and we display a QMessageBox to
+ inform the user that the contact has been added.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp submitContact part2
+
+ If the contact already exists, again, we display a QMessageBox to inform
+ the user about this, preventing the user from adding duplicate contacts.
+ Our \c contacts object is based on key-value pairs of name and address,
+ hence, we want to ensure that \e key is unique.
+
+ \li Once we have handled both cases mentioned above, we restore the push
+ buttons to their normal state with the following code:
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp submitContact part3
+
+ \endlist
+
+ The screenshot below shows the QMessageBox object we use to display
+ information messages to the user.
+
+ \image addressbook-tutorial-part2-add-successful.png
+
+ The \c cancel() function restores the last displayed contact details and
+ enables \c addButton, as well as hides \c submitButton and
+ \c cancelButton.
+
+ \snippet tutorials/addressbook/part2/addressbook.cpp cancel
+
+ The general idea behind adding a contact is to give the user the
+ flexibility to click \gui Submit or \gui Cancel at any time. The flowchart below
+ further explains this concept:
+
+ \image addressbook-tutorial-part2-add-flowchart.png
+*/
+
+/*!
+ \page tutorials-addressbook-part3.html
+
+ \example tutorials/addressbook/part3
+ \title Part 3 - Navigating between Entries
+
+ The address book is now about half complete. We should add the
+ capability to navigate among the contacts, but first we must
+ decide what sort of a data structure we need for containing these
+ contacts.
+
+ In the previous section, we used a QMap of key-value pairs with
+ the contact's name as the \e key, and the contact's address as the
+ \e value. This works well for our case. However, in order to
+ navigate and display each entry, a little bit of enhancement is
+ needed.
+
+ We enhance the QMap by making it replicate a data structure similar to a
+ circularly-linked list, where all elements are connected, including the
+ first element and the last element. The figure below illustrates this data
+ structure.
+
+ \image addressbook-tutorial-part3-linkedlist.png
+
+ \section1 Defining the AddressBook Class
+
+ To add navigation functions to the address book, we must add two
+ more slots to the \c AddressBook class: \c next() and \c
+ previous() to the \c addressbook.h file:
+
+ \snippet tutorials/addressbook/part3/addressbook.h navigation functions
+
+ We also require another two QPushButton objects, so we declare \c nextButton
+ and \c previousButton as private variables:
+
+ \snippet tutorials/addressbook/part3/addressbook.h navigation pushbuttons
+
+ \section1 Implementing the AddressBook Class
+
+ In the \c AddressBook constructor in \c addressbook.cpp, we instantiate
+ \c nextButton and \c previousButton and disable them by default. This is
+ because navigation is only enabled when there is more than one contact
+ in the address book.
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp navigation pushbuttons
+
+ We then connect these push buttons to their respective slots:
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp connecting navigation signals
+
+ The image below is the expected graphical user interface.
+
+ \image addressbook-tutorial-part3-screenshot.png
+
+ We follow basic conventions for \c next() and \c previous() functions by
+ placing the \c nextButton on the right and the \c previousButton on the
+ left. In order to achieve this intuitive layout, we use QHBoxLayout to
+ place the widgets side-by-side:
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp navigation layout
+
+ The QHBoxLayout object, \c buttonLayout2, is then added to \c mainLayout.
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp adding navigation layout
+
+ The figure below shows the coordinates of the widgets in \c mainLayout.
+ \image addressbook-tutorial-part3-labeled-layout.png
+
+ Within our \c addContact() function, we have to disable these buttons so
+ that the user does not attempt to navigate while adding a contact.
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp disabling navigation
+
+ Also, in our \c submitContact() function, we enable the navigation
+ buttons, \c nextButton and \c previousButton, depending on the size
+ of \c contacts. As mentioned earlier, navigation is only enabled when
+ there is more than one contact in the address book. The following lines
+ of code demonstrates how to do this:
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp enabling navigation
+
+ We also include these lines of code in the \c cancel() function.
+
+ Recall that we intend to emulate a circularly-linked list with our QMap
+ object, \c contacts. So, in the \c next() function, we obtain an iterator
+ for \c contacts and then:
+
+ \list
+ \li If the iterator is not at the end of \c contacts, we increment it
+ by one.
+ \li If the iterator is at the end of \c contacts, we move it to the
+ beginning of \c contacts. This gives us the illusion that our QMap is
+ working like a circularly-linked list.
+ \endlist
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp next() function
+
+ Once we have iterated to the correct object in \c contacts, we display
+ its contents on \c nameLine and \c addressText.
+
+ Similarly, for the \c previous() function, we obtain an iterator for
+ \c contacts and then:
+
+ \list
+ \li If the iterator is at the end of \c contacts, we clear the
+ display and return.
+ \li If the iterator is at the beginning of \c contacts, we move it to
+ the end.
+ \li We then decrement the iterator by one.
+ \endlist
+
+ \snippet tutorials/addressbook/part3/addressbook.cpp previous() function
+
+ Again, we display the contents of the current object in \c contacts.
+
+*/
+
+/*!
+ \page tutorials-addressbook-part4.html
+
+ \example tutorials/addressbook/part4
+ \title Part 4 - Editing and Removing Addresses
+
+ Now we look at ways to modify the contents of contacts stored in
+ the address book.
+
+ \image addressbook-tutorial-screenshot.png
+
+ We now have an address book that not only holds contacts in an
+ organized manner, but also allows navigation. It would be
+ convenient to include edit and remove functions so that a
+ contact's details can be changed when needed. However, this
+ requires a little improvement, in the form of enums. We defined
+ two modes: \c{AddingMode} and \c{NavigationMode}, but they were
+ not defined as enum values. Instead, we enabled and disabled the
+ corresponding buttons manually, resulting in multiple lines of
+ repeated code.
+
+ Here we define the \c Mode enum with three different values:
+
+ \list
+ \li \c{NavigationMode},
+ \li \c{AddingMode}, and
+ \li \c{EditingMode}.
+ \endlist
+
+ \section1 Defining the AddressBook Class
+
+ The \c addressbook.h file is updated to contain the \c Mode enum:
+
+ \snippet tutorials/addressbook/part4/addressbook.h Mode enum
+
+ We also add two new slots, \c editContact() and \c removeContact(), to
+ our current list of public slots.
+
+ \snippet tutorials/addressbook/part4/addressbook.h edit and remove slots
+
+ In order to switch between modes, we introduce the \c updateInterface() function
+ to control the enabling and disabling of all QPushButton objects. We also
+ add two new push buttons, \c editButton and \c removeButton, for the edit
+ and remove functions mentioned earlier.
+
+ \snippet tutorials/addressbook/part4/addressbook.h updateInterface() declaration
+ \dots
+ \snippet tutorials/addressbook/part4/addressbook.h buttons declaration
+ \dots
+ \snippet tutorials/addressbook/part4/addressbook.h mode declaration
+
+ Lastly, we declare \c currentMode to keep track of the enum's current mode.
+
+ \section1 Implementing the AddressBook Class
+
+ We now implement the mode-changing features of the address
+ book. The \c editButton and \c removeButton are instantiated and
+ disabled by default. The address book starts with zero contacts
+ in memory.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp edit and remove buttons
+
+ These buttons are then connected to their respective slots, \c editContact()
+ and \c removeContact(), and we add them to \c buttonLayout1.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp connecting edit and remove
+ \dots
+ \snippet tutorials/addressbook/part4/addressbook.cpp adding edit and remove to the layout
+
+ The \c editContact() function stores the contact's old details in
+ \c oldName and \c oldAddress, before switching the mode to \c EditingMode.
+ In this mode, the \c submitButton and \c cancelButton are both enabled,
+ hence, the user can change the contact's details and click either button.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp editContact() function
+
+ The \c submitContact() function has been divided in two with an \c{if-else}
+ statement. We check \c currentMode to see if it's in \c AddingMode. If it is,
+ we proceed with our adding process.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp submitContact() function beginning
+ \dots
+ \snippet tutorials/addressbook/part4/addressbook.cpp submitContact() function part1
+
+ Otherwise, we check to see if \c currentMode is in \c EditingMode. If it
+ is, we compare \c oldName with \c name. If the name has changed, we remove
+ the old contact from \c contacts and insert the newly updated contact.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp submitContact() function part2
+
+ If only the address has changed (i.e., \c oldAddress is not the same as \c address),
+ we update the contact's address. Lastly, we set \c currentMode to
+ \c NavigationMode. This is an important step as it re-enables all the
+ disabled push buttons.
+
+ To remove a contact from the address book, we implement the
+ \c removeContact() function. This function checks to see if the contact
+ exists in \c contacts.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp removeContact() function
+
+ If it does, we display a QMessageBox, to confirm the removal with the
+ user. Once the user has confirmed, we call \c previous() to ensure that the
+ user interface shows another contact, and we remove the contact using \l{QMap}'s
+ \l{QMap::remove()}{remove()} function. As a courtesy, we display a QMessageBox
+ to inform the user. Both the message boxes used in this function are shown below:
+
+ \image addressbook-tutorial-part4-remove.png
+
+ \section2 Updating the User Interface
+
+ We mentioned the \c updateInterface() function earlier as a means to
+ enable and disable the push buttons depending on the current mode.
+ The function updates the current mode according to the \c mode argument
+ passed to it, assigning it to \c currentMode before checking its value.
+
+ Each of the push buttons is then enabled or disabled, depending on the
+ current mode. The code for \c AddingMode and \c EditingMode is shown below:
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp update interface() part 1
+
+ For \c NavigationMode, however, we include conditions within the parameters
+ of the QPushButton::setEnabled() function. This is to ensure that
+ \c editButton and \c removeButton are enabled when there is at least one
+ contact in the address book; \c nextButton and \c previousButton are only
+ enabled when there is more than one contact in the address book.
+
+ \snippet tutorials/addressbook/part4/addressbook.cpp update interface() part 2
+
+ By setting the mode and updating the user interface in the same
+ function, we avoid the possibility of the user interface getting
+ out of sync with the internal state of the application.
+ */
+
+/*!
+ \page tutorials-addressbook-part5.html
+
+ \example tutorials/addressbook/part5
+ \title Part 5 - Adding a Find Function
+
+ Here we look at ways to locate contacts and addresses in the
+ address book.
+
+ \image addressbook-tutorial-part5-screenshot.png
+
+ As we add contacts to our address book, it becomes tedious to
+ navigate the list with the \e Next and \e Previous buttons. A \e
+ Find function would be more efficient. The screenshot above shows
+ the \e Find button and its position on the panel of buttons.
+
+ When the user clicks on the \e Find button, it is useful to
+ display a dialog that prompts for a contact's name. Qt provides
+ QDialog, which we subclass here to implement a \c FindDialog
+ class.
+
+ \section1 Defining the FindDialog Class
+
+ \image addressbook-tutorial-part5-finddialog.png
+
+ In order to subclass QDialog, we first include the header for QDialog in
+ the \c finddialog.h file. Also, we use forward declaration to declare
+ QLineEdit and QPushButton since we will be using those widgets in our
+ dialog class.
+
+ As in our \c AddressBook class, the \c FindDialog class includes
+ the Q_OBJECT macro and its constructor is defined to accept a parent
+ QWidget, even though the dialog will be opened as a separate window.
+
+ \snippet tutorials/addressbook/part5/finddialog.h FindDialog header
+
+ We define a public function, \c getFindText(), to be used by classes that
+ instantiate \c FindDialog. This function allows these classes to obtain the
+ search string entered by the user. A public slot, \c findClicked(), is also
+ defined to handle the search string when the user clicks the \gui Find
+ button.
+
+ Lastly, we define the private variables, \c findButton, \c lineEdit
+ and \c findText, corresponding to the \gui Find button, the line edit
+ into which the user types the search string, and an internal string
+ used to store the search string for later use.
+
+ \section1 Implementing the FindDialog Class
+
+ Within the constructor of \c FindDialog, we set up the private variables,
+ \c lineEdit, \c findButton and \c findText. We use a QHBoxLayout to
+ position the widgets.
+
+ \snippet tutorials/addressbook/part5/finddialog.cpp constructor
+
+ We set the layout and window title, as well as connect the signals to their
+ respective slots. Notice that \c{findButton}'s \l{QPushButton::clicked()}
+ {clicked()} signal is connected to to \c findClicked() and
+ \l{QDialog::accept()}{accept()}. The \l{QDialog::accept()}{accept()} slot
+ provided by QDialog hides the dialog and sets the result code to
+ \l{QDialog::}{Accepted}. We use this function to help \c{AddressBook}'s
+ \c findContact() function know when the \c FindDialog object has been
+ closed. We will explain this logic in further detail when discussing the
+ \c findContact() function.
+
+ \image addressbook-tutorial-part5-signals-and-slots.png
+
+ In \c findClicked(), we validate \c lineEdit to ensure that the user
+ did not click the \gui Find button without entering a contact's name. Then, we set
+ \c findText to the search string, extracted from \c lineEdit. After that,
+ we clear the contents of \c lineEdit and hide the dialog.
+
+ \snippet tutorials/addressbook/part5/finddialog.cpp findClicked() function
+
+ The \c findText variable has a public getter function, \c getFindText(),
+ associated with it. Since we only ever set \c findText directly in both the
+ constructor and in the \c findClicked() function, we do not create a
+ setter function to accompany \c getFindText().
+ Because \c getFindText() is public, classes instantiating and using
+ \c FindDialog can always access the search string that the user has
+ entered and accepted.
+
+ \snippet tutorials/addressbook/part5/finddialog.cpp getFindText() function
+
+ \section1 Defining the AddressBook Class
+
+ To ensure we can use \c FindDialog from within our \c AddressBook class, we
+ include \c finddialog.h in the \c addressbook.h file.
+
+ \snippet tutorials/addressbook/part5/addressbook.h include finddialog's header
+
+ So far, all our address book features have a QPushButton and a
+ corresponding slot. Similarly, for the \gui Find feature we have
+ \c findButton and \c findContact().
+
+ The \c findButton is declared as a private variable and the
+ \c findContact() function is declared as a public slot.
+
+ \snippet tutorials/addressbook/part5/addressbook.h findContact() declaration
+ \dots
+ \snippet tutorials/addressbook/part5/addressbook.h findButton declaration
+
+ Lastly, we declare the private variable, \c dialog, which we will use to
+ refer to an instance of \c FindDialog.
+
+ \snippet tutorials/addressbook/part5/addressbook.h FindDialog declaration
+
+ Once we have instantiated a dialog, we will want to use it more than once;
+ using a private variable allows us to refer to it from more than one place
+ in the class.
+
+ \section1 Implementing the AddressBook Class
+
+ Within the \c AddressBook class's constructor, we instantiate our private
+ objects, \c findButton and \c findDialog:
+
+ \snippet tutorials/addressbook/part5/addressbook.cpp instantiating findButton
+ \dots
+ \snippet tutorials/addressbook/part5/addressbook.cpp instantiating FindDialog
+
+ Next, we connect the \c{findButton}'s
+ \l{QPushButton::clicked()}{clicked()} signal to \c findContact().
+
+ \snippet tutorials/addressbook/part5/addressbook.cpp signals and slots for find
+
+ Now all that is left is the code for our \c findContact() function:
+
+ \snippet tutorials/addressbook/part5/addressbook.cpp findContact() function
+
+ We start out by displaying the \c FindDialog instance, \c dialog. This is
+ when the user enters a contact name to look up. Once the user clicks
+ the dialog's \c findButton, the dialog is hidden and the result code is
+ set to QDialog::Accepted. This ensures that
+ our \c if statement is always true.
+
+ We then proceed to extract the search string, which in this case is
+ \c contactName, using \c{FindDialog}'s \c getFindText() function. If the
+ contact exists in our address book, we display it immediately. Otherwise,
+ we display the QMessageBox shown below to indicate that their search
+ failed.
+
+ \image addressbook-tutorial-part5-notfound.png
+*/
+
+/*!
+ \page tutorials-addressbook-part6.html
+
+ \example tutorials/addressbook/part6
+ \title Part 6 - Loading and Saving
+
+ This part covers the Qt file handling features we use to write
+ loading and saving routines for the address book.
+
+ \image addressbook-tutorial-part6-screenshot.png
+
+ Although browsing and searching the contact list are useful
+ features, our address book is not complete until we can save
+ existing contacts and load them again at a later time.
+
+ Qt provides a number of classes for \l{Input/Output and Networking}
+ {input and output}, but we have chosen to use two which are simple to use
+ in combination: QFile and QDataStream.
+
+ A QFile object represents a file on disk that can be read from and written
+ to. QFile is a subclass of the more general QIODevice class which
+ represents many different kinds of devices.
+
+ A QDataStream object is used to serialize binary data so that it can be
+ stored in a QIODevice and retrieved again later. Reading from a QIODevice
+ and writing to it is as simple as opening the stream - with the respective
+ device as a parameter - and reading from or writing to it.
+
+
+ \section1 Defining the AddressBook Class
+
+ We declare two public slots, \c saveToFile() and \c loadFromFile(), as well
+ as two QPushButton objects, \c loadButton and \c saveButton.
+
+ \snippet tutorials/addressbook/part6/addressbook.h save and load functions declaration
+ \dots
+ \snippet tutorials/addressbook/part6/addressbook.h save and load buttons declaration
+
+ \section1 Implementing the AddressBook Class
+
+ In our constructor, we instantiate \c loadButton and \c saveButton.
+ Ideally, it would be more user-friendly to set the push buttons' labels
+ to "Load contacts from a file" and "Save contacts to a file". However, due
+ to the size of our other push buttons, we set the labels to \gui{Load...}
+ and \gui{Save...}. Fortunately, Qt provides a simple way to set tooltips with
+ \l{QWidget::setToolTip()}{setToolTip()} and we use it in the following way
+ for our push buttons:
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp tooltip 1
+ \dots
+ \snippet tutorials/addressbook/part6/addressbook.cpp tooltip 2
+
+ Although it is not shown here, just like the other features we implemented,
+ we add the push buttons to the layout panel on the right, \c buttonLayout1,
+ and we connect the push buttons' \l{QPushButton::clicked()}{clicked()}
+ signals to their respective slots.
+
+ For the saving feature, we first obtain \c fileName using
+ QFileDialog::getSaveFileName(). This is a convenience function provided
+ by QFileDialog, which pops up a modal file dialog and allows the user to
+ enter a file name or select any existing \c{.abk} file. The \c{.abk} file
+ is our Address Book extension that we create when we save contacts.
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part1
+
+ The file dialog that pops up is displayed in the screenshot below:
+
+ \image addressbook-tutorial-part6-save.png
+
+ If \c fileName is not empty, we create a QFile object, \c file, with
+ \c fileName. QFile works with QDataStream as QFile is a QIODevice.
+
+ Next, we attempt to open the file in \l{QIODevice::}{WriteOnly} mode.
+ If this is unsuccessful, we display a QMessageBox to inform the user.
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part2
+
+ Otherwise, we instantiate a QDataStream object, \c out, to write the open
+ file. QDataStream requires that the same version of the stream is used
+ for reading and writing. We ensure that this is the case by setting the
+ version used to the \l{QDataStream::Qt_4_5}{version introduced with Qt 4.5}
+ before serializing the data to \c file.
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part3
+
+ For the loading feature, we also obtain \c fileName using
+ QFileDialog::getOpenFileName(). This function, the counterpart to
+ QFileDialog::getSaveFileName(), also pops up the modal file dialog and
+ allows the user to enter a file name or select any existing \c{.abk} file
+ to load it into the address book.
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part1
+
+ On Windows, for example, this function pops up a native file dialog, as
+ shown in the following screenshot.
+
+ \image addressbook-tutorial-part6-load.png
+
+ If \c fileName is not empty, again, we use a QFile object, \c file, and
+ attempt to open it in \l{QIODevice::}{ReadOnly} mode. Similar to our
+ implementation of \c saveToFile(), if this attempt is unsuccessful, we
+ display a QMessageBox to inform the user.
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part2
+
+ Otherwise, we instantiate a QDataStream object, \c in, set its version as
+ above and read the serialized data into the \c contacts data structure.
+ The \c contacts object is emptied before data is read into it to simplify
+ the file reading process. A more advanced method would be to read the
+ contacts into a temporary QMap object, and copy over non-duplicate contacts
+ into \c contacts.
+
+ \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part3
+
+ To display the contacts that have been read from the file, we must first
+ validate the data obtained to ensure that the file we read from actually
+ contains address book contacts. If it does, we display the first contact;
+ otherwise, we display a QMessageBox to inform the user about the problem.
+ Lastly, we update the interface to enable and disable the push buttons
+ accordingly.
+*/
+
+/*!
+ \page tutorials-addressbook-part7.html
+
+ \example tutorials/addressbook/part7
+ \title Part 7 - Additional Features
+
+ This part covers some additional features that make the address
+ book more convenient for the frequent user.
+
+ \image addressbook-tutorial-part7-screenshot.png
+
+ Although our address book is useful in isolation, it would be
+ better if we could exchange contact data with other applications.
+ The vCard format is a popular file format that can be used for
+ this purpose. Here we extend our address book client to allow
+ contacts to be exported to vCard \c{.vcf} files.
+
+ \section1 Defining the AddressBook Class
+
+ We add a QPushButton object, \c exportButton, and a corresponding public
+ slot, \c exportAsVCard() to our \c AddressBook class in the
+ \c addressbook.h file.
+
+ \snippet tutorials/addressbook/part7/addressbook.h exportAsVCard() declaration
+ \dots
+ \snippet tutorials/addressbook/part7/addressbook.h exportButton declaration
+
+ \section1 Implementing the AddressBook Class
+
+ Within the \c AddressBook constructor, we connect \c{exportButton}'s
+ \l{QPushButton::clicked()}{clicked()} signal to \c exportAsVCard().
+ We also add this button to our \c buttonLayout1, the layout responsible
+ for our panel of buttons on the right.
+
+ In our \c exportAsVCard() function, we start by extracting the contact's
+ name into \c name. We declare \c firstName, \c lastName and \c nameList.
+ Next, we look for the index of the first white space in \c name. If there
+ is a white space, we split the contact's name into \c firstName and
+ \c lastName. Then, we replace the space with an underscore ("_").
+ Alternately, if there is no white space, we assume that the contact only
+ has a first name.
+
+ \snippet tutorials/addressbook/part7/addressbook.cpp export function part1
+
+ As with the \c saveToFile() function, we open a file dialog to let the user
+ choose a location for the file. Using the file name chosen, we create an
+ instance of QFile to write to.
+
+ We attempt to open the file in \l{QIODevice::}{WriteOnly} mode. If this
+ process fails, we display a QMessageBox to inform the user about the
+ problem and return. Otherwise, we pass the file as a parameter to a
+ QTextStream object, \c out. Like QDataStream, the QTextStream class
+ provides functionality to read and write plain text to files. As a result,
+ the \c{.vcf} file generated can be opened for editing in a text editor.
+
+ \snippet tutorials/addressbook/part7/addressbook.cpp export function part2
+
+ We then write out a vCard file with the \c{BEGIN:VCARD} tag, followed by
+ the \c{VERSION:2.1} tag. The contact's name is written with the \c{N:}
+ tag. For the \c{FN:} tag, which fills in the "File as" property of a vCard,
+ we have to check whether the contact has a last name or not. If the contact
+ does, we use the details in \c nameList to fill it. Otherwise, we write
+ \c firstName only.
+
+ \snippet tutorials/addressbook/part7/addressbook.cpp export function part3
+
+ We proceed to write the contact's address. The semicolons in the address
+ are escaped with "\\", the newlines are replaced with semicolons, and the
+ commas are replaced with spaces. Lastly, we write the \c{ADR;HOME:;}
+ tag, followed by \c address and then the \c{END:VCARD} tag.
+
+ \snippet tutorials/addressbook/part7/addressbook.cpp export function part4
+
+ In the end, a QMessageBox is displayed to inform the user that the vCard
+ has been successfully exported.
+
+ \e{vCard is a trademark of the \l{http://www.imc.org}
+ {Internet Mail Consortium}}.
+*/
diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc
new file mode 100644
index 0000000000..0e48efbff8
--- /dev/null
+++ b/src/widgets/doc/src/model-view-programming.qdoc
@@ -0,0 +1,2339 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \group model-view
+ \title Model/View Classes
+*/
+
+/*!
+ \page model-view-programming.html
+ \ingroup qt-basic-concepts
+
+ \title Model/View Programming
+ \brief A guide to Qt's extensible model/view architecture.
+
+ \section1 Introduction to Model/View Programming
+
+ Qt 4 introduced a new set of item view classes that use a model/view
+ architecture to manage the relationship between data and the way it
+ is presented to the user. The separation of functionality introduced by
+ this architecture gives developers greater flexibility to customize the
+ presentation of items, and provides a standard model interface to allow
+ a wide range of data sources to be used with existing item views.
+ In this document, we give a brief introduction to the model/view paradigm,
+ outline the concepts involved, and describe the architecture of the item
+ view system. Each of the components in the architecture is explained,
+ and examples are given that show how to use the classes provided.
+
+ \section2 The model/view architecture
+
+ Model-View-Controller (MVC) is a design pattern originating from
+ Smalltalk that is often used when building user interfaces.
+ In \l{Design Patterns}, Gamma et al. write:
+
+ \quotation
+ MVC consists of three kinds of objects. The Model is the application
+ object, the View is its screen presentation, and the Controller defines
+ the way the user interface reacts to user input. Before MVC, user
+ interface designs tended to lump these objects together. MVC decouples
+ them to increase flexibility and reuse.
+ \endquotation
+
+ If the view and the controller objects are combined, the result is
+ the model/view architecture. This still separates the way that data
+ is stored from the way that it is presented to the user, but provides
+ a simpler framework based on the same principles. This separation
+ makes it possible to display the same data in several different views,
+ and to implement new types of views, without changing the underlying
+ data structures.
+ To allow flexible handling of user input, we introduce the concept of
+ the \e delegate. The advantage of having a delegate in this framework
+ is that it allows the way items of data are rendered and edited to be
+ customized.
+
+ \table
+ \row \li \inlineimage modelview-overview.png
+ \li \b{The model/view architecture}
+
+ The model communicates with a source of data, providing an \e interface
+ for the other components in the architecture. The nature of the
+ communication depends on the type of data source, and the way the model
+ is implemented.
+
+ The view obtains \e{model indexes} from the model; these are references
+ to items of data. By supplying model indexes to the model, the view can
+ retrieve items of data from the data source.
+
+ In standard views, a \e delegate renders the items of data. When an item
+ is edited, the delegate communicates with the model directly using
+ model indexes.
+ \endtable
+
+ Generally, the model/view classes can be separated into the three groups
+ described above: models, views, and delegates. Each of these components
+ is defined by \e abstract classes that provide common interfaces and,
+ in some cases, default implementations of features.
+ Abstract classes are meant to be subclassed in order to provide the full
+ set of functionality expected by other components; this also allows
+ specialized components to be written.
+
+ Models, views, and delegates communicate with each other using \e{signals
+ and slots}:
+
+ \list
+ \li Signals from the model inform the view about changes to the data
+ held by the data source.
+ \li Signals from the view provide information about the user's interaction
+ with the items being displayed.
+ \li Signals from the delegate are used during editing to tell the
+ model and view about the state of the editor.
+ \endlist
+
+ \section3 Models
+
+ All item models are based on the QAbstractItemModel class. This class
+ defines an interface that is used by views and delegates to access data.
+ The data itself does not have to be stored in the model; it can be held
+ in a data structure or repository provided by a separate class, a file,
+ a database, or some other application component.
+
+ The basic concepts surrounding models are presented in the section
+ on \l{Model Classes}.
+
+ QAbstractItemModel
+ provides an interface to data that is flexible enough to handle views
+ that represent data in the form of tables, lists, and trees. However,
+ when implementing new models for list and table-like data structures,
+ the QAbstractListModel and QAbstractTableModel classes are better
+ starting points because they provide appropriate default implementations
+ of common functions. Each of these classes can be subclassed to provide
+ models that support specialized kinds of lists and tables.
+
+ The process of subclassing models is discussed in the section on
+ \l{Creating New Models}.
+
+ Qt provides some ready-made models that can be used to handle items of
+ data:
+
+ \list
+ \li QStringListModel is used to store a simple list of QString items.
+ \li QStandardItemModel manages more complex tree structures of items, each
+ of which can contain arbitrary data.
+ \li QFileSystemModel provides information about files and directories in the
+ local filing system.
+ \li QSqlQueryModel, QSqlTableModel, and QSqlRelationalTableModel are used
+ to access databases using model/view conventions.
+ \endlist
+
+ If these standard models do not meet your requirements, you can subclass
+ QAbstractItemModel, QAbstractListModel, or QAbstractTableModel to create
+ your own custom models.
+
+ \section3 Views
+
+ Complete implementations are provided for different kinds of
+ views: QListView displays a list of items, QTableView displays data
+ from a model in a table, and QTreeView shows model items of data in a
+ hierarchical list. Each of these classes is based on the
+ QAbstractItemView abstract base class. Although these classes are
+ ready-to-use implementations, they can also be subclassed to provide
+ customized views.
+
+ The available views are examined in the section on \l{View Classes}.
+
+ \section3 Delegates
+
+ QAbstractItemDelegate is the abstract base class for delegates in the
+ model/view framework. Since Qt 4.4, the default delegate implementation is
+ provided by QStyledItemDelegate, and this is used as the default delegate
+ by Qt's standard views. However, QStyledItemDelegate and QItemDelegate are
+ independent alternatives to painting and providing editors for items in
+ views. The difference between them is that QStyledItemDelegate uses the
+ current style to paint its items. We therefore recommend using
+ QStyledItemDelegate as the base class when implementing custom delegates or
+ when working with Qt style sheets.
+
+ Delegates are described in the section on \l{Delegate Classes}.
+
+ \section3 Sorting
+
+ There are two ways of approaching sorting in the model/view
+ architecture; which approach to choose depends on your underlying
+ model.
+
+ If your model is sortable, i.e, if it reimplements the
+ QAbstractItemModel::sort() function, both QTableView and QTreeView
+ provide an API that allows you to sort your model data
+ programmatically. In addition, you can enable interactive sorting
+ (i.e. allowing the users to sort the data by clicking the view's
+ headers), by connecting the QHeaderView::sortIndicatorChanged() signal
+ to the QTableView::sortByColumn() slot or the
+ QTreeView::sortByColumn() slot, respectively.
+
+ The alternative approach, if your model do not have the required
+ interface or if you want to use a list view to present your data,
+ is to use a proxy model to transform the structure of your model
+ before presenting the data in the view. This is covered in detail
+ in the section on \l {Proxy Models}.
+
+ \section3 Convenience classes
+
+ A number of \e convenience classes are derived from the standard view
+ classes for the benefit of applications that rely on Qt's item-based
+ item view and table classes. They are not intended to be subclassed,
+ but simply exist to provide a familiar interface to the equivalent classes
+ in Qt 3.
+ Examples of such classes include \l QListWidget, \l QTreeWidget, and
+ \l QTableWidget; these provide similar behavior to the \c QListBox,
+ \c QListView, and \c QTable classes in Qt 3.
+
+ These classes are less flexible than the view classes, and cannot be
+ used with arbitrary models. We recommend that you use a model/view
+ approach to handling data in item views unless you strongly need an
+ item-based set of classes.
+
+ If you wish to take advantage of the features provided by the model/view
+ approach while still using an item-based interface, consider using view
+ classes, such as QListView, QTableView, and QTreeView with
+ QStandardItemModel.
+
+ \section1 Using models and views
+
+ The following sections explain how to use the model/view pattern
+ in Qt. Each section includes an an example and is followed by a
+ section showing how to create new components.
+
+ \section2 Two models included in Qt
+
+ Two of the standard models provided by Qt are QStandardItemModel and
+ QFileSystemModel. QStandardItemModel is a multi-purpose model that can be
+ used to represent various different data structures needed by list, table,
+ and tree views. This model also holds the items of data.
+ QFileSystemModel is a model that maintains information about the contents
+ of a directory. As a result, it does not hold any items of data itself, but
+ simply represents files and directories on the local filing system.
+
+ QFileSystemModel provides a ready-to-use model to experiment with, and can be
+ easily configured to use existing data. Using this model, we can show how
+ to set up a model for use with ready-made views, and explore how to
+ manipulate data using model indexes.
+
+ \section2 Using views with an existing model
+
+ The QListView and QTreeView classes are the most suitable views
+ to use with QFileSystemModel. The example presented below displays the
+ contents of a directory in a tree view next to the same information in
+ a list view. The views share the user's selection so that the selected
+ items are highlighted in both views.
+
+ \image shareddirmodel.png
+
+ We set up a QFileSystemModel so that it is ready for use, and create some
+ views to display the contents of a directory. This shows the simplest
+ way to use a model. The construction and use of the model is
+ performed from within a single \c main() function:
+
+ \snippet shareddirmodel/main.cpp 0
+
+ The model is set up to use data from a certain file system. The call to
+ \l{QFileSystemModel::}{setRootPath()} tell the model which drive on the
+ file system to expose to the views.
+
+ We create two views so that we can examine the items held in the model in two
+ different ways:
+
+ \snippet shareddirmodel/main.cpp 5
+
+ The views are constructed in the same way as other widgets. Setting up
+ a view to display the items in the model is simply a matter of calling its
+ \l{QAbstractItemView::setModel()}{setModel()} function with the directory
+ model as the argument. We filter the data supplied by the model by calling
+ the \l{QAbstractItemView::}{setRootIndex()} function on each view, passing
+ a suitable \e{model index} from the file system model for the current
+ directory.
+
+ The \c index() function used in this case is unique to QFileSystemModel; we
+ supply it with a directory and it returns a model index. Model indexes are
+ discussed in \l{Model Classes}.
+
+ The rest of the function just displays the views within a splitter
+ widget, and runs the application's event loop:
+
+ \snippet shareddirmodel/main.cpp 8
+
+ In the above example, we neglected to mention how to handle selections
+ of items. This subject is covered in more detail in the section about
+ \l{Handling Selections in Item Views}.
+
+ \section1 Model classes
+
+ Before examining how selections are handled, you may find it
+ useful to examine the concepts used in the model/view framework.
+
+ \section2 Basic concepts
+
+ In the model/view architecture, the model provides a standard interface
+ that views and delegates use to access data. In Qt, the standard
+ interface is defined by the QAbstractItemModel class. No matter how the
+ items of data are stored in any underlying data structure, all subclasses
+ of QAbstractItemModel represent the data as a hierarchical structure
+ containing tables of items. Views use this \e convention to access items
+ of data in the model, but they are not restricted in the way that they
+ present this information to the user.
+
+ \image modelview-models.png
+
+ Models also notify any attached views about changes to data through the
+ signals and slots mechanism.
+
+ This section describes some basic concepts that are central to the way
+ item of data are accessed by other components via a model class. More
+ advanced concepts are discussed in later sections.
+
+ \section3 Model indexes
+
+ To ensure that the representation of the data is kept separate from the
+ way it is accessed, the concept of a \e{model index} is introduced. Each
+ piece of information that can be obtained via a model is represented by
+ a model index. Views and delegates use these indexes to request items of
+ data to display.
+
+ As a result, only the model needs to know how to obtain data, and the type
+ of data managed by the model can be defined fairly generally. Model indexes
+ contain a pointer to the model that created them, and this prevents
+ confusion when working with more than one model.
+
+ \snippet code/doc_src_model-view-programming.cpp 0
+
+ Model indexes provide \e temporary references to pieces of information, and
+ can be used to retrieve or modify data via the model. Since models may
+ reorganize their internal structures from time to time, model indexes may
+ become invalid, and \e{should not be stored}. If a long-term reference to a
+ piece of information is required, a \e{persistent model index} must be
+ created. This provides a reference to the information that the model keeps
+ up-to-date. Temporary model indexes are provided by the QModelIndex class,
+ and persistent model indexes are provided by the QPersistentModelIndex
+ class.
+
+ To obtain a model index that corresponds to an item of data, three
+ properties must be specified to the model: a row number, a column number,
+ and the model index of a parent item. The following sections describe
+ and explain these properties in detail.
+
+ \section3 Rows and columns
+
+ In its most basic form, a model can be accessed as a simple table in which
+ items are located by their row and column numbers. \e{This does not mean
+ that the underlying pieces of data are stored in an array structure}; the
+ use of row and column numbers is only a convention to allow components to
+ communicate with each other. We can retrieve information about any given
+ item by specifying its row and column numbers to the model, and we receive
+ an index that represents the item:
+
+ \snippet code/doc_src_model-view-programming.cpp 1
+
+ Models that provide interfaces to simple, single level data structures like
+ lists and tables do not need any other information to be provided but, as
+ the above code indicates, we need to supply more information when obtaining
+ a model index.
+
+ \table
+ \row \li \inlineimage modelview-tablemodel.png
+ \li \b{Rows and columns}
+
+ The diagram shows a representation of a basic table model in which each
+ item is located by a pair of row and column numbers. We obtain a model
+ index that refers to an item of data by passing the relevant row and
+ column numbers to the model.
+
+ \snippet code/doc_src_model-view-programming.cpp 2
+
+ Top level items in a model are always referenced by specifying
+ \c QModelIndex() as their parent item. This is discussed in the next
+ section.
+ \endtable
+
+ \section3 Parents of items
+
+ The table-like interface to item data provided by models is ideal when
+ using data in a table or list view; the row and column number system maps
+ exactly to the way the views display items. However, structures such as
+ tree views require the model to expose a more flexible interface to the
+ items within. As a result, each item can also be the parent of another
+ table of items, in much the same way that a top-level item in a tree view
+ can contain another list of items.
+
+ When requesting an index for a model item, we must provide some information
+ about the item's parent. Outside the model, the only way to refer to an
+ item is through a model index, so a parent model index must also be given:
+
+ \snippet code/doc_src_model-view-programming.cpp 3
+
+ \table
+ \row \li \inlineimage modelview-treemodel.png
+ \li \b{Parents, rows, and columns}
+
+ The diagram shows a representation of a tree model in which each item is
+ referred to by a parent, a row number, and a column number.
+
+ Items "A" and "C" are represented as top-level siblings in the model:
+
+ \snippet code/doc_src_model-view-programming.cpp 4
+
+ Item "A" has a number of children. A model index for item "B" is
+ obtained with the following code:
+
+ \snippet code/doc_src_model-view-programming.cpp 5
+ \endtable
+
+ \section3 Item roles
+
+ Items in a model can perform various \e roles for other components,
+ allowing different kinds of data to be supplied for different situations.
+ For example, Qt::DisplayRole is used to access a string that can be
+ displayed as text in a view. Typically, items contain data for a number of
+ different roles, and the standard roles are defined by Qt::ItemDataRole.
+
+ We can ask the model for the item's data by passing it the model index
+ corresponding to the item, and by specifying a role to obtain the type
+ of data we want:
+
+ \snippet code/doc_src_model-view-programming.cpp 6
+
+ \table
+ \row \li \inlineimage modelview-roles.png
+ \li \b{Item roles}
+
+ The role indicates to the model which type of data is being referred to.
+ Views can display the roles in different ways, so it is important to
+ supply appropriate information for each role.
+
+ The \l{Creating New Models} section covers some specific uses of roles in
+ more detail.
+ \endtable
+
+ Most common uses for item data are covered by the standard roles defined in
+ Qt::ItemDataRole. By supplying appropriate item data for each role, models
+ can provide hints to views and delegates about how items should be
+ presented to the user. Different kinds of views have the freedom to
+ interpret or ignore this information as required. It is also possible to
+ define additional roles for application-specific purposes.
+
+ \section3 Summary
+
+ \list
+ \li Model indexes give views and delegates information about the location
+ of items provided by models in a way that is independent of any
+ underlying data structures.
+ \li Items are referred to by their row and column numbers, and by the model
+ index of their parent items.
+ \li Model indexes are constructed by models at the request of other
+ components, such as views and delegates.
+ \li If a valid model index is specified for the parent item when an index is
+ requested using \l{QAbstractItemModel::index()}{index()}, the index
+ returned refers to an item beneath that parent item in the model.
+ The index obtained refers to a child of that item.
+ \li If an invalid model index is specified for the parent item when an index
+ is requested using \l{QAbstractItemModel::index()}{index()}, the index
+ returned refers to a top-level item in the model.
+ \li The \l{Qt::ItemDataRole}{role} distinguishes between the
+ different kinds of data associated with an item.
+ \endlist
+
+ \section2 Using model indexes
+
+ To demonstrate how data can be retrieved from a model, using model
+ indexes, we set up a QFileSystemModel without a view and display the
+ names of files and directories in a widget.
+ Although this does not show a normal way of using a model, it demonstrates
+ the conventions used by models when dealing with model indexes.
+
+ We construct a file system model in the following way:
+
+ \snippet simplemodel-use/main.cpp 0
+
+ In this case, we set up a default QFileSystemModel, obtain a parent index
+ using a specific implementation of \l{QFileSystemModel::}{index()}
+ provided by that model, and we count the number of rows in the model using
+ the \l{QFileSystemModel::}{rowCount()} function.
+
+ For simplicity, we are only interested in the items in the first column
+ of the model. We examine each row in turn, obtaining a model index for
+ the first item in each row, and read the data stored for that item
+ in the model.
+
+ \snippet simplemodel-use/main.cpp 1
+
+ To obtain a model index, we specify the row number, column number (zero
+ for the first column), and the appropriate model index for the parent
+ of all the items that we want.
+ The text stored in each item is retrieved using the model's
+ \l{QFileSystemModel::}{data()} function. We specify the model index and
+ the \l{Qt::ItemDataRole}{DisplayRole} to obtain data for the
+ item in the form of a string.
+
+ \snippet simplemodel-use/main.cpp 2
+ \codeline
+ \snippet simplemodel-use/main.cpp 3
+
+ The above example demonstrates the basic principles used to retrieve
+ data from a model:
+
+ \list
+ \li The dimensions of a model can be found using
+ \l{QAbstractItemModel::rowCount()}{rowCount()} and
+ \l{QAbstractItemModel::columnCount()}{columnCount()}.
+ These functions generally require a parent model index to be
+ specified.
+ \li Model indexes are used to access items in the model. The row, column,
+ and parent model index are needed to specify the item.
+ \li To access top-level items in a model, specify a null model index
+ as the parent index with \c QModelIndex().
+ \li Items contain data for different roles. To obtain the data for a
+ particular role, both the model index and the role must be supplied
+ to the model.
+ \endlist
+
+ \section2 Further reading
+
+ New models can be created by implementing the standard interface
+ provided by QAbstractItemModel. In the \l{Creating New Models}
+ section, we demonstrate this by creating a convenient ready-to-use
+ model for holding lists of strings.
+
+ \section1 View classes
+
+ \section2 Concepts
+
+ In the model/view architecture, the view obtains items of data from the
+ model and presents them to the user. The way that the data is
+ presented need not resemble the representation of the data provided by
+ the model, and may be \e{completely different} from the underlying data
+ structure used to store items of data.
+
+ The separation of content and presentation is achieved by the use of a
+ standard model interface provided by QAbstractItemModel, a standard view
+ interface provided by QAbstractItemView, and the use of model indexes
+ that represent items of data in a general way.
+ Views typically manage the overall layout of the data obtained from
+ models. They may render individual items of data themselves, or use
+ \l{Delegate Classes}{delegates} to handle both rendering and editing
+ features.
+
+ As well as presenting data, views handle navigation between items,
+ and some aspects of item selection. The views also implement basic
+ user interface features, such as context menus and drag and drop.
+ A view can provide default editing facilities for items, or it may
+ work with a \l{Delegate Classes}{delegate} to provide a custom
+ editor.
+
+ A view can be constructed without a model, but a model must be
+ provided before it can display useful information. Views keep track of
+ the items that the user has selected through the use of
+ \l{Handling Selections in Item Views}{selections} which can be maintained
+ separately for each view, or shared between multiple views.
+
+ Some views, such as QTableView and QTreeView, display headers as well
+ as items. These are also implemented by a view class, QHeaderView.
+ Headers usually access the same model as the view that contains them.
+ They retrieve data from the model using the
+ \l{QAbstractItemModel::headerData()} function, and usually display
+ header information in the form of a label. New headers can be
+ subclassed from the QHeaderView class to provide more specialized
+ labels for views.
+
+ \section2 Using an existing view
+
+ Qt provides three ready-to-use view classes that present data from
+ models in ways that are familiar to most users.
+ QListView can display items from a model as a simple list, or in the
+ form of a classic icon view. QTreeView displays items from a
+ model as a hierarchy of lists, allowing deeply nested structures to be
+ represented in a compact way. QTableView presents items from a model
+ in the form of a table, much like the layout of a spreadsheet
+ application.
+
+ \image standard-views.png
+
+ The default behavior of the standard views shown above should be
+ sufficient for most applications. They provide basic editing
+ facilities, and can be customized to suit the needs of more specialized
+ user interfaces.
+
+ \section3 Using a model
+
+ We take the string list model that \l{Creating New Models}{we created as
+ an example model}, set it up with some data, and construct a view to
+ display the contents of the model. This can all be performed within a
+ single function:
+
+ \snippet stringlistmodel/main.cpp 0
+
+ Note that the \c StringListModel is declared as a \l QAbstractItemModel.
+ This allows us to use the abstract interface to the model, and
+ ensures that the code still works, even if we replace the string list
+ model with a different model.
+
+ The list view provided by \l QListView is sufficient for presenting
+ the items in the string list model. We construct the view, and set up
+ the model using the following lines of code:
+
+ \snippet stringlistmodel/main.cpp 2
+ \snippet stringlistmodel/main.cpp 4
+
+ The view is shown in the normal way:
+
+ \snippet stringlistmodel/main.cpp 5
+
+ The view renders the contents of a model, accessing data via the model's
+ interface. When the user tries to edit an item, the view uses a default
+ delegate to provide an editor widget.
+
+ \image stringlistmodel.png
+
+ The above image shows how a QListView represents the data in the string
+ list model. Since the model is editable, the view automatically allows
+ each item in the list to be edited using the default delegate.
+
+ \section3 Using multiple views of a model
+
+ Providing multiple views onto the same model is simply a matter of
+ setting the same model for each view. In the following code we create
+ two table views, each using the same simple table model which we have
+ created for this example:
+
+ \snippet sharedtablemodel/main.cpp 0
+ \codeline
+ \snippet sharedtablemodel/main.cpp 1
+
+ The use of signals and slots in the model/view architecture means that
+ changes to the model can be propagated to all the attached views,
+ ensuring that we can always access the same data regardless of the
+ view being used.
+
+ \image sharedmodel-tableviews.png
+
+ The above image shows two different views onto the same model, each
+ containing a number of selected items. Although the data from the model
+ is shown consistently across view, each view maintains its own internal
+ selection model. This can be useful in certain situations but, for
+ many applications, a shared selection model is desirable.
+
+ \section2 Handling selections of items
+
+ The mechanism for handling selections of items within views is provided
+ by the \l QItemSelectionModel class. All of the standard views construct
+ their own selection models by default, and interact with them in the
+ normal way. The selection model being used by a view can be obtained
+ through the \l{QAbstractItemView::selectionModel()}{selectionModel()}
+ function, and a replacement selection model can be specified with
+ \l{QAbstractItemView::setSelectionModel()}{setSelectionModel()}.
+ The ability to control the selection model used by a view is useful
+ when we want to provide multiple consistent views onto the same model
+ data.
+
+ Generally, unless you are subclassing a model or view, you don't
+ need to manipulate the contents of selections directly. However,
+ the interface to the selection model can be accessed, if required,
+ and this is explored in \l{Handling Selections in Item Views}.
+
+ \section3 Sharing selections among views
+
+ Although it is convenient that the view classes provide their own
+ selection models by default, when we use more than one view onto the
+ same model it is often desirable that both the model's data and the
+ user's selection are shown consistently in all views.
+ Since the view classes allow their internal selection models to be
+ replaced, we can achieve a unified selection between views with the
+ following line:
+
+ \snippet sharedtablemodel/main.cpp 2
+
+ The second view is given the selection model for the first view.
+ Both views now operate on the same selection model, keeping both
+ the data and the selected items synchronized.
+
+ \image sharedselection-tableviews.png
+
+ In the example shown above, two views of the same type were used to
+ display the same model's data. However, if two different types of view
+ were used, the selected items may be represented very differently in
+ each view; for example, a contiguous selection in a table view can be
+ represented as a fragmented set of highlighted items in a tree view.
+
+ \section1 Delegate classes
+
+ \section2 Concepts
+
+ Unlike the Model-View-Controller pattern, the model/view design does not
+ include a completely separate component for managing interaction with
+ the user. Generally, the view is responsible for the presentation of
+ model data to the user, and for processing user input. To allow some
+ flexibility in the way this input is obtained, the interaction is
+ performed by delegates. These components provide input capabilities
+ and are also responsible for rendering individual items in some views.
+ The standard interface for controlling delegates is defined in the
+ \l QAbstractItemDelegate class.
+
+ Delegates are expected to be able to render their contents themselves
+ by implementing the \l{QItemDelegate::paint()}{paint()}
+ and \l{QItemDelegate::sizeHint()}{sizeHint()} functions.
+ However, simple widget-based delegates can subclass \l QItemDelegate
+ instead of \l QAbstractItemDelegate, and take advantage of the default
+ implementations of these functions.
+
+ Editors for delegates can be implemented either by using widgets to manage
+ the editing process or by handling events directly.
+ The first approach is covered later in this section, and it is also
+ shown in the \l{Spin Box Delegate Example}{Spin Box Delegate} example.
+
+ The \l{Pixelator Example}{Pixelator} example shows how to create a
+ custom delegate that performs specialized rendering for a table view.
+
+ \section2 Using an existing delegate
+
+ The standard views provided with Qt use instances of \l QItemDelegate
+ to provide editing facilities. This default implementation of the
+ delegate interface renders items in the usual style for each of the
+ standard views: \l QListView, \l QTableView, and \l QTreeView.
+
+ All the standard roles are handled by the default delegate used by
+ the standard views. The way these are interpreted is described in the
+ QItemDelegate documentation.
+
+ The delegate used by a view is returned by the
+ \l{QAbstractItemView::itemDelegate()}{itemDelegate()} function.
+ The \l{QAbstractItemView::setItemDelegate()}{setItemDelegate()} function
+ allows you to install a custom delegate for a standard view, and it is
+ necessary to use this function when setting the delegate for a custom
+ view.
+
+ \section2 A simple delegate
+
+ The delegate implemented here uses a \l QSpinBox to provide
+ editing facilities, and is mainly intended for use with models
+ that display integers. Although we set up a custom integer-based
+ table model for this purpose, we could easily have used \l
+ QStandardItemModel instead, since the custom delegate controls
+ data entry. We construct a table view to display the contents of
+ the model, and this will use the custom delegate for editing.
+
+ \image spinboxdelegate-example.png
+
+ We subclass the delegate from \l QItemDelegate because we do not want
+ to write custom display functions. However, we must still provide
+ functions to manage the editor widget:
+
+ \snippet itemviews/spinboxdelegate/delegate.h 0
+
+ Note that no editor widgets are set up when the delegate is
+ constructed. We only construct an editor widget when it is needed.
+
+ \section3 Providing an editor
+
+ In this example, when the table view needs to provide an editor, it
+ asks the delegate to provide an editor widget that is appropriate
+ for the item being modified. The
+ \l{QAbstractItemDelegate::createEditor()}{createEditor()} function is
+ supplied with everything that the delegate needs to be able to set up
+ a suitable widget:
+
+ \snippet itemviews/spinboxdelegate/delegate.cpp 1
+
+ Note that we do not need to keep a pointer to the editor widget because
+ the view takes responsibility for destroying it when it is no longer
+ needed.
+
+ We install the delegate's default event filter on the editor to ensure
+ that it provides the standard editing shortcuts that users expect.
+ Additional shortcuts can be added to the editor to allow more
+ sophisticated behavior; these are discussed in the section on
+ \l{#EditingHints}{Editing Hints}.
+
+ The view ensures that the editor's data and geometry are set
+ correctly by calling functions that we define later for these purposes.
+ We can create different editors depending on the model index supplied
+ by the view. For example, if we have a column of integers and a column
+ of strings we could return either a \c QSpinBox or a \c QLineEdit,
+ depending on which column is being edited.
+
+ The delegate must provide a function to copy model data into the
+ editor. In this example, we read the data stored in the
+ \l{Qt::ItemDataRole}{display role}, and set the value in the
+ spin box accordingly.
+
+ \snippet itemviews/spinboxdelegate/delegate.cpp 2
+
+ In this example, we know that the editor widget is a spin box, but we
+ could have provided different editors for different types of data in
+ the model, in which case we would need to cast the widget to the
+ appropriate type before accessing its member functions.
+
+ \section3 Submitting data to the model
+
+ When the user has finished editing the value in the spin box, the view
+ asks the delegate to store the edited value in the model by calling the
+ \l{QAbstractItemDelegate::setModelData()}{setModelData()} function.
+
+ \snippet itemviews/spinboxdelegate/delegate.cpp 3
+
+ Since the view manages the editor widgets for the delegate, we only
+ need to update the model with the contents of the editor supplied.
+ In this case, we ensure that the spin box is up-to-date, and update
+ the model with the value it contains using the index specified.
+
+ The standard \l QItemDelegate class informs the view when it has
+ finished editing by emitting the
+ \l{QAbstractItemDelegate::closeEditor()}{closeEditor()} signal.
+ The view ensures that the editor widget is closed and destroyed. In
+ this example, we only provide simple editing facilities, so we need
+ never emit this signal.
+
+ All the operations on data are performed through the interface
+ provided by \l QAbstractItemModel. This makes the delegate mostly
+ independent from the type of data it manipulates, but some
+ assumptions must be made in order to use certain types of
+ editor widgets. In this example, we have assumed that the model
+ always contains integer values, but we can still use this
+ delegate with different kinds of models because \l{QVariant}
+ provides sensible default values for unexpected data.
+
+ \section3 Updating the editor's geometry
+
+ It is the responsibility of the delegate to manage the editor's
+ geometry. The geometry must be set when the editor is created, and
+ when the item's size or position in the view is changed. Fortunately,
+ the view provides all the necessary geometry information inside a
+ \l{QStyleOptionViewItem}{view option} object.
+
+ \snippet itemviews/spinboxdelegate/delegate.cpp 4
+
+ In this case, we just use the geometry information provided by the
+ view option in the item rectangle. A delegate that renders items with
+ several elements would not use the item rectangle directly. It would
+ position the editor in relation to the other elements in the item.
+
+ \target EditingHints
+ \section3 Editing hints
+
+ After editing, delegates should provide hints to the other components
+ about the result of the editing process, and provide hints that will
+ assist any subsequent editing operations. This is achieved by
+ emitting the \l{QAbstractItemDelegate::closeEditor()}{closeEditor()}
+ signal with a suitable hint. This is taken care of by the default
+ QItemDelegate event filter which we installed on the spin box when
+ it was constructed.
+
+ The behavior of the spin box could be adjusted to make it more user
+ friendly. In the default event filter supplied by QItemDelegate, if
+ the user hits \key Return to confirm their choice in the spin box,
+ the delegate commits the value to the model and closes the spin box.
+ We can change this behavior by installing our own event filter on the
+ spin box, and provide editing hints that suit our needs; for example,
+ we might emit \l{QAbstractItemDelegate::closeEditor()}{closeEditor()}
+ with the \l{QAbstractItemDelegate::EndEditHint}{EditNextItem} hint to
+ automatically start editing the next item in the view.
+
+ Another approach that does not require the use of an event
+ filter is to provide our own editor widget, perhaps subclassing
+ QSpinBox for convenience. This alternative approach would give us
+ more control over how the editor widget behaves at the cost of
+ writing additional code. It is usually easier to install an event
+ filter in the delegate if you need to customize the behavior of
+ a standard Qt editor widget.
+
+ Delegates do not have to emit these hints, but those that do not will
+ be less integrated into applications, and will be less usable than
+ those that emit hints to support common editing actions.
+
+ \section1 Handling selections in item views
+
+ \section2 Concepts
+
+ The selection model used in the item view classes offers many improvements
+ over the selection model used in Qt 3. It provides a more general
+ description of selections based on the facilities of the model/view
+ architecture. Although the standard classes for manipulating selections are
+ sufficient for the item views provided, the selection model allows you to
+ create specialized selection models to suit the requirements for your own
+ item models and views.
+
+ Information about the items selected in a view is stored in an instance of
+ the \l QItemSelectionModel class. This maintains model indexes for items in
+ a single model, and is independent of any views. Since there can be many
+ views onto a model, it is possible to share selections between views,
+ allowing applications to show multiple views in a consistent way.
+
+ Selections are made up of \e{selection ranges}. These efficiently maintain
+ information about large selections of items by recording only the starting
+ and ending model indexes for each range of selected items. Non-contiguous
+ selections of items are constructed by using more than one selection range
+ to describe the selection.
+
+ Selections are applied to a collection of model indexes held by a selection
+ model. The most recent selection of items applied is known as the
+ \e{current selection}. The effects of this selection can be modified even
+ after its application through the use of certain types of selection
+ commands. These are discussed later in this section.
+
+ \section3 Current item and selected items
+
+ In a view, there is always a current item and a selected item - two
+ independent states. An item can be the current item and selected at the
+ same time. The view is responsible for ensuring that there is always a
+ current item as keyboard navigation, for example, requires a current item.
+
+ The table below highlights the differences between current item and
+ selected items.
+
+ \table
+ \header
+ \li Current Item
+ \li Selected Items
+
+ \row
+ \li There can only be one current item.
+ \li There can be multiple selected items.
+ \row
+ \li The current item will be changed with key navigation or mouse
+ button clicks.
+ \li The selected state of items is set or unset, depending on several
+ pre-defined modes - e.g., single selection, multiple selection,
+ etc. - when the user interacts with the items.
+ \row
+ \li The current item will be edited if the edit key, \uicontrol F2, is
+ pressed or the item is double-clicked (provided that editing is
+ enabled).
+ \li The current item can be used together with an anchor to specify a
+ range that should be selected or deselected (or a combination of
+ the two).
+ \row
+ \li The current item is indicated by the focus rectangle.
+ \li The selected items are indicated with the selection rectangle.
+ \endtable
+
+ When manipulating selections, it is often helpful to think of
+ \l QItemSelectionModel as a record of the selection state of all the items
+ in an item model. Once a selection model is set up, collections of items
+ can be selected, deselected, or their selection states can be toggled
+ without the need to know which items are already selected. The indexes of
+ all selected items can be retrieved at any time, and other components can
+ be informed of changes to the selection model via the signals and slots
+ mechanism.
+
+ \section2 Using a selection model
+
+ The standard view classes provide default selection models that can
+ be used in most applications. A selection model belonging to one view
+ can be obtained using the view's
+ \l{QAbstractItemView::selectionModel()}{selectionModel()} function,
+ and shared between many views with
+ \l{QAbstractItemView::setSelectionModel()}{setSelectionModel()},
+ so the construction of new selection models is generally not required.
+
+ A selection is created by specifying a model, and a pair of model
+ indexes to a \l QItemSelection. This uses the indexes to refer to items
+ in the given model, and interprets them as the top-left and bottom-right
+ items in a block of selected items.
+ To apply the selection to items in a model requires the selection to be
+ submitted to a selection model; this can be achieved in a number of ways,
+ each having a different effect on the selections already present in the
+ selection model.
+
+ \section3 Selecting items
+
+ To demonstrate some of the principal features of selections, we construct
+ an instance of a custom table model with 32 items in total, and open a
+ table view onto its data:
+
+ \snippet itemselection/main.cpp 0
+
+ The table view's default selection model is retrieved for later use.
+ We do not modify any items in the model, but instead select a few
+ items that the view will display at the top-left of the table. To do
+ this, we need to retrieve the model indexes corresponding to the
+ top-left and bottom-right items in the region to be selected:
+
+ \snippet itemselection/main.cpp 1
+
+ To select these items in the model, and see the corresponding change
+ in the table view, we need to construct a selection object then apply
+ it to the selection model:
+
+ \snippet itemselection/main.cpp 2
+
+ The selection is applied to the selection model using a command
+ defined by a combination of
+ \l{QItemSelectionModel::SelectionFlag}{selection flags}.
+ In this case, the flags used cause the items recorded in the
+ selection object to be included in the selection model, regardless
+ of their previous state. The resulting selection is shown by the view.
+
+ \image selected-items1.png
+
+ The selection of items can be modified using various operations that
+ are defined by the selection flags. The selection that results from
+ these operations may have a complex structure, but it is represented
+ efficiently by the selection model. The use of different selection
+ flags to manipulate the selected items is described when we examine
+ how to update a selection.
+
+ \section3 Reading the selection state
+
+ The model indexes stored in the selection model can be read using
+ the \l{QItemSelectionModel::selectedIndexes()}{selectedIndexes()}
+ function. This returns an unsorted list of model indexes that we can
+ iterate over as long as we know which model they are for:
+
+ \snippet reading-selections/window.cpp 0
+
+ The above code uses Qt's convenient \l{Container Classes}{foreach
+ keyword} to iterate over, and modify, the items corresponding to the
+ indexes returned by the selection model.
+
+ The selection model emits signals to indicate changes in the
+ selection. These notify other components about changes to both the
+ selection as a whole and the currently focused item in the item
+ model. We can connect the
+ \l{QItemSelectionModel::selectionChanged()}{selectionChanged()}
+ signal to a slot, and examine the items in the model that are selected or
+ deselected when the selection changes. The slot is called with two
+ \l{QItemSelection} objects: one contains a list of indexes that
+ correspond to newly selected items; the other contains indexes that
+ correspond to newly deselected items.
+
+ In the following code, we provide a slot that receives the
+ \l{QItemSelectionModel::selectionChanged()}{selectionChanged()}
+ signal, fills in the selected items with
+ a string, and clears the contents of the deselected items.
+
+ \snippet updating-selections/window.cpp 0
+ \snippet updating-selections/window.cpp 1
+ \codeline
+ \snippet updating-selections/window.cpp 2
+
+ We can keep track of the currently focused item by connecting the
+ \l{QItemSelectionModel::currentChanged()}{currentChanged()} signal
+ to a slot that is called with two model indexes. These correspond to
+ the previously focused item, and the currently focused item.
+
+ In the following code, we provide a slot that receives the
+ \l{QItemSelectionModel::currentChanged()}{currentChanged()} signal,
+ and uses the information provided to update the status bar of a
+ \l QMainWindow:
+
+ \snippet updating-selections/window.cpp 3
+
+ Monitoring selections made by the user is straightforward with these
+ signals, but we can also update the selection model directly.
+
+ \section3 Updating a selection
+
+ Selection commands are provided by a combination of selection flags,
+ defined by \l{QItemSelectionModel::SelectionFlag}.
+ Each selection flag tells the selection model how to update its
+ internal record of selected items when either of the
+ \l{QItemSelection::select()}{select()} functions are called.
+ The most commonly used flag is the
+ \l{QItemSelectionModel::SelectionFlag}{Select} flag
+ which instructs the selection model to record the specified items as
+ being selected. The
+ \l{QItemSelectionModel::SelectionFlag}{Toggle} flag causes the
+ selection model to invert the state of the specified items,
+ selecting any deselected items given, and deselecting any currently
+ selected items. The \l{QItemSelectionModel::SelectionFlag}{Deselect}
+ flag deselects all the specified items.
+
+ Individual items in the selection model are updated by creating a
+ selection of items, and applying them to the selection model. In the
+ following code, we apply a second selection of items to the table
+ model shown above, using the
+ \l{QItemSelectionModel::SelectionFlag}{Toggle} command to invert the
+ selection state of the items given.
+
+ \snippet itemselection/main.cpp 3
+
+ The results of this operation are displayed in the table view,
+ providing a convenient way of visualizing what we have achieved:
+
+ \image selected-items2.png
+
+ By default, the selection commands only operate on the individual
+ items specified by the model indexes. However, the flag used to
+ describe the selection command can be combined with additional flags
+ to change entire rows and columns. For example if you call
+ \l{QItemSelectionModel::select()}{select()} with only one index, but
+ with a command that is a combination of
+ \l{QItemSelectionModel::SelectionFlag}{Select} and
+ \l{QItemSelectionModel::SelectionFlag}{Rows}, the
+ entire row containing the item referred to is selected.
+ The following code demonstrates the use of the
+ \l{QItemSelectionModel::SelectionFlag}{Rows} and
+ \l{QItemSelectionModel::SelectionFlag}{Columns} flags:
+
+ \snippet itemselection/main.cpp 4
+
+ Although only four indexes are supplied to the selection model, the
+ use of the
+ \l{QItemSelectionModel::SelectionFlag}{Columns} and
+ \l{QItemSelectionModel::SelectionFlag}{Rows} selection flags means
+ that two columns and two rows are selected. The following image shows
+ the result of these two selections:
+
+ \image selected-items3.png
+
+ The commands performed on the example model have all involved
+ accumulating a selection of items in the model. It is also possible
+ to clear the selection, or to replace the current selection with
+ a new one.
+
+ To replace the current selection with a new selection, combine
+ the other selection flags with the
+ \l{QItemSelectionModel::SelectionFlag}{Current} flag. A command using
+ this flag instructs the selection model to replace its current collection
+ of model indexes with those specified in a call to
+ \l{QItemSelectionModel::select()}{select()}.
+ To clear all selections before you start adding new ones,
+ combine the other selection flags with the
+ \l{QItemSelectionModel::SelectionFlag}{Clear} flag. This
+ has the effect of resetting the selection model's collection of model
+ indexes.
+
+ \section3 Selecting all items in a model
+
+ To select all items in a model, it is necessary to create a
+ selection for each level of the model that covers all items in that
+ level. We do this by retrieving the indexes corresponding to the
+ top-left and bottom-right items with a given parent index:
+
+ \snippet reading-selections/window.cpp 2
+
+ A selection is constructed with these indexes and the model. The
+ corresponding items are then selected in the selection model:
+
+ \snippet reading-selections/window.cpp 3
+
+ This needs to be performed for all levels in the model.
+ For top-level items, we would define the parent index in the usual way:
+
+ \snippet reading-selections/window.cpp 1
+
+ For hierarchical models, the
+ \l{QAbstractItemModel::hasChildren()}{hasChildren()} function is used to
+ determine whether any given item is the parent of another level of
+ items.
+
+ \section1 Creating new models
+
+ The separation of functionality between the model/view components allows
+ models to be created that can take advantage of existing views. This
+ approach lets us present data from a variety of sources using standard
+ graphical user interface components, such as QListView, QTableView, and
+ QTreeView.
+
+ The QAbstractItemModel class provides an interface that is flexible
+ enough to support data sources that arrange information in hierarchical
+ structures, allowing for the possibility that data will be inserted,
+ removed, modified, or sorted in some way. It also provides support for
+ drag and drop operations.
+
+ The QAbstractListModel and QAbstractTableModel classes provide support
+ for interfaces to simpler non-hierarchical data structures, and are
+ easier to use as a starting point for simple list and table models.
+
+ In this section, we create a simple read-only model to explore
+ the basic principles of the model/view architecture. Later in this
+ section, we adapt this simple model so that items can be modified
+ by the user.
+
+ For an example of a more complex model, see the
+ \l{itemviews/simpletreemodel}{Simple Tree Model} example.
+
+ The requirements of QAbstractItemModel subclasses is described in more
+ detail in the \l{Model Subclassing Reference} document.
+
+ \section2 Designing a model
+
+ When creating a new model for an existing data structure, it is
+ important to consider which type of model should be used to
+ provide an interface onto the data. If the data structure can be
+ represented as a list or table of items, you can subclass
+ QAbstractListModel or QAbstractTableModel since these classes
+ provide suitable default implementations for many functions.
+
+ However, if the underlying data structure can only be represented
+ by a hierarchical tree structure, it is necessary to subclass
+ QAbstractItemModel. This approach is taken in the
+ \l{itemviews/simpletreemodel}{Simple Tree Model} example.
+
+ In this section, we implement a simple model based on a list of
+ strings, so the QAbstractListModel provides an ideal base class on
+ which to build.
+
+ Whatever form the underlying data structure takes, it is
+ usually a good idea to supplement the standard QAbstractItemModel API
+ in specialized models with one that allows more natural access to the
+ underlying data structure. This makes it easier to populate the model
+ with data, yet still enables other general model/view components to
+ interact with it using the standard API. The model described below
+ provides a custom constructor for just this purpose.
+
+ \section2 A read-only example model
+
+ The model implemented here is a simple, non-hierarchical, read-only data
+ model based on the standard QStringListModel class. It has a \l QStringList
+ as its internal data source, and implements only what is needed to make a
+ functioning model. To make the implementation easier, we subclass
+ \l QAbstractListModel because it defines sensible default behavior for list
+ models, and it exposes a simpler interface than the \l QAbstractItemModel
+ class.
+
+ When implementing a model it is important to remember that
+ \l QAbstractItemModel does not store any data itself, it merely
+ presents an interface that the views use to access the data.
+ For a minimal read-only model it is only necessary to implement a few
+ functions as there are default implementations for most of the
+ interface. The class declaration is as follows:
+
+ \snippet stringlistmodel/model.h 0
+ \snippet stringlistmodel/model.h 1
+ \codeline
+ \snippet stringlistmodel/model.h 5
+
+ Apart from the model's constructor, we only need to implement two
+ functions: \l{QAbstractItemModel::rowCount()}{rowCount()} returns the
+ number of rows in the model and \l{QAbstractItemModel::data()}{data()}
+ returns an item of data corresponding to a specified model index.
+
+ Well behaved models also implement
+ \l{QAbstractItemModel::headerData()}{headerData()} to give tree and
+ table views something to display in their headers.
+
+ Note that this is a non-hierarchical model, so we don't have to worry
+ about the parent-child relationships. If our model was hierarchical, we
+ would also have to implement the
+ \l{QAbstractItemModel::index()}{index()} and
+ \l{QAbstractItemModel::parent()}{parent()} functions.
+
+ The list of strings is stored internally in the \c stringList private
+ member variable.
+
+ \section3 Dimensions of the model
+
+ We want the number of rows in the model to be the same as the number of
+ strings in the string list. We implement the
+ \l{QAbstractItemModel::rowCount()}{rowCount()} function with this in
+ mind:
+
+ \snippet stringlistmodel/model.cpp 0
+
+ Since the model is non-hierarchical, we can safely ignore the model index
+ corresponding to the parent item. By default, models derived from
+ QAbstractListModel only contain one column, so we do not need to
+ reimplement the \l{QAbstractItemModel::columnCount()}{columnCount()}
+ function.
+
+ \section3 Model headers and data
+
+ For items in the view, we want to return the strings in the string list.
+ The \l{QAbstractItemModel::data()}{data()} function is responsible for
+ returning the item of data that corresponds to the index argument:
+
+ \snippet stringlistmodel/model.cpp 1-data-read-only
+
+ We only return a valid QVariant if the model index supplied is valid,
+ the row number is within the range of items in the string list, and the
+ requested role is one that we support.
+
+ Some views, such as QTreeView and QTableView, are able to display headers
+ along with the item data. If our model is displayed in a view with headers,
+ we want the headers to show the row and column numbers. We can provide
+ information about the headers by subclassing the
+ \l{QAbstractItemModel::headerData()}{headerData()} function:
+
+ \snippet stringlistmodel/model.cpp 2
+
+ Again, we return a valid QVariant only if the role is one that we support.
+ The orientation of the header is also taken into account when deciding the
+ exact data to return.
+
+ Not all views display headers with the item data, and those that do may
+ be configured to hide them. Nonetheless, it is recommended that you
+ implement the \l{QAbstractItemModel::headerData()}{headerData()} function
+ to provide relevant information about the data provided by the model.
+
+ An item can have several roles, giving out different data depending on the
+ role specified. The items in our model only have one role,
+ \l{Qt::ItemDataRole}{DisplayRole}, so we return the data
+ for items irrespective of the role specified.
+ However, we could reuse the data we provide for the
+ \l{Qt::ItemDataRole}{DisplayRole} in
+ other roles, such as the
+ \l{Qt::ItemDataRole}{ToolTipRole} that views can use to
+ display information about items in a tooltip.
+
+ \section2 An editable model
+
+ The read-only model shows how simple choices could be presented to the
+ user but, for many applications, an editable list model is much more
+ useful. We can modify the read-only model to make the items editable
+ by changing the data() function we implemented for read-only, and
+ by implementing two extra functions:
+ \l{QAbstractItemModel::flags()}{flags()} and
+ \l{QAbstractItemModel::setData()}{setData()}.
+ The following function declarations are added to the class definition:
+
+ \snippet stringlistmodel/model.h 2
+ \snippet stringlistmodel/model.h 3
+
+ \section3 Making the model editable
+
+ A delegate checks whether an item is editable before creating an
+ editor. The model must let the delegate know that its items are
+ editable. We do this by returning the correct flags for each item in
+ the model; in this case, we enable all items and make them both
+ selectable and editable:
+
+ \snippet stringlistmodel/model.cpp 3
+
+ Note that we do not have to know how the delegate performs the actual
+ editing process. We only have to provide a way for the delegate to set the
+ data in the model. This is achieved through the
+ \l{QAbstractItemModel::setData()}{setData()} function:
+
+ \snippet stringlistmodel/model.cpp 4
+ \snippet stringlistmodel/model.cpp 5
+
+ In this model, the item in the string list that corresponds to the
+ model index is replaced by the value provided. However, before we
+ can modify the string list, we must make sure that the index is
+ valid, the item is of the correct type, and that the role is
+ supported. By convention, we insist that the role is the
+ \l{Qt::ItemDataRole}{EditRole} since this is the role used by the
+ standard item delegate. For boolean values, however, you can use
+ Qt::CheckStateRole and set the Qt::ItemIsUserCheckable flag; a
+ checkbox is then used for editing the value. The underlying
+ data in this model is the same for all roles, so this detail just
+ makes it easier to integrate the model with standard components.
+
+ When the data has been set, the model must let the views know that some
+ data has changed. This is done by emitting the
+ \l{QAbstractItemModel::dataChanged()}{dataChanged()} signal. Since only
+ one item of data has changed, the range of items specified in the signal
+ is limited to just one model index.
+
+ Also the data() function needs to be changed to add the Qt::EditRole test:
+
+ \snippet stringlistmodel/model.cpp 1
+
+ \section3 Inserting and removing rows
+
+ It is possible to change the number of rows and columns in a model. In the
+ string list model it only makes sense to change the number of rows, so we
+ only reimplement the functions for inserting and removing rows. These are
+ declared in the class definition:
+
+ \snippet stringlistmodel/model.h 4
+
+ Since rows in this model correspond to strings in a list, the
+ \c insertRows() function inserts a number of empty strings into the string
+ list before the specified position. The number of strings inserted is
+ equivalent to the number of rows specified.
+
+ The parent index is normally used to determine where in the model the
+ rows should be added. In this case, we only have a single top-level list
+ of strings, so we just insert empty strings into that list.
+
+ \snippet stringlistmodel/model.cpp 6
+ \snippet stringlistmodel/model.cpp 7
+
+ The model first calls the
+ \l{QAbstractItemModel::beginInsertRows()}{beginInsertRows()} function to
+ inform other components that the number of rows is about to change. The
+ function specifies the row numbers of the first and last new rows to be
+ inserted, and the model index for their parent item. After changing the
+ string list, it calls
+ \l{QAbstractItemModel::endInsertRows()}{endInsertRows()} to complete the
+ operation and inform other components that the dimensions of the model
+ have changed, returning true to indicate success.
+
+ The function to remove rows from the model is also simple to write.
+ The rows to be removed from the model are specified by the position and
+ the number of rows given.
+ We ignore the parent index to simplify our implementation, and just
+ remove the corresponding items from the string list.
+
+ \snippet stringlistmodel/model.cpp 8
+ \snippet stringlistmodel/model.cpp 9
+
+ The \l{QAbstractItemModel::beginRemoveRows()}{beginRemoveRows()} function
+ is always called before any underlying data is removed, and specifies the
+ first and last rows to be removed. This allows other components to access
+ the data before it becomes unavailable.
+ After the rows have been removed, the model emits
+ \l{QAbstractItemModel::endRemoveRows()}{endRemoveRows()} to finish the
+ operation and let other components know that the dimensions of the model
+ have changed.
+
+ \section2 Next steps
+
+ We can display the data provided by this model, or any other model, using
+ the \l QListView class to present the model's items in the form of a vertical
+ list.
+ For the string list model, this view also provides a default editor so that
+ the items can be manipulated. We examine the possibilities made available by
+ the standard view classes in \l{View Classes}.
+
+ The \l{Model Subclassing Reference} document discusses the requirements of
+ QAbstractItemModel subclasses in more detail, and provides a guide to the
+ virtual functions that must be implemented to enable various features in
+ different types of models.
+
+ \section1 Item view convenience classes
+
+ Qt 4 also introduced some standard widgets to provide classic
+ item-based container widgets. These behave in a similar way to the
+ item view classes in Qt 3, but have been rewritten to use the
+ underlying model/view framework for performance and
+ maintainability. The old item view classes are still available in
+ the compatibility library (see the \l{porting4.html}{Porting
+ Guide} for more information).
+
+ The item-based widgets have been given names which reflect their uses:
+ \c QListWidget provides a list of items, \c QTreeWidget displays a
+ multi-level tree structure, and \c QTableWidget provides a table of cell
+ items. Each class inherits the behavior of the \c QAbstractItemView
+ class which implements common behavior for item selection and header
+ management.
+
+ \section2 List widgets
+
+ Single level lists of items are typically displayed using a \c QListWidget
+ and a number of \c{QListWidgetItem}s. A list widget is constructed in the
+ same way as any other widget:
+
+ \snippet qlistwidget-using/mainwindow.cpp 0
+
+ List items can be added directly to the list widget when they are
+ constructed:
+
+ \snippet qlistwidget-using/mainwindow.cpp 3
+
+ They can also be constructed without a parent list widget and added to
+ a list at some later time:
+
+ \snippet qlistwidget-using/mainwindow.cpp 6
+ \snippet qlistwidget-using/mainwindow.cpp 7
+
+ Each item in a list can display a text label and an icon. The colors
+ and font used to render the text can be changed to provide a customized
+ appearance for items. Tooltips, status tips, and "What's
+ This?" help are all easily configured to ensure that the list is properly
+ integrated into the application.
+
+ \snippet qlistwidget-using/mainwindow.cpp 8
+
+ By default, items in a list are presented in the order of their creation.
+ Lists of items can be sorted according to the criteria given in
+ \l{Qt::SortOrder} to produce a list of items that is sorted in forward or
+ reverse alphabetical order:
+
+ \snippet qlistwidget-using/mainwindow.cpp 4
+ \snippet qlistwidget-using/mainwindow.cpp 5
+
+ \section2 Tree widgets
+
+ Trees or hierarchical lists of items are provided by the \c QTreeWidget
+ and \c QTreeWidgetItem classes. Each item in the tree widget can have
+ child items of its own, and can display a number of columns of
+ information. Tree widgets are created just like any other widget:
+
+ \snippet qtreewidget-using/mainwindow.cpp 0
+
+ Before items can be added to the tree widget, the number of columns must
+ be set. For example, we could define two columns, and create a header
+ to provide labels at the top of each column:
+
+ \snippet qtreewidget-using/mainwindow.cpp 1
+ \snippet qtreewidget-using/mainwindow.cpp 2
+
+ The easiest way to set up the labels for each section is to supply a string
+ list. For more sophisticated headers, you can construct a tree item,
+ decorate it as you wish, and use that as the tree widget's header.
+
+ Top-level items in the tree widget are constructed with the tree widget as
+ their parent widget. They can be inserted in an arbitrary order, or you
+ can ensure that they are listed in a particular order by specifying the
+ previous item when constructing each item:
+
+ \snippet qtreewidget-using/mainwindow.cpp 3
+ \codeline
+ \snippet qtreewidget-using/mainwindow.cpp 4
+
+ Tree widgets deal with top-level items slightly differently to other
+ items from deeper within the tree. Items can be removed from the top
+ level of the tree by calling the tree widget's
+ \l{QTreeWidget::takeTopLevelItem()}{takeTopLevelItem()} function, but
+ items from lower levels are removed by calling their parent item's
+ \l{QTreeWidgetItem::takeChild()}{takeChild()} function.
+ Items are inserted in the top level of the tree with the
+ \l{QTreeWidget::insertTopLevelItem()}{insertTopLevelItem()} function.
+ At lower levels in the tree, the parent item's
+ \l{QTreeWidgetItem::insertChild()}{insertChild()} function is used.
+
+ It is easy to move items around between the top level and lower levels
+ in the tree. We just need to check whether the items are top-level items
+ or not, and this information is supplied by each item's \c parent()
+ function. For example, we can remove the current item in the tree widget
+ regardless of its location:
+
+ \snippet qtreewidget-using/mainwindow.cpp 10
+ \snippet qtreewidget-using/mainwindow.cpp 11
+
+ Inserting the item somewhere else in the tree widget follows the same
+ pattern:
+
+ \snippet qtreewidget-using/mainwindow.cpp 8
+ \snippet qtreewidget-using/mainwindow.cpp 9
+
+ \section2 Table widgets
+
+ Tables of items similar to those found in spreadsheet applications
+ are constructed with the \c QTableWidget and \c QTableWidgetItem. These
+ provide a scrolling table widget with headers and items to use within it.
+
+ Tables can be created with a set number of rows and columns, or these
+ can be added to an unsized table as they are needed.
+
+ \snippet qtablewidget-using/mainwindow.h 0
+ \snippet qtablewidget-using/mainwindow.cpp 0
+
+ Items are constructed outside the table before being added to the table
+ at the required location:
+
+ \snippet qtablewidget-using/mainwindow.cpp 3
+
+ Horizontal and vertical headers can be added to the table by constructing
+ items outside the table and using them as headers:
+
+ \snippet qtablewidget-using/mainwindow.cpp 1
+
+ Note that the rows and columns in the table begin at zero.
+
+ \section2 Common features
+
+ There are a number of item-based features common to each of the
+ convenience classes that are available through the same interfaces
+ in each class. We present these in the following sections with some
+ examples for different widgets.
+ Look at the list of \l{Model/View Classes} for each of the widgets
+ for more details about the use of each function used.
+
+ \section3 Hidden items
+
+ It is sometimes useful to be able to hide items in an item view widget
+ rather than remove them. Items for all of the above widgets can be
+ hidden and later shown again. You can determine whether an item is hidden
+ by calling the isItemHidden() function, and items can be hidden with
+ \c setItemHidden().
+
+ Since this operation is item-based, the same function is available for
+ all three convenience classes.
+
+ \section3 Selections
+
+ The way items are selected is controlled by the widget's selection mode
+ (\l{QAbstractItemView::SelectionMode}).
+ This property controls whether the user can select one or many items and,
+ in many-item selections, whether the selection must be a continuous range
+ of items. The selection mode works in the same way for all of the
+ above widgets.
+
+ \table
+ \row
+ \li \image selection-single.png
+ \li \b{Single item selections:}
+ Where the user needs to choose a single item from a widget, the
+ default \c SingleSelection mode is most suitable. In this mode, the
+ current item and the selected item are the same.
+
+ \row
+ \li \image selection-multi.png
+ \li \b{Multi-item selections:}
+ In this mode, the user can toggle the selection state of any item in the
+ widget without changing the existing selection, much like the way
+ non-exclusive checkboxes can be toggled independently.
+
+ \row
+ \li \image selection-extended.png
+ \li \b{Extended selections:}
+ Widgets that often require many adjacent items to be selected, such
+ as those found in spreadsheets, require the \c ExtendedSelection mode.
+ In this mode, continuous ranges of items in the widget can be selected
+ with both the mouse and the keyboard.
+ Complex selections, involving many items that are not adjacent to other
+ selected items in the widget, can also be created if modifier keys are
+ used.
+
+ If the user selects an item without using a modifier key, the existing
+ selection is cleared.
+ \endtable
+
+ The selected items in a widget are read using the \c selectedItems()
+ function, providing a list of relevant items that can be iterated over.
+ For example, we can find the sum of all the numeric values within a
+ list of selected items with the following code:
+
+ \snippet qtablewidget-using/mainwindow.cpp 4
+
+ Note that for the single selection mode, the current item will be in
+ the selection. In the multi-selection and extended selection modes, the
+ current item may not lie within the selection, depending on the way the
+ user formed the selection.
+
+ \section3 Searching
+
+ It is often useful to be able to find items within an item view widget,
+ either as a developer or as a service to present to users. All three
+ item view convenience classes provide a common \c findItems() function
+ to make this as consistent and simple as possible.
+
+ Items are searched for by the text that they contain according to
+ criteria specified by a selection of values from Qt::MatchFlags.
+ We can obtain a list of matching items with the \c findItems()
+ function:
+
+ \snippet qtreewidget-using/mainwindow.cpp 6
+ \snippet qtreewidget-using/mainwindow.cpp 7
+
+ The above code causes items in a tree widget to be selected if they
+ contain the text given in the search string. This pattern can also be
+ used in the list and table widgets.
+
+ \section1 Using Drag and Drop with Item Views
+
+ Qt's drag and drop infrastructure is fully supported by the model/view framework.
+ Items in lists, tables, and trees can be dragged within the views, and data can be
+ imported and exported as MIME-encoded data.
+
+ The standard views automatically support internal drag and drop, where items are
+ moved around to change the order in which they are displayed. By default, drag and
+ drop is not enabled for these views because they are configured for the simplest,
+ most common uses. To allow items to be dragged around, certain properties of the
+ view need to be enabled, and the items themselves must also allow dragging to occur.
+
+ The requirements for a model that only allows items to be exported from a
+ view, and which does not allow data to be dropped into it, are fewer than
+ those for a fully-enabled drag and drop model.
+
+ See also the \l{Model Subclassing Reference} for more information about
+ enabling drag and drop support in new models.
+
+ \section2 Using convenience views
+
+ Each of the types of item used with QListWidget, QTableWidget, and QTreeWidget
+ is configured to use a different set of flags by default. For example, each
+ QListWidgetItem or QTreeWidgetItem is initially enabled, checkable, selectable,
+ and can be used as the source of a drag and drop operation; each QTableWidgetItem
+ can also be edited and used as the target of a drag and drop operation.
+
+ Although all of the standard items have one or both flags set for drag and drop,
+ you generally need to set various properties in the view itself to take advantage
+ of the built-in support for drag and drop:
+
+ \list
+ \li To enable item dragging, set the view's
+ \l{QAbstractItemView::dragEnabled}{dragEnabled} property to \c true.
+ \li To allow the user to drop either internal or external items within the view,
+ set the view's \l{QAbstractScrollArea::}{viewport()}'s
+ \l{QWidget::acceptDrops}{acceptDrops} property to \c true.
+ \li To show the user where the item currently being dragged will be placed if
+ dropped, set the view's \l{QAbstractItemView::showDropIndicator}{showDropIndicator}
+ property. This provides the user with continuously updating information about
+ item placement within the view.
+ \endlist
+
+ For example, we can enable drag and drop in a list widget with the following lines
+ of code:
+
+ \snippet qlistwidget-dnd/mainwindow.cpp 0
+
+ The result is a list widget which allows the items to be copied
+ around within the view, and even lets the user drag items between
+ views containing the same type of data. In both situations, the
+ items are copied rather than moved.
+
+ To enable the user to move the items around within the view, we
+ must set the list widget's \l {QAbstractItemView::}{dragDropMode}:
+
+ \snippet qlistwidget-dnd/mainwindow.cpp 1
+
+ \section2 Using model/view classes
+
+ Setting up a view for drag and drop follows the same pattern used with the
+ convenience views. For example, a QListView can be set up in the same way as a
+ QListWidget:
+
+ \snippet qlistview-dnd/mainwindow.cpp 0
+
+ Since access to the data displayed by the view is controlled by a model, the
+ model used also has to provide support for drag and drop operations. The
+ actions supported by a model can be specified by reimplementing the
+ QAbstractItemModel::supportedDropActions() function. For example, copy and
+ move operations are enabled with the following code:
+
+ \snippet qlistview-dnd/model.cpp 10
+
+ Although any combination of values from Qt::DropActions can be given, the
+ model needs to be written to support them. For example, to allow Qt::MoveAction
+ to be used properly with a list model, the model must provide an implementation
+ of QAbstractItemModel::removeRows(), either directly or by inheriting the
+ implementation from its base class.
+
+ \section3 Enabling drag and drop for items
+
+ Models indicate to views which items can be dragged, and which will accept drops,
+ by reimplementing the QAbstractItemModel::flags() function to provide suitable
+ flags.
+
+ For example, a model which provides a simple list based on QAbstractListModel
+ can enable drag and drop for each of the items by ensuring that the flags
+ returned contain the \l Qt::ItemIsDragEnabled and \l Qt::ItemIsDropEnabled
+ values:
+
+ \snippet qlistview-dnd/model.cpp 7
+
+ Note that items can be dropped into the top level of the model, but dragging is
+ only enabled for valid items.
+
+ In the above code, since the model is derived from QStringListModel, we
+ obtain a default set of flags by calling its implementation of the flags()
+ function.
+
+ \section3 Encoding exported data
+
+ When items of data are exported from a model in a drag and drop operation, they
+ are encoded into an appropriate format corresponding to one or more MIME types.
+ Models declare the MIME types that they can use to supply items by reimplementing
+ the QAbstractItemModel::mimeTypes() function, returning a list of standard MIME
+ types.
+
+ For example, a model that only provides plain text would provide the following
+ implementation:
+
+ \snippet qlistview-dnd/model.cpp 9
+
+ The model must also provide code to encode data in the advertised format. This
+ is achieved by reimplementing the QAbstractItemModel::mimeData() function to
+ provide a QMimeData object, just as in any other drag and drop operation.
+
+ The following code shows how each item of data, corresponding to a given list of
+ indexes, is encoded as plain text and stored in a QMimeData object.
+
+ \snippet qlistview-dnd/model.cpp 8
+
+ Since a list of model indexes is supplied to the function, this approach is general
+ enough to be used in both hierarchical and non-heirarchical models.
+
+ Note that custom datatypes must be declared as \l{QMetaObject}{meta objects}
+ and that stream operators must be implemented for them. See the QMetaObject
+ class description for details.
+
+ \section3 Inserting dropped data into a model
+
+ The way that any given model handles dropped data depends on both its type
+ (list, table, or tree) and the way its contents is likely to be presented to
+ the user. Generally, the approach taken to accommodate dropped data should
+ be the one that most suits the model's underlying data store.
+
+ Different types of model tend to handle dropped data in different ways. List
+ and table models only provide a flat structure in which items of data are
+ stored. As a result, they may insert new rows (and columns) when data is
+ dropped on an existing item in a view, or they may overwrite the item's
+ contents in the model using some of the data supplied. Tree models are
+ often able to add child items containing new data to their underlying data
+ stores, and will therefore behave more predictably as far as the user
+ is concerned.
+
+ Dropped data is handled by a model's reimplementation of
+ QAbstractItemModel::dropMimeData(). For example, a model that handles a
+ simple list of strings can provide an implementation that handles data
+ dropped onto existing items separately to data dropped into the top level
+ of the model (i.e., onto an invalid item).
+
+ The model first has to make sure that the operation should be acted on,
+ the data supplied is in a format that can be used, and that its destination
+ within the model is valid:
+
+ \snippet qlistview-dnd/model.cpp 0
+ \snippet qlistview-dnd/model.cpp 1
+
+ A simple one column string list model can indicate failure if the data
+ supplied is not plain text, or if the column number given for the drop
+ is invalid.
+
+ The data to be inserted into the model is treated differently depending on
+ whether it is dropped onto an existing item or not. In this simple example,
+ we want to allow drops between existing items, before the first item in the
+ list, and after the last item.
+
+ When a drop occurs, the model index corresponding to the parent item will
+ either be valid, indicating that the drop occurred on an item, or it will
+ be invalid, indicating that the drop occurred somewhere in the view that
+ corresponds to top level of the model.
+
+ \snippet qlistview-dnd/model.cpp 2
+
+ We initially examine the row number supplied to see if we can use it
+ to insert items into the model, regardless of whether the parent index is
+ valid or not.
+
+ \snippet qlistview-dnd/model.cpp 3
+
+ If the parent model index is valid, the drop occurred on an item. In this
+ simple list model, we find out the row number of the item and use that
+ value to insert dropped items into the top level of the model.
+
+ \snippet qlistview-dnd/model.cpp 4
+
+ When a drop occurs elsewhere in the view, and the row number is unusable,
+ we append items to the top level of the model.
+
+ In hierarchical models, when a drop occurs on an item, it would be better to
+ insert new items into the model as children of that item. In the simple
+ example shown here, the model only has one level, so this approach is not
+ appropriate.
+
+ \section3 Decoding imported data
+
+ Each implementation of \l{QAbstractItemModel::dropMimeData()}{dropMimeData()} must
+ also decode the data and insert it into the model's underlying data structure.
+
+ For a simple string list model, the encoded items can be decoded and streamed
+ into a QStringList:
+
+ \snippet qlistview-dnd/model.cpp 5
+
+ The strings can then be inserted into the underlying data store. For consistency,
+ this can be done through the model's own interface:
+
+ \snippet qlistview-dnd/model.cpp 6
+
+ Note that the model will typically need to provide implementations of the
+ QAbstractItemModel::insertRows() and QAbstractItemModel::setData() functions.
+
+ \sa {Item Views Puzzle Example}
+
+ \section1 Proxy models
+
+ In the model/view framework, items of data supplied by a single model can be shared
+ by any number of views, and each of these can possibly represent the same information
+ in completely different ways.
+ Custom views and delegates are effective ways to provide radically different
+ representations of the same data. However, applications often need to provide
+ conventional views onto processed versions of the same data, such as differently-sorted
+ views onto a list of items.
+
+ Although it seems appropriate to perform sorting and filtering operations as internal
+ functions of views, this approach does not allow multiple views to share the results
+ of such potentially costly operations. The alternative approach, involving sorting
+ within the model itself, leads to the similar problem where each view has to display
+ items of data that are organized according to the most recent processing operation.
+
+ To solve this problem, the model/view framework uses proxy models to manage the
+ information supplied between individual models and views. Proxy models are components
+ that behave like ordinary models from the perspective of a view, and access data from
+ source models on behalf of that view. The signals and slots used by the model/view
+ framework ensure that each view is updated appropriately no matter how many proxy models
+ are placed between itself and the source model.
+
+ \section2 Using proxy models
+
+ Proxy models can be inserted between an existing model and any number of views.
+ Qt is supplied with a standard proxy model, QSortFilterProxyModel, that is usually
+ instantiated and used directly, but can also be subclassed to provide custom filtering
+ and sorting behavior. The QSortFilterProxyModel class can be used in the following way:
+
+ \snippet qsortfilterproxymodel/main.cpp 0
+ \codeline
+ \snippet qsortfilterproxymodel/main.cpp 1
+
+ Since proxy models are inherit from QAbstractItemModel, they can be connected to
+ any kind of view, and can be shared between views. They can also be used to
+ process the information obtained from other proxy models in a pipeline arrangement.
+
+ The QSortFilterProxyModel class is designed to be instantiated and used directly
+ in applications. More specialized proxy models can be created by subclassing this
+ classes and implementing the required comparison operations.
+
+ \section2 Customizing proxy models
+
+ Generally, the type of processing used in a proxy model involves mapping each item of
+ data from its original location in the source model to either a different location in
+ the proxy model. In some models, some items may have no corresponding location in the
+ proxy model; these models are \e filtering proxy models. Views access items using
+ model indexes provided by the proxy model, and these contain no information about the
+ source model or the locations of the original items in that model.
+
+ QSortFilterProxyModel enables data from a source model to be filtered before
+ being supplied to views, and also allows the contents of a source model to
+ be supplied to views as pre-sorted data.
+
+ \section3 Custom filtering models
+
+ The QSortFilterProxyModel class provides a filtering model that is fairly versatile,
+ and which can be used in a variety of common situations. For advanced users,
+ QSortFilterProxyModel can be subclassed, providing a mechanism that enables custom
+ filters to be implemented.
+
+ Subclasses of QSortFilterProxyModel can reimplement two virtual functions that are
+ called whenever a model index from the proxy model is requested or used:
+
+ \list
+ \li \l{QSortFilterProxyModel::filterAcceptsColumn()}{filterAcceptsColumn()} is used to
+ filter specific columns from part of the source model.
+ \li \l{QSortFilterProxyModel::filterAcceptsRow()}{filterAcceptsRow()} is used to filter
+ specific rows from part of the source model.
+ \endlist
+
+ The default implementations of the above functions in QSortFilterProxyModel
+ return true to ensure that all items are passed through to views; reimplementations
+ of these functions should return false to filter out individual rows and columns.
+
+ \section3 Custom sorting models
+
+ QSortFilterProxyModel instances use Qt's built-in qStableSort() function to set up
+ mappings between items in the source model and those in the proxy model, allowing a
+ sorted hierarchy of items to be exposed to views without modifying the structure of the
+ source model. To provide custom sorting behavior, reimplement the
+ \l{QSortFilterProxyModel::lessThan()}{lessThan()} function to perform custom
+ comparisons.
+
+ \section1 Model subclassing reference
+
+ Model subclasses need to provide implementations of many of the virtual functions
+ defined in the QAbstractItemModel base class. The number of these functions that need
+ to be implemented depends on the type of model - whether it supplies views with
+ a simple list, a table, or a complex hierarchy of items. Models that inherit from
+ QAbstractListModel and QAbstractTableModel can take advantage of the default
+ implementations of functions provided by those classes. Models that expose items
+ of data in tree-like structures must provide implementations for many of the
+ virtual functions in QAbstractItemModel.
+
+ The functions that need to be implemented in a model subclass can be divided into three
+ groups:
+
+ \list
+ \li \b{Item data handling:} All models need to implement functions to enable views and
+ delegates to query the dimensions of the model, examine items, and retrieve data.
+ \li \b{Navigation and index creation:} Hierarchical models need to provide functions
+ that views can call to navigate the tree-like structures they expose, and obtain
+ model indexes for items.
+ \li \b{Drag and drop support and MIME type handling:} Models inherit functions that
+ control the way that internal and external drag and drop operations are performed.
+ These functions allow items of data to be described in terms of MIME types that
+ other components and applications can understand.
+ \endlist
+
+ For more information, see the \l
+ {"Item View Classes" Chapter of C++ GUI Programming with Qt 4}.
+
+ \section2 Item data handling
+
+ Models can provide varying levels of access to the data they provide: They can be
+ simple read-only components, some models may support resizing operations, and
+ others may allow items to be edited.
+
+ \section2 Read-Only access
+
+ To provide read-only access to data provided by a model, the following functions
+ \e{must} be implemented in the model's subclass:
+
+ \table 90%
+ \row \li \l{QAbstractItemModel::flags()}{flags()}
+ \li Used by other components to obtain information about each item provided by
+ the model. In many models, the combination of flags should include
+ Qt::ItemIsEnabled and Qt::ItemIsSelectable.
+ \row \li \l{QAbstractItemModel::data()}{data()}
+ \li Used to supply item data to views and delegates. Generally, models only
+ need to supply data for Qt::DisplayRole and any application-specific user
+ roles, but it is also good practice to provide data for Qt::ToolTipRole,
+ Qt::AccessibleTextRole, and Qt::AccessibleDescriptionRole.
+ See the Qt::ItemDataRole enum documentation for information about the types
+ associated with each role.
+ \row \li \l{QAbstractItemModel::headerData()}{headerData()}
+ \li Provides views with information to show in their headers. The information is
+ only retrieved by views that can display header information.
+ \row \li \l{QAbstractItemModel::rowCount()}{rowCount()}
+ \li Provides the number of rows of data exposed by the model.
+ \endtable
+
+ These four functions must be implemented in all types of model, including list models
+ (QAbstractListModel subclasses) and table models (QAbstractTableModel subclasses).
+
+ Additionally, the following functions \e{must} be implemented in direct subclasses
+ of QAbstractTableModel and QAbstractItemModel:
+
+ \table 90%
+ \row \li \l{QAbstractItemModel::columnCount()}{columnCount()}
+ \li Provides the number of columns of data exposed by the model. List models do not
+ provide this function because it is already implemented in QAbstractListModel.
+ \endtable
+
+ \section3 Editable items
+
+ Editable models allow items of data to be modified, and may also provide
+ functions to allow rows and columns to be inserted and removed. To enable
+ editing, the following functions must be implemented correctly:
+
+ \table 90%
+ \row \li \l{QAbstractItemModel::flags()}{flags()}
+ \li Must return an appropriate combination of flags for each item. In particular,
+ the value returned by this function must include \l{Qt::ItemIsEditable} in
+ addition to the values applied to items in a read-only model.
+ \row \li \l{QAbstractItemModel::setData()}{setData()}
+ \li Used to modify the item of data associated with a specified model index.
+ To be able to accept user input, provided by user interface elements, this
+ function must handle data associated with Qt::EditRole.
+ The implementation may also accept data associated with many different kinds
+ of roles specified by Qt::ItemDataRole. After changing the item of data,
+ models must emit the \l{QAbstractItemModel::dataChanged()}{dataChanged()}
+ signal to inform other components of the change.
+ \row \li \l{QAbstractItemModel::setHeaderData()}{setHeaderData()}
+ \li Used to modify horizontal and vertical header information. After changing
+ the item of data, models must emit the
+ \l{QAbstractItemModel::headerDataChanged()}{headerDataChanged()}
+ signal to inform other components of the change.
+ \endtable
+
+ \section3 Resizable models
+
+ All types of model can support the insertion and removal of rows. Table models
+ and hierarchical models can also support the insertion and removal of columns.
+ It is important to notify other components about changes to the model's dimensions
+ both \e before and \e after they occur. As a result, the following functions
+ can be implemented to allow the model to be resized, but implementations must
+ ensure that the appropriate functions are called to notify attached views and
+ delegates:
+
+ \table 90%
+ \row \li \l{QAbstractItemModel::insertRows()}{insertRows()}
+ \li Used to add new rows and items of data to all types of model.
+ Implementations must call
+ \l{QAbstractItemModel::beginInsertRows()}{beginInsertRows()} \e before
+ inserting new rows into any underlying data structures, and call
+ \l{QAbstractItemModel::endInsertRows()}{endInsertRows()}
+ \e{immediately afterwards}.
+ \row \li \l{QAbstractItemModel::removeRows()}{removeRows()}
+ \li Used to remove rows and the items of data they contain from all types of model.
+ Implementations must call
+ \l{QAbstractItemModel::beginRemoveRows()}{beginRemoveRows()}
+ \e before inserting new columns into any underlying data structures, and call
+ \l{QAbstractItemModel::endRemoveRows()}{endRemoveRows()}
+ \e{immediately afterwards}.
+ \row \li \l{QAbstractItemModel::insertColumns()}{insertColumns()}
+ \li Used to add new columns and items of data to table models and hierarchical models.
+ Implementations must call
+ \l{QAbstractItemModel::beginInsertColumns()}{beginInsertColumns()} \e before
+ rows are removed from any underlying data structures, and call
+ \l{QAbstractItemModel::endInsertColumns()}{endInsertColumns()}
+ \e{immediately afterwards}.
+ \row \li \l{QAbstractItemModel::removeColumns()}{removeColumns()}
+ \li Used to remove columns and the items of data they contain from table models and
+ hierarchical models.
+ Implementations must call
+ \l{QAbstractItemModel::beginRemoveColumns()}{beginRemoveColumns()}
+ \e before columns are removed from any underlying data structures, and call
+ \l{QAbstractItemModel::endRemoveColumns()}{endRemoveColumns()}
+ \e{immediately afterwards}.
+ \endtable
+
+ Generally, these functions should return true if the operation was successful.
+ However, there may be cases where the operation only partly succeeded; for example,
+ if less than the specified number of rows could be inserted. In such cases, the
+ model should return false to indicate failure to enable any attached components to
+ handle the situation.
+
+ The signals emitted by the functions called in implementations of the resizing
+ API give attached components the chance to take action before any data becomes
+ unavailable. The encapsulation of insert and remove operations with begin and end
+ functions also enable the model to manage
+ \l{QPersistentModelIndex}{persistent model indexes} correctly.
+
+ Normally, the begin and end functions are capable of informing other components
+ about changes to the model's underlying structure. For more complex changes to the
+ model's structure, perhaps involving internal reorganization or sorting of data,
+ it is necessary to emit the \l{QAbstractItemModel::layoutChanged()}{layoutChanged()}
+ signal to cause any attached views to be updated.
+
+ \section3 Lazy population of model data
+
+ Lazy population of model data effectively allows requests for information
+ about the model to be deferred until it is actually needed by views.
+
+ Some models need to obtain data from remote sources, or must perform
+ time-consuming operations to obtain information about the way the
+ data is organized. Since views generally request as much information
+ as possible in order to accurately display model data, it can be useful
+ to restrict the amount of information returned to them to reduce
+ unnecessary follow-up requests for data.
+
+ In hierarchical models where finding the number of children of a given
+ item is an expensive operation, it is useful to ensure that the model's
+ \l{QAbstractItemModel::}{rowCount()} implementation is only called when
+ necessary. In such cases, the \l{QAbstractItemModel::}{hasChildren()}
+ function can be reimplemented to provide an inexpensive way for views to
+ check for the presence of children and, in the case of QTreeView, draw
+ the appropriate decoration for their parent item.
+
+ Whether the reimplementation of \l{QAbstractItemModel::}{hasChildren()}
+ returns \c true or \c false, it may not be necessary for the view to call
+ \l{QAbstractItemModel::}{rowCount()} to find out how many children are
+ present. For example, QTreeView does not need to know how many children
+ there are if the parent item has not been expanded to show them.
+
+ If it is known that many items will have children, reimplementing
+ \l{QAbstractItemModel::}{hasChildren()} to unconditionally return \c true
+ is sometimes a useful approach to take. This ensures that each item can
+ be later examined for children while making initial population of model
+ data as fast as possible. The only disadvantage is that items without
+ children may be displayed incorrectly in some views until the user
+ attempts to view the non-existent child items.
+
+ \section2 Navigation and model index creation
+
+ Hierarchical models need to provide functions that views can call to navigate the
+ tree-like structures they expose, and obtain model indexes for items.
+
+ \section3 Parents and children
+
+ Since the structure exposed to views is determined by the underlying data
+ structure, it is up to each model subclass to create its own model indexes
+ by providing implementations of the following functions:
+
+ \table 90%
+ \row \li \l{QAbstractItemModel::index()}{index()}
+ \li Given a model index for a parent item, this function allows views and delegates
+ to access children of that item. If no valid child item - corresponding to the
+ specified row, column, and parent model index, can be found, the function
+ must return QModelIndex(), which is an invalid model index.
+ \row \li \l{QAbstractItemModel::parent()}{parent()}
+ \li Provides a model index corresponding to the parent of any given child item.
+ If the model index specified corresponds to a top-level item in the model, or if
+ there is no valid parent item in the model, the function must return
+ an invalid model index, created with the empty QModelIndex() constructor.
+ \endtable
+
+ Both functions above use the \l{QAbstractItemModel::createIndex()}{createIndex()}
+ factory function to generate indexes for other components to use. It is normal for
+ models to supply some unique identifier to this function to ensure that
+ the model index can be re-associated with its corresponding item later on.
+
+ \section2 Drag and drop support and MIME type handling
+
+ The model/view classes support drag and drop operations, providing default behavior
+ that is sufficient for many applications. However, it is also possible to customize
+ the way items are encoded during drag and drop operations, whether they are copied
+ or moved by default, and how they are inserted into existing models.
+
+ Additionally, the convenience view classes implement specialized behavior that
+ should closely follow that expected by existing developers.
+ The \l{#Convenience Views}{Convenience Views} section provides an overview of this
+ behavior.
+
+ \section3 MIME data
+
+ By default, the built-in models and views use an internal MIME type
+ (\c{application/x-qabstractitemmodeldatalist}) to pass around information about
+ model indexes. This specifies data for a list of items, containing the row and
+ column numbers of each item, and information about the roles that each item
+ supports.
+
+ Data encoded using this MIME type can be obtained by calling
+ QAbstractItemModel::mimeData() with a QModelIndexList containing the items to
+ be serialized.
+ \omit
+ The following types are used to store information about
+ each item as it is streamed into a QByteArray and stored in a QMimeData object:
+
+ \table 90%
+ \header \li Description \li Type
+ \row \li Row \li int
+ \row \li Column \li int
+ \row \li Data for each role \li QMap<int, QVariant>
+ \endtable
+
+ This information can be retrieved for use in non-model classes by calling
+ QMimeData::data() with the \c{application/x-qabstractitemmodeldatalist} MIME
+ type and streaming out the items one by one.
+ \endomit
+
+ When implementing drag and drop support in a custom model, it is possible to
+ export items of data in specialized formats by reimplementing the following
+ function:
+
+ \table 90%
+ \row \li \l{QAbstractItemModel::mimeData()}{mimeData()}
+ \li This function can be reimplemented to return data in formats other
+ than the default \c{application/x-qabstractitemmodeldatalist} internal
+ MIME type.
+
+ Subclasses can obtain the default QMimeData object from the base class
+ and add data to it in additional formats.
+ \endtable
+
+ For many models, it is useful to provide the contents of items in common format
+ represented by MIME types such as \c{text/plain} and \c{image/png}. Note that
+ images, colors and HTML documents can easily be added to a QMimeData object with
+ the QMimeData::setImageData(), QMimeData::setColorData(), and
+ QMimeData::setHtml() functions.
+
+ \section3 Accepting dropped data
+
+ When a drag and drop operation is performed over a view, the underlying model is
+ queried to determine which types of operation it supports and the MIME types
+ it can accept. This information is provided by the
+ QAbstractItemModel::supportedDropActions() and QAbstractItemModel::mimeTypes()
+ functions. Models that do not override the implementations provided by
+ QAbstractItemModel support copy operations and the default internal MIME type
+ for items.
+
+ When serialized item data is dropped onto a view, the data is inserted into
+ the current model using its implementation of QAbstractItemModel::dropMimeData().
+ The default implementation of this function will never overwrite any data in the
+ model; instead, it tries to insert the items of data either as siblings of an
+ item, or as children of that item.
+
+ To take advantage of QAbstractItemModel's default implementation for the built-in
+ MIME type, new models must provide reimplementations of the following functions:
+
+ \table 90%
+ \row \li \l{QAbstractItemModel::insertRows()}{insertRows()}
+ \li {1, 2} These functions enable the model to automatically insert new data using
+ the existing implementation provided by QAbstractItemModel::dropMimeData().
+ \row \li \l{QAbstractItemModel::insertColumns()}{insertColumns()}
+ \row \li \l{QAbstractItemModel::setData()}{setData()}
+ \li Allows the new rows and columns to be populated with items.
+ \row \li \l{QAbstractItemModel::setItemData()}{setItemData()}
+ \li This function provides more efficient support for populating new items.
+ \endtable
+
+ To accept other forms of data, these functions must be reimplemented:
+
+ \table 90%
+ \row \li \l{QAbstractItemModel::supportedDropActions()}{supportedDropActions()}
+ \li Used to return a combination of \l{Qt::DropActions}{drop actions},
+ indicating the types of drag and drop operations that the model accepts.
+ \row \li \l{QAbstractItemModel::mimeTypes()}{mimeTypes()}
+ \li Used to return a list of MIME types that can be decoded and handled by
+ the model. Generally, the MIME types that are supported for input into
+ the model are the same as those that it can use when encoding data for
+ use by external components.
+ \row \li \l{QAbstractItemModel::dropMimeData()}{dropMimeData()}
+ \li Performs the actual decoding of the data transferred by drag and drop
+ operations, determines where in the model it will be set, and inserts
+ new rows and columns where necessary. How this function is implemented
+ in subclasses depends on the requirements of the data exposed by each
+ model.
+ \endtable
+
+ If the implementation of the \l{QAbstractItemModel::dropMimeData()}{dropMimeData()}
+ function changes the dimensions of a model by inserting or removing rows or
+ columns, or if items of data are modified, care must be taken to ensure that
+ all relevant signals are emitted. It can be useful to simply call
+ reimplementations of other functions in the subclass, such as
+ \l{QAbstractItemModel::setData()}{setData()},
+ \l{QAbstractItemModel::insertRows()}{insertRows()}, and
+ \l{QAbstractItemModel::insertColumns()}{insertColumns()}, to ensure that the
+ model behaves consistently.
+
+ In order to ensure drag operations work properly, it is important to
+ reimplement the following functions that remove data from the model:
+
+ \list
+ \li \l{QAbstractItemModel::}{removeRows()}
+ \li \l{QAbstractItemModel::}{removeRow()}
+ \li \l{QAbstractItemModel::}{removeColumns()}
+ \li \l{QAbstractItemModel::}{removeColumn()}
+ \endlist
+
+ For more information about drag and drop with item views, refer to
+ \l{Using drag and drop with item views}.
+
+ \section3 Convenience views
+
+ The convenience views (QListWidget, QTableWidget, and QTreeWidget) override
+ the default drag and drop functionality to provide less flexible, but more
+ natural behavior that is appropriate for many applications. For example,
+ since it is more common to drop data into cells in a QTableWidget, replacing
+ the existing contents with the data being transferred, the underlying model
+ will set the data of the target items rather than insert new rows and columns
+ into the model. For more information on drag and drop in convenience views,
+ you can see \l{Using drag and drop with item views}.
+
+ \section2 Performance optimization for large amounts of data
+
+ The \l{QAbstractItemModel::}{canFetchMore()} function checks if the parent
+ has more data available and returns true or false accordingly. The
+ \l{QAbstractItemModel::}{fetchMore()} function fetches data based on the
+ parent specified. Both these functions can be combined, for example, in a
+ database query involving incremental data to populate a QAbstractItemModel.
+ We reimplement \l{QAbstractItemModel::}{canFetchMore()} to indicate if there
+ is more data to be fetched and \l{QAbstractItemModel::}{fetchMore()} to
+ populate the model as required.
+
+ Another example would be dynamically populated tree models, where we
+ reimplement \l{QAbstractItemModel::}{fetchMore()} when a branch in the tree
+ model is expanded.
+
+ If your reimplementation of \l{QAbstractItemModel::}{fetchMore()} adds rows
+ to the model, you need to call \l{QAbstractItemModel::}{beginInsertRows()}
+ and \l{QAbstractItemModel::}{endInsertRows()}. Also, both
+ \l{QAbstractItemModel::}{canFetchMore()} and \l{QAbstractItemModel::}
+ {fetchMore()} must be reimplemented as their default implementation returns
+ false and does nothing.
+
+ \keyword Model/View Classes
+ \section1 The model/view classes
+
+ These classes use the model/view design pattern in which the
+ underlying data (in the model) is kept separate from the way the
+ data is presented and manipulated by the user (in the view).
+
+ \annotatedlist model-view
+
+ \section1 Related examples
+
+ \list
+ \li \l{itemviews/dirview}{Dir View}
+ \li \l{itemviews/spinboxdelegate}{Spin Box Delegate}
+ \li \l{itemviews/pixelator}{Pixelator}
+ \li \l{itemviews/simpletreemodel}{Simple Tree Model}
+ \li \l{itemviews/chart}{Chart}
+ \endlist
+*/
diff --git a/src/widgets/doc/src/modelview.qdoc b/src/widgets/doc/src/modelview.qdoc
new file mode 100644
index 0000000000..97432b4df4
--- /dev/null
+++ b/src/widgets/doc/src/modelview.qdoc
@@ -0,0 +1,897 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page modelview.html
+ \ingroup tutorials
+ \startpage {index.html}{Qt Reference Documentation}
+
+ \title Model/View Tutorial
+ \brief An introduction to ModelView programming
+
+ Every UI developer should know about ModelView programming and the goal of
+ this tutorial is to provide you with an easily understandable introduction
+ to this topic.
+
+ Table, list and tree widgets are components frequently used in GUIs. There
+ are 2 different ways how these widgets can access their data. The
+ traditional way involves widgets which include internal containers for
+ storing data. This approach is very intuitive, however, in many non-trivial
+ applications, it leads to data synchronization issues.
+ The second approach is model/view programming, in
+ which widgets do not maintain internal data containers. They access external
+ data through a standardized interface and therefore avoid data duplication.
+ This may seem complicated at first, but once you take a closer look, it is
+ not only easy to grasp, but the many benefits of model/view programming also
+ become clearer.
+
+ \image treeview.png
+
+ In the process, we will learn about some basic technologies provided by Qt,
+ such as:
+
+ \list
+ \li The difference between standard and model/view widgets
+ \li Adapters between forms and models
+ \li Developing a simple model/view application
+ \li Predefined models
+ \li Intermediate topics such as:
+ \list
+ \li Tree views
+ \li Selection
+ \li Delegates
+ \li Debugging with model test
+ \endlist
+ \endlist
+
+ You will also learn whether your new application can be written easier with
+ model/view programming or if classic widgets will work just as well.
+
+ This tutorial includes example code for you to edit and integrate into your
+ project. The tutorial's source code is located in Qt's
+ \c examples/tutorials/modelview directory.
+
+ For more detailed information you may also want to look at the
+ \l{model-view-programming.html}{reference documentation}
+
+ If you are completely new to Qt, please read \l{How to Learn Qt} if you
+ have not already done so.
+
+
+ \section1 1. Introduction
+
+ Model/View is a technology used to separate data from views in widgets that
+ handle data sets. Standard widgets are not designed for separating data
+ from views and this is why Qt 4 has two different types of widgets. Both
+ types of widgets look the same, but they interact with data differently.
+
+ \table
+ \row
+ \li Standard widgets use data that is part of the widget.
+ \li \image standardwidget.png
+ \row
+ \li View classes operate on external data (the model)
+ \li \image modelview.png
+ \endtable
+
+ \section2 1.1 Standard Widgets
+
+ Let's have a closer look at a standard table widget. A table widget is a 2D
+ array of the data elements that the user can change. The table widget can be
+ integrated into a program flow by reading and writing the data elements that
+ the table widget provides.
+ This method is very intuitive and useful in many applications, but displaying
+ and editing a database table with a standard table widget can be problematic.
+ Two copies of the data have to be coordinated: one outside the
+ widget; one inside the widget. The developer is responsible for
+ synchronizing both versions. Besides this, the tight coupling of presentation and data
+ makes it harder to write unit tests.
+
+ \section2 1.2 Model/View to the Rescue
+
+ Model/view stepped up to provide a solution that uses a more versatile
+ architecture. Model/view eliminates the data consistency problems that may
+ occur with standard widgets. Model/view also makes it easier to use more
+ than one view of the same data because one model can be passed on to many
+ views. The most important difference is that model/view widgets do not store
+ data behind the table cells. In fact, they operate directly from your data.
+ Since view classes do not know your data's structure, you need to provide a
+ wrapper to make your data conform to the QAbstractItemModel interface. A
+ view uses this interface to read from and write to your data. Any instance
+ of a class that implements QAbstractItemModel is said to be a model. Once
+ the view receives a pointer to a model, it will read and display its content
+ and be its editor.
+
+ \section2 1.3 Overview of the Model/View Widgets
+
+ Here is an overview of the model/view widgets and their corresponding
+ standard widgets.
+
+ \table
+ \header
+ \li Widget
+ \li Standard Widget\br
+ (an item based convenience class)
+ \li Model/View View Class\br
+ (for use with external data)
+ \row
+ \li \inlineimage listview.png
+ \li \l QListWidget
+ \li \l QListView
+ \row
+ \li \inlineimage tableview.png
+ \li \l QTableWidget
+ \li \l QTableView
+ \row
+ \li \inlineimage treeview.png
+ \li \l QTreeWidget
+ \li \l QTreeView
+ \row
+ \li \inlineimage columnview.png
+ \li
+ \li \l QColumnView shows a tree as a hierarchy of lists
+ \row
+ \li \inlineimage modelview-combobox.png
+ \li {2, 1} \l QComboBox can work as both a view class and also
+ as a traditional widget
+ \endtable
+
+ \section2 1.4 Using Adapters between Forms and Models
+
+ Having adapters between forms and models can come in handy.
+
+ We can edit data stored in tables directly from within the table itself, but
+ it's much more comfortable to edit data in text fields. There is no direct
+ model/view counterpart that separates data and views for widgets that
+ operate on one value (QLineEdit, QCheckBox ...) instead of a dataset, so we
+ need an adapter in order to connect the form to the source of data.
+
+ \l QDataWidgetMapper is a great solution because it maps form widgets to a
+ table row and makes it very easy to build forms for database tables.
+
+ \image widgetmapper.png
+
+ Another example of an adapter is \l QCompleter. Qt has \l QCompleter for
+ providing auto-completions in Qt widgets such as \l QComboBox and, as shown
+ below, \l QLineEdit. \l QCompleter uses a model as its data source.
+
+ \image qcompleter.png
+
+
+ \section1 2. A Simple Model/View Application
+ If you want to develop a model/view application, where should you start?
+ We recommend starting with a simple example and extending it step-by-step.
+ This makes understanding the architecture a lot easier. Trying to understand
+ the model/view architecture in detail before invoking the IDE has proven
+ to be less convenient for many developers. It is substantially easier to
+ start with a simple model/view application that has demo data. Give it a
+ try! Simply replace the data in the examples below with your own.
+
+ Below are 7 very simple and independent applications that show different
+ sides of model/view programming. The source code can be found inside the
+ \c{examples/tutorials/modelview} directory.
+
+ \section2 2.1 A Read Only Table
+
+ We start with an application that uses a QTableView to show data. We will
+ add editing capabilities later.
+
+ (file source: examples/tutorials/modelview/1_readonly/main.cpp)
+ \snippet tutorials/modelview/1_readonly/main.cpp Quoting ModelView Tutorial
+
+ We have the usual \l {modelview-part2-main-cpp.html}{main()} function:
+
+ Here is the interesting part: We create an instance of MyModel and use
+ \l{QTableView::setModel()}{tableView.setModel(&myModel);} to pass a
+ pointer of it to to \l{QTableView}{tableView}. \l{QTableView}{tableView}
+ will invoke the methods of the pointer it has received to find out two
+ things:
+
+ \list
+ \li How many rows and columns should be displayed.
+ \li What content should be printed into each cell.
+ \endlist
+
+ The model needs some code to respond to this.
+
+ We have a table data set, so let's start with QAbstractTableModel since it
+ is easier to use than the more general QAbstractItemModel.
+
+ (file source: examples/tutorials/modelview/1_readonly/mymodel.h)
+ \snippet tutorials/modelview/1_readonly/mymodel.h Quoting ModelView Tutorial
+
+ QAbstractTableModel requires the implementation of three abstract methods.
+
+ (file source: examples/tutorials/modelview/1_readonly/mymodel.cpp)
+ \snippet tutorials/modelview/1_readonly/mymodel.cpp Quoting ModelView Tutorial
+
+ The number of rows and columns is provided by
+ \l{QAbstractItemModel::rowCount()}{MyModel::rowCount()} and
+ \l{QAbstractItemModel::columnCount()}{MyModel::columnCount()}. When the view
+ has to know what the cell's text is, it calls the method
+ \l{QAbstractItemModel::data()}{MyModel::data()}. Row and column information
+ is specified with parameter \c index and the role is set to
+ \l{Qt::ItemDataRole}{Qt::DisplayRole}. Other roles are covered in the next
+ section. In our example, the data that should be displayed is generated. In
+ a real application, \c MyModel would have a member called \c MyData, which
+ serves as the target for all reading and writing operations.
+
+ This small example demonstrates the passive nature of a model. The model
+ does not know when it will be used or which data is needed. It simply
+ provides data each time the view requests it.
+
+ What happens when the model's data needs to be changed? How does the view
+ realize that data has changed and needs to be read again? The model has to
+ emit a signal that indicates what range of cells has changed. This will be
+ demonstrated in section 2.3.
+
+ \section2 2.2 Extending the Read Only Example with Roles
+
+ In addition to controlling what text the view displays, the model also
+ controls the text's appearance. When we slightly change the model, we get
+ the following result: \image readonlytable_role.png
+
+ In fact, nothing except for the \l{QAbstractItemModel::}{data()} method
+ needs to be changed to set fonts, background colour, alignment and a
+ checkbox.
+ Below is the \l{QAbstractItemModel::data()}{data()} method that produces the
+ result shown above. The difference is that this time we use parameter int
+ role to return different pieces of information depending on its value.
+
+ (file source: examples/tutorials/modelview/2_formatting/mymodel.cpp)
+ \snippet tutorials/modelview/2_formatting/mymodel.cpp Quoting ModelView Tutorial
+
+ Each formatting property will be requested from the model with a separate
+ call to the \l{QAbstractItemModel::data()}{data()} method. The \c role
+ parameter is used to let the model know which property is being requested:
+
+ \table
+ \header
+ \li \l{Qt::ItemDataRole}{enum Qt::ItemDataRole}
+ \li Meaning
+ \li Type
+ \row
+ \li \l{Qt::ItemDataRole}{}Qt::DisplayRole
+ \li text
+ \li QString
+ \row
+ \li \l{Qt::ItemDataRole}{Qt::FontRole}
+ \li font
+ \li QFont
+ \row
+ \li \l{Qt::ItemDataRole}{BackgroundRole}
+ \li brush for the background of the cell
+ \li QBrush
+ \row
+ \li \l{Qt::ItemDataRole}{Qt::TextAlignmentRole}
+ \li text alignment
+ \li \l{Qt::AlignmentFlag}{enum Qt::AlignmentFlag}
+ \row
+ \li {1, 3} \l{Qt::ItemDataRole}{Qt::CheckStateRole}
+ \li {1, 3} suppresses checkboxes with \l{QVariant}{QVariant()},
+
+ sets checkboxes with \l{Qt::CheckState}{Qt::Checked}
+
+ or \l{Qt::CheckState}{Qt::Unchecked}
+ \li {1, 3} \l{Qt::ItemDataRole}{enum Qt::ItemDataRole}
+ \endtable
+
+ Refer to the Qt namespace documentation to learn more about the
+ \l{Qt::ItemDataRole}{Qt::ItemDataRole} enum's capabilities.
+
+ Now we need to determine how using a separated model impacts the
+ application's performance, so let's trace how often the view calls the
+ \l{QAbstractItemModel::}{data()} method. In order to track how often the
+ view calls the model, we have put a debug statement in the
+ \l{QAbstractItemModel::}{data()} method, which logs onto the error output
+ stream. In our small example, \l{QAbstractItemModel::}{data()} will be
+ called 42 times.
+ Each time you hover the cursor over the field,
+ \l{QAbstractItemModel::}{data()} will be called again -- 7 times for
+ each cell. That's why it is important to make sure that your data is
+ available when \l{QAbstractItemModel::}{data()} is invoked and expensive
+ lookup operations are cached.
+
+ \section2 2.3 A Clock inside a Table Cell
+
+ \image clock.png
+
+ We still have a read only table, but this time the content changes every
+ second because we are showing the current time.
+
+ (file source: examples/tutorials/modelview/3_changingmodel/mymodel.cpp)
+ \snippet tutorials/modelview/3_changingmodel/mymodel.cpp quoting mymodel_QVariant
+
+ Something is missing to make the clock tick. We need to tell the view every
+ second that the time has changed and that it needs to be read again. We do
+ this with a timer. In the constructor, we set its interval to 1 second and
+ connect its timeout signal.
+
+ (file source: examples/tutorials/modelview/3_changingmodel/mymodel.cpp)
+ \snippet tutorials/modelview/3_changingmodel/mymodel.cpp quoting mymodel_a
+
+ Here is the corresponding slot:
+
+ (file source: examples/tutorials/modelview/3_changingmodel/mymodel.cpp)
+ \snippet tutorials/modelview/3_changingmodel/mymodel.cpp quoting mymodel_b
+
+ We ask the view to read the data in the top left cell again by emitting the
+ \l{QAbstractItemModel::}{dataChanged()} signal. Note that we did not
+ explicitly connect the \l{QAbstractItemModel::}{dataChanged()} signal to the
+ view. This happened automatically when we called \l{QTableView::}{setModel()}.
+
+ \section2 2.4 Setting up Headers for Columns and Rows
+
+ Headers can be hidden via a view method: \c{tableView->verticalHeader()->hide();}
+ \image modelview-header.png
+
+ The header content, however, is set via the model, so we reimplement the
+ \l{QAbstractItemModel::headerData()}{headerData()} method:
+
+ (file source: examples/tutorials/modelview/4_headers/mymodel.cpp)
+ \snippet tutorials/modelview/4_headers/mymodel.cpp quoting mymodel_c
+
+ Note that method \l{QAbstractItemModel::headerData()}{headerData()} also has
+ a parameter role which has the same meaning as in
+ \l{QAbstractItemModel::data()}{MyModel::data()}.
+
+ \section2 2.5 The Minimal Editing Example
+
+ In this example, we are going to build an application that automatically
+ populates a window title with content by repeating values entered into table
+ cells. To be able to access the window title easily we put the QTableView in
+ a QMainWindow.
+
+ The model decides whether editing capabilities are available. We only have
+ to modify the model in order for the available editing capabilities to be
+ enabled. This is done by reimplementing the following virtual methods:
+ \l{QAbstractItemModel::}{setData()} and \l{QAbstractItemModel::}{flags()}.
+
+ (file source: examples/tutorials/modelview/5_edit/mymodel.h)
+ \snippet tutorials/modelview/5_edit/mymodel.h Quoting ModelView Tutorial
+
+ We use \c the two-dimensional array QString \c m_gridData to store our data.
+ This makes \c m_gridData the core of \c MyModel. The rest of \c MyModel acts
+ like a wrapper and adapts \c m_gridData to the QAbstractItemModel
+ interface. We have also introduced the \c editCompleted() signal, which
+ makes it possible to transfer the modified text to the window title.
+
+ (file source: examples/tutorials/modelview/5_edit/mymodel.cpp)
+ \snippet tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_e
+
+ \l{QAbstractItemModel::setData()}{setData()} will be called each time the
+ user edits a cell. The \c index parameter tells us which field has been
+ edited and \c value provides the result of the editing process. The role
+ will always be set to \l Qt::EditRole because our cells only contain text.
+ If a checkbox were present and user permissions are set to allow the
+ checkbox to be selected, calls would also be made with the role set to
+ \l Qt::CheckStateRole.
+
+ (file source: examples/tutorials/modelview/5_edit/mymodel.cpp)
+ \snippet tutorials/modelview/5_edit/mymodel.cpp quoting mymodel_f
+
+ Various properties of a cell can be adjusted with
+ \l{QAbstractItemModel::flags()}{flags()}.
+
+ Returning \l{Qt::ItemFlag}{Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled}
+ is enough to show an editor that a cell can be selected.
+
+ If editing one cell modifies more data than the data in that particular
+ cell, the model must emit a \l{QAbstractItemModel::}{dataChanged()} signal
+ in order for the data that has been changed to be read.
+
+
+ \section1 3. Intermediate Topics
+
+ \section2 3.1 TreeView
+
+ You can convert the example above into an application with a tree view.
+ Simply replace QTableView with QTreeView, which results in a read/write
+ tree. No changes have to be made to the model. The tree won't have any
+ hierarchies because there aren't any hierarchies in the model itself.
+
+ \image dummy_tree.png
+
+ QListView, QTableView and QTreeView all use a model abstraction, which is a
+ merged list, table and tree. This makes it possible to use several different
+ types of view classes from the same model.
+
+ \image list_table_tree.png
+
+ This is how our example model looks so far:
+
+ \image example_model.png
+
+ We want to present a real tree. We have wrapped our data in the examples
+ above in order to make a model. This time we use QStandardItemModel, which
+ is a container for hierarchical data that also implements
+ QAbstractItemModel. To show a tree, QStandardItemModel must be populated
+ with \l{QStandardItem}s, which are able to hold all the standard properties
+ of items like text, fonts, checkboxes or brushes.
+
+ \image tree_2_with_algorithm.png
+
+ (file source: examples/tutorials/modelview/6_treeview/mainwindow.cpp)
+ \snippet tutorials/modelview/6_treeview/mainwindow.cpp Quoting ModelView Tutorial
+
+ We simply instantiate a QStandardItemModel and add a couple of
+ \l{QStandardItem}{QStandardItems} to the constructor. We can then make a
+ hierarchical data structure because a QStandardItem can hold other
+ \l{QStandardItem}{QStandardItems}. Nodes are collapsed and expanded within
+ the view.
+
+ \section2 3.2 Working with Selections
+
+ We want to access a selected item's content in order to output it into the
+ window title together with the hierarchy level.
+
+ \image selection2.png
+
+ So let's create a couple of items:
+
+ (file source: examples/tutorials/modelview/7_selections/mainwindow.cpp)
+ \snippet tutorials/modelview/7_selections/mainwindow.cpp quoting modelview_a
+
+ Views manage selections within a separate selection model, which can be
+ retrieved with the \l{QAbstractItemView::}{selectionModel()} method. We
+ retrieve the selection Model in order to connect a slot to its
+ \l{QAbstractItemView::}{selectionChanged()} signal.
+
+ (file source: examples/tutorials/modelview/7_selections/mainwindow.cpp)
+ \snippet tutorials/modelview/7_selections/mainwindow.cpp quoting modelview_b
+
+ We get the model index that corresponds to the selection by calling
+ \l{QItemSelectionModel::currentIndex()}{treeView->selectionModel()->currentIndex()}
+ and we get the the field's string by using the model index. Then we just
+ calculate the item's \c hierarchyLevel. Top level items do not have parents
+ and the \l{QAbstractItemModel::}{parent()} method will return a default
+ constructed \l{QModelIndex}{QModelIndex()}. This is why we use the
+ \l{QAbstractItemModel::}{parent()} method to iterate to the top level while
+ counting the steps performed during iteration.
+
+ The selection model (as shown above) can be retrieved, but it can also be
+ set with \l{QAbstractItemView}{QAbstractItemView::setSelectionModel}. This
+ is how it's possible to have 3 view classes with synchronized selections
+ because only one instance of a selection model is used. To share a selection
+ model between 3 views use \l{QAbstractItemView::}{selectionModel()} and
+ assign the result to the second and third view class with
+ \l{QAbstractItemView::}{setSelectionModel()}.
+
+ \section2 3.3 Predefined Models
+
+ The typical way to use model/view is to wrap specific data to make it usable
+ with view classes. Qt, however, also provides predefined models for common
+ underlying data structures. If one of the available data structures is
+ suitable for your application, a predefined model can be a good choice.
+
+ \table
+ \row
+ \li QStringListModel
+ \li Stores a list of strings
+ \row
+ \li QStandardItemModel
+ \li Stores arbitrary hierarchical items
+ \row
+ \li QFileSystemModel\br
+ QDirModel
+ \li Encapsulate the local file system
+ \row
+ \li QSqlQueryModel
+ \li Encapsulate an SQL result set
+ \row
+ \li QSqlTableModel
+ \li Encapsulates an SQL table
+ \row
+ \li QSqlRelationalTableModel
+ \li Encapsulates an SQL table with foreign keys
+ \row
+ \li QSortFilterProxyModel
+ \li Sorts and/or filters another model
+
+ \endtable
+
+ \section2 3.4 Delegates
+
+ In all examples so far, data is presented as text or a checkbox in a cell
+ and is edited as text or a checkbox. The component that provides these
+ presentation and editing services is called a \e delegate. We are only just
+ beginning to work with the delegate because the view uses a default
+ delegate. But imagine that we want to have a different editor (e.g., a
+ slider or a drop down list) Or imagine that we want to present data as
+ graphics.
+ Let's take a look at an example called \l{Star Delegate Example}{Star
+ Delegate}, in which stars are used to show a rating:
+
+ \image stardelegate.png
+
+ The view has a \l{QAbstractItemView::}{setItemDelegate()} method that
+ replaces the default delegate and installs a custom delegate.
+ A new delegate can be written by creating a class that inherits from
+ QStyledItemDelegate. In order to write a delegate that displays stars and
+ has no input capabilities, we only need to override 2 methods.
+
+ \code
+ class StarDelegate : public QStyledItemDelegate
+ {
+ Q_OBJECT
+ public:
+ StarDelegate(QWidget *parent = 0);
+ void paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+ QSize sizeHint(const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+ };
+ \endcode
+
+ \l{QStyledItemDelegate::}{paint()} draws stars depending on the content of
+ the underlying data. The data can be looked up by calling
+ \l{QModelIndex::data()}{index.data()}. The delegate's
+ \l{QAbstractItemDelegate::}{sizeHint()} method is used to obtain each
+ star's dimensions, so the the cell will provide enough height and width to
+ accommodate the stars.
+
+ Writing custom delegates is the right choice if you want to show your data
+ with a custom graphical representation inside the grid of the view class. If
+ you want to leave the grid, you would not use a custom delegate but a custom
+ view class.
+
+ Other references to delegates in Qt Documentation:
+
+ \list
+ \li \l{Spin Box Delegate Example}
+ \li \l{QAbstractItemDelegate}{QAbstractItemDelegate Class Reference}
+ \li \l{QSqlRelationalDelegate}{QSqlRelationalDelegate Class Reference}
+ \li \l{QStyledItemDelegate}{QStyledItemDelegate Class Reference}
+ \li \l{QItemDelegate}{QItemDelegate Class Reference}
+ \endlist
+
+
+ \section2 3.5 Debugging with ModelTest
+
+ The passive nature of models provides new challenges for programmers.
+ Inconsistencies in the model can cause the application to crash. Since the
+ model is hit by numerous calls from the view, it is hard to find out which
+ call has crashed the application and which operation has introduced the
+ problem.
+
+ Qt Labs provides software called
+ \l{http://labs.qt.nokia.com/page/Projects/Itemview/Modeltest}{ModelTest},
+ which checks models while your programming is running. Every time the model
+ is changed, ModelTest scans the model and reports errors with an assert.
+ This is especially important for tree models, since their hierarchical
+ nature leaves many possibilities for subtle inconsistencies.
+
+ Unlike view classes, ModelTest uses out of range indexes to test the model.
+ This means your application may crash with ModelTest even if it runs
+ perfectly without it. So you also need to handle all of the indexes that are
+ out of range when using ModelTest.
+
+
+ \section1 4. Good Sources of Additional Information
+
+ \section2 4.1 Books
+
+ Model/View programming is covered quite extensively in the documentation of
+ Qt but also in several good books.
+
+ \list 1
+ \li \b{C++ GUI Programming with Qt 4} / Jasmin Blanchette, Mark Summerfield,
+ \e{Prentice Hall, 2nd edition}, ISBN 0-13-235416-0. Also available in
+ German: \b{C++ GUI Programmierung mit Qt 4: Die offizielle Einführung},
+ \e{Addison-Wesley}, ISBN 3-827327-29-6
+ \li \b{The Book of Qt4, The Art of Building Qt Applications} / Daniel Molkentin,
+ \e{Open Source Press}, ISBN 1-59327-147-6.
+ Translated from \b{Qt 4, Einführung in die Applikationsentwicklung},
+ \e{Open Source Press}, ISBN 3-937514-12-0.
+ \li \b{Foundations of Qt Development} / Johan Thelin, \e{Apress}, ISBN 1-59059-831-8.
+ \li \b{Advanced Qt Programming} / Mark Summerfield, \e{Prentice Hall}, ISBN 0-321-63590-6.
+ This book covers Model/View programming on more than 150 pages.
+ \endlist
+
+ More information about these books is available on the
+ \l{Books about Qt Programming}{Qt Web site}.
+
+ The following list provides an overview of example programs contained in the first three
+ books listed above. Some of them make very good templates for developing similar
+ applications.
+
+ \table
+ \header
+ \li Example name
+ \li View class used
+ \li Model used
+ \li Aspects covered
+ \li
+ \row
+ \li Team Leaders
+ \li QListview
+ \li QStringListModel
+ \li
+ \li Book 1, Chapter 10, Figure 10.6
+ \row
+ \li Directory Viewer
+ \li QTreeView
+ \li QDirModel
+ \li
+ \li Book 1, Chapter 10, Figure 10.7
+ \row
+ \li Color Names
+ \li QListView
+ \li QSortFilterProxyModel
+ applied to QStringListModel
+ \li
+ \li Book 1, Chapter 10, Figure 10.8
+ \row
+ \li Currencies
+ \li QTableView
+ \li custom model based on
+ QAbstractTableModel
+ \li Read only
+ \li Book 1, Chapter 10, Figure 10.10
+ \row
+ \li Cities
+ \li QTableView
+ \li Custom model based on
+ QAbstractTableModel
+ \li Read / write
+ \li Book 1, Chapter 10, Figure 10.12
+ \row
+ \li Boolean Parser
+ \li QTreeView
+ \li Custom model based on
+ QAbstractItemModel
+ \li Read only
+ \li Book 1, Chapter 10, Figure 10.14
+ \row
+ \li Track Editor
+ \li {2, 1} QTableWidget
+ \li Custom delegate providing a custom editor
+ \li Book 1, Chapter 10, Figure 10.15
+
+ \row
+ \li Four directory views
+ \li QListView
+ QTableView
+ QTreeView
+ \li QDirModel
+ \li Demonstrates the use of multiple views
+ \li Book2, Chapter 8.2
+ \row
+ \li Address Book
+ \li QListView
+ QTableView
+ QTreeView
+ \li Custom model based on
+ QAbstractTableModel
+ \li Read / write
+ \li Book2, Chapter 8.4
+ \row
+ \li Address Book with sorting
+ \li
+ \li QProxyModel
+ \li Introducing sort and filter capabilities
+ \li Book2, Chapter 8.5
+ \row
+ \li Address Book
+ with checkboxes
+ \li
+ \li
+ \li Introducing checkboxes in model/view
+ \li Book2, Chapter 8.6
+ \row
+ \li Address Book with transposed grid
+ \li
+ \li Custom proxy Model based on QAbstractProxyModel
+ \li Introducing a custom model
+ \li Book2, Chapter 8.7
+ \row
+ \li Address Book with drag and drop
+ \li
+ \li
+ \li Introducing drag and drop support
+ \li Book2, Chapter 8.8
+ \row
+ \li Address Book with custom editor
+ \li
+ \li
+ \li Introducing custom delegates
+ \li Book2, Chapter 8.9
+ \row
+ \li Views
+ \li QListView
+ QTableView
+ QTreeView
+ \li QStandardItemModel
+ \li Read only
+ \li Book 3, Chapter 5, figure 5-3
+ \row
+ \li Bardelegate
+ \li QTableView
+ \li
+ \li Custom delegate for presentation based on QAbstractItemDelegate
+ \li Book 3, Chapter 5, figure 5-5
+ \row
+ \li Editdelegate
+ \li QTableView
+ \li
+ \li Custom delegate for editing based on QAbstractItemDelegate
+ \li Book 3, Chapter 5, figure 5-6
+ \row
+ \li Singleitemview
+ \li Custom view based on QAbstractItemView
+ \li
+ \li Custom view
+ \li Book 3,
+ Chapter 5,
+ figure 5-7
+ \row
+ \li listmodel
+ \li QTableView
+ \li Custom Model based on QAbstractTableModel
+ \li Read only
+ \li Book 3, Chapter 5, Figure 5-8
+ \row
+ \li treemodel
+ \li QTreeView
+ \li Custom Model based on QAbstractItemModel
+ \li Read only
+ \li Book 3, Chapter 5, Figure 5-10
+ \row
+ \li edit integers
+ \li QListView
+ \li Custom Model based on QAbstractListModel
+ \li Read / write
+ \li Book 3, Chapter 5, Listing 5-37, Figure 5-11
+ \row
+ \li sorting
+ \li QTableView
+ \li QSortFilterProxyModel applied to QStringListModel
+ \li Demonstrates sorting
+ \li Book 3, Chapter 5, Figure 5-12
+ \endtable
+
+
+ \section2 4.2 Qt Documentation
+
+ Qt 5.0 comes with 19 examples for model/view.
+ The examples can be found on the \l{Item Views Examples} page.
+
+ \table
+ \header
+ \li Example name
+ \li View class used
+ \li Model used
+ \li Aspects covered
+ \row
+ \li Address Book
+ \li QTableView
+ \li QAbstractTableModel
+ QSortFilterProxyModel
+ \li Usage of QSortFilterProxyModel to generate different
+ subsets from one data pool
+ \row
+ \li Basic Sort/Filter Model
+ \li QTreeView
+ \li QStandardItemModel
+ QSortFilterProxyModel
+ \li
+ \row
+ \li Chart
+ \li Custom view
+ \li QStandardItemModel
+ \li Designing custom views that cooperate with selection models
+ \row
+ \li Color Editor Factory
+ \li {2, 1} QTableWidget
+ \li Enhancing the standard delegate with a new custom editor to choose colours
+ \row
+ \li Combo Widget Mapper
+ \li QDataWidgetMapper to map QLineEdit, QTextEdit and QComboBox
+ \li QStandardItemModel
+ \li Shows how a QComboBox can serve as a view class
+ \row
+ \li Custom Sort/Filter Model
+ \li QTreeView
+ \li QStandardItemModel
+ QSortFilterProxyModel
+ \li Subclass QSortFilterProxyModel for advanced sorting and filtering
+ \row
+ \li Dir View
+ \li QTreeView
+ \li QDirModel
+ \li Very small example to demonstrate how to assign a model to a view
+ \row
+ \li Editable Tree Model
+ \li QTreeView
+ \li Custom tree model
+ \li Comprehensive example for working with trees, demonstrates
+ editing cells and tree structure with an underlying custom
+ model
+ \row
+ \li Fetch More
+ \li QListView
+ \li Custom list model
+ \li Dynamically changing model
+ \row
+ \li Frozen Column
+ \li QTableView
+ \li QStandardItemModel
+ \li
+ \row
+ \li Interview
+ \li Multiple
+ \li Custom item model
+ \li Multiple views
+ \row
+ \li Pixelator
+ \li QTableView
+ \li Custom table model
+ \li Implementation of a custom delegate
+ \row
+ \li Puzzle
+ \li QListView
+ \li Custom list model
+ \li Model/view with drag and drop
+ \row
+ \li Simple DOM Model
+ \li QTreeView
+ \li Custom tree model
+ \li Read only example for a custom tree model
+ \row
+ \li Simple Tree Model
+ \li QTreeView
+ \li Custom tree model
+ \li Read only example for a custom tree model
+ \row
+ \li Simple Widget Mapper
+ \li QDataWidgetMapper to map QLineEdit, QTextEdit and QSpinBox
+ \li QStandardItemModel
+ \li Basic QDataWidgetMapper usage
+ \row
+ \li Spin Box Delegate
+ \li QTableView
+ \li QStandardItemModel
+ \li Custom delegate that uses a spin box as a cell editor
+ \row
+ \li Spreadsheet
+ \li {2, 1} QTableView
+ \li Custom delegates
+ \row
+ \li Star Delegate
+ \li {2, 1} QTableWidget
+ \li Comprehensive custom delegate example.
+ \endtable
+
+ A \l{Model/View Programming}{reference document} for model/view technology
+ is also available.
+*/
+
+/*!
+ \page modelview-part2-main-cpp.html
+ \title main.cpp
+ \quotefile tutorials/modelview/1_readonly/main.cpp
+*/
diff --git a/src/widgets/doc/src/qtwidgets.qdoc b/src/widgets/doc/src/qtwidgets.qdoc
new file mode 100644
index 0000000000..9267b0fb44
--- /dev/null
+++ b/src/widgets/doc/src/qtwidgets.qdoc
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \module QtWidgets
+ \title QtWidgets Module
+ \ingroup modules
+
+ \brief The QtWidgets module extends QtGui with C++ widget functionality.
+
+ To include the definitions of the module's classes, use the
+ following directive:
+
+ \snippet code/doc_src_qtwidgets.cpp 1
+
+ To link against the module, add this line to your \l qmake \c
+ .pro file:
+
+ \snippet code/doc_src_qtwidgets.pro 0
+*/
+
diff --git a/src/widgets/doc/src/widgets-and-layouts/focus.qdoc b/src/widgets/doc/src/widgets-and-layouts/focus.qdoc
new file mode 100644
index 0000000000..60f05948b4
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/focus.qdoc
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page focus.html
+ \title Keyboard Focus
+ \brief Keyboard focus management and handling.
+ \ingroup frameworks-technologies
+
+ \keyword keyboard focus
+
+ Qt's widgets handle keyboard focus in the ways that have become
+ customary in GUIs.
+
+ The basic issue is that the user's key strokes can be directed at any
+ of several windows on the screen, and any of several widgets inside
+ the intended window. When the user presses a key, they expect it to go
+ to the right place, and the software must try to meet this
+ expectation. The system must determine which application the key stroke
+ is directed at, which window within that application, and which widget
+ within that window.
+
+ \section1 Focus Motion
+
+ The customs which have evolved for directing keyboard focus to a
+ particular widget are these:
+
+ \list 1
+
+ \li The user presses \key Tab (or \key Shift+Tab).
+ \li The user clicks a widget.
+ \li The user presses a keyboard shortcut.
+ \li The user uses the mouse wheel.
+ \li The user moves the focus to a window, and the application must
+ determine which widget within the window should get the focus.
+ \endlist
+
+ Each of these motion mechanisms is different, and different types of
+ widgets receive focus in only some of them. We'll cover each of them
+ in turn.
+
+ \section2 Tab or Shift+Tab
+
+ Pressing \key Tab is by far the most common way to move focus
+ using the keyboard. (Sometimes in data-entry applications Enter
+ does the same as \key{Tab}; this can easily be achieved in Qt by
+ implementing an \l{The Event System}{event filter}.)
+
+ Pressing \key Tab, in all window systems in common use today,
+ moves the keyboard focus to the next widget in a circular
+ per-window list. \key Tab moves focus along the circular list in
+ one direction, \key Shift+Tab in the other. The order in which
+ \key Tab presses move from widget to widget is called the tab order.
+
+ You can customize the tab order using QWidget::setTabOrder(). (If
+ you don't, \key Tab generally moves focus in the order of widget
+ construction.) \l{Qt Designer} provides a means of visually
+ changing the tab order.
+
+ Since pressing \key Tab is so common, most widgets that can have focus
+ should support tab focus. The major exception is widgets that are
+ rarely used, and where there is some keyboard accelerator or error
+ handler that moves the focus.
+
+ For example, in a data entry dialog, there might be a field that
+ is only necessary in one per cent of all cases. In such a dialog,
+ \key Tab could skip this field, and the dialog could use one of
+ these mechanisms:
+
+ \list 1
+
+ \li If the program can determine whether the field is needed, it can
+ move focus there when the user finishes entry and presses \gui OK, or when
+ the user presses Enter after finishing the other fields. Alternately,
+ include the field in the tab order but disable it. Enable it if it
+ becomes appropriate in view of what the user has set in the other
+ fields.
+
+ \li The label for the field can include a keyboard shortcut that moves
+ focus to this field.
+
+ \endlist
+
+ Another exception to \key Tab support is text-entry widgets that
+ must support the insertion of tabs; almost all text editors fall
+ into this class. Qt treats \key Ctrl+Tab as \key Tab and \key
+ Ctrl+Shift+Tab as \key Shift+Tab, and such widgets can
+ reimplement QWidget::event() and handle Tab before calling
+ QWidget::event() to get normal processing of all other keys.
+ However, since some systems use \key Ctrl+Tab for other purposes,
+ and many users aren't aware of \key Ctrl+Tab anyway, this isn't a
+ complete solution.
+
+ \section2 The User Clicks a Widget
+
+ This is perhaps even more common than pressing \key Tab on
+ computers with a mouse or other pointing device.
+
+ Clicking to move the focus is slightly more powerful than \key
+ Tab. While it moves the focus \e to a widget, for editor widgets
+ it also moves the text cursor (the widget's internal focus) to
+ the spot where the mouse is clicked.
+
+ Since it is so common and people are used to it, it's a good idea to
+ support it for most widgets. However, there is also an important
+ reason to avoid it: you may not want to remove focus from the widget
+ where it was.
+
+ For example, in a word processor, when the user clicks the 'B' (bold)
+ tool button, what should happen to the keyboard focus? Should it
+ remain where it was, almost certainly in the editing widget, or should
+ it move to the 'B' button?
+
+ We advise supporting click-to-focus for widgets that support text
+ entry, and to avoid it for most widgets where a mouse click has a
+ different effect. (For buttons, we also recommend adding a keyboard
+ shortcut: QAbstractButton and its subclasses make this very easy.)
+
+ In Qt, only the QWidget::setFocusPolicy() function affects
+ click-to-focus.
+
+ \section2 The User Presses a Keyboard Shortcut
+
+ It's not unusual for keyboard shortcuts to move the focus. This
+ can happen implicitly by opening modal dialogs, but also
+ explicitly using focus accelerators such as those provided by
+ QLabel::setBuddy(), QGroupBox, and QTabBar.
+
+ We advise supporting shortcut focus for all widgets that the user
+ may want to jump to. For example, a tab dialog can have keyboard
+ shortcuts for each of its pages, so the user can press e.g. \key
+ Alt+P to step to the \underline{P}rinting page. It is easy to
+ overdo this: there are only a few keys, and it's also important
+ to provide keyboard shortcuts for commands. \key Alt+P is also
+ used for Paste, Play, Print, and Print Here in the \l{Standard
+ Accelerator Keys} list, for example.
+
+ \section2 The User Rotates the Mouse Wheel
+
+ On Microsoft Windows, mouse wheel usage is always handled by the
+ widget that has keyboard focus. On Mac OS X and X11, it's handled by
+ the widget that gets other mouse events.
+
+ The way Qt handles this platform difference is by letting widgets move
+ the keyboard focus when the wheel is used. With the right focus policy
+ on each widget, applications can work idiomatically correctly on
+ Windows, Mac OS X, and X11.
+
+ \section2 The User Moves the Focus to This Window
+
+ In this situation the application must determine which widget within
+ the window should receive the focus.
+
+ This can be simple: If the focus has been in this window before,
+ then the last widget to have focus should regain it. Qt does this
+ automatically.
+
+ If focus has never been in this window before and you know where
+ focus should start out, call QWidget::setFocus() on the widget
+ which should receive focus before you call QWidget::show() it. If
+ you don't, Qt will pick a suitable widget.
+*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery-cde.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery-cde.qdoc
new file mode 100644
index 0000000000..a74cab0509
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/gallery-cde.qdoc
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page gallery-cde.html
+
+ \title CDE Style Widget Gallery
+ \ingroup gallery
+
+ This page shows some of the widgets available in Qt
+ when configured to use the "cde" style.
+
+\section2 Buttons
+
+\table 100%
+\row
+\li \image cde-checkbox.png
+ \caption The QCheckBox widget provides a checkbox with a text label.
+\li \image cde-radiobutton.png
+ \caption The QRadioButton widget provides a radio button with a text or pixmap label.
+\li \image cde-pushbutton.png
+ \image cde-toolbutton.png
+ \caption The QPushButton widget provides a command button.
+\endtable
+
+\section2 Containers
+
+\table 100%
+\row
+\li \image cde-groupbox.png
+ The The QGroupBox widget provides a group box frame with a title.
+\li \image cde-tabwidget.png
+ The QTabWidget class provides a stack of tabbed widgets.
+\li \image cde-frame.png
+ The QFrame widget provides a simple decorated container for other widgets.
+\li \image cde-toolbox.png
+ The QToolBox class provides a column of tabbed widget items.
+\endtable
+
+\section2 Item Views
+
+\table 100%
+\row
+\li \image cde-listview.png
+ The QListView class provides a default model/view implementation of a list/icon view. The QListWidget class provides a classic item-based list/icon view.
+\li \image cde-treeview.png
+ The QTreeView class provides a default model/view implementation of a tree view. The QTreeWidget class provides a classic item-based tree view.
+\li \image cde-tableview.png
+ The QTableView class provides a default model/view implementation of a table view. The QTableWidget class provides a classic item-based table view.\li
+\li
+\endtable
+
+\section2 Display Widgets
+
+\table 100%
+\row
+\li \image cde-progressbar.png
+ The QProgressBar widget provides a horizontal progress bar.
+\li \image cde-label.png
+ The QLabel widget provides a text or image display.
+\li \image cde-lcdnumber.png
+ The QLCDNumber widget displays a number with LCD-like digits.
+\endtable
+
+\section2 Input Widgets
+
+\table 100%
+\row
+\li \image cde-lineedit.png
+ The QLineEdit widget is a one-line text editor.
+\li \image cde-dateedit.png
+ The QDateEdit class provides a widget for editing dates.
+\li \image cde-timeedit.png
+ The QTimeEdit class provides a widget for editing times.
+\li \image cde-datetimeedit.png
+ The QDateTimeEdit class provides a widget for editing dates and times.
+\endtable
+
+\table 100%
+\row
+\li \image cde-slider.png
+ The QSlider widget provides a vertical or horizontal slider.
+\li \image cde-combobox.png
+ The QComboBox widget is a combined button and pop-up list.
+\li \image cde-spinbox.png
+ The QSpinBox class provides a spin box widget.
+\endtable
+
+\table 100%
+\row
+\li \image cde-fontcombobox.png
+ The QFontComboBox widget is a specialized combobox that enables fonts to be selected from a pop-up list containing previews of available fonts.
+\li \image cde-doublespinbox.png
+ The QDoubleSpinBox class provides a spin box widget that allows double precision floating point numbers to be entered.
+\li \image cde-horizontalscrollbar.png
+ The QScrollBar widget provides a vertical or horizontal scroll bar. Here, we show a scroll bar with horizontal orientation.
+\endtable
+
+\table 100%
+\row
+\li \image cde-dial.png
+ The QDial class provides a rounded range control (like a speedometer or potentiometer).
+\li \image cde-textedit.png
+ The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
+\li \image cde-calendarwidget.png
+ The QCalendarWidget class provides a monthly calendar widget that can be used to select dates.
+\endtable
+
+*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery-cleanlooks.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery-cleanlooks.qdoc
new file mode 100644
index 0000000000..bed6d0ca40
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/gallery-cleanlooks.qdoc
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page gallery-cleanlooks.html
+
+ \title Cleanlooks Style Widget Gallery
+ \ingroup gallery
+
+ This page shows some of the widgets available in Qt
+ when configured to use the "cleanlooks" style.
+
+\section2 Buttons
+
+\table 100%
+\row
+\li \image cleanlooks-pushbutton.png
+ \caption The QPushButton widget provides a command button.
+\li \image cleanlooks-toolbutton.png
+ \caption The QToolButton class provides a quick-access button to commands
+ or options, usually used inside a QToolBar.
+\endtable
+
+\table 100%
+\row
+\li \image cleanlooks-checkbox.png
+ \caption The QCheckBox widget provides a checkbox with a text label.
+\li \image cleanlooks-radiobutton.png
+ \caption The QRadioButton widget provides a radio button with a text or pixmap label.
+\endtable
+
+\section2 Containers
+
+\table 100%
+\row
+\li \image cleanlooks-groupbox.png
+ The The QGroupBox widget provides a group box frame with a title.
+\li \image cleanlooks-tabwidget.png
+ The QTabWidget class provides a stack of tabbed widgets.
+\li \image cleanlooks-frame.png
+ The QFrame widget provides a simple decorated container for other widgets.
+\li \image cleanlooks-toolbox.png
+ The QToolBox class provides a column of tabbed widget items.
+\endtable
+
+\section2 Item Views
+
+\table 100%
+\row
+\li \image cleanlooks-listview.png
+ The QListView class provides a default model/view implementation of a list/icon view. The QListWidget class provides a classic item-based list/icon view.
+\li \image cleanlooks-treeview.png
+ The QTreeView class provides a default model/view implementation of a tree view. The QTreeWidget class provides a classic item-based tree view.
+\li \image cleanlooks-tableview.png
+ The QTableView class provides a default model/view implementation of a table view. The QTableWidget class provides a classic item-based table view.\li
+\li
+\endtable
+
+\section2 Display Widgets
+
+\table 100%
+\row
+\li \image cleanlooks-progressbar.png
+ The QProgressBar widget provides a horizontal progress bar.
+\li \image cleanlooks-label.png
+ The QLabel widget provides a text or image display.
+\li \image cleanlooks-lcdnumber.png
+ The QLCDNumber widget displays a number with LCD-like digits.
+\endtable
+
+\section2 Input Widgets
+
+\table 100%
+\row
+\li \image cleanlooks-lineedit.png
+ The QLineEdit widget is a one-line text editor.
+\li \image cleanlooks-dateedit.png
+ The QDateEdit class provides a widget for editing dates.
+\li \image cleanlooks-timeedit.png
+ The QTimeEdit class provides a widget for editing times.
+\li \image cleanlooks-datetimeedit.png
+ The QDateTimeEdit class provides a widget for editing dates and times.
+\endtable
+
+\table 100%
+\row
+\li \image cleanlooks-slider.png
+ The QSlider widget provides a vertical or horizontal slider.
+\li \image cleanlooks-combobox.png
+ The QComboBox widget is a combined button and pop-up list.
+\li \image cleanlooks-spinbox.png
+ The QSpinBox class provides a spin box widget.
+\endtable
+
+\table 100%
+\row
+\li \image cleanlooks-fontcombobox.png
+ The QFontComboBox widget is a specialized combobox that enables fonts to be selected from a pop-up list containing previews of available fonts.
+\li \image cleanlooks-doublespinbox.png
+ The QDoubleSpinBox class provides a spin box widget that allows double precision floating point numbers to be entered.
+\li \image cleanlooks-horizontalscrollbar.png
+ The QScrollBar widget provides a vertical or horizontal scroll bar. Here, we show a scroll bar with horizontal orientation.
+\endtable
+
+\table 100%
+\row
+\li \image cleanlooks-dial.png
+ The QDial class provides a rounded range control (like a speedometer or potentiometer).
+\li \image cleanlooks-textedit.png
+ The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
+\li \image cleanlooks-calendarwidget.png
+ The QCalendarWidget class provides a monthly calendar widget that can be used to select dates.
+\endtable
+*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery-gtk.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery-gtk.qdoc
new file mode 100644
index 0000000000..820f0b4140
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/gallery-gtk.qdoc
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page gallery-gtk.html
+
+ \title GTK Style Widget Gallery
+ \ingroup gallery
+
+ This page shows some of the widgets available in Qt
+ when configured to use the "gtk" style.
+
+ Take a look at the \l{Qt Widget Gallery} to see how Qt
+ applications appear in other styles.
+
+\section2 Buttons
+
+\table 100%
+\row
+\li \image gtk-pushbutton.png
+ \caption The QPushButton widget provides a command button.
+\li \image gtk-toolbutton.png
+ \caption The QToolButton class provides a quick-access button to commands
+ or options, usually used inside a QToolBar.
+\endtable
+
+\table 100%
+\row
+\li \image gtk-checkbox.png
+ \caption The QCheckBox widget provides a checkbox with a text label.
+\li \image gtk-radiobutton.png
+ \caption The QRadioButton widget provides a radio button with a text or pixmap label.
+\endtable
+
+\section2 Containers
+
+\table 100%
+\row
+\li \image gtk-groupbox.png
+ The The QGroupBox widget provides a group box frame with a title.
+\li \image gtk-tabwidget.png
+ The QTabWidget class provides a stack of tabbed widgets.
+\li \image gtk-frame.png
+ The QFrame widget provides a simple decorated container for other widgets.
+\li \image gtk-toolbox.png
+ The QToolBox class provides a column of tabbed widget items.
+\endtable
+
+\section2 Item Views
+
+\table 100%
+\row
+\li \image gtk-listview.png
+ The QListView class provides a default model/view implementation of a list/icon view. The QListWidget class provides a classic item-based list/icon view.
+\li \image gtk-treeview.png
+ The QTreeView class provides a default model/view implementation of a tree view. The QTreeWidget class provides a classic item-based tree view.
+\li \image gtk-tableview.png
+ The QTableView class provides a default model/view implementation of a table view. The QTableWidget class provides a classic item-based table view.\li
+\li
+\endtable
+
+\section2 Display Widgets
+
+\table 100%
+\row
+\li \image gtk-progressbar.png
+ The QProgressBar widget provides a horizontal progress bar.
+\li \image gtk-label.png
+ The QLabel widget provides a text or image display.
+\li \image gtk-lcdnumber.png
+ The QLCDNumber widget displays a number with LCD-like digits.
+\endtable
+
+\section2 Input Widgets
+
+\table 100%
+\row
+\li \image gtk-lineedit.png
+ The QLineEdit widget is a one-line text editor.
+\li \image gtk-dateedit.png
+ The QDateEdit class provides a widget for editing dates.
+\li \image gtk-timeedit.png
+ The QTimeEdit class provides a widget for editing times.
+\li \image gtk-datetimeedit.png
+ The QDateTimeEdit class provides a widget for editing dates and times.
+\endtable
+
+\table 100%
+\row
+\li \image gtk-slider.png
+ The QSlider widget provides a vertical or horizontal slider.
+\li \image gtk-combobox.png
+ The QComboBox widget is a combined button and pop-up list.
+\li \image gtk-spinbox.png
+ The QSpinBox class provides a spin box widget.
+\endtable
+
+\table 100%
+\row
+\li \image gtk-fontcombobox.png
+ The QFontComboBox widget is a specialized combobox that enables fonts to be selected from a pop-up list containing previews of available fonts.
+\li \image gtk-doublespinbox.png
+ The QDoubleSpinBox class provides a spin box widget that allows double precision floating point numbers to be entered.
+\li \image gtk-horizontalscrollbar.png
+ The QScrollBar widget provides a vertical or horizontal scroll bar. Here, we show a scroll bar with horizontal orientation.
+\endtable
+
+\table 100%
+\row
+\li \image gtk-dial.png
+ The QDial class provides a rounded range control (like a speedometer or potentiometer).
+\li \image gtk-textedit.png
+ The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
+\li \image gtk-calendarwidget.png
+ The QCalendarWidget class provides a monthly calendar widget that can be used to select dates.
+\endtable
+*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery-macintosh.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery-macintosh.qdoc
new file mode 100644
index 0000000000..488a3f7665
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/gallery-macintosh.qdoc
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page gallery-macintosh.html
+
+ \title Macintosh Style Widget Gallery
+ \ingroup gallery
+
+ This page shows some of the widgets available in Qt
+ when configured to use the "macintosh" style.
+
+\section2 Buttons
+
+\table 100%
+\row
+\li \image macintosh-pushbutton.png
+ \caption The QPushButton widget provides a command button.
+\li \image macintosh-toolbutton.png
+ \caption The QToolButton class provides a quick-access button to commands
+ or options, usually used inside a QToolBar.
+\endtable
+
+\table 100%
+\row
+\li \image macintosh-checkbox.png
+ \caption The QCheckBox widget provides a checkbox with a text label.
+\li \image macintosh-radiobutton.png
+ \caption The QRadioButton widget provides a radio button with a text or pixmap label.
+\endtable
+
+\section2 Containers
+
+\table 100%
+\row
+\li \image macintosh-groupbox.png
+ The The QGroupBox widget provides a group box frame with a title.
+\li \image macintosh-tabwidget.png
+ The QTabWidget class provides a stack of tabbed widgets.
+\li \image macintosh-frame.png
+ The QFrame widget provides a simple decorated container for other widgets.
+\li \image macintosh-toolbox.png
+ The QToolBox class provides a column of tabbed widget items.
+\endtable
+
+\section2 Item Views
+
+\table 100%
+\row
+\li \image macintosh-listview.png
+ The QListView class provides a default model/view implementation of a list/icon view. The QListWidget class provides a classic item-based list/icon view.
+\li \image macintosh-treeview.png
+ The QTreeView class provides a default model/view implementation of a tree view. The QTreeWidget class provides a classic item-based tree view.
+\li \image macintosh-tableview.png
+ The QTableView class provides a default model/view implementation of a table view. The QTableWidget class provides a classic item-based table view.\li
+\li
+\endtable
+
+\section2 Display Widgets
+
+\table 100%
+\row
+\li \image macintosh-progressbar.png
+ The QProgressBar widget provides a horizontal progress bar.
+\li \image macintosh-label.png
+ The QLabel widget provides a text or image display.
+\li \image macintosh-lcdnumber.png
+ The QLCDNumber widget displays a number with LCD-like digits.
+\endtable
+
+\section2 Input Widgets
+
+\table 100%
+\row
+\li \image macintosh-lineedit.png
+ The QLineEdit widget is a one-line text editor.
+\li \image macintosh-dateedit.png
+ The QDateEdit class provides a widget for editing dates.
+\li \image macintosh-timeedit.png
+ The QTimeEdit class provides a widget for editing times.
+\li \image macintosh-datetimeedit.png
+ The QDateTimeEdit class provides a widget for editing dates and times.
+\endtable
+
+\table 100%
+\row
+\li \image macintosh-slider.png
+ The QSlider widget provides a vertical or horizontal slider.
+\li \image macintosh-combobox.png
+ The QComboBox widget is a combined button and pop-up list.
+\li \image macintosh-spinbox.png
+ The QSpinBox class provides a spin box widget.
+\endtable
+
+\table 100%
+\row
+\li \image macintosh-fontcombobox.png
+ The QFontComboBox widget is a specialized combobox that enables fonts to be selected from a pop-up list containing previews of available fonts.
+\li \image macintosh-doublespinbox.png
+ The QDoubleSpinBox class provides a spin box widget that allows double precision floating point numbers to be entered.
+\li \image macintosh-horizontalscrollbar.png
+ The QScrollBar widget provides a vertical or horizontal scroll bar. Here, we show a scroll bar with horizontal orientation.
+\endtable
+
+\table 100%
+\row
+\li \image macintosh-dial.png
+ The QDial class provides a rounded range control (like a speedometer or potentiometer).
+\li \image macintosh-textedit.png
+ The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
+\li \image macintosh-calendarwidget.png
+ The QCalendarWidget class provides a monthly calendar widget that can be used to select dates.
+\endtable
+*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery-motif.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery-motif.qdoc
new file mode 100644
index 0000000000..5cbffc5516
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/gallery-motif.qdoc
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page gallery-motif.html
+
+ \title Motif Style Widget Gallery
+ \ingroup gallery
+
+ This page shows some of the widgets available in Qt
+ when configured to use the "motif" style.
+
+\section2 Buttons
+
+\table 100%
+\row
+\li \image motif-pushbutton.png
+ \caption The QPushButton widget provides a command button.
+\li \image motif-toolbutton.png
+ \caption The QToolButton class provides a quick-access button to commands
+ or options, usually used inside a QToolBar.
+\endtable
+
+\table 100%
+\row
+\li \image motif-checkbox.png
+ \caption The QCheckBox widget provides a checkbox with a text label.
+\li \image motif-radiobutton.png
+ \caption The QRadioButton widget provides a radio button with a text or pixmap label.
+\endtable
+
+\section2 Containers
+
+\table 100%
+\row
+\li \image motif-groupbox.png
+ The The QGroupBox widget provides a group box frame with a title.
+\li \image motif-tabwidget.png
+ The QTabWidget class provides a stack of tabbed widgets.
+\li \image motif-frame.png
+ The QFrame widget provides a simple decorated container for other widgets.
+\li \image motif-toolbox.png
+ The QToolBox class provides a column of tabbed widget items.
+\endtable
+
+\section2 Item Views
+
+\table 100%
+\row
+\li \image motif-listview.png
+ The QListView class provides a default model/view implementation of a list/icon view. The QListWidget class provides a classic item-based list/icon view.
+\li \image motif-treeview.png
+ The QTreeView class provides a default model/view implementation of a tree view. The QTreeWidget class provides a classic item-based tree view.
+\li \image motif-tableview.png
+ The QTableView class provides a default model/view implementation of a table view. The QTableWidget class provides a classic item-based table view.\li
+\li
+\endtable
+
+\section2 Display Widgets
+
+\table 100%
+\row
+\li \image motif-progressbar.png
+ The QProgressBar widget provides a horizontal progress bar.
+\li \image motif-label.png
+ The QLabel widget provides a text or image display.
+\li \image motif-lcdnumber.png
+ The QLCDNumber widget displays a number with LCD-like digits.
+\endtable
+
+\section2 Input Widgets
+
+\table 100%
+\row
+\li \image motif-lineedit.png
+ The QLineEdit widget is a one-line text editor.
+\li \image motif-dateedit.png
+ The QDateEdit class provides a widget for editing dates.
+\li \image motif-timeedit.png
+ The QTimeEdit class provides a widget for editing times.
+\li \image motif-datetimeedit.png
+ The QDateTimeEdit class provides a widget for editing dates and times.
+\endtable
+
+\table 100%
+\row
+\li \image motif-slider.png
+ The QSlider widget provides a vertical or horizontal slider.
+\li \image motif-combobox.png
+ The QComboBox widget is a combined button and pop-up list.
+\li \image motif-spinbox.png
+ The QSpinBox class provides a spin box widget.
+\endtable
+
+\table 100%
+\row
+\li \image motif-fontcombobox.png
+ The QFontComboBox widget is a specialized combobox that enables fonts to be selected from a pop-up list containing previews of available fonts.
+\li \image motif-doublespinbox.png
+ The QDoubleSpinBox class provides a spin box widget that allows double precision floating point numbers to be entered.
+\li \image motif-horizontalscrollbar.png
+ The QScrollBar widget provides a vertical or horizontal scroll bar. Here, we show a scroll bar with horizontal orientation.
+\endtable
+
+\table 100%
+\row
+\li \image motif-dial.png
+ The QDial class provides a rounded range control (like a speedometer or potentiometer).
+\li \image motif-textedit.png
+ The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
+\li \image motif-calendarwidget.png
+ The QCalendarWidget class provides a monthly calendar widget that can be used to select dates.
+\endtable
+*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery-plastique.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery-plastique.qdoc
new file mode 100644
index 0000000000..359fac8018
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/gallery-plastique.qdoc
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page gallery-plastique.html
+
+ \title Plastique Style Widget Gallery
+ \ingroup gallery
+
+ This page shows some of the widgets available in Qt
+ when configured to use the "plastique" style.
+
+\section2 Buttons
+
+\table 100%
+\row
+\li \image plastique-pushbutton.png
+ \caption The QPushButton widget provides a command button.
+\li \image plastique-toolbutton.png
+ \caption The QToolButton class provides a quick-access button to commands
+ or options, usually used inside a QToolBar.
+\endtable
+
+\table 100%
+\row
+\li \image plastique-checkbox.png
+ \caption The QCheckBox widget provides a checkbox with a text label.
+\li \image plastique-radiobutton.png
+ \caption The QRadioButton widget provides a radio button with a text or pixmap label.
+\endtable
+
+\section2 Containers
+
+\table 100%
+\row
+\li \image plastique-groupbox.png
+ The The QGroupBox widget provides a group box frame with a title.
+\li \image plastique-tabwidget.png
+ The QTabWidget class provides a stack of tabbed widgets.
+\li \image plastique-frame.png
+ The QFrame widget provides a simple decorated container for other widgets.
+\li \image plastique-toolbox.png
+ The QToolBox class provides a column of tabbed widget items.
+\endtable
+
+\section2 Item Views
+
+\table 100%
+\row
+\li \image plastique-listview.png
+ The QListView class provides a default model/view implementation of a list/icon view. The QListWidget class provides a classic item-based list/icon view.
+\li \image plastique-treeview.png
+ The QTreeView class provides a default model/view implementation of a tree view. The QTreeWidget class provides a classic item-based tree view.
+\li \image plastique-tableview.png
+ The QTableView class provides a default model/view implementation of a table view. The QTableWidget class provides a classic item-based table view.\li
+\li
+\endtable
+
+\section2 Display Widgets
+
+\table 100%
+\row
+\li \image plastique-progressbar.png
+ The QProgressBar widget provides a horizontal progress bar.
+\li \image plastique-label.png
+ The QLabel widget provides a text or image display.
+\li \image plastique-lcdnumber.png
+ The QLCDNumber widget displays a number with LCD-like digits.
+\endtable
+
+\section2 Input Widgets
+
+\table 100%
+\row
+\li \image plastique-lineedit.png
+ The QLineEdit widget is a one-line text editor.
+\li \image plastique-dateedit.png
+ The QDateEdit class provides a widget for editing dates.
+\li \image plastique-timeedit.png
+ The QTimeEdit class provides a widget for editing times.
+\li \image plastique-datetimeedit.png
+ The QDateTimeEdit class provides a widget for editing dates and times.
+\endtable
+
+\table 100%
+\row
+\li \image plastique-slider.png
+ The QSlider widget provides a vertical or horizontal slider.
+\li \image plastique-combobox.png
+ The QComboBox widget is a combined button and pop-up list.
+\li \image plastique-spinbox.png
+ The QSpinBox class provides a spin box widget.
+\endtable
+
+\table 100%
+\row
+\li \image plastique-fontcombobox.png
+ The QFontComboBox widget is a specialized combobox that enables fonts to be selected from a pop-up list containing previews of available fonts.
+\li \image plastique-doublespinbox.png
+ The QDoubleSpinBox class provides a spin box widget that allows double precision floating point numbers to be entered.
+\li \image plastique-horizontalscrollbar.png
+ The QScrollBar widget provides a vertical or horizontal scroll bar. Here, we show a scroll bar with horizontal orientation.
+\endtable
+
+\table 100%
+\row
+\li \image plastique-dial.png
+ The QDial class provides a rounded range control (like a speedometer or potentiometer).
+\li \image plastique-textedit.png
+ The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
+\li \image plastique-calendarwidget.png
+ The QCalendarWidget class provides a monthly calendar widget that can be used to select dates.
+\endtable
+*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery-windows.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery-windows.qdoc
new file mode 100644
index 0000000000..b118c845c6
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/gallery-windows.qdoc
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page gallery-windows.html
+
+ \title Windows Style Widget Gallery
+ \ingroup gallery
+
+ This page shows some of the widgets available in Qt
+ when configured to use the "windows" style.
+
+\section2 Buttons
+
+\table 100%
+\row
+\li \image windows-pushbutton.png
+ \caption The QPushButton widget provides a command button.
+\li \image windows-toolbutton.png
+ \caption The QToolButton class provides a quick-access button to commands
+ or options, usually used inside a QToolBar.
+\endtable
+
+\table 100%
+\row
+\li \image windows-checkbox.png
+ \caption The QCheckBox widget provides a checkbox with a text label.
+\li \image windows-radiobutton.png
+ \caption The QRadioButton widget provides a radio button with a text or pixmap label.
+\endtable
+
+\section2 Containers
+
+\table 100%
+\row
+\li \image windows-groupbox.png
+ The The QGroupBox widget provides a group box frame with a title.
+\li \image windows-tabwidget.png
+ The QTabWidget class provides a stack of tabbed widgets.
+\li \image windows-frame.png
+ The QFrame widget provides a simple decorated container for other widgets.
+\li \image windows-toolbox.png
+ The QToolBox class provides a column of tabbed widget items.
+\endtable
+
+\section2 Item Views
+
+\table 100%
+\row
+\li \image windows-listview.png
+ The QListView class provides a default model/view implementation of a list/icon view. The QListWidget class provides a classic item-based list/icon view.
+\li \image windows-treeview.png
+ The QTreeView class provides a default model/view implementation of a tree view. The QTreeWidget class provides a classic item-based tree view.
+\li \image windows-tableview.png
+ The QTableView class provides a default model/view implementation of a table view. The QTableWidget class provides a classic item-based table view.\li
+\li
+\endtable
+
+\section2 Display Widgets
+
+\table 100%
+\row
+\li \image windows-progressbar.png
+ The QProgressBar widget provides a horizontal progress bar.
+\li \image windows-label.png
+ The QLabel widget provides a text or image display.
+\li \image windows-lcdnumber.png
+ The QLCDNumber widget displays a number with LCD-like digits.
+\endtable
+
+\section2 Input Widgets
+
+\table 100%
+\row
+\li \image windows-lineedit.png
+ The QLineEdit widget is a one-line text editor.
+\li \image windows-dateedit.png
+ The QDateEdit class provides a widget for editing dates.
+\li \image windows-timeedit.png
+ The QTimeEdit class provides a widget for editing times.
+\li \image windows-datetimeedit.png
+ The QDateTimeEdit class provides a widget for editing dates and times.
+\endtable
+
+\table 100%
+\row
+\li \image windows-slider.png
+ The QSlider widget provides a vertical or horizontal slider.
+\li \image windows-combobox.png
+ The QComboBox widget is a combined button and pop-up list.
+\li \image windows-spinbox.png
+ The QSpinBox class provides a spin box widget.
+\endtable
+
+\table 100%
+\row
+\li \image windows-fontcombobox.png
+ The QFontComboBox widget is a specialized combobox that enables fonts to be selected from a pop-up list containing previews of available fonts.
+\li \image windows-doublespinbox.png
+ The QDoubleSpinBox class provides a spin box widget that allows double precision floating point numbers to be entered.
+\li \image windows-horizontalscrollbar.png
+ The QScrollBar widget provides a vertical or horizontal scroll bar. Here, we show a scroll bar with horizontal orientation.
+\endtable
+
+\table 100%
+\row
+\li \image windows-dial.png
+ The QDial class provides a rounded range control (like a speedometer or potentiometer).
+\li \image windows-textedit.png
+ The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
+\li \image windows-calendarwidget.png
+ The QCalendarWidget class provides a monthly calendar widget that can be used to select dates.
+\endtable
+*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery-windowsvista.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery-windowsvista.qdoc
new file mode 100644
index 0000000000..db1a7cee90
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/gallery-windowsvista.qdoc
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page gallery-windowsvista.html
+
+ \title Windows Vista Style Widget Gallery
+ \ingroup gallery
+
+ This page shows some of the widgets available in Qt
+ when configured to use the "windowsvista" style.
+
+\section2 Buttons
+
+\table 100%
+\row
+\li \image windowsvista-pushbutton.png
+ \caption The QPushButton widget provides a command button.
+\li \image windowsvista-toolbutton.png
+ \caption The QToolButton class provides a quick-access button to commands
+ or options, usually used inside a QToolBar.
+\endtable
+
+\table 100%
+\row
+\li \image windowsvista-checkbox.png
+ \caption The QCheckBox widget provides a checkbox with a text label.
+\li \image windowsvista-radiobutton.png
+ \caption The QRadioButton widget provides a radio button with a text or pixmap label.
+\endtable
+
+\section2 Containers
+
+\table 100%
+\row
+\li \image windowsvista-groupbox.png
+ The The QGroupBox widget provides a group box frame with a title.
+\li \image windowsvista-tabwidget.png
+ The QTabWidget class provides a stack of tabbed widgets.
+\li \image windowsvista-frame.png
+ The QFrame widget provides a simple decorated container for other widgets.
+\li \image windowsvista-toolbox.png
+ The QToolBox class provides a column of tabbed widget items.
+\endtable
+
+\section2 Item Views
+
+\table 100%
+\row
+\li \image windowsvista-listview.png
+ The QListView class provides a default model/view implementation of a list/icon view. The QListWidget class provides a classic item-based list/icon view.
+\li \image windowsvista-treeview.png
+ The QTreeView class provides a default model/view implementation of a tree view. The QTreeWidget class provides a classic item-based tree view.
+\li \image windowsvista-tableview.png
+ The QTableView class provides a default model/view implementation of a table view. The QTableWidget class provides a classic item-based table view.\li
+\li
+\endtable
+
+\section2 Display Widgets
+
+\table 100%
+\row
+\li \image windowsvista-progressbar.png
+ The QProgressBar widget provides a horizontal progress bar.
+\li \image windowsvista-label.png
+ The QLabel widget provides a text or image display.
+\li \image windowsvista-lcdnumber.png
+ The QLCDNumber widget displays a number with LCD-like digits.
+\endtable
+
+\section2 Input Widgets
+
+\table 100%
+\row
+\li \image windowsvista-lineedit.png
+ The QLineEdit widget is a one-line text editor.
+\li \image windowsvista-dateedit.png
+ The QDateEdit class provides a widget for editing dates.
+\li \image windowsvista-timeedit.png
+ The QTimeEdit class provides a widget for editing times.
+\li \image windowsvista-datetimeedit.png
+ The QDateTimeEdit class provides a widget for editing dates and times.
+\endtable
+
+\table 100%
+\row
+\li \image windowsvista-slider.png
+ The QSlider widget provides a vertical or horizontal slider.
+\li \image windowsvista-combobox.png
+ The QComboBox widget is a combined button and pop-up list.
+\li \image windowsvista-spinbox.png
+ The QSpinBox class provides a spin box widget.
+\endtable
+
+\table 100%
+\row
+\li \image windowsvista-fontcombobox.png
+ The QFontComboBox widget is a specialized combobox that enables fonts to be selected from a pop-up list containing previews of available fonts.
+\li \image windowsvista-doublespinbox.png
+ The QDoubleSpinBox class provides a spin box widget that allows double precision floating point numbers to be entered.
+\li \image windowsvista-horizontalscrollbar.png
+ The QScrollBar widget provides a vertical or horizontal scroll bar. Here, we show a scroll bar with horizontal orientation.
+\endtable
+
+\table 100%
+\row
+\li \image windowsvista-dial.png
+ The QDial class provides a rounded range control (like a speedometer or potentiometer).
+\li \image windowsvista-textedit.png
+ The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
+\li \image windowsvista-calendarwidget.png
+ The QCalendarWidget class provides a monthly calendar widget that can be used to select dates.
+\endtable
+*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery-windowsxp.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery-windowsxp.qdoc
new file mode 100644
index 0000000000..2ade5681e2
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/gallery-windowsxp.qdoc
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page gallery-windowsxp.html
+
+ \title Windows XP Style Widget Gallery
+ \ingroup gallery
+
+ This page shows some of the widgets available in Qt
+ when configured to use the "windowsxp" style.
+
+\section2 Buttons
+
+\table 100%
+\row
+\li \image windowsxp-pushbutton.png
+ \caption The QPushButton widget provides a command button.
+\li \image windowsxp-toolbutton.png
+ \caption The QToolButton class provides a quick-access button to commands
+ or options, usually used inside a QToolBar.
+\endtable
+
+\table 100%
+\row
+\li \image windowsxp-checkbox.png
+ \caption The QCheckBox widget provides a checkbox with a text label.
+\li \image windowsxp-radiobutton.png
+ \caption The QRadioButton widget provides a radio button with a text or pixmap label.
+\endtable
+
+\section2 Containers
+
+\table 100%
+\row
+\li \image windowsxp-groupbox.png
+ The The QGroupBox widget provides a group box frame with a title.
+\li \image windowsxp-tabwidget.png
+ The QTabWidget class provides a stack of tabbed widgets.
+\li \image windowsxp-frame.png
+ The QFrame widget provides a simple decorated container for other widgets.
+\li \image windowsxp-toolbox.png
+ The QToolBox class provides a column of tabbed widget items.
+\endtable
+
+\section2 Item Views
+
+\table 100%
+\row
+\li \image windowsxp-listview.png
+ The QListView class provides a default model/view implementation of a list/icon view. The QListWidget class provides a classic item-based list/icon view.
+\li \image windowsxp-treeview.png
+ The QTreeView class provides a default model/view implementation of a tree view. The QTreeWidget class provides a classic item-based tree view.
+\li \image windowsxp-tableview.png
+ The QTableView class provides a default model/view implementation of a table view. The QTableWidget class provides a classic item-based table view.\li
+\li
+\endtable
+
+\section2 Display Widgets
+
+\table 100%
+\row
+\li \image windowsxp-progressbar.png
+ The QProgressBar widget provides a horizontal progress bar.
+\li \image windowsxp-label.png
+ The QLabel widget provides a text or image display.
+\li \image windowsxp-lcdnumber.png
+ The QLCDNumber widget displays a number with LCD-like digits.
+\endtable
+
+\section2 Input Widgets
+
+\table 100%
+\row
+\li \image windowsxp-lineedit.png
+ The QLineEdit widget is a one-line text editor.
+\li \image windowsxp-dateedit.png
+ The QDateEdit class provides a widget for editing dates.
+\li \image windowsxp-timeedit.png
+ The QTimeEdit class provides a widget for editing times.
+\li \image windowsxp-datetimeedit.png
+ The QDateTimeEdit class provides a widget for editing dates and times.
+\endtable
+
+\table 100%
+\row
+\li \image windowsxp-slider.png
+ The QSlider widget provides a vertical or horizontal slider.
+\li \image windowsxp-combobox.png
+ The QComboBox widget is a combined button and pop-up list.
+\li \image windowsxp-spinbox.png
+ The QSpinBox class provides a spin box widget.
+\endtable
+
+\table 100%
+\row
+\li \image windowsxp-fontcombobox.png
+ The QFontComboBox widget is a specialized combobox that enables fonts to be selected from a pop-up list containing previews of available fonts.
+\li \image windowsxp-doublespinbox.png
+ The QDoubleSpinBox class provides a spin box widget that allows double precision floating point numbers to be entered.
+\li \image windowsxp-horizontalscrollbar.png
+ The QScrollBar widget provides a vertical or horizontal scroll bar. Here, we show a scroll bar with horizontal orientation.
+\endtable
+
+\table 100%
+\row
+\li \image windowsxp-dial.png
+ The QDial class provides a rounded range control (like a speedometer or potentiometer).
+\li \image windowsxp-textedit.png
+ The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
+\li \image windowsxp-calendarwidget.png
+ The QCalendarWidget class provides a monthly calendar widget that can be used to select dates.
+\endtable
+*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc
new file mode 100644
index 0000000000..a2f4db5a7b
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \group gallery
+ \title Qt Widget Gallery
+ \brief Qt widgets shown in different styles on various platforms.
+
+ Qt's support for widget styles and themes enables your application to fit in
+ with the native desktop environment. Below, you can find links to the various
+ widget styles that are supplied with Qt 4.
+
+ \table
+ \row
+ \li \image plastique-tabwidget.png Plastique Style Widget Gallery
+ \caption \l{Plastique Style Widget Gallery}
+
+ The Plastique style is provided by QPlastiqueStyle.
+ \li \image windowsxp-tabwidget.png Windows XP Style Widget Gallery
+ \caption \l{Windows XP Style Widget Gallery}
+
+ The Windows XP style is provided by QWindowsXPStyle.
+ \li \image windows-tabwidget.png Windows Style Widget Gallery
+ \caption \l{Windows Style Widget Gallery}
+
+ The Windows style is provided by QWindowsStyle.
+ \endtable
+
+ \table
+ \row
+ \li \image macintosh-tabwidget.png Macintosh Style Widget Gallery
+ \caption \l{Macintosh Style Widget Gallery}
+
+ The Macintosh style is provided by QMacStyle.
+ \li \image cleanlooks-tabwidget.png Cleanlooks Style Widget Gallery
+ \caption \l{Cleanlooks Style Widget Gallery}
+
+ The Cleanlooks style is provided by QCleanlooksStyle.
+ \li \image windowsvista-tabwidget.png Windows Vista Style Widget Gallery
+ \caption \l{Windows Vista Style Widget Gallery}
+
+ The Windows Vista style is provided by QWindowsVistaStyle.
+ \endtable
+
+ \table
+ \row
+ \li \image gtk-tabwidget.png GTK Style Widget Gallery
+ \caption \l{GTK Style Widget Gallery}
+
+ The GTK style is provided by QGtkStyle.
+ \li \image motif-tabwidget.png Motif Style Widget Gallery
+ \caption \l{Motif Style Widget Gallery}
+
+ The Motif style is provided by QMotifStyle.
+ \li \image cde-tabwidget.png CDE Style Widget Gallery
+ \caption \l{CDE Style Widget Gallery}
+
+ The Common Desktop Environment style is provided by QCDEStyle.
+ \endtable
+*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
new file mode 100644
index 0000000000..807f9ae8f9
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
@@ -0,0 +1,396 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \group geomanagement
+ \title Layout Classes
+*/
+
+/*!
+ \page layout.html
+ \title Layout Management
+ \ingroup qt-basic-concepts
+ \ingroup qt-gui-concepts
+ \brief A tour of the standard layout managers and an introduction to custom
+ layouts.
+
+ \previouspage Widgets and Layouts
+ \contentspage Widgets and Layouts
+ \nextpage {Styles and Style Aware Widgets}{Styles}
+
+ \ingroup frameworks-technologies
+
+ The Qt layout system provides a simple and powerful way of automatically
+ arranging child widgets within a widget to ensure that they make good use
+ of the available space.
+
+ \tableofcontents
+
+ \section1 Introduction
+
+ Qt includes a set of layout management classes that are used to describe
+ how widgets are laid out in an application's user interface. These layouts
+ automatically position and resize widgets when the amount of space
+ available for them changes, ensuring that they are consistently arranged
+ and that the user interface as a whole remains usable.
+
+ All QWidget subclasses can use layouts to manage their children. The
+ QWidget::setLayout() function applies a layout to a widget. When a layout
+ is set on a widget in this way, it takes charge of the following tasks:
+
+ \list
+ \li Positioning of child widgets.
+ \li Sensible default sizes for windows.
+ \li Sensible minimum sizes for windows.
+ \li Resize handling.
+ \li Automatic updates when contents change:
+ \list
+ \li Font size, text or other contents of child widgets.
+ \li Hiding or showing a child widget.
+ \li Removal of child widgets.
+ \endlist
+ \endlist
+
+ \section1 Qt's Layout Classes
+
+ Qt's layout classes were designed for hand-written C++ code, allowing
+ measurements to be specified in pixels for simplicity, so they are easy to
+ understand and use. The code generated for forms created using \QD also
+ uses the layout classes. \QD is useful to use when experimenting with the
+ design of a form since it avoids the compile, link and run cycle usually
+ involved in user interface development.
+
+ \annotatedlist geomanagement
+
+ \section1 Horizontal, Vertical, Grid, and Form Layouts
+
+ The easiest way to give your widgets a good layout is to use the built-in
+ layout managers: QHBoxLayout, QVBoxLayout, QGridLayout, and QFormLayout.
+ These classes inherit from QLayout, which in turn derives from QObject (not
+ QWidget). They take care of geometry management for a set of widgets. To
+ create more complex layouts, you can nest layout managers inside each other.
+
+ \list
+ \li A QHBoxLayout lays out widgets in a horizontal row, from left to
+ right (or right to left for right-to-left languages).
+ \image qhboxlayout-with-5-children.png
+
+ \li A QVBoxLayout lays out widgets in a vertical column, from top to
+ bottom.
+ \image qvboxlayout-with-5-children.png
+
+ \li A QGridLayout lays out widgets in a two-dimensional grid. Widgets
+ can occupy multiple cells.
+ \image qgridlayout-with-5-children.png
+
+ \li A QFormLayout lays out widgets in a 2-column descriptive label-
+ field style.
+ \image qformlayout-with-6-children.png
+ \endlist
+
+
+ \section2 Laying Out Widgets in Code
+
+ The following code creates a QHBoxLayout that manages the geometry of five
+ \l{QPushButton}{QPushButtons}, as shown on the first screenshot above:
+
+ \snippet layouts/layouts.cpp 0
+ \snippet layouts/layouts.cpp 1
+ \snippet layouts/layouts.cpp 2
+ \codeline
+ \snippet layouts/layouts.cpp 3
+ \snippet layouts/layouts.cpp 4
+ \snippet layouts/layouts.cpp 5
+
+ The code for QVBoxLayout is identical, except the line where the layout is
+ created. The code for QGridLayout is a bit different, because we need to
+ specify the row and column position of the child widget:
+
+ \snippet layouts/layouts.cpp 12
+ \snippet layouts/layouts.cpp 13
+ \snippet layouts/layouts.cpp 14
+ \codeline
+ \snippet layouts/layouts.cpp 15
+ \snippet layouts/layouts.cpp 16
+ \snippet layouts/layouts.cpp 17
+
+ The third QPushButton spans 2 columns. This is possible by specifying 2 as
+ the fifth argument to QGridLayout::addWidget().
+
+ QFormLayout will add two widgets on a row, commonly a QLabel and a QLineEdit
+ to create forms. Adding a QLabel and a QLineEdit on the same row will set
+ the QLineEdit as the QLabel's buddy. The following code will use the
+ QFormLayout to place three \l{QPushButton}{QPushButtons} and a corresponding
+ QLineEdit on a row.
+
+ \snippet layouts/layouts.cpp 18
+ \snippet layouts/layouts.cpp 19
+ \snippet layouts/layouts.cpp 20
+ \codeline
+ \snippet layouts/layouts.cpp 21
+ \snippet layouts/layouts.cpp 22
+ \snippet layouts/layouts.cpp 23
+
+
+ \section2 Tips for Using Layouts
+
+ When you use a layout, you do not need to pass a parent when constructing
+ the child widgets. The layout will automatically reparent the widgets
+ (using QWidget::setParent()) so that they are children of the widget on
+ which the layout is installed.
+
+ \note Widgets in a layout are children of the widget on which the layout
+ is installed, \e not of the layout itself. Widgets can only have other
+ widgets as parent, not layouts.
+
+ You can nest layouts using \c addLayout() on a layout; the inner layout
+ then becomes a child of the layout it is inserted into.
+
+
+ \section1 Adding Widgets to a Layout
+
+ When you add widgets to a layout, the layout process works as follows:
+
+ \list 1
+ \li All the widgets will initially be allocated an amount of space in
+ accordance with their QWidget::sizePolicy() and
+ QWidget::sizeHint().
+
+ \li If any of the widgets have stretch factors set, with a value
+ greater than zero, then they are allocated space in proportion to
+ their stretch factor (explained below).
+
+ \li If any of the widgets have stretch factors set to zero they will
+ only get more space if no other widgets want the space. Of these,
+ space is allocated to widgets with an
+ \l{QSizePolicy::Expanding}{Expanding} size policy first.
+
+ \li Any widgets that are allocated less space than their minimum size
+ (or minimum size hint if no minimum size is specified) are
+ allocated this minimum size they require. (Widgets don't have to
+ have a minimum size or minimum size hint in which case the stretch
+ factor is their determining factor.)
+
+ \li Any widgets that are allocated more space than their maximum size
+ are allocated the maximum size space they require. (Widgets do not
+ have to have a maximum size in which case the stretch factor is
+ their determining factor.)
+ \endlist
+
+
+ \section2 Stretch Factors
+ \keyword stretch factor
+
+ Widgets are normally created without any stretch factor set. When they are
+ laid out in a layout the widgets are given a share of space in accordance
+ with their QWidget::sizePolicy() or their minimum size hint whichever is
+ the greater. Stretch factors are used to change how much space widgets are
+ given in proportion to one another.
+
+ If we have three widgets laid out using a QHBoxLayout with no stretch
+ factors set we will get a layout like this:
+
+ \img layout1.png Three widgets in a row
+
+ If we apply stretch factors to each widget, they will be laid out in
+ proportion (but never less than their minimum size hint), e.g.
+
+ \img layout2.png Three widgets with different stretch factors in a row
+
+
+ \section1 Custom Widgets in Layouts
+
+ When you make your own widget class, you should also communicate its layout
+ properties. If the widget has a one of Qt's layouts, this is already taken
+ care of. If the widget does not have any child widgets, or uses manual
+ layout, you can change the behavior of the widget using any or all of the
+ following mechanisms:
+
+ \list
+ \li Reimplement QWidget::sizeHint() to return the preferred size of the
+ widget.
+ \li Reimplement QWidget::minimumSizeHint() to return the smallest size
+ the widget can have.
+ \li Call QWidget::setSizePolicy() to specify the space requirements of
+ the widget.
+ \endlist
+
+ Call QWidget::updateGeometry() whenever the size hint, minimum size hint or
+ size policy changes. This will cause a layout recalculation. Multiple
+ consecutive calls to QWidget::updateGeometry() will only cause one layout
+ recalculation.
+
+ If the preferred height of your widget depends on its actual width (e.g.,
+ a label with automatic word-breaking), set the
+ \l{QSizePolicy::hasHeightForWidth()}{height-for-width} flag in the
+ widget's \l{QWidget::sizePolicy}{size policy} and reimplement
+ QWidget::heightForWidth().
+
+ Even if you implement QWidget::heightForWidth(), it is still a good idea to
+ provide a reasonable sizeHint().
+
+ For further guidance when implementing these functions, see the
+ \e{Qt Quarterly} article
+ \l{http://doc.qt.nokia.com/qq/qq04-height-for-width.html}
+ {Trading Height for Width}.
+
+
+ \section1 Layout Issues
+
+ The use of rich text in a label widget can introduce some problems to the
+ layout of its parent widget. Problems occur due to the way rich text is
+ handled by Qt's layout managers when the label is word wrapped.
+
+ In certain cases the parent layout is put into QLayout::FreeResize mode,
+ meaning that it will not adapt the layout of its contents to fit inside
+ small sized windows, or even prevent the user from making the window too
+ small to be usable. This can be overcome by subclassing the problematic
+ widgets, and implementing suitable \l{QWidget::}{sizeHint()} and
+ \l{QWidget::}{minimumSizeHint()} functions.
+
+ In some cases, it is relevant when a layout is added to a widget. When
+ you set the widget of a QDockWidget or a QScrollArea (with
+ QDockWidget::setWidget() and QScrollArea::setWidget()), the layout must
+ already have been set on the widget. If not, the widget will not be
+ visible.
+
+
+ \section1 Manual Layout
+
+ If you are making a one-of-a-kind special layout, you can also make a
+ custom widget as described above. Reimplement QWidget::resizeEvent() to
+ calculate the required distribution of sizes and call
+ \l{QWidget::}{setGeometry()} on each child.
+
+ The widget will get an event of type QEvent::LayoutRequest when the
+ layout needs to be recalculated. Reimplement QWidget::event() to handle
+ QEvent::LayoutRequest events.
+
+
+ \section1 How to Write A Custom Layout Manager
+
+ An alternative to manual layout is to write your own layout manager by
+ subclassing QLayout. The \l{layouts/borderlayout}{Border Layout} and
+ \l{layouts/flowlayout}{Flow Layout} examples show how to do this.
+
+ Here we present an example in detail. The \c CardLayout class is inspired
+ by the Java layout manager of the same name. It lays out the items (widgets
+ or nested layouts) on top of each other, each item offset by
+ QLayout::spacing().
+
+ To write your own layout class, you must define the following:
+ \list
+ \li A data structure to store the items handled by the layout. Each
+ item is a \link QLayoutItem QLayoutItem\endlink. We will use a
+ QList in this example.
+ \li \l{QLayout::}{addItem()}, how to add items to the layout.
+ \li \l{QLayout::}{setGeometry()}, how to perform the layout.
+ \li \l{QLayout::}{sizeHint()}, the preferred size of the layout.
+ \li \l{QLayout::}{itemAt()}, how to iterate over the layout.
+ \li \l{QLayout::}{takeAt()}, how to remove items from the layout.
+ \endlist
+
+ In most cases, you will also implement \l{QLayout::}{minimumSize()}.
+
+
+ \section2 The Header File (\c card.h)
+
+ \snippet code/doc_src_layout.cpp 0
+
+
+ \section2 The Implementation File (\c card.cpp)
+
+ \snippet code/doc_src_layout.cpp 1
+
+ First we define \c{count()} to fetch the number of items in the list.
+
+ \snippet code/doc_src_layout.cpp 2
+
+ Then we define two functions that iterate over the layout: \c{itemAt()}
+ and \c{takeAt()}. These functions are used internally by the layout system
+ to handle deletion of widgets. They are also available for application
+ programmers.
+
+ \c{itemAt()} returns the item at the given index. \c{takeAt()} removes the
+ item at the given index, and returns it. In this case we use the list index
+ as the layout index. In other cases where we have a more complex data
+ structure, we may have to spend more effort defining a linear order for the
+ items.
+
+ \snippet code/doc_src_layout.cpp 3
+
+ \c{addItem()} implements the default placement strategy for layout items.
+ This function must be implemented. It is used by QLayout::add(), by the
+ QLayout constructor that takes a layout as parent. If your layout has
+ advanced placement options that require parameters, you must provide extra
+ access functions such as the row and column spanning overloads of
+ QGridLayout::addItem(), QGridLayout::addWidget(), and
+ QGridLayout::addLayout().
+
+ \snippet code/doc_src_layout.cpp 4
+
+ The layout takes over responsibility of the items added. Since QLayoutItem
+ does not inherit QObject, we must delete the items manually. In the
+ destructor, we remove each item from the list using \c{takeAt()}, and
+ then delete it.
+
+ \snippet code/doc_src_layout.cpp 5
+
+ The \c{setGeometry()} function actually performs the layout. The rectangle
+ supplied as an argument does not include \c{margin()}. If relevant, use
+ \c{spacing()} as the distance between items.
+
+ \snippet code/doc_src_layout.cpp 6
+
+ \c{sizeHint()} and \c{minimumSize()} are normally very similar in
+ implementation. The sizes returned by both functions should include
+ \c{spacing()}, but not \c{margin()}.
+
+ \snippet code/doc_src_layout.cpp 7
+
+
+ \section2 Further Notes
+
+ \list
+ \li This custom layout does not handle height for width.
+ \li We ignore QLayoutItem::isEmpty(); this means that the layout will
+ treat hidden widgets as visible.
+ \li For complex layouts, speed can be greatly increased by caching
+ calculated values. In that case, implement
+ QLayoutItem::invalidate() to mark the cached data is dirty.
+ \li Calling QLayoutItem::sizeHint(), etc. may be expensive. So, you
+ should store the value in a local variable if you need it again
+ later within in the same function.
+ \li You should not call QLayoutItem::setGeometry() twice on the same
+ item in the same function. This call can be very expensive if the
+ item has several child widgets, because the layout manager must do
+ a complete layout every time. Instead, calculate the geometry and
+ then set it. (This does not only apply to layouts, you should do
+ the same if you implement your own resizeEvent(), for example.)
+ \endlist
+*/
+
diff --git a/src/widgets/doc/src/widgets-and-layouts/styles.qdoc b/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
new file mode 100644
index 0000000000..d6706d7994
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
@@ -0,0 +1,2102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \group appearance
+ \title Widget Appearance and Style
+ \brief Classes used for customizing UI appearance and style.
+*/
+
+/*!
+ \page style-reference.html
+ \title Styles and Style Aware Widgets
+ \ingroup qt-gui-concepts
+ \brief Styles and the styling of widgets.
+
+ Styles (classes that inherit QStyle) draw on behalf of widgets
+ and encapsulate the look and feel of a GUI. The QStyle class is
+ an abstract base class that encapsulates the look and feel of a
+ GUI. Qt's built-in widgets use it to perform nearly all of their
+ drawing, ensuring that they look exactly like the equivalent
+ native widgets.
+
+ Several styles are built into Qt (e.g., windows style and motif style).
+ Other styles are only available on specific platforms (such as
+ the windows XP style). Custom styles are made available as plugins
+ or by creating an instance of the style class in an application and
+ setting it with QApplication::setStyle().
+
+ To implement a new style, you inherit one of Qt's existing styles
+ - the one most resembling the style you want to create - and
+ reimplement a few virtual functions. This process is somewhat
+ involved, and we therefore provide this overview. We give a
+ step-by-step walkthrough of how to style individual Qt widgets.
+ We will examine the QStyle virtual functions, member variables,
+ and enumerations.
+
+ The part of this document that does not concern the styling of
+ individual widgets is meant to be read sequentially because later
+ sections tend to depend on earlier ones. The description of the
+ widgets can be used for reference while implementing a style.
+ However, you may need to consult the Qt source code in some cases.
+ The sequence in the styling process should become clear after
+ reading this document, which will aid you in locating relevant code.
+
+ To develop style aware widgets (i.e., widgets that conform to
+ the style in which they are drawn), you need to draw them using the
+ current style. This document shows how widgets draw themselves
+ and which possibilities the style gives them.
+
+ \section1 Classes for Widget Styling
+
+ These classes are used to customize an application's appearance and
+ style.
+
+ \annotatedlist appearance
+
+ \section1 The QStyle implementation
+
+ The API of QStyle contains functions that draw the widgets, static
+ helper functions to do common and difficult tasks (e.g.,
+ calculating the position of slider handles) and functions to do
+ the various calculations necessary while drawing (e.g., for the
+ widgets to calculate their size hints). The style also help some
+ widgets with the layout of their contents. In addition, it creates
+ a QPalette that contains \l{QBrush}es to draw with.
+
+ QStyle draws graphical elements; an element is a widget or a
+ widget part like a push button bevel, a window frame, or a scroll
+ bar. Most draw functions now take four arguments:
+
+ \list
+ \li an enum value specifying which graphical element to draw
+ \li a QStyleOption specifying how and where to render that element
+ \li a QPainter that should be used to draw the element
+ \li a QWidget on which the drawing is performed (optional)
+ \endlist
+
+ When a widget asks a style to draw an element, it provides the style
+ with a QStyleOption, which is a class that contains the information
+ necessary for drawing. Thanks to QStyleOption, it is possible to make
+ QStyle draw widgets without linking in any code for the widget. This
+ makes it possible to use \l{QStyle}'s draw functions on any paint
+ device, i.e., you can draw a combobox on any widget, not just on a
+ QComboBox.
+
+ The widget is passed as the last argument in case the style needs
+ it to perform special effects (such as animated default buttons on
+ Mac OS X), but it isn't mandatory.
+
+ We will in the course of this section look at the style elements,
+ the style options, and the functions of QStyle. Finally, we describe
+ how the palette is used.
+
+ Items in item views is drawn by \l{Delegate Classes}{delegates} in
+ Qt. The item view headers are still drawn by the style. Qt's
+ default delegate, QStyledItemDelegate, draws its items partially
+ through the current style; it draws the check box indicators and
+ calculate bounding rectangles for the elements of which the item
+ consists. In this document, we only describe how to implement a
+ QStyle subclass. If you wish to add support for other datatypes
+ than those supported by the QStyledItemDelegate, you need to
+ implement a custom delegate. Note that delegates must be set
+ programmatically for each individual widget (i.e., default
+ delegates cannot be provided as plugins).
+
+ \section2 The Style Elements
+
+ A style element is a graphical part of a GUI. A widget consists
+ of a hierarchy (or tree) of style elements. For instance, when a
+ style receives a request to draw a push button (from QPushButton,
+ for example), it draws a label (text and icon), a button bevel,
+ and a focus frame. The button bevel, in turn, consists of a frame
+ around the bevel and two other elements, which we will look at
+ later. Below is a conceptual illustration of the push button
+ element tree. We will see the actual tree for QPushButton when we
+ go through the individual widgets.
+
+ \image javastyle/conceptualpushbuttontree.png
+
+ Widgets are not necessarily drawn by asking the style to draw
+ only one element. Widgets can make several calls to the style to
+ draw different elements. An example is QTabWidget, which draws its
+ tabs and frame individually.
+
+ There are three element types: primitive elements, control
+ elements, and complex control elements. The elements are defined
+ by the \l{QStyle::}{ComplexControl}, \l{QStyle::}{ControlElement},
+ and \l{QStyle::}{PrimitiveElement} enums. The values of
+ each element enum has a prefix to identify their type: \c{CC_} for
+ complex elements, \c{CE_} for control elements, and \c{PE_} for
+ primitive elements. We will in the following three sections see what
+ defines the different elements and see examples of widgets that use
+ them.
+
+ The QStyle class description contains a list of these elements and
+ their roles in styling widgets. We will see how they are used when
+ we style individual widgets.
+
+ \section3 Primitive Elements
+
+ Primitive elements are GUI elements that are common and often used
+ by several widgets. Examples of these are frames, button bevels,
+ and arrows for spin boxes, scroll bars, and combo boxes.
+ Primitive elements cannot exist on their own: they are always part
+ of a larger construct. They take no part in the interaction with
+ the user, but are passive decorations in the GUI.
+
+ \section3 Control Elements
+
+ A control element performs an action or displays information
+ to the user. Examples of control elements are push buttons, check
+ boxes, and header sections in tables and tree views. Control
+ elements are not necessarily complete widgets such as push
+ buttons, but can also be widget parts such as tab bar tabs and
+ scroll bar sliders. They differ from primitive elements in that
+ they are not passive, but fill a function in the interaction with
+ the user. Controls that consist of several elements often use the
+ style to calculate the bounding rectangles of the elements. The
+ available sub elements are defined by the \l{QStyle::}{SubElement}
+ enum. This enum is only used for calculating bounding rectangles,
+ and sub elements are as such not graphical elements to be drawn
+ like primitive, control, and complex elements.
+
+ \section3 Complex Control Elements
+
+ Complex control elements contain sub controls. Complex controls
+ behave differently depending on where the user handles them with
+ the mouse and which keyboard keys are pressed. This is dependent
+ on which sub control (if any) that the mouse is over or received a
+ mouse press. Examples of complex controls are scroll bars and
+ combo boxes. With a scroll bar, you can use the mouse to move the
+ slider and press the line up and line down buttons. The available
+ sub controls are defined by the \l{QStyle}{SubControl} enum.
+
+ In addition to drawing, the style needs to provide the widgets
+ with information on which sub control (if any) a mouse press was
+ made on. For instance, a QScrollBar needs to know if the user
+ pressed the slider, the slider groove, or one of the buttons.
+
+ Note that sub controls are not the same as the control elements
+ described in the previous section. You cannot use the style to
+ draw a sub control; the style will only calculate the bounding
+ rectangle in which the sub control should be drawn. It is common,
+ though, that complex elements use control and primitive elements
+ to draw their sub controls, which is an approach that is
+ frequently used by the built-in styles in Qt and also the Java
+ style. For instance, the Java style uses PE_IndicatorCheckBox to
+ draw the check box in group boxes (which is a sub control of
+ CC_GroupBox). Some sub controls have an equivalent control element,
+ e.g., the scroll bar slider (SC_SCrollBarSlider and
+ CE_ScrollBarSlider).
+
+ \section3 Other QStyle Tasks
+
+ The style elements and widgets, as mentioned, use the style to
+ calculate bounding rectangles of sub elements and sub controls,
+ and pixel metrics, which is a style dependent size in screen
+ pixels, for measures when drawing. The available rectangles and
+ pixel metrics are represented by three enums in QStyle:
+ \l{QStyle::}{SubElement}, \l{QStyle::}{SubControl}, and
+ \l{QStyle::}{PixelMetric}. Values of the enums can easily by
+ identified as they start with SE_, SC_ and PM_.
+
+ The style also contain a set of style hints, which is
+ represented as values in the \l{QStyle::}{StyleHint} enum. All
+ widgets do not have the same functionality and look in the
+ different styles. For instance, when the menu items in a menu do not
+ fit in a single column on the screen, some styles support
+ scrolling while others draw more than one column to fit all items.
+
+ A style usually has a set of standard images (such as a warning, a
+ question, and an error image) for message boxes, file dialogs,
+ etc. QStyle provides the \l{QStyle::}{StandardPixmap} enum. Its
+ values represent the standard images. Qt's widgets use these, so
+ when you implement a custom style you should supply the images
+ used by the style that is being implemented.
+
+ The style calculates the spacing between widgets in layouts. There
+ are two ways the style can handle these calculations. You can set
+ the PM_LayoutHorizontalSpacing and PM_LayoutVerticalSpacing, which
+ is the way the java style does it (through QCommonStyle).
+ Alternatively, you can implement QStyle::layoutSpacing() and
+ QStyle::layoutSpacingImplementation() if you need more control over
+ this part of the layout. In these functions you can calculate the
+ spacing based on control types (QSizePolicy::ControlType) for
+ different size policies (QSizePolicy::Policy) and also the style
+ option for the widget in question.
+
+ \section2 Style Options
+
+ The sub-classes of QStyleOption contain all information necessary
+ to style the individual elements. Style options are instantiated -
+ usually on the stack - and filled out by the caller of the QStyle
+ function. Depending on what is drawn the style will expect
+ different a different style option class. For example, the
+ QStyle::PE_FrameFocusRect element expects a QStyleOptionFocusRect
+ argument, and it's possible to create custom subclasses that a
+ custom style can use. The style options keep public variables
+ for performance reasons.
+
+ The widgets can be in a number of different states, which are
+ defined by the \l{QStyle::}{State} enum. Some of the state flags have
+ different meanings depending on the widget, but others are common
+ for all widgets like State_Disabled. It is QStyleOption that sets
+ the common states with QStyleOption::initFrom(); the rest of the
+ states are set by the individual widgets.
+
+ Most notably, the style options contain the palette and bounding
+ rectangles of the widgets to be drawn. Most widgets have
+ specialized style options. QPushButton and QCheckBox, for
+ instance, use QStyleOptionButton as style option, which contain
+ the text, icon, and the size of their icon. The exact contents of
+ all options are described when we go through individual widgets.
+
+ When reimplementing QStyle functions that take a
+ QStyleOption parameter, you often need to cast the
+ QStyleOption to a subclass (e.g., QStyleOptionFocusRect). For
+ safety, you can use qstyleoption_cast() to ensure that the
+ pointer type is correct. If the object isn't of the right type,
+ qstyleoption_cast() returns 0. For example:
+
+ \snippet code/doc_src_qt4-styles.cpp 0
+
+ The following code snippet illustrates how to use QStyle to
+ draw the focus rectangle from a custom widget's paintEvent():
+
+ \snippet code/doc_src_qt4-styles.cpp 1
+
+ The next example shows how to derive from an existing style to
+ customize the look of a graphical element:
+
+ \snippet customstyle/customstyle.h 0
+ \codeline
+ \snippet customstyle/customstyle.cpp 2
+ \snippet customstyle/customstyle.cpp 3
+ \snippet customstyle/customstyle.cpp 4
+
+ \section2 QStyle Functions
+
+ The QStyle class defines three functions for drawing the primitive,
+ control, and complex elements:
+ \l{QStyle::}{drawPrimitive()},
+ \l{QStyle::}{drawControl()}, and
+ \l{QStyle::}{drawComplexControl()}. The functions takes the
+ following parameters:
+
+ \list
+ \li the enum value of the element to draw
+ \li a QStyleOption which contains the information needed to
+ draw the element.
+ \li a QPainter with which to draw the element.
+ \li a pointer to a QWidget, typically the widget
+ that the element is painted on.
+ \endlist
+
+ Not all widgets send a pointer to themselves. If the style
+ option sent to the function does not contain the information you
+ need, you should check the widget implementation to see if it
+ sends a pointer to itself.
+
+ The QStyle class also provides helper functions that are used
+ when drawing the elements. The \l{QStyle::}{drawItemText()}
+ function draws text within a specified rectangle and taking a
+ QPalette as a parameter. The \l{QStyle::}{drawItemPixmap()}
+ function helps to align a pixmap within a specified bounding
+ rectangle.
+
+ Other QStyle functions do various calculations for the
+ functions that draw. The widgets also use these functions for
+ calculating size hints and also for bounding rectangle
+ calculations if they draw several style elements themselves.
+ As with the functions that draw elements the helper functions
+ typically takes the same arguments.
+
+ \list
+ \li The \l{QStyle::}{subElementRect()} function takes a
+ \l{QStyle::}{SubElement} enum value, and calculates a bounding
+ rectangle for a sub element. The style uses this function to
+ know where to draw the different parts of an element. This is
+ mainly done for reuse. If you create a new style, you can use
+ the same location of sub elements as the super class.
+
+ \li The \l{QStyle::}{subControlRect()} function is used to
+ calculate bounding rectangles for sub controls in complex
+ controls. When you implement a new style, you reimplement \c
+ subControlRect() and calculate the rectangles that are different
+ from the super class.
+
+ \li The \l{QStyle::}{pixelMetric()} function returns a pixel
+ metric, which is a style dependent size given in screen
+ pixels. It takes a value of the \l{QStyle::}{PixelMetric} enum
+ and returns the correct measure. Note that pixel metrics do
+ not necessarily have to be static measures, but can be
+ calculated with, for example, the style option.
+
+ \li The \l{QStyle::}{hitTestComplexControl()} function returns the
+ sub control that the mouse pointer is over in a complex control.
+ Usually, this is simply a matter of using
+ \l{QStyle::}{subControlRect()} to get the bounding rectangles of
+ the sub controls, and see which rectangle contains the position of
+ the cursor.
+ \endlist
+
+ QStyle also have the functions \l{QStyle::}{polish()} and
+ \l{QStyle::}{unpolish()}. All widgets are sent to the \c polish()
+ function before being shown and to \c unpolish() when they
+ are hidden. You can use these functions to set attributes on the
+ widgets or do other work that is required by your style. For
+ instance, if you need to know when the mouse is hovering over the
+ widget, you need to set the \l{Qt::}{WA_Hover} widget attribute.
+ The State_MouseOver state flag will then be set in the widget's
+ style options.
+
+ QStyle has a few static helper functions that do some common and
+ difficult tasks. They can calculate the position of a slider
+ handle from the value of the slider and transform rectangles
+ and draw text considering reverse layouts; see the QStyle
+ class documentation for more details.
+
+ The usual approach when one reimplements QStyle virtual
+ functions is to do work on elements that are different from the
+ super class; for all other elements, you can simply use the super
+ class implementation.
+
+ \section2 The Palette
+
+ Each style provides a color - that is, QBrush - palette that
+ should be used for drawing the widgets. There is one set of colors
+ for the different widget states (QPalette::ColorGroup): active
+ (widgets in the window that has keyboard focus), inactive (widgets
+ used for other windows), and disabled (widgets that are set
+ disabled). The states can be found by querying the State_Active
+ and State_Enabled state flags. Each set contains color certain
+ roles given by the QPalette::ColorRole enum. The roles describe in
+ which situations the colors should be used (e.g., for painting
+ widget backgrounds, text, or buttons).
+
+ How the color roles are used is up to the style. For instance, if
+ the style uses gradients, one can use a palette color and make it
+ darker or lighter with QColor::darker() and QColor::lighter() to
+ create the gradient. In general, if you need a brush that is not
+ provided by the palette, you should try to derive it from one.
+
+ QPalette, which provides the palette, stores colors for
+ different widget states and color roles. The palette for a style
+ is returned by \l{QStyle::}{standardPalette()}. The standard
+ palette is not installed automatically when a new style is set
+ on the application (QApplication::setStyle()) or widget
+ (QWidget::setStyle()), so you must set the palette yourself
+ with (QApplication::setPalette()) or (QWidget::setPalette()).
+
+ It is not recommended to hard code colors as applications and
+ individual widgets can set their own palette and also use the
+ styles palette for drawing. Note that none of Qt's widgets set
+ their own palette. The java style does hard code some colors, but
+ its author looks past this in silence. Of course, it is not
+ intended that the style should look good with any palette.
+
+ \section2 Implementation Issues
+
+ When you implement styles, there are several issues to
+ consider. We will give some hints and advice on implementation
+ here.
+
+ When implementing styles, it is necessary to look through the
+ code of the widgets and code of the base class and its ancestors.
+ This is because the widgets use the style differently, because the
+ implementation in the different styles virtual functions can
+ affect the state of the drawing (e.g., by altering the QPainter
+ state without restoring it and drawing some elements without using
+ the appropriate pixel metrics and sub elements).
+
+ It is recommended that the styles do not alter the proposed size
+ of widgets with the QStyle::sizeFromContents() function but let
+ the QCommonStyle implementation handle it. If changes need to be
+ made, you should try to keep them small; application development
+ may be difficult if the layout of widgets looks considerably
+ different in the various styles.
+
+ We recommend using the QPainter directly for drawing, i.e., not
+ use pixmaps or images. This makes it easier for the style conform
+ to the palette (although you can set your own color table on a
+ QImage with \l{QImage::}{setColorTable()}).
+
+ It is, naturally, possible to draw elements without using the
+ style to draw the sub elements as intended by Qt. This is
+ discouraged as custom widgets may depend on these sub elements to
+ be implemented correctly. The widget walkthrough shows how Qt
+ uses the sub elements.
+
+ \section1 Java Style
+
+ We have implemented a style that resembles the Java default look
+ and feel (previously known as Metal). We have done this as it is
+ relatively simple to implement and we wanted to build a style for
+ this overview document. To keep it simple and not to extensive, we
+ have simplified the style somewhat, but Qt is perfectly able to
+ make an exact copy of the style. However, there are no concrete
+ plans to implement the style as a part of Qt.
+
+ In this section we will have a look at some implementation
+ issues. Finally, we will see a complete example on the styling of
+ a Java widget. We will continue to use the java style
+ throughout the document for examples and widget images. The
+ implementation itself is somewhat involved, and it is not
+ intended that you should read through it.
+
+ \section2 Design and Implementation
+
+ The first step in designing the style was to select the base
+ class. We chose to subclass QWindowsStyle. This class implements
+ most of the functionality we need other than performing the actual
+ drawing. Also, windows and java share layout of sub controls for
+ several of the complex controls (which reduces the amount of code
+ required considerably).
+
+ The style is implemented in one class. We have done this
+ because we find it convenient to keep all code in one file. Also,
+ it is an advantage with regards to optimization as we instantiate
+ less objects. We also keep the number of functions at a minimum by
+ using switches to identify which element to draw in the functions.
+ This results in large functions, but since we divide the code for
+ each element in the switches, the code should still be easy to
+ read.
+
+ \section2 Limitations and Differences from Java
+
+ We have not fully implemented every element in the Java style.
+ This way, we have reduced the amount and complexity of the code.
+ In general, the style was intended as a practical example for
+ this style overview document, and not to be a part of Qt
+ itself.
+
+ Not all widgets have every state implemented. This goes for
+ states that are common, e.g., State_Disabled. Each state is,
+ however, implemented for at least one widget.
+
+ We have only implemented ticks below the slider. Flat push
+ buttons are also left out. We do not handle the case where the
+ title bars and dock window titles grows to small for their
+ contents, but simply draw sub controls over each other.
+
+ We have not tried to emulate the Java fonts. Java and Qt use very
+ different font engines, so we don't consider it worth the effort
+ as we only use the style as an example for this overview.
+
+ We have hardcoded the colors (we don't use the QPalette) for
+ the linear gradients, which are used, for example, for button
+ bevels, tool bars, and check boxes. This is because the Java
+ palette cannot produce these colors. Java does not change these
+ colors based on widget color group or role anyway (they are not
+ dependent on the palette), so it does not present a problem in any
+ case.
+
+ It is Qt's widgets that are styled. Some widgets do not exist
+ at all in Java, e.g., QToolBox. Others contain elements that the
+ Java widgets don't. The tree widget is an example of the latter in
+ which Java's JTree does not have a header.
+
+ The style does not handle reverse layouts. We assume that the
+ layout direction is left to right. QWindowsStyle handles reverse
+ widgets; if we implemented reverse layouts, widgets that we change
+ the position of sub elements, or handle text alignment in labels
+ our selves would need to be updated.
+
+ \section2 Styling Java Check Boxes
+
+ As an example, we will examine the styling of check boxes in the
+ java style. We describe the complete process and print all code in
+ both the java style and Qt classes involved. In the rest of this
+ document, we will not examine the source code of the individual
+ widgets. Hopefully, this will give you an idea on how to search
+ through the code if you need to check specific implementation
+ details; most widgets follow the same structure as the check
+ boxes. We have edited the QCommonStyle code somewhat to remove
+ code that is not directly relevant for check box styling.
+
+ We start with a look at how QCheckBox builds it style option,
+ which is QStyleOptionButton for checkboxes:
+
+ \snippet code/doc_src_styles.cpp 0
+
+ First we let QStyleOption set up the option with the information
+ that is common for all widgets with \c initFrom(). We will look at
+ this shortly.
+
+ The down boolean is true when the user press the box down; this is
+ true whether the box is checked or not of the checkbox. The
+ State_NoChange state is set when we have a tristate checkbox and
+ it is partially checked. It has State_On if the box is checked and
+ State_Off if it is unchecked. State_MouseOver is set if the mouse
+ hovers over the checkbox and the widget has attribute Qt::WA_Hover
+ set - you set this in QStyle::polish(). In addition, the style
+ option also contains the text, icon, and icon size of the button.
+
+ \l{QStyleOption::}{initFrom()} sets up the style option with the
+ attributes that are common for all widgets. We print its
+ implementation here:
+
+ \snippet code/doc_src_styles.cpp 1
+
+ The State_Enabled is set when the widget is enabled. When the
+ widget has focus the State_HasFocus flag is set. Equally, the
+ State_Active flag is set when the widget is a child of the active
+ window. The State_MouseOver will only be set if the widget has
+ the WA_HoverEnabled windows flag set. Notice that keypad
+ navigation must be enabled in Qt for the State_HasEditFocus to
+ be included; it is not included by default.
+
+ In addition to setting state flags the QStyleOption contains
+ other information about the widget: \c direction is the layout
+ direction of the layout, \c rect is the bounding rectangle of the
+ widget (the area in which to draw), \c palette is the QPalette
+ that should be used for drawing the widget, and \c fontMetrics is
+ the metrics of the font that is used by the widget.
+
+ We give an image of a checkbox and the style option to match
+ it.
+
+ \image javastyle/checkboxexample.png A java style checkbox
+
+ The above checkbox will have the following state flags in its
+ style option:
+
+ \table 90%
+ \header
+ \li State flag
+ \li Set
+ \row
+ \li State_Sunken
+ \li Yes
+ \row
+ \li State_NoChange
+ \li No
+ \row
+ \li State_On
+ \li Yes
+ \row
+ \li State_Off
+ \li No
+ \row
+ \li State_MouseOver
+ \li Yes
+ \row
+ \li State_Enabled
+ \li Yes
+ \row
+ \li State_HasFocus
+ \li Yes
+ \row
+ \li State_KeyboardFocusChange
+ \li No
+ \row
+ \li State_Active
+ \li Yes
+ \endtable
+
+ The QCheckBox paints itself in QWidget::paintEvent() with
+ style option \c opt and QStylePainter \c p. The QStylePainter
+ class is a convenience class to draw style elements. Most
+ notably, it wraps the methods in QStyle used for painting. The
+ QCheckBox draws itself as follows:
+
+ \snippet code/doc_src_styles.cpp 2
+
+ QCommonStyle handles the CE_CheckBox element. The QCheckBox
+ has two sub elements: SE_CheckBoxIndicator (the checked indicator)
+ and SE_CheckBoxContents (the contents, which is used for the
+ checkbox label). QCommonStyle also implements these sub element
+ bounding rectangles. We have a look at the QCommonStyle code:
+
+ \snippet code/doc_src_styles.cpp 3
+
+ As can be seen from the code extract, the common style gets
+ the bounding rectangles of the two sub elements of
+ CE_CheckBox, and then draws them. If the checkbox has focus,
+ the focus frame is also drawn.
+
+ The java style draws CE_CheckBoxIndicator, while QCommonStyle
+ handles CE_CheckboxLabel. We will examine each implementation and
+ start with CE_CheckBoxLabel:
+
+ \snippet code/doc_src_styles.cpp 4
+
+ \l{QStyle::}{visualAlignment()} adjusts the alignment of text
+ according to the layout direction. We then draw an icon if it
+ exists, and adjust the space left for the text.
+ \l{QStyle::}{drawItemText()} draws the text taking alignment,
+ layout direction, and the mnemonic into account. It also uses the
+ palette to draw the text in the right color.
+
+ The drawing of labels often get somewhat involved. Luckily, it
+ can usually be handled by the base class. The java style
+ implements its own push button label since Java-contrary to
+ windows-center button contents also when the button has an icon.
+ You can examine that implementation if you need an example of
+ reimplementing label drawing.
+
+ We take a look at the java implementation
+ of CE_CheckBoxIndicator in \c drawControl():
+
+ \snippet javastyle.cpp 0
+
+ We first save the state of the painter. This is not always
+ necessary but in this case the QWindowsStyle needs the painter in
+ the same state as it was when PE_IndicatorCheckBox was called (We
+ could also set the state with function calls, of course). We then
+ use \c drawButtonBackground() to draw the background of the check
+ box indicator. This is a helper function that draws the background
+ and also the frame of push buttons and check boxes. We take a look
+ at that function below. We then check if the mouse is hovering
+ over the checkbox. If it is, we draw the frame java checkboxes
+ have when the box is not pressed down and the mouse is over it.
+ You may note that java does not handle tristate boxes, so we have
+ not implemented it.
+
+ Here we use a png image for our indicator. We could also check
+ here if the widget is disabled. We would then have to use
+ another image with the indicator in the disabled color.
+
+ \snippet javastyle.cpp 1
+
+ We have seen how check boxes are styled in the java style from the
+ widget gets a paint request to the style is finished painting. To
+ learn in detail how each widget is painted, you need to go through
+ the code step-by-step as we have done here. However, it is
+ usually enough to know which style elements the widgets draw. The
+ widget builds a style option and calls on the style one or more
+ times to draw the style elements of which it consists. Usually,
+ it is also sufficient to know the states a widget can be in and the
+ other contents of the style option, i.e., what we list in the next
+ section.
+
+ \section1 Widget Walkthrough
+
+ In this section, we will examine how most of Qt's widgets are
+ styled. Hopefully, this will save you some time and effort while
+ developing your own styles and widgets. You will not find
+ information here that is not attainable elsewhere (i.e., by
+ examining the source code or the class descriptions for the style
+ related classes).
+
+ We mostly use java style widgets as examples. The java style does not
+ draw every element in the element trees. This is because they are
+ not visible for that widget in the java style. We still make sure
+ that all elements are implemented in a way that conforms with the
+ java style as custom widgets might need them (this does not
+ exclude leaving implementations to QWindowsStyle though).
+
+ The following is given for each widget:
+
+ \list
+ \li A table with the members (variables, etc.) of its style option.
+ \li A table over the state flags (QStyle::StateFlag) that
+ can be set on the widget and when the states are set.
+ \li Its element tree (see section \l{The Style Elements}).
+ \li An image of the widget in which the elements are outlined.
+ \omit This is not written yet - probably never will be
+ either
+ \li List of style hints that should be checked for the
+ widget.
+ \li List of standard pixmaps that could be used by the
+ elements.
+ \endomit
+ \endlist
+
+ The element tree contains the primitive, control, and complex
+ style elements. By doing a top-down traversal of the element tree,
+ you get the sequence in which the elements should be drawn. In the
+ nodes, we have written the sub element rectangles, sub control
+ elements, and pixel metrics that should be considered when drawing
+ the element of the node.
+
+ Our approach on styling center on the drawing of the widgets. The
+ calculations of sub elements rectangles, sub controls, and pixel
+ metrics used \b during drawing is only listed as contents in
+ the element trees. Note that there are rectangles and pixel
+ metrics that are only used by widgets. This leaves these
+ calculations untreated in the walkthrough. For instance, the
+ \l{QStyle::}{subControlRect()} and
+ \l{QStyle::}{sizeFromContents()} functions often call
+ \l{QStyle::}{subElementRect()} to calculate their bounding
+ rectangles. We could draw trees for this as well. However, how
+ these calculations are done is completely up to the individual
+ styles, and they do not have to follow a specific structure (Qt
+ does not impose a specific structure). You should still make sure
+ that you use the appropriate pixel metrics, though. To limit the
+ size of the document, we have therefore chosen not to include
+ trees or describe the calculations made by the Java (or any other)
+ style.
+
+ You may be confused about how the different pixel metrics, sub
+ element rectangles, and sub control rectangles should be used when
+ examining the trees. If you are in doubt after reading the QStyle
+ enum descriptions, we suggest that you examine the QCommonStyle
+ and QWindowsStyle implementations.
+
+ Some of the bounding rectangles that we outline in the widget
+ images are equal. Reasons for this are that some elements draw
+ backgrounds while others draw frames and labels. If in doubt,
+ check the description of each element in QStyle. Also, some
+ elements are there to layout, i.e., decide where to draw, other
+ elements.
+
+ \section2 Common Widget Properties
+
+ Some states and variables are common for all widgets. These are
+ set with QStyleOption::initFrom(). Not all elements use this function;
+ it is the widgets that create the style options, and for some
+ elements the information from \l{QStyleOption::}{initFrom()} is not
+ necessary.
+
+ A table with the common states follows:
+
+ \table 90%
+ \header
+ \li State
+ \li State Set When
+ \row
+ \li State_Enabled
+ \li Set if the widget is not disabled (see
+ QWidget::setEnabled())
+ \row
+ \li State_Focus
+ \li Set if the widget has focus (see
+ QWidget::hasFocus())
+ \row
+ \li State_KeyobordFocusChange
+ \li Set when the user changes focus with the keyboard
+ (see Qt::WA_KeyboardFocusChange)
+ \row
+ \li State_MouseOver
+ \li Set if the mouse cursor is over the widget
+ \row
+ \li State_Active
+ \li Set if the widget is a child of the active window.
+ \row
+ \li State_HasEditFocus
+ \li Set if the widget has the edit focus
+ \endtable
+
+ The other common members for widgets are:
+
+ \table 90%
+ \header
+ \li Member
+ \li Content
+ \row
+ \li rect
+ \li The bounding rectangle of the element to draw. This
+ is set to the widget bounding rectangle
+ (QWidget::rect()).
+ \row
+ \li direction
+ \li The layout direction; a value of the
+ Qt::LayoutDirection enum.
+ \row
+ \li palette
+ \li The QPalette to use when drawing the element. This
+ is set to the widgets palette (QWidget::palette()).
+ \row
+ \li fontMetrics
+ \li The QFontMetrics to use when drawing text on the
+ widget.
+ \endtable
+
+ The complex style options (classes that inherit
+ QStyleOptionComplex) used for complex style elements share two
+ variables: \l{QStyleOptionComplex::}{subControls} and
+ \l{QStyleOptionComplex::}{activeSubControls}. Both variables are
+ an OR'ed combination of QStyle::SubControl enum values. They
+ indicate which sub controls the complex control consists of and
+ which of these controls are currently active.
+
+ As mentioned, the style calculates the size of the widgets
+ contents, which the widgets calculate their size hints from. In
+ addition, complex controls also use the style to test which
+ sub-controls the mouse is over.
+
+ \section2 Widget Reference
+
+ Without further delay, we present the widget walkthrough; each
+ widget has its own sub-section.
+
+ \section3 Push Buttons
+
+ The style structure for push buttons is shown below. By doing a
+ top-down traversal of the tree, you get the sequence in which the
+ elements should be drawn.
+
+ \image javastyle/pushbutton.png The style structure for push buttons
+
+ The layout of the buttons, with regard element bounds, varies from
+ style to style. This makes it difficult to show conceptual images
+ of this. Also, elements may - even be intended to - have the same
+ bounds; the PE_PushButtonBevel, for instance, is used in
+ QCommonStyle to draw the elements that contains it:
+ PE_FrameDefaultButton, PE_FrameButtonBevel, and
+ PE_PanelButtonCommand, all of which have the same bounds in common
+ and windows style. PE_PushButtonBevel is also responsible for
+ drawing the menu indicator (QCommonStyle draws
+ PE_IndicatorArrowDown).
+
+ An image of a push button in the java style that show the bounding
+ rectangles of the elements is given below. Colors are used to
+ separate the bounding rectangles in the image; they do not fill
+ any other purpose. This is also true for similar images for the
+ other widgets.
+
+ \image javastyle/button.png
+
+ The java style, as well as all other styles implemented in Qt,
+ does not use PE_FrameButtonBevel. It is usual that a button
+ with a PE_DefaultFrame adjusts the PE_PanelButtonCommand's
+ rectangle by PM_ButtonDefaultIndicator. The CE_PushButtonLabel
+ is found by adjusting the rect by PM_DefaultFrameWidth.
+
+ We will now examine the style option for push
+ buttons - QStyleOptionButton. A table for the states that
+ QPushButton can set on the style option follows:
+
+ \table 90%
+ \header
+ \li State
+ \li State Set When
+ \row
+ \li State_Sunken
+ \li Button is down or menu is pressed shown
+ \row
+ \li State_On
+ \li Button is checked
+ \row
+ \li State_Raised
+ \li Button is not flat and not pressed down
+ \endtable
+
+ Other members of QStyleOptionButton is:
+
+ \table 90%
+ \header
+ \li Member
+ \li Content
+ \row
+ \li features
+ \li Flags of the QStyleOptionButton::ButtonFeatures enum,
+ which describes various button properties (see enum)
+ \row
+ \li icon
+ \li The buttons QIcon (if any)
+ \row
+ \li iconSize
+ \li The QSize of the icon
+ \row
+ \li text
+ \li a QString with the buttons text
+ \endtable
+
+ \section3 Check and Radio Buttons
+
+ The structures for radio and check buttons are identical.
+ We show the structure using QCheckBox element and pixel
+ metric names:
+
+ \image javastyle/checkbox.png
+
+ QStyleOptionButton is used as the style option for both check
+ and radio buttons. We first give a table of the states that
+ can be set in the option:
+
+ \table 90%
+ \header
+ \li State
+ \li State Set When
+ \row
+ \li State_sunken
+ \li The box is pressed down
+ \row
+ \li State_NoChange
+ \li The box is partially checked (for tristate
+ checkboxes.)
+ \row
+ \li State_On
+ \li The box is checked
+ \row
+ \li State_Off
+ \li The box is unchecked
+ \endtable
+
+ See \l{Push Buttons} for a table over other members in the
+ QStyleOptionButtonClass.
+
+ \section3 Tabs
+
+ In Qt, QTabBar uses the style to draw its tabs. Tabs exist either
+ in a QTabWidget, which contains a QTabBar, or as a separate bar.
+ If the bar is not part of a tab widget, it draws its own base.
+
+ QTabBar lays out the tabs, so the style does not have control over
+ tab placement. However, while laying out its tabs, the bar asks
+ the style for PM_TabBarTabHSpace and PM_TabBarTabVSpace, which is
+ extra width and height over the minimum size of the tab bar tab
+ label (icon and text). The style can also further influence the
+ tab size before it is laid out, as the tab bar asks for
+ CT_TabBarTab. The bounding rectangle of the bar is decided by the
+ tab widget when it is part of the widget (still considering
+ CT_TabBarTab).
+
+ The tab bar is responsible for drawing the buttons that appear on
+ the tab bar when all tabs do not fit. Their placement is not
+ controlled by the style, but the buttons are \l{QToolButton}s
+ and are therefore drawn by the style.
+
+ Here is the style structure for QTabWidget and QTabBar:
+
+ \image javastyle/tab.png
+
+ The dotted lines indicate that the QTabWidget contains a tab bar,
+ but does not draw it itself, that QTabBar only draws its base line
+ when not part of a tab widget, and that the tab bar keeps two tool
+ buttons that scroll the bar when all tabs do not fit; see \l{Tool
+ Buttons} for their element tree. Also note that since the buttons
+ are children of the tab bar, they are drawn after the bar. The
+ tabs bounding rectangles overlap the base by PM_TabBarBaseOverlap.
+
+ Here is a tab widget in the java style:
+
+ \image javastyle/tabwidget.png
+
+ In the java style (and also windows), the tab bar shape and label
+ have the same bounding rectangle as CE_TabBarTab. Notice that the
+ tabs overlap with the tab widget frame. The base of the tab bar
+ (if drawn) is the area where the tabs and frame overlap.
+
+ The style option for tabs (QStyleOptionTab) contains the necessary
+ information for drawing tabs. The option contains the position of
+ the tab in the tab bar, the position of the selected tab, the
+ shape of the tab, the text, and icon. After Qt 4.1 the option
+ should be cast to a QStyleOptionTabV2, which also contains the
+ icons size.
+
+ As the java style tabs don't overlap, we also present an image of
+ a tab widget in the windows style. Note that if you want the tabs
+ to overlap horizontally, you do that when drawing the tabs in
+ CE_TabBarTabShape; the tabs bounding rectangles will not be
+ altered by the tab bar. The tabs are drawn from left to right in a
+ north tab bar shape, top to bottom in an east tab bar shape, etc.
+ The selected tab is drawn last, so that it is easy to draw it over
+ the other tabs (if it is to be bigger).
+
+ \image javastyle/windowstabimage.png
+
+ A table of the states a tab bar can set on its tabs follows:
+
+ \table 90%
+ \header
+ \li State
+ \li State Set When
+ \row
+ \li State_Sunken
+ \li The tab is pressed on with the mouse.
+ \row
+ \li State_Selected
+ \li If it is the current tab.
+ \row
+ \li State_HasFocus
+ \li The tab bar has focus and the tab is selected
+ \endtable
+
+ Note that individual tabs may be disabled even if the tab bar
+ is not. The tab will be active if the tab bar is active.
+
+ Here follows a table of QStyleOptionTabV2's members:
+
+ \table 90%
+ \header
+ \li Member
+ \li Content
+ \row
+ \li cornerWidgets
+ \li Is flags of the CornerWidget enum, which indicate
+ if and which corner widgets the tab bar has.
+ \row
+ \li icon
+ \li The QIcon of the tab
+ \row
+ \li iconSize
+ \li The QSize of the icon
+ \row
+ \li position
+ \li A TabPosition enum value that indicates the tabs
+ position on the bar relative to the other tabs.
+ \row
+ \li row
+ \li holds which row the tab is in
+ \row
+ \li selectedPosition
+ \li A value of the SelectedPosition enum that indicates
+ whether the selected tab is adjacent to or is the
+ tab.
+ \row
+ \li shape
+ \li A value of the QTabBar::Shape enum indication
+ whether the tab has rounded or triangular corners
+ and the orientation of the tab.
+ \row
+ \li text
+ \li The tab text
+ \endtable
+
+ The frame for tab widgets use QStyleOptionTabWidgetFrame as
+ style option. We list its members here. It does not have
+ states set besides the common flags.
+
+ \table 90%
+ \header
+ \li Member
+ \li content
+ \row
+ \li leftCornerWidgetSize
+ \li The QSize of the left corner widget (if any).
+ \row
+ \li rightCornerWidgetSize
+ \li The QSize of the right corner widget (if any).
+ \row
+ \li lineWidth
+ \li holds the line with for drawing the panel.
+ \row
+ \li midLineWith
+ \li this value is currently always 0.
+ \row
+ \li shape
+ \li The shape of the tabs on the tab bar.
+ \row
+ \li tabBarSize
+ \li The QSize of the tab bar.
+ \endtable
+
+ \section3 Scroll Bars
+
+ Here is the style structure for scrollBars:
+
+ \image javastyle/scrollbar.png
+
+ QScrollBar simply creates its style option and then draws
+ CC_ScrollBar. Some styles draw the background of add page and sub
+ page with PE_PanelButtonBevel and also use indicator arrows to
+ draw the arrows in the nest and previous line indicators; we have
+ not included these in the tree as their use is up to the
+ individual style. The style's PM_MaximumDragDistance is the
+ maximum distance in pixels the mouse can move from the bounds
+ of the scroll bar and still move the handle.
+
+ Here is an image of a scrollbar in the java style:
+
+ \image javastyle/scrollbarimage.png
+
+ You may notice that the scrollbar is slightly different from
+ Java's as it has two line up indicators. We have done this to show
+ how that you can have two separate bounding rectangles for a
+ single sub control. The scroll bar is an example of a widget that
+ is entirely implemented by the java style - neither QWindowsStyle
+ nor QCommonStyle are involved in the drawing.
+
+ We have a look at the different states a scroll bar can set on
+ the style option:
+
+ \table 90%
+ \header
+ \li State
+ \li State Set When
+ \row
+ \li State_Horizontal
+ \li The scroll bar is horizontal
+ \endtable
+
+ The style option of QScrollBar is QStyleOptionSlider. Its
+ members are listed in the following table. The option is used
+ by all \l{QAbstractSlider}s; we only describe the members
+ relevant for scroll bars here.
+
+ \table 90%
+ \header
+ \li Member
+ \li Content
+ \row
+ \li maximum
+ \li the maximum value of the scroll bar
+ \row
+ \li minimum
+ \li the minimum value of the scroll bar
+ \row
+ \li notchTarget
+ \li the number of pixels between notches
+ \row
+ \li orientation
+ \li a value of the Qt::Orientation enum that specifies
+ whether the scroll bar is vertical or horizontal
+ \row
+ \li pageStep
+ \li the number to increase or decrease the sliders
+ value (relative to the size of the slider and its value
+ range) on page steps.
+ \row
+ \li singleStep
+ \li the number to increase or decrease the sliders
+ value on single (or line) steps
+ \row
+ \li sliderValue
+ \li The value of the slider
+ \row
+ \li sliderPosition
+ \li the position of the slider handle. This is the same
+ as \c sliderValue if the scroll bar is
+ QAbstractSlider::tracking. If not, the scroll
+ bar does not update its value before the mouse
+ releases the handle.
+ \row
+ \li upsideDown
+ \li holds the direction in which the scroll bar
+ increases its value. This is used instead of
+ QStyleOption::direction for all abstract sliders.
+ \endtable
+
+ \section3 Sliders
+
+ When calculating the sliders size hint, PM_SliderTickness and
+ PM_SliderLength is queried from the style. As with scroll bars,
+ the QSlider only lets the user move the handle if the mouse is
+ within PM_MaximumDragDistance from the slider bounds. When it
+ draws itself it creates the style option and calls \c
+ drawComplexControl() with CC_Slider:
+
+ \image javastyle/slider.png
+
+ We also show a picture of a slider in the java style. We show
+ the bounding rectangles of the sub elements as all drawing is done
+ in CC_Slider.
+
+ \image javastyle/sliderimage.png
+
+ QSlider uses QStyleOptionSlider as all \l{QAbstractSlider}s do. We
+ present a table with the members that affect QSlider:
+
+ \table 90%
+ \header
+ \li Member
+ \li Content
+ \row
+ \li maximum
+ \li the maximum value of the slider
+ \row
+ \li minimum
+ \li the minimum value of the slider
+ \row
+ \li notchTarget
+ \li this is the number of pixels between each notch
+ \row
+ \li orientation
+ \li a Qt::Orientation enum value that gives whether the
+ slider is vertical or horizontal.
+ \row
+ \li pageStep
+ \li a number in slider value to increase or decrease
+ for page steps
+ \row
+ \li singleStep
+ \li the number to increase or decrease the sliders
+ value on single (or line) steps.
+ \row
+ \li sliderValue
+ \li the value of the slider.
+ \row
+ \li sliderPosition
+ \li the position of the slider given as a slider value.
+ This will be equal to the \c sliderValue if the
+ slider is \l{QAbstractSlider::}{tracking}; if
+ not, the sliders value will not change until the handle is
+ released with the mouse.
+ \row
+ \li upsideDown
+ \li this member is used instead of QStyleOption::direction
+ for all abstract sliders.
+ \endtable
+
+ You should note that the slider does not use direction for
+ reverse layouts; it uses \c upsideDown.
+
+ \section3 Spin Boxes
+
+ When QSpinBox paints itself it creates a QStyleOptionSpinBox and
+ asks the style to draw CC_SpinBox. The edit field is a line
+ edit that is a child of the spin box. The dimensions of the
+ field is calculated by the style with SC_SpinBoxEditField.
+
+ Here follows the style tree for spin boxes. It is not
+ required that a style uses the button panel primitive to paint
+ the indicator backgrounds. You can see an image below the tree
+ showing the sub elements in QSpinBox in the java style.
+
+ \image javastyle/spinbox.png
+
+ \image javastyle/spinboximage.png
+
+ The QStyleOptionSpinBox, which is the style option for spin
+ boxes. It can set the following states on the spin box.:
+
+ \table 90%
+ \header
+ \li State
+ \li State Set When
+ \row
+ \li State_Sunken
+ \li Is set if one of the sub controls CC_SpinUp or
+ CC_SpinDown is pressed on with the mouse.
+ \endtable
+
+ The rest of the members in the spin boxes style options are:
+
+ \table 90%
+ \header
+ \li Property
+ \li Function
+ \row
+ \li frame
+ \li boolean that is true if the spin box is to draw a
+ frame.
+ \row
+ \li buttonSymbols
+ \li Value of the ButtonSymbols enum that decides the
+ symbol on the up/down buttons.
+ \row
+ \li stepEnabled
+ \li A value of the StepEnabled indication which of the
+ spin box buttons are pressed down.
+ \endtable
+
+ \section3 Title Bar
+
+ The title bar complex control, CC_TitleBar, is used to draw
+ the title bars of internal windows in QMdiArea. It typically
+ consists of a window title and close, minimize, system menu, and
+ maximize buttons. Some styles also provide buttons for shading
+ the window, and a button for context sensitive help.
+
+ The bar is drawn in CC_TitleBar without using any sub elements.
+ How the individual styles draw their buttons is individual, but
+ there are standard pixmaps for the buttons that the style should
+ provide.
+
+ \image javastyle/titlebar.png
+
+ In an image over a title bar in the java style, we show the
+ bounding rectangles of the sub elements supported by the java style
+ (all of which are drawn with standard pixmaps). It is usual to
+ draw the button backgrounds using PE_PanelButtonTool, but it's no
+ rule.
+
+ \image javastyle/titlebarimage.png
+
+ The style option for title bars is QStyleOptionTitleBar. It's
+ members are:
+
+ \table 90%
+ \header
+ \li Member
+ \li Content
+ \row
+ \li icon
+ \li The title bars icon
+ \row
+ \li text
+ \li the text for the title bar's label
+ \row
+ \li windowFlags
+ \li flags of the Qt::WindowFlag enum. The window flags
+ used by QMdiArea for window management.
+ \row
+ \li titleBarState
+ \li this is the QWidget::windowState() of the window
+ that contains the title bar.
+ \endtable
+
+ \section3 Combo Box
+
+ A QComboBox uses the style to draw the button and label of
+ non-editable boxes with CC_ComboBox and CE_ComboBoxLabel.
+
+ The list that pops up when the user clicks on the combo box is
+ drawn by a \l{Delegate Classes}{delegate}, which we do not cover
+ in this overview. You can, however, use the style to control the
+ list's size and position with the sub element
+ SC_ComboBoxListBoxPopup. The style also decides where the edit
+ field for editable boxes should be with SC_ComboBoxEditField; the
+ field itself is a QLineEdit that is a child of the combo box.
+
+ \image javastyle/combobox.png
+
+ We show an image over a java style combo box in which we have
+ outlined its sub elements and sub element rectangles:
+
+ \image javastyle/comboboximage.png
+
+ Java combo boxes do not use the focus rect; it changes its
+ background color when it has focus. The SC_ComboBoxEdit field is
+ used both by QComboBox to calculate the size of the edit field and
+ the style for calculating the size of the combo box label.
+
+ The style option for combo boxes is QStyleOptionComboBox. It
+ can set the following states:
+
+ \table 90%
+ \header
+ \li State
+ \li Set When
+ \row
+ \li State_Selected
+ \li The box is not editable and has focus
+ \row
+ \li State_Sunken
+ \li SC_ComboBoxArrow is active
+ \row
+ \li State_on
+ \li The container (list) of the box is visible
+ \endtable
+
+ The style options other members are:
+
+ \table
+ \header
+ \li Member
+ \li Content
+ \row
+ \li currentIcon
+ \li the icon of the current (selected) item of the
+ combo box.
+ \row
+ \li currentText
+ \li the text of the current item in the box.
+ \row
+ \li editable
+ \li holds whether the combo box is editable or not
+ \row
+ \li frame
+ \li holds whether the combo box has a frame or not
+ \row
+ \li iconSize
+ \li the size of the current items icon.
+ \row
+ \li popupRect
+ \li the bounding rectangle of the combo box's popup
+ list.
+ \endtable
+
+ \section3 Group Boxes
+
+ When calculating the size hint, QGroupBox fetches three pixel
+ metrics from the style: PM_IndicatorWidth,
+ PM_CheckBoxLabelSpacing, and PM_IndicatorHeight. QGroupBox has
+ the following style element tree:
+
+ \image javastyle/groupbox.png
+
+ Qt does not impose restrictions on how the check box is drawn; the
+ java style draws it with CE_IndicatorCheckBox. See \l{Check and
+ Radio Buttons} for the complete tree.
+
+ We also give an image of the widget with the sub controls and
+ sub control rectangles drawn:
+
+ \image javastyle/groupboximage.png
+
+ The style option for group boxes are QStyleOptionGroupBox. The
+ following states can be set on it:
+
+ \table 90%
+ \header
+ \li State
+ \li Set When
+ \row
+ \li State_On
+ \li The check box is checked
+ \row
+ \li State_Sunken
+ \li The checkbox is pressed down
+ \row
+ \li State_Off
+ \li The check box is unchecked (or there is no check box)
+ \endtable
+
+ The remaining members of QStyleOptionGroupBox are:
+
+ \table
+ \header
+ \li Member
+ \li Content
+ \row
+ \li features
+ \li flags of the QStyleOptionFrameV2::FrameFeatures
+ enum describing the frame of the group box.
+ \row
+ \li lineWidth
+ \li the line width with which to draw the panel. This
+ is always 1.
+ \row
+ \li text
+ \li the text of the group box.
+ \row
+ \li textAlignment
+ \li the alignment of the group box title
+ \row
+ \li textColor
+ \li the QColor of the text
+ \endtable
+
+ \section3 Splitters
+
+ As the structure of splitters are simple and do not contain any
+ sub elements, we do not include image of splitters. CE_Splitter
+ does not use any other elements or metrics.
+
+ For its style option, Splitters uses the base class QStyleOption.
+ It can set the following state flags on it:
+
+ \table 90%
+ \header
+ \li State
+ \li Set When
+ \row
+ \li State_Horizontal
+ \li Set if it is a horizontal splitter
+ \endtable
+
+ QSplitter does not use \l{QStyleOption::}{initFrom()} to set up its
+ option; it sets the State_MouseOver and State_Disabled flags
+ itself.
+
+ \section3 Progress Bar
+
+ The CE_ProgressBar element is used by QProgressBar, and it is the
+ only element used by this widget. We start with looking at the
+ style structure:
+
+ \image javastyle/progressbar.png
+
+ Here is a progress bar in the windows style (the java style
+ bounding rectangles are equal):
+
+ \image javastyle/progressbarimage.png
+
+ The style option for QProgressBar is QStyleOptionProgressBarV2.
+ The bar does not set any state flags, but the other members of the
+ option are:
+
+ \table 90%
+ \header
+ \li Member
+ \li Content
+ \row
+ \li minimum
+ \li The minimum value of the bar
+ \row
+ \li maximum
+ \li The maximum value of the bar
+ \row
+ \li progress
+ \li The current value of the bar
+ \row
+ \li textAlignment
+ \li How the text is aligned in the label
+ \row
+ \li textVisible
+ \li Whether the label is drawn
+ \row
+ \li text
+ \li The label text
+ \row
+ \li orientation
+ \li Progress bars can be vertical or horizontal
+ \row
+ \li invertedAppearance
+ \li The progress is inverted (i.e., right to left in a
+ horizontal bar)
+ \row
+ \li bottomToTop
+ \li Boolean that if true, turns the label of vertical
+ progress bars 90 degrees.
+ \endtable
+
+ \section3 Tool Buttons
+
+ Tool buttons exist either independently or as part of tool bars.
+ They are drawn equally either way. The QToolButton draws only one
+ style element: CC_ToolButton.
+
+ As you must be used to by now (at least if you have read this
+ document sequentially), we have a tree of the widget's style
+ structure:
+
+ \image javastyle/toolbutton.png
+
+ Note that PE_FrameButtonTool and PE_IndicatorArrowDown are
+ included in the tree as the java style draws them, but they can
+ safely be omitted if you prefer it. The structure may also be
+ different. QWindowsStyle, for instance, draws both
+ PE_IndicatorButtonDropDown and PE_IndicatorArrowDown in
+ CE_ToolButton.
+
+ We also have an image of a tool button where we have outlined
+ the sub element bounding rectangles and sub controls.
+
+ \image javastyle/toolbuttonimage.png
+
+ Here is the states table for tool buttons:
+
+ \table 90%
+ \header
+ \li State
+ \li Set When
+ \row
+ \li State_AutoRise
+ \li the tool button has the autoRise property set
+ \row
+ \li State_raised
+ \li the button is not sunken (i.e., by being checked or
+ pressed on with the mouse).
+ \row
+ \li State_Sunken
+ \li the button is down
+ \row
+ \li State_On
+ \li the button is checkable and checked.
+ \endtable
+
+ QStyleOptionToolButton also contains the following members:
+
+ \table
+ \header
+ \li Member
+ \li Content
+ \row
+ \li arrowType
+ \li a Qt::ArrowType enum value, which contains the
+ direction of the buttons arrow (if an arrow is to
+ be used in place of an icon)
+ \row
+ \li features
+ \li flags of the QStyleOptionToolButton::ButtonFeature
+ enum describing if the button has an arrow, a menu,
+ and/or has a popup-delay.
+ \row
+ \li font
+ \li the QFont of the buttons label
+ \row
+ \li icon
+ \li the QIcon of the tool button
+ \row
+ \li iconSize
+ \li the icon size of the button's icon
+ \row
+ \li pos
+ \li the position of the button, as given by
+ QWidget::pos()
+ \row
+ \li text
+ \li the text of the button
+ \row
+ \li toolButtonStyle
+ \li a Qt::ToolButtonStyle enum value which decides
+ whether the button shows the icon, the text, or both.
+ \endtable
+
+ \section3 Toolbars
+
+ Toolbars are part of the \l{QMainWindow}{main window framework}
+ and cooperates with the QMainWindow to which it belongs while it
+ builds its style option. A main window has 4 areas that toolbars
+ can be placed in. They are positioned next to the four sides of
+ the window (i.e., north, south, west, and east). Within each area
+ there can be more than one line of toolbars; a line consists of
+ toolbars with equal orientation (vertical or horizontal) placed
+ next to each other.
+
+ \l{QToolbar}{QToolbar}s in Qt consists of three elements
+ CE_ToolBar, PE_IndicatorToolBarHandle, and
+ PE_IndicatorToolBarSeparator. It is QMainWindowLayout that
+ calculates the bounding rectangles (i.e., position and size of the
+ toolbars and their contents. The main window also uses the \c
+ sizeHint() of the items in the toolbars when calculating the size
+ of the bars.
+
+ Here is the element tree for QToolBar:
+
+ \image javastyle/toolbar.png
+
+ The dotted lines indicate that the QToolBar keeps an instance of
+ QToolBarLayout and that QToolBarSeparators are kept by
+ QToolBarLayout. When the toolbar is floating (i.e., has its own
+ window) the PE_FrameMenu element is drawn, else QToolbar draws
+ CE_ToolBar.
+
+ Here is an image of a toolbar in the java style:
+
+ \image javastyle/toolbarimage.png
+
+ QToolBarSaparator uses QStyleOption for their style option. It
+ sets the State_horizontal flag if the toolbar they live in is
+ horizontal. Other than that, they use \l{QStyleOption::}{initFrom()}.
+
+ The style option for QToolBar is QStyleOptionToolBar. The only
+ state flag set (besides the common flags) is State_Horizontal
+ if the bar is horizontal (i.e., in the north or south toolbar area).
+ The member variables of the style option are:
+
+ \table 90%
+ \header
+ \li Member
+ \li Content
+ \row
+ \li features
+ \li Holds whether the bar is movable in a value of the
+ ToolBarFeature, which is either Movable or None.
+ \row
+ \li lineWidth
+ \li The width of the tool bar frame.
+ \row
+ \li midLineWidth
+ \li This variable is currently not used and is always
+ 0.
+ \row
+ \li positionOfLine
+ \li The position of the toolbar line within the toolbar
+ area to which it belongs.
+ \row
+ \li positionWithinLine
+ \li The position of the toolbar within the toolbar line.
+ \row
+ \li toolBarArea
+ \li The toolbar area in which the toolbar lives.
+ \endtable
+
+ \section3 Menus
+
+ Menus in Qt are implemented in QMenu. The QMenu keeps a list of
+ action, which it draws as menu items. When QMenu receives paint
+ events ,it calculates the size of each menu item and draws them
+ individually with CE_MenuItem. (Menu items do not have a separate
+ element for their label (contents), so all drawing is done in
+ CE_MenuItem. The menu also draws the frame of the menu with
+ PE_FrameMenu. It also draws CE_MenuScroller if the style supports
+ scrolling. CE_MenuTearOff is drawn if the menu is to large for its
+ bounding rectangle.
+
+ In the style structure tree, we also include QMenu as it also does
+ styling related work. The bounding rectangles of menu items are
+ calculated for the menus size hint and when the menu is displayed
+ or resized.
+
+ \image javastyle/menu.png
+
+ The CE_MenuScroller and CE_MenuTearOff elements are handled by
+ QCommonStyle and are not shown unless the menu is to large to fit
+ on the screen. PE_FrameMenu is only drawn for pop-up menus.
+
+ QMenu calculates rectangles based on its actions and calls
+ CE_MenuItem and CE_MenuScroller if the style supports that.
+
+ It is also usual to use PE_IndicatorCheckBox (instead of using
+ PE_IndicatorMenuCheckMark) and PE_IndicatorRadioButton for drawing
+ checkable menu items; we have not included them in the style tree
+ as this is optional and varies from style to style.
+
+ \image javastyle/menuimage.png
+
+ The style option for menu items is QStyleOptionMenuItem. The
+ following tables describe its state flags and other members.
+
+ \table 90%
+ \header
+ \li State
+ \li Set When
+ \row
+ \li State_Selected
+ \li The mouse is over the action and the action is not
+ a separator.
+ \row
+ \li State_Sunken
+ \li The mouse is pressed down on the menu item.
+ \row
+ \li State_DownArrow
+ \li Set if the menu item is a menu scroller and it scrolls
+ the menu downwards.
+ \endtable
+
+ \table 90%
+ \header
+ \li Member
+ \li Content
+ \row
+ \li checkType
+ \li A value of the \l{QStyleOptionMenuItem::}{CheckType} enum,
+ which is either NotCheckable, Exclusive, or
+ NonExclusive.
+ \row
+ \li checked
+ \li Boolean that is true if the menu item is checked.
+ \row
+ \li font
+ \li The QFont to use for the menu item's text.
+ \row
+ \li icon
+ \li the QIcon of the menu item.
+ \row
+ \li maxIconWidth
+ \li The maximum width allowed for the icon
+ \row
+ \li menuHasChecableItem
+ \li Boolean which is true if at least one item in the
+ menu is checkable.
+ \row
+ \li menuItemType
+ \li The type of the menu item. This a value of the
+ \l{QStyleOptionMenuItem::}{MenuItemType}.
+ \row
+ \li menuRect
+ \li The bounding rectangle for the QMenu that the menu
+ item lives in.
+ \row
+ \li tabWidth
+ \li This is the distance between the text of the menu
+ item and the shortcut.
+ \row
+ \li text
+ \li The text of the menu item.
+ \endtable
+
+ The setup of the style option for CE_MenuTearOff and
+ CE_MenuScroller also uses QStyleOptionMenuItem; they only set the
+ \c menuRect variable in addition to the common settings with
+ QStyleOption's \l{QStyleOption::}{initFrom()}.
+
+ \section3 Menu Bar
+
+ QMenuBar uses the style to draw each menu bar item and the empty
+ area of the menu bar. The pull-down menus themselves are
+ \l{QMenu}s (see \l{Menus}). The style element tree for the menu
+ bar follows:
+
+ \image javastyle/menubar.png
+
+ The panel and empty area is drawn after the menu items. The
+ QPainter that the QMenuBar sends to the style has the bounding
+ rectangles of the items clipped out (i.e., clip region), so you
+ don't need to worry about drawing over the items. The pixel
+ metrics in QMenuBar is used when the bounding rectangles of the
+ menu bar items are calculated.
+
+ \image javastyle/menubarimage.png
+
+ QStyleOptionMenuItem is used for menu bar items. The members that
+ are used by QMenuBar is described in the following table:
+
+ \table
+ \header
+ \li Member
+ \li Content
+ \row
+ \li menuRect
+ \li the bounding rectangle of the entire menu bar to
+ which the item belongs.
+ \row
+ \li text
+ \li the text of the item
+ \row
+ \li icon
+ \li the icon of the menu item (it is not common that
+ styles draw this icon)
+ \endtable
+
+ QStyleOptionMenuItem is also used for drawing CE_EmptyMenuBarArea.
+
+ QStyleOptionFrame is used for drawing the panel frame The
+ \l{QStyleOptionFrame::}{lineWidth} is set to PM_MenuBarPanelWidth.
+ The \l{QStyleOptionFrame::}{midLineWidth} is currently always set
+ to 0.
+
+ \section3 Item View Headers
+
+ It is the style that draws the headers of Qt's item views. The
+ item views keeps the dimensions on individual sections. Also
+ note that the delegates may use the style to paint decorations
+ and frames around items. QItemDelegate, for instance, draws
+ PE_FrameFocusRect and PE_IndicatorViewItemCheck.
+
+ \image javastyle/header.png
+
+ Here is a QTableWidget showing the bounding rects of a Java
+ header:
+
+ \image javastyle/headerimage.png
+
+ The QHeaderView uses CT_HeaderSection, PM_HeaderMargin and
+ PM_HeaderGripMargin for size and hit test calculations. The
+ PM_HeaderMarkSize is currently not used by Qt. QTableView draws
+ the button in the top-left corner (i.e., the area where the
+ vertical and horizontal headers intersect) as a CE_Header.
+
+ The style option for header views is QStyleOptionHeader. The view
+ paints one header section at a time, so the data is for the
+ section being drawn. Its contents are:
+
+ \table 90%
+ \header
+ \li Member
+ \li Content
+ \row
+ \li icon
+ \li the icon of the header (for section that is being
+ drawn).
+ \row
+ \li iconAlignment
+ \li the alignment (Qt::Alignment) of the icon in the header.
+ \row
+ \li orientation
+ \li a Qt::Orientation value deciding whether the header
+ is the horizontal header above the view or the
+ vertical header on the left.
+ \row
+ \li position
+ \li a QStyleOptionHeader::SectionPosition value
+ giving the header section's position relative to
+ the other sections.
+ \row
+ \li section
+ \li holds the section that is being drawn.
+ \row
+ \li selectedPosition
+ \li a QStyleOptionHeader::SelectedPosition value giving
+ the selected section's position relative to the
+ section that is being painted.
+ \row
+ \li sortIndicator
+ \li a QStyleOptionHeader::SortIndicator value that
+ describes the direction in which the section's sort
+ indicator should be drawn.
+ \row
+ \li text
+ \li the text of the currently drawn section.
+ \row
+ \li textAlignment
+ \li the Qt::Alignment of the text within the
+ headersection.
+ \endtable
+
+ \section3 Tree Branch Indicators
+
+ The branch indicators in a tree view is drawn by the style with
+ PE_IndicatorBranch. We think of indicators here as the indicators
+ that describe the relationship of the nodes in the tree. The
+ generic QStyleOption is sent to the style for drawing this
+ elements. The various branch types are described by states. Since
+ there are no specific style option, we simply present the states
+ table:
+
+ \table 90%
+ \header
+ \li State
+ \li Set When
+ \row
+ \li State_Sibling
+ \li the node in the tree has a sibling (i.e., there is
+ another node in the same column).
+ \row
+ \li State_Item
+ \li this branch indicator has an item.
+ \row
+ \li State_Children
+ \li the branch has children (i.e., a new sub-tree can
+ be opened at the branch).
+ \row
+ \li State_Open
+ \li the branch indicator has an opened sub-tree.
+ \endtable
+
+ The tree view (and tree widget) use the style to draw the branches
+ (or nodes if you will) of the tree.
+
+ QStyleOption is used as the style for PE_IndicatorBranch has state
+ flags set depending on what type of branch it is.
+
+ Since there is no tree structure for branch indicators, we only
+ present an image of a tree in the java style. Each state is marked
+ in the image with a rectangle in a specific color (i.e., these
+ rectangles are not bounding rectangles). All combinations of
+ states you must be aware of are represented in the image.
+
+ \image javastyle/branchindicatorimage.png
+
+ \section3 Tool Boxes
+
+ PM_SmallIconSize for sizeHints.
+
+ QToolBox is a container that keeps a collection of widgets. It has
+ one tab for each widget and display one of them at a time. The
+ tool box lays the components it displays (the tool box buttons
+ and selected widget) in a QVBoxLayout. The style tree for tool
+ boxes looks like this:
+
+ \image javastyle/toolbox.png
+
+ We show an image of a tool box in the Plastique style:
+
+ \image javastyle/toolboximage.png
+
+ All elements have the same bounding rectangles in the
+ Plastique as well as the other Qt built-in styles.
+
+ The style option for tool boxes is QStyleOptionToolBox. It
+ contains the text and icon of the tool box contents. The only
+ state set by QToolBox is State_Sunken, which is set when the user
+ presses a tab down with the mouse. The rest of the
+ QStyleOptionToolBox members are:
+
+ \table 90%
+ \header
+ \li Member
+ \li Content
+ \row
+ \li icon
+ \li the icon on the toolbox tab
+ \row
+ \li text
+ \li the text on the toolbox tab
+ \endtable
+
+ \section3 Size Grip
+
+ The size grip calculates its size hint with CT_SizeGrip. The pixel
+ metric PM_SizeGripSize is currently unused by Qt. The element tree
+ for and an image in the Plastique style of QSizeGrip follows:
+
+ \image javastyle/sizegrip.png
+
+ \image javastyle/sizegripimage.png
+
+ We show the size grip in a \l{QMainWindow}'s bottom right
+ corner.
+
+ The size grip style option, QStyleOptionSizeGrip, have one
+ member except the common members from QStyleOption:
+
+ \table 90%
+ \header
+ \li Member
+ \li Content
+ \row
+ \li corner
+ \li a Qt::Corner value that describe which corner in a
+ window (or equivalent) the grip is located.
+ \endtable
+
+ \section3 Rubber Band
+
+ The \l{QRubberBand}'s style tree consists of two nodes.
+
+ \image javastyle/rubberband.png
+
+ We present an image of a Java style window being moved in a
+ QMdiArea with a rubber band:
+
+ \image javastyle/rubberbandimage.png
+
+ The style option for rubber bands is QStyleOptionRubberBand.
+ Its members are:
+
+ \table
+ \header
+ \li Member
+ \li Content
+ \row
+ \li opaque
+ \li boolean that is true if the rubber band must be
+ drawn in an opaque style (i.e., color)
+ \row
+ \li shape
+ \li a QRubberBand::Shape enum value that holds the
+ shape of the band (which is either a rectangle or a
+ line)
+ \endtable
+
+ \section3 Dock Widgets
+
+ When the dock widget lays out its contents it asks the style for
+ these pixel metrics: PM_DockWidgetSeparatorExtent,
+ PM_DockWidgetTitleBarButtonMargin, PM_DockWidgetFrameWidth, and
+ PM_DockWidgetTitleMargin. It also calculates the bounding
+ rectangles of the float and close buttons with
+ SE_DockWidgetCloseButton and SE_DockWidgetFloatButton.
+
+ \image javastyle/dockwidget.png
+
+ The dotted lines indicate that the sender keeps instances of the
+ recipient of the arrow (i.e., it is not a style element to draw).
+ The dock widget only draws PE_frameDockWidget when it is detached
+ from its main window (i.e., it is a top level window). If it is
+ docked it draws the indicator dock widget resize handle. We show a
+ dock widget in both docked and floating state in the plastique
+ style:
+
+ \image javastyle/dockwidgetimage.png
+
+ The style option is QStyleOptionDockWidget:
+
+ \table 90%
+ \header
+ \li Member
+ \li Content
+ \row
+ \li closeable
+ \li boolean that holds whether the dock window can be
+ closed
+ \row
+ \li floatable
+ \li boolean that holds whether the dock window can
+ float (i.e., detach from the main window in which
+ it lives)
+ \row
+ \li movable
+ \li boolean that holds whether the window is movable
+ (i.e., can move to other dock widget areas)
+ \row
+ \li title
+ \li the title text of the dock window
+ \endtable
+
+ For the buttons, QStyleOptionButton is used (see \l{Tool Buttons}
+ for content description). The dock widget resize handle has a
+ plain QStyleOption.
+*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
new file mode 100644
index 0000000000..3b31efbdfc
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
@@ -0,0 +1,3963 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page stylesheet.html
+ \title Qt Style Sheets
+ \brief How to use style sheets to customize the appearance of widgets.
+
+ \ingroup frameworks-technologies
+ \ingroup qt-basic-concepts
+ \ingroup qt-gui-concepts
+
+ \previouspage {Styles and Style Aware Widgets}{Styles}
+ \contentspage Widgets and Layouts
+ \nextpage The Style Sheet Syntax
+
+ \keyword style sheet
+ \keyword stylesheet
+
+ Qt Style Sheets are a powerful mechanism that allows you to
+ customize the appearance of widgets, in addition to what is
+ already possible by subclassing QStyle. The concepts,
+ terminology, and syntax of Qt Style Sheets are heavily inspired
+ by HTML \l{http://www.w3.org/Style/CSS/}{Cascading Style Sheets
+ (CSS)} but adapted to the world of widgets.
+
+ Topics:
+
+ \list
+ \li \l{Overview}
+ \li \l{The Style Sheet Syntax}
+ \li \l{Qt Designer Integration}
+ \li \l{Customizing Qt Widgets Using Style Sheets}
+ \li \l{Qt Style Sheets Reference}
+ \li \l{Qt Style Sheets Examples}
+ \endlist
+
+ \target overview
+ \section1 Overview
+
+ Styles sheets are textual specifications that can be set on the
+ whole application using QApplication::setStyleSheet() or on a
+ specific widget (and its children) using
+ QWidget::setStyleSheet(). If several style sheets are set at
+ different levels, Qt derives the effective style sheet from all
+ of those that are set. This is called cascading.
+
+ For example, the following style sheet specifies that all
+ \l{QLineEdit}s should use yellow as their background color, and
+ all \l{QCheckBox}es should use red as the text color:
+
+ \snippet code/doc_src_stylesheet.qdoc 0
+
+ For this kind of customization, style sheets are much more
+ powerful than QPalette. For example, it might be tempting to set
+ the QPalette::Button role to red for a QPushButton to obtain a
+ red push button. However, this wasn't guaranteed to work for all
+ styles, because style authors are restricted by the different
+ platforms' guidelines and (on Windows XP and Mac OS X) by the
+ native theme engine.
+
+ Style sheets let you perform all kinds of customizations that are
+ difficult or impossible to perform using QPalette alone. If you
+ want yellow backgrounds for mandatory fields, red text for
+ potentially destructive push buttons, or fancy check boxes, style
+ sheets are the answer.
+
+ Style sheets are applied on top of the current \l{QStyle}{widget
+ style}, meaning that your applications will look as native as
+ possible, but any style sheet constraints will be taken into
+ consideration. Unlike palette fiddling, style sheets offer
+ guarantees: If you set the background color of a QPushButton to be
+ red, you can be assured that the button will have a red background
+ in all styles, on all platforms. In addition, \l{Qt Designer}
+ provides style sheet integration, making it easy to view the effects
+ of a style sheet in different \l{QStyle}{widget styles}.
+
+ In addition, style sheets can be used to provide a distinctive
+ look and feel for your application, without having to subclass
+ QStyle. For example, you can specify arbitrary images for radio
+ buttons and check boxes to make them stand out. Using this
+ technique, you can also achieve minor customizations that would
+ normally require subclassing several style classes, such as
+ specifying a \l{QStyle::styleHint()}{style hint}. The
+ \l{widgets/stylesheet}{Style Sheet} example depicted below defines
+ two distinctive style sheets that you can try out and modify at
+ will.
+
+ \table
+ \row \li \inlineimage stylesheet-coffee-xp.png
+ \li \inlineimage stylesheet-pagefold.png
+ \row \li Coffee theme running on Windows XP
+ \li Pagefold theme running on Windows XP
+ \endtable
+
+ \table
+ \row \li \inlineimage stylesheet-coffee-cleanlooks.png
+ \li \inlineimage stylesheet-pagefold-mac.png
+ \row \li Coffee theme running on Ubuntu Linux
+ \li Pagefold theme running on Mac OS X
+ \endtable
+
+ When a style sheet is active, the QStyle returned by QWidget::style()
+ is a wrapper "style sheet" style, \e not the platform-specific style. The
+ wrapper style ensures that any active style sheet is respected and
+ otherwise forwards the drawing operations to the underlying,
+ platform-specific style (e.g., QWindowsXPStyle on Windows XP).
+
+ Since Qt 4.5, Qt style sheets fully supports Mac OS X.
+
+ \warning Qt style sheets are currently not supported for custom QStyle
+ subclasses. We plan to address this in some future release.
+*/
+
+/*!
+ \page stylesheet-syntax.html
+ \contentspage {Qt Style Sheet}{Contents}
+ \previouspage Qt Style Sheet
+ \nextpage Qt Designer Integration
+ \title The Style Sheet Syntax
+
+ Qt Style Sheet terminology and syntactic rules are almost
+ identical to those of HTML CSS. If you already know CSS, you can
+ probably skim quickly through this section.
+
+ \tableofcontents
+
+ \section1 Style Rules
+
+ Style sheets consist of a sequence of style rules. A \e{style
+ rule} is made up of a selector and a declaration. The
+ \e{selector} specifies which widgets are affected by the rule;
+ the \e{declaration} specifies which properties should be set on
+ the widget. For example:
+
+ \snippet code/doc_src_stylesheet.qdoc 1
+
+ In the above style rule, \c QPushButton is the selector and \c{{
+ color: red }} is the declaration. The rule specifies that
+ QPushButton and its subclasses (e.g., \c MyPushButton) should use
+ red as their foreground color.
+
+ Qt Style Sheet is generally case insensitive (i.e., \c color,
+ \c Color, \c COLOR, and \c cOloR refer to the same property).
+ The only exceptions are class names,
+ \l{QObject::setObjectName()}{object names}, and Qt property
+ names, which are case sensitive.
+
+ Several selectors can be specified for the same declaration,
+ using commas (\c{,}) to separate the selectors. For example,
+ the rule
+
+ \snippet code/doc_src_stylesheet.qdoc 2
+
+ is equivalent to this sequence of three rules:
+
+ \snippet code/doc_src_stylesheet.qdoc 3
+
+ The declaration part of a style rule is a list of
+ \tt{\e{property}: \e{value}} pairs, enclosed in braces (\c{{}})
+ and separated with semicolons. For example:
+
+ \snippet code/doc_src_stylesheet.qdoc 4
+
+ See the \l{List of Properties} section below for the list of
+ properties provided by Qt widgets.
+
+ \section1 Selector Types
+
+ All the examples so far used the simplest type of selector, the
+ Type Selector. Qt Style Sheets support all the
+ \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{selectors
+ defined in CSS2}. The table below summarizes the most useful
+ types of selectors.
+
+ \table 100%
+ \header
+ \li Selector
+ \li Example
+ \li Explanation
+
+ \row
+ \li Universal Selector
+ \li \c *
+ \li Matches all widgets.
+
+ \row
+ \li Type Selector
+ \li \c QPushButton
+ \li Matches instances of QPushButton and of its subclasses.
+
+ \row
+ \li Property Selector
+ \li \c{QPushButton[flat="false"]}
+ \li Matches instances of QPushButton that are not
+ \l{QPushButton::}{flat}. You may use this selector to test
+ for any Qt \l{Qt's Property System}{property} that supports
+ QVariant::toString() (see the \l{QVariant::}{toString()}
+ function documentation for details). In addition, the
+ special \c class property is supported, for the name of the
+ class.
+
+ This selector may also be used to test dynamic properties.
+ For more information on customization using dynamic properties,
+ refer to \l{Customizing Using Dynamic Properties}.
+
+ Instead of \c =, you can also use \c ~= to test whether a
+ Qt property of type QStringList contains a given QString.
+
+ \warning If the value of the Qt property changes after the
+ style sheet has been set, it might be necessary to force a
+ style sheet recomputation. One way to achieve this is to
+ unset the style sheet and set it again.
+
+ \row
+ \li Class Selector
+ \li \c .QPushButton
+ \li Matches instances of QPushButton, but not of its subclasses.
+
+ This is equivalent to \c{*[class~="QPushButton"]}.
+
+ \row
+ \li ID \target ID Selector
+ Selector
+ \li \c{QPushButton#okButton}
+ \li Matches all QPushButton instances whose
+ \l{QObject::objectName}{object name} is \c okButton.
+
+ \row
+ \li Descendant Selector
+ \li \c{QDialog QPushButton}
+ \li Matches all instances of QPushButton that are descendants
+ (children, grandchildren, etc.) of a QDialog.
+
+ \row
+ \li Child Selector
+ \li \c{QDialog > QPushButton}
+ \li Matches all instances of QPushButton that are direct
+ children of a QDialog.
+ \endtable
+
+ \section1 Sub-Controls
+
+ For styling complex widgets, it is necessary to access subcontrols of the
+ widget, such as the drop-down button of a QComboBox or the up and down
+ arrows of a QSpinBox. Selectors may contain \e{subcontrols} that make it
+ possible to restrict the application of a rule to specific widget
+ subcontrols. For example:
+
+ \snippet code/doc_src_stylesheet.qdoc 5
+
+ The above rule styles the drop-down button of all \l{QComboBox}es.
+ Although the double-colon (\c{::}) syntax is reminiscent of CSS3
+ Pseudo-Elements, Qt Sub-Controls differ conceptually from these and have
+ different cascading semantics.
+
+ Sub-controls are always positioned with respect to another element - a
+ reference element. This reference element could be the widget or another
+ Sub-control. For example, the \l{Qt Style Sheets Reference#drop-down-sub}
+ {::drop-down} of a QComboBox is placed, by default, in the top right corner
+ of the Padding rectangle of the QComboBox. The
+ \l{Qt Style Sheets Reference#drop-down-sub}{::drop-down} is placed,
+ by default, in the Center of the Contents rectangle of the
+ \l{Qt Style Sheets Reference#drop-down-sub}{::drop-down} Sub-control. See
+ the \l{List of Stylable Widgets} below for the Sub-controls to use to
+ style a widget and their default positions.
+
+ The origin rectangle to be used can be changed using the
+ \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}
+ property. For example, if we want to place the drop-down in the margin
+ rectangle of the QComboBox instead of the default Padding rectangle, we
+ can specify:
+
+ \snippet code/doc_src_stylesheet.qdoc 6
+
+ The alignment of the drop-down within the Margin rectangle is changed
+ using \l{Qt Style Sheets Reference#subcontrol-position-prop}
+ {subcontrol-position} property.
+
+ The \l{Qt Style Sheets Reference#width-prop}{width} and
+ \l{Qt Style Sheets Reference#height-prop}{height} properties can be used
+ to control the size of the Sub-control. Note that setting a
+ \l{Qt Style Sheets Reference#image-prop}{image} implicitly sets the size
+ of a Sub-control.
+
+ The relative positioning scheme
+ (\l{Qt Style Sheets Reference#position-prop}{position} : relative),
+ allows the position of the Sub-Control to be offset from its initial
+ position. For example, when the QComboBox's drop-down button is
+ pressed, we might like the arrow inside to be offset to give a
+ "pressed" effect. To achieve this, we can specify:
+
+ \snippet code/doc_src_stylesheet.qdoc 7
+
+ The absolute positioning scheme
+ (\l{Qt Style Sheets Reference#position-prop}{position} : absolute),
+ allows the position and size of the Sub-control to be changed with
+ respect to the reference element.
+
+ Once positioned, they are treated the same as widgets and can be styled
+ using the \l{box model}.
+
+ See the \l{List of Sub-Controls} below for a list of supported
+ sub-controls, and \l{Customizing the QPushButton's Menu Indicator
+ Sub-Control} for a realistic example.
+
+ \note With complex widgets such as QComboBox and QScrollBar, if one
+ property or sub-control is customized, \b{all} the other properties or
+ sub-controls must be customized as well.
+
+ \section1 Pseudo-States
+
+ Selectors may contain \e{pseudo-states} that denote that restrict
+ the application of the rule based on the widget's state.
+ Pseudo-states appear at the end of the selector, with a colon
+ (\c{:}) in between. For example, the following rule applies when
+ the mouse hovers over a QPushButton:
+
+ \snippet code/doc_src_stylesheet.qdoc 8
+
+ Pseudo-states can be negated using the exclamation operator. For
+ example, the following rule applies when the mouse does not hover
+ over a QRadioButton:
+
+ \snippet code/doc_src_stylesheet.qdoc 9
+
+ Pseudo-states can be chained, in which case a logical AND is
+ implied. For example, the following rule applies to when the
+ mouse hovers over a checked QCheckBox:
+
+ \snippet code/doc_src_stylesheet.qdoc 10
+
+ Negated Pseudo-states may appear in Pseudo-state chains. For example,
+ the following rule applies when the mouse hovers over a QPushButton
+ that is not pressed:
+
+ \snippet code/doc_src_stylesheet.qdoc 11
+
+ If needed, logical OR can be expressed using the comma operator:
+
+ \snippet code/doc_src_stylesheet.qdoc 12
+
+ Pseudo-states can appear in combination with subcontrols. For
+ example:
+
+ \snippet code/doc_src_stylesheet.qdoc 13
+
+ See the \l{List of Pseudo-States} section below for the list of
+ pseudo-states provided by Qt widgets.
+
+ \section1 Conflict Resolution
+
+ Conflicts arise when several style rules specify the same
+ properties with different values. Consider the following style
+ sheet:
+
+ \snippet code/doc_src_stylesheet.qdoc 14
+
+ Both rules match QPushButton instances called \c okButton and
+ there is a conflict for the \c color property. To resolve this
+ conflict, we must take into account the \e specificity of the
+ selectors. In the above example, \c{QPushButton#okButton} is
+ considered more specific than \c QPushButton, because it
+ (usually) refers to a single object, not to all instances of a
+ class.
+
+ Similarly, selectors with pseudo-states are more specific than
+ ones that do not specify pseudo-states. Thus, the following style
+ sheet specifies that a \l{QPushButton} should have white text
+ when the mouse is hovering over it, otherwise red text:
+
+ \snippet code/doc_src_stylesheet.qdoc 15
+
+ Here's a tricky one:
+
+ \snippet code/doc_src_stylesheet.qdoc 16
+
+ Here, both selectors have the same specificity, so if the mouse
+ hovers over the button while it is enabled, the second rule takes
+ precedence. If we want the text to be white in that case, we can
+ reorder the rules like this:
+
+ \snippet code/doc_src_stylesheet.qdoc 17
+
+ Alternatively, we can make the first rule more specific:
+
+ \snippet code/doc_src_stylesheet.qdoc 18
+
+ A similar issue arises in conjunction with Type Selectors.
+ Consider the following example:
+
+ \snippet code/doc_src_stylesheet.qdoc 19
+
+ Both rules apply to QPushButton instances (since QPushButton
+ inherits QAbstractButton) and there is a conflict for the
+ \l{Qt Style Sheets Reference#color-prop}{color} property. Because QPushButton
+ inherits QAbstractButton, it might be tempting to assume that
+ \c QPushButton is more specific than \c QAbstractButton. However,
+ for style sheet computations, all Type Selectors have the same
+ specificity, and the rule that appears last takes precedence. In
+ other words, \l{Qt Style Sheets Reference#color-prop}{color} is set to \c gray
+ for all \l{QAbstractButton}s, including \l{QPushButton}s. If we really
+ want \l{QPushButton}s to have red text, we can always reorder the
+ rules.
+
+ For determining the specificity of a rule, Qt Style Sheets follow
+ the
+ \l{http://www.w3.org/TR/REC-CSS2/cascade.html#specificity}{CSS2
+ Specification}:
+
+ \quotation
+ \e{A selector's specificity is calculated as follows:}
+
+ \list
+ \li \e{count the number of ID attributes in the selector (= a)}
+ \li \e{count the number of other attributes and pseudo-classes in the selector (= b)}
+ \li \e{count the number of element names in the selector (= c)}
+ \li \e{ignore pseudo-elements [i.e., \l{subcontrols}].}
+ \endlist
+
+ \e{Concatenating the three numbers a-b-c (in a number system with a
+ large base) gives the specificity.}
+
+ \e{Some examples:}
+
+ \snippet code/doc_src_stylesheet.qdoc 20
+ \endquotation
+
+ \section1 Cascading
+
+ Style sheets can be set on the QApplication, on parent widgets,
+ and on child widgets. An arbitrary widget's effective style sheet
+ is obtained by merging the style sheets set on the widget's
+ ancestors (parent, grandparent, etc.), as well as any style sheet
+ set on the QApplication.
+
+ When conflicts arise, the widget's own style sheet is always
+ preferred to any inherited style sheet, irrespective of the
+ specificity of the conflicting rules. Likewise, the parent
+ widget's style sheet is preferred to the grandparent's, etc.
+
+ One consequence of this is that setting a style rule on a widget
+ automatically gives it precedence over other rules specified in
+ the ancestor widgets' style sheets or the QApplication style
+ sheet. Consider the following example. First, we set a style
+ sheet on the QApplication:
+
+ \snippet code/doc_src_stylesheet.cpp 21
+
+ Then we set a style sheet on a QPushButton object:
+
+ \snippet code/doc_src_stylesheet.cpp 22
+
+ The style sheet on the QPushButton forces the QPushButton (and
+ any child widget) to have blue text, in spite of the more
+ specific rule set provided by the application-wide style sheet.
+
+ The result would have been the same if we had written
+
+ \snippet code/doc_src_stylesheet.cpp 23
+
+ except that if the QPushButton had children (which is unlikely),
+ the style sheet would have no impact on them.
+
+ Style sheet cascading is a complex topic. Refer to the
+ \l{http://www.w3.org/TR/CSS2/cascade.html#cascade}{CSS2
+ Specification} for the gory details. Be aware that Qt currently
+ doesn't implement \c{!important}.
+
+ \section1 Inheritance
+
+ In classic CSS, when font and color of an item is not explicitly set,
+ it gets automatically inherited from the parent. When using Qt Style Sheets,
+ a widget does \b{not} automatically inherit its font and color setting
+ from its parent widget.
+
+ For example, consider a QPushButton inside a QGroupBox:
+
+ \snippet code/doc_src_stylesheet.cpp 24
+
+ The QPushButton does not have an explicit color set. Hence, instead
+ of inheriting color of its parent QGroupBox, it has the system color.
+ If we want to set the color on a QGroupBox and its children,
+ we can write:
+
+ \snippet code/doc_src_stylesheet.cpp 25
+
+ In contrast, setting a font and propagate using QWidget::setFont() and
+ QWidget::setPalette() propagates to child widgets.
+
+ \section1 Widgets inside C++ namespaces
+
+ The Type Selector can be used to style widgets of a particular type. For
+ example,
+
+ \snippet code/doc_src_stylesheet.cpp 26
+
+ Qt Style Sheet uses QObject::className() of the widget to determine
+ when to apply the Type Selector. When custom widgets are inside namespaces,
+ the QObject::className() returns <namespace>::<classname>. This conflicts
+ with the syntax for \l{Sub-Controls}. To overcome this problem,
+ when using the Type Selector for widgets inside namespaces, we must
+ replace the "::" with "--". For example,
+
+ \snippet code/doc_src_stylesheet.cpp 27
+
+ \section1 Setting QObject properties
+
+ From 4.3 and above, any designable Q_PROPERTY
+ can be set using the qproperty-<property name> syntax.
+
+ For example,
+ \snippet code/doc_src_stylesheet.qdoc 28
+
+ If the property references an enum declared with Q_ENUMS, you should
+ reference its constants by name, i.e., not their numeric value.
+
+*/
+
+/*!
+ \page stylesheet-designer.html
+ \contentspage {Qt Style Sheet}{Contents}
+ \previouspage The Style Sheet Syntax
+ \nextpage Customizing Qt Widgets Using Style Sheets
+ \title Qt Designer Integration
+
+ \l{Qt Designer}{Qt Designer} is an excellent tool
+ to preview style sheets. You can right-click on any widget in Designer
+ and select \gui{Change styleSheet...} to set the style sheet.
+
+ \image designer-stylesheet-options.png
+
+ In Qt 4.2 and later, \l{Qt Designer}{Qt Designer} also includes a
+ style sheet syntax highlighter and validator. The validator indicates
+ if the syntax is valid or invalid, at the bottom left of the \gui{Edit
+ Style Sheet} dialog.
+
+ \image designer-validator-highlighter.png
+
+ When you click \gui{OK} or \gui{Apply}, \QD will automatically display
+ the widget with its new stylesheet.
+
+ \image designer-stylesheet-usage.png
+ */
+
+/*!
+ \page stylesheet-customizing.html
+ \contentspage {Qt Style Sheet}{Contents}
+ \previouspage Qt Designer Integration
+ \nextpage Qt Style Sheets Reference
+ \title Customizing Qt Widgets Using Style Sheets
+
+ When using style sheets, every widget is treated as a box with four
+ concentric rectangles: the margin rectangle, the border rectangle, the
+ padding rectangle, and the content rectangle. The box model describes
+ this in further detail.
+
+ \tableofcontents
+
+ \target box model
+ \section1 The Box Model
+
+ The four concentric rectangles appear conceptually as below:
+
+ \image stylesheet-boxmodel.png
+
+ \list
+ \li The margin falls outside the border.
+ \li The border is drawn between the margin and the padding.
+ \li The padding falls inside the border, between the border and
+ the actual contents.
+ \li The content is what is left from the original widget or
+ subcontrol once we have removed the margin, the border, and
+ the padding.
+ \endlist
+
+ The \l{Qt Style Sheets Reference#margin-prop}{margin},
+ \l{Qt Style Sheets Reference#border-width-prop}
+ {border-width}, and
+ \l{Qt Style Sheets Reference#padding-prop}{padding}
+ properties all default to zero. In that case, all four rectangles
+ (\c margin, \c border, \c padding, and \c content) coincide exactly.
+
+ You can specify a background for the widget using the
+ \l{Qt Style Sheets Reference#background-image-prop}{background-image}
+ property. By default, the background-image is drawn only for the area
+ inside the border. This can be changed using the
+ \l{Qt Style Sheets Reference#background-clip-prop}{background-clip}
+ property. You can use
+ \l{Qt Style Sheets Reference#background-repeat-prop}{background-repeat}
+ and
+ \l{Qt Style Sheets Reference#background-origin-prop}{background-origin}
+ to control the repetition and origin of the background image.
+
+ A background-image does not scale with the size of the widget. To provide
+ a "skin" or background that scales along with the widget size, one must
+ use
+ \l{Qt Style Sheets Reference#border-image-prop}{border-image}. Since the
+ border-image property provides an alternate background, it is not required
+ to specify a background-image when border-image is specified. In the case,
+ when both of them are specified, the border-image draws over the
+ background-image.
+
+ In addition, the \l{Qt Style Sheets Reference#image-prop}{image} property
+ may be used to draw an image over the border-image. The image specified does
+ not tile or stretch and when its size does not match the size of the widget,
+ its alignment is specified using the
+ \l{Qt Style Sheets Reference#image-position-prop}{image-position}
+ property. Unlike background-image and border-image, one may specify a
+ SVG in the image property, in which case the image is scaled automatically
+ according to the widget size.
+
+ The steps to render a rule are as follows:
+ \list
+ \li Set clip for entire rendering operation (border-radius)
+ \li Draw the background (background-image)
+ \li Draw the border (border-image, border)
+ \li Draw overlay image (image)
+ \endlist
+
+ \target sub controls
+ \section1 Sub-controls
+
+ A widget is considered as a hierarchy (tree) of subcontrols drawn on top
+ of each other. For example, the QComboBox draws the drop-down sub-control
+ followed by the down-arrow sub-control. A QComboBox is thus rendered as
+ follows:
+ \list
+ \li Render the QComboBox { } rule
+ \li Render the QComboBox::drop-down { } rule
+ \li Render the QComboBox::down-arrow { } rule
+ \endlist
+
+ Sub-controls share a parent-child relationship. In the case of QComboBox,
+ the parent of down-arrow is the drop-down and the parent of drop-down is
+ the widget itself. Sub-controls are positioned within their parent using
+ the \l{Qt Style Sheets Reference#subcontrol-position-prop}
+ {subcontrol-position} and
+ \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}
+ properties.
+
+ Once positioned, sub-controls can be styled using the \l{box model}.
+
+ \note With complex widgets such as QComboBox and QScrollBar, if one
+ property or sub-control is customized, \b{all} the other properties or
+ sub-controls must be customized as well.
+
+*/
+
+/*!
+ \page stylesheet-reference.html
+ \contentspage {Qt Style Sheet}{Contents}
+ \previouspage Customizing Qt Widgets Using Style Sheets
+ \nextpage Qt Style Sheets Examples
+ \title Qt Style Sheets Reference
+
+ Qt Style Sheets support various properties, pseudo-states, and
+ subcontrols that make it possible to customize the look of
+ widgets.
+
+ \tableofcontents
+
+ \section1 List of Stylable Widgets
+
+ The following table lists the Qt widgets that can be customized
+ using style sheets:
+
+ \table 100%
+ \header
+ \li Widget
+ \li How to Style
+
+ \row
+ \li QAbstractScrollArea \target qabstractscrollarea-widget
+ \li Supports the \l{box model}.
+
+ All derivatives of QAbstractScrollArea, including QTextEdit,
+ and QAbstractItemView (all item view classes), support
+ scrollable backgrounds using
+ \l{Qt Style Sheets Reference#background-attachment-prop}
+ {background-attachment}. Setting the background-attachment to
+ \c{fixed} provides a background-image that does not scroll with the
+ viewport. Setting the background-attachment to \c{scroll}, scrolls
+ the background-image when the scroll bars move.
+
+ See \l{Qt Style Sheets Examples#Customizing QAbstractScrollArea}
+ {Customizing QAbstractScrollArea} for an example.
+
+ \row
+ \li QCheckBox \target qcheckbox-widget
+ \li Supports the \l{box model}. The check indicator can be
+ styled using the \l{#indicator-sub}{::indicator}
+ subcontrol. By default, the indicator is placed in the Top
+ Left corner of the Contents rectangle of the widget.
+
+ The \l{#spacing-prop}{spacing} property
+ specifies the spacing between the check indicator and
+ the text.
+
+ See \l{Qt Style Sheets Examples#Customizing QCheckBox}
+ {Customizing QCheckBox} for an example.
+
+ \row
+ \li QColumnView \target qcolumnview-widget
+ \li The grip can be styled be using the \l{image-prop}{image} property.
+ The arrow indicators can by styled using the
+ \l{left-arrow-sub}{::left-arrow} subcontrol and the
+ \l{right-arrow-sub}{::right-arrow} subcontrol.
+
+ \row
+ \li QComboBox \target qcombobox-widget
+ \li The frame around the combobox can be styled using the
+ \l{box model}. The drop-down button can be styled using
+ the \l{#drop-down-sub}{::drop-down} subcontrol. By default, the
+ drop-down button is placed in the top right corner of the padding
+ rectangle of the widget. The arrow mark inside the drop-down button
+ can be styled using the \l{#down-arrow-sub}{::down-arrow}
+ subcontrol. By default, the arrow is placed in the center of the
+ contents rectangle of the drop-down subcontrol.
+
+ See \l{Qt Style Sheets Examples#Customizing QComboBox}{Customizing QComboBox}
+ for an example.
+
+ \row
+ \li QDateEdit \target qdateedit-widget
+ \li See \l{#qspinbox-widget}{QSpinBox}.
+
+ \row
+ \li QDateTimeEdit \target qdatetimeedit-widget
+ \li See \l{#qspinbox-widget}{QSpinBox}.
+
+ \row
+ \li QDialog \target qdialog-widget
+ \li Supports only the \l{Qt Style Sheets Reference#background-prop}{background},
+ \l{#background-clip-prop}{background-clip} and
+ \l{#background-origin-prop}{background-origin} properties.
+
+ \warning Make sure you define the Q_OBJECT macro for your custom
+ widget.
+
+ \row
+ \li QDialogButtonBox \target qdialogbuttonbox-widget
+ \li The layout of buttons can be altered using the
+ \l{#button-layout-prop}{button-layout} property.
+
+ \row
+ \li QDockWidget \target qdockwidget-widget
+ \li Supports styling of the title bar and the title bar buttons when docked.
+
+ The dock widget border can be styled using the \l{#border-prop}{border}
+ property. The \l{#title-sub}{::title} subcontrol can be used to customize
+ the title bar. The close and float buttons are positioned with respect
+ to the \l{title-sub}{::title} subcontrol using the
+ \l{#close-button-sub}{::close-button} and
+ \l{#float-button-sub}{::float-button} respectively.
+
+ When the title bar is vertical, the \l{#vertical-ps}{:vertical} pseudo
+ class is set. In addition, depending on QDockWidget::DockWidgetFeature,
+ the \l{#closable-ps}{:closable}, \l{#floatable-ps}{:floatable} and
+ \l{#movable-ps}{:movable} pseudo states are set.
+
+ \note Use QMainWindow::separator to style the resize handle.
+
+ \warning The style sheet has no effect when the QDockWidget is undocked
+ as Qt uses native top level windows when undocked.
+
+ See \l{Qt Style Sheets Examples#Customizing QDockWidget}
+ {Customizing QDockWidget} for an example.
+
+ \row
+ \li QDoubleSpinBox \target qdoublespinbox-widget
+ \li See \l{#qspinbox-widget}{QSpinBox}.
+
+ \row
+ \li QFrame \target qframe-widget
+ \li Supports the \l{box model}.
+
+ Since 4.3, setting a stylesheet on a QLabel automatically
+ sets the QFrame::frameStyle property to QFrame::StyledPanel.
+
+ See \l{Qt Style Sheets Examples#Customizing QFrame}{Customizing QFrame}
+ for an example.
+
+ \row
+ \li QGroupBox \target qgroupbox-widget
+ \li Supports the \l{box model}. The title can be styled using the
+ \l{#title-sub}{::title} subcontrol. By default, the title is placed
+ depending on QGroupBox::textAlignment.
+
+ In the case of a checkable QGroupBox, the title includes the
+ check indicator. The indicator is styled using the
+ the \l{#indicator-sub}{::indicator} subcontrol. The
+ \l{#spacing-prop}{spacing} property can be used to control
+ the spacing between the text and indicator.
+
+ See \l{Qt Style Sheets Examples#Customizing QGroupBox}{Customizing QGroupBox}
+ for an example.
+
+ \row
+ \li QHeaderView \target qheaderview-widget
+ \li Supports the \l{box model}. The sections of the header view are
+ styled using the \l{#section-sub}{::section} sub control. The
+ \c{section} Sub-control supports the \l{#middle-ps}{:middle},
+ \l{#first-ps}{:first}, \l{#last-ps}{:last},
+ \l{#only-one-ps}{:only-one}, \l{#next-selected-ps}{:next-selected},
+ \l{#previous-selected-ps}{:previous-selected},
+ \l{#selected-ps}{:selected},
+ and \l{#checked-ps}{:checked} pseudo states.
+
+ Sort indicator in can be styled using the
+ \l{#up-arrow-sub}{::up-arrow} and the
+ \l{#down-arrow-sub}{::down-arrow} Sub-control.
+
+ See \l{Qt Style Sheets Examples#Customizing QHeaderView}{Customizing QHeaderView}
+ for an example.
+
+ \row
+ \li QLabel \target qlabel-widget
+ \li Supports the \l{box model}. Does not support the
+ \l{#hover-ps}{:hover} pseudo-state.
+
+ Since 4.3, setting a stylesheet on a QLabel automatically
+ sets the QFrame::frameStyle property to QFrame::StyledPanel.
+
+ See \l{Qt Style Sheets Examples#Customizing QFrame}{Customizing QFrame} for an
+ example (a QLabel derives from QFrame).
+
+ \row
+ \li QLineEdit \target qlineedit-widget
+ \li Support the \l{box model}.
+
+ The color and background of the selected item is styled using
+ \l{#selection-color-prop}{selection-color} and
+ \l{#selection-background-color-prop}{selection-background-color}
+ respectively.
+
+ The password character can be styled using the
+ \l{#lineedit-password-character-prop}{lineedit-password-character}
+ property.
+
+ See \l{Qt Style Sheets Examples#Customizing QLineEdit}{Customizing QLineEdit}
+ for an example.
+
+ \row
+ \li QListView \target qlistview-widget
+ \li Supports the \l{box model}. When
+ \l{QAbstractItemView::alternatingRowColors}{alternating row colors}
+ is enabled, the alternating colors can be styled using the
+ \l{#alternate-background-color-prop}{alternate-background-color}
+ property.
+
+ The color and background of the selected item is styled using
+ \l{#selection-color-prop}{selection-color} and
+ \l{#selection-background-color-prop}{selection-background-color}
+ respectively.
+
+ The selection behavior is controlled by the
+ \l{#show-decoration-selected-prop}{show-decoration-selected} property.
+
+ Use the \l{#item-sub}{::item} subcontrol for more fine grained
+ control over the items in the QListView.
+
+ See \l{qabstractscrollarea-widget}{QAbsractScrollArea} to
+ style scrollable backgrounds.
+
+ See \l{Qt Style Sheets Examples#Customizing QListView}
+ {Customzing QListView} for an example.
+
+ \row
+ \li QListWidget \target qlistwidget-widget
+ \li See \l{#qlistview-widget}{QListView}.
+
+ \row
+ \li QMainWindow \target qmainwindow-widget
+ \li Supports styling of the separator
+
+ The separator in a QMainWindow when using QDockWidget is styled
+ using the \l{#separator-sub}{::separator} subcontrol.
+
+ See \l{Qt Style Sheets Examples#Customizing QMainWindow}{Customizing QMainWindow}
+ for an example.
+
+ \row
+ \li QMenu \target qmenu-widget
+ \li Supports the \l{box model}.
+
+ Individual items are styled using the \l{#item-sub}{::item}
+ subcontrol. In addition to the usually supported pseudo states,
+ \c{item} subcontrol supports the
+ \l{#selected-ps}{:selected}, \l{#default-ps}{:default},
+ \l{#exclusive-ps}{:exclusive} and the
+ \l{#non-exclusive-ps}{non-exclusive} pseudo states.
+
+ The indicator of checkable menu items is styled using the
+ \l{#indicator-sub}{::indicator} subcontrol.
+
+ The separator is styled using the \l{#separator-sub}{::separator}
+ subcontrol.
+
+ For items with a sub menu, the arrow marks are styled using the
+ \l{right-arrow-sub}{right-arrow} and
+ \l{left-arrow-sub}{left-arrow}.
+
+ The scroller is styled using the \l{#scroller-sub}{::scroller}.
+
+ The tear-off is styled using the \l{#tearoff-sub}{::tearoff}.
+
+ See \l{Qt Style Sheets Examples#Customizing QMenu}{Customizing QMenu}
+ for an example.
+
+ \row
+ \li QMenuBar \target qmenubar-widget
+ \li Supports the \l{box model}. The \l{#spacing-prop}{spacing}
+ property specifies the spacing between menu items.
+ Individual items are styled using the \l{#item-sub}{::item}
+ subcontrol.
+
+ \warning When running on Qt/Mac, the menu bar is usually embedded into the
+ system-wide menu bar. In this case, the style sheet will have no effect.
+
+ See \l{Qt Style Sheets Examples#Customizing QMenuBar}{Customizing QMenuBar}
+ for an example.
+
+ \row
+ \li QMessageBox \target qmessagebox-widget
+ \li The \l{#messagebox-text-interaction-flags-prop}
+ {messagebox-text-interaction-flags} property can be used to alter
+ the interaction with text in the message box.
+
+ \row
+ \li QProgressBar \target qprogressbar-widget
+ \li Supports the \l{box model}. The chunks of the progress bar
+ can be styled using the \l{#chunk-sub}{::chunk} subcontrol.
+ The chunk is displayed on the Contents rectangle of the widget.
+
+ If the progress bar displays text, use the \l{text-align-prop}{text-align}
+ property to position the text.
+
+ Indeterminate progress bars have the
+ \l{#indeterminate-ps}{:indeterminate} pseudo state set.
+
+ See \l{Qt Style Sheets Examples#Customizing QProgressBar}{Customizing QProgressBar}
+ for an example.
+
+ \row
+ \li QPushButton \target qpushbutton-widget
+ \li Supports the \l{box model}. Supports the \l{#default-ps}{:default},
+ \l{#flat-ps}{:flat}, \l{#checked-ps}{:checked} pseudo states.
+
+ For QPushButton with a menu, the menu indicator is styled
+ using the \l{#menu-indicator-sub}{::menu-indicator}
+ subcontrol. Appearance of checkable push buttons can be
+ customized using the \l{#open-ps}{:open} and
+ \l{#closed-ps}{:closed} pseudo-states.
+
+ \warning If you only set a background-color on a QPushButton, the background
+ may not appear unless you set the border property to some value. This is
+ because, by default, the QPushButton draws a native border which completely
+ overlaps the background-color. For example,
+
+ \snippet code/doc_src_stylesheet.qdoc 30
+
+ See \l{Qt Style Sheets Examples#Customizing QPushButton}{Customizing QPushButton}
+ for an example.
+
+ \row
+ \li QRadioButton \target qradiobutton-widget
+ \li Supports the \l{box model}. The check indicator can be
+ styled using the \l{#indicator-sub}{::indicator}
+ subcontrol. By default, the indicator is placed in the Top
+ Left corner of the Contents rectangle of the widget.
+
+ The \l{#spacing-prop}{spacing} property
+ specifies the spacing between the check indicator and
+ the text.
+
+ See \l{Qt Style Sheets Examples#Customizing QRadioButton}
+ {Customizing QRadioButton} for an example.
+
+ \row
+ \li QScrollBar \target qscrollbar-widget
+ \li Supports the \l{box model}. The Contents rectangle of the widget
+ is considered to be the groove over which the slider moves. The extent
+ of the QScrollBar (i.e the width or the height depending on the orientation)
+ is set using the \l{#width-prop}{width} or \l{#height-prop}{height} property
+ respectively. To determine the orientation, use the
+ \l{#horizontal-ps}{:horizontal} and the \l{vertical-ps}{:vertical}
+ pseudo states.
+
+ The slider can be styled using the \l{#handle-sub}{::handle} subcontrol.
+ Setting the \l{#min-width-prop}{min-width} or \l{#min-height-prop}{min-height}
+ provides size contraints for the slider depending on the orientation.
+
+ The \l{add-line-sub}{::add-line} subcontrol can be used to style the
+ button to add a line. By default, the add-line subcontrol is placed in
+ top right corner of the Border rectangle of the widget. Depending on the
+ orientation the \l{#right-arrow-sub}{::right-arrow} or
+ \l{#down-arrow-sub}{::down-arrow}. By default, the arrows are placed in
+ the center of the Contents rectangle of the add-line subcontrol.
+
+ The \l{sub-line-sub}{::sub-line} subcontrol can be used to style the
+ button to subtract a line. By default, the sub-line subcontrol is placed in
+ bottom right corner of the Border rectangle of the widget. Depending on the
+ orientation the \l{#left-arrow-sub}{::left-arrow} or
+ \l{#up-arrow-sub}{::up-arrow}. By default, the arrows are placed in
+ the center of the Contents rectangle of the sub-line subcontrol.
+
+ The \l{sub-page-sub}{::sub-page} subcontrol can be used to style the
+ region of the slider that subtracts a page. The \l{add-page-sub}{::add-page}
+ subcontrol can be used to style the region of the slider that adds a page.
+
+ See \l{Qt Style Sheets Examples#Customizing QScrollBar}{Customizing QScrollBar}
+ for an example.
+
+ \row
+ \li QSizeGrip \target qsizegrip-widget
+ \li Supports the \l{#width-prop}{width},
+ \l{#height-prop}{height}, and \l{#image-prop}{image}
+ properties.
+
+ See \l{Qt Style Sheets Examples#Customizing QSizeGrip}{Customizing QSizeGrip}
+ for an example.
+
+ \row
+ \li QSlider \target qslider-widget
+ \li Supports the \l{box model}. For horizontal slides, the
+ \l{min-width-prop}{min-width} and \l{height-prop}{height}
+ properties must be provided. For vertical sliders, the
+ \l{min-height-prop}{min-height} and \l{width-prop}{width}
+ properties must be provided.
+
+ The groove of the slider is styled
+ using the \l{#groove-sub}{::groove}. The groove is
+ positioned by default in the Contents rectangle of the widget.
+ The thumb of the slider is styled using \l{#handle-sub}{::handle}
+ subcontrol. The subcontrol moves in the Contents rectangle of
+ the groove subcontrol.
+
+ See \l{Qt Style Sheets Examples#Customizing QSlider}{Customizing QSlider}
+ for an example.
+
+ \row
+ \li QSpinBox \target qspinbox-widget
+ \li The frame of the spin box can be styled using the \l{box
+ model}.
+
+ The up button and arrow can be styled using the
+ \l{#up-button-sub}{::up-button} and
+ \l{#up-arrow-sub}{::up-arrow} subcontrols. By default,
+ the up-button is placed in the top right corner in the
+ Padding rectangle of the widget. Without an explicit size,
+ it occupies half the height of its reference rectangle.
+ The up-arrow is placed in the center of the Contents
+ rectangle of the up-button.
+
+ The down button and arrow can be styled using the
+ \l{#down-button-sub}{::down-button} and
+ \l{#down-arrow-sub}{::down-arrow} subcontrols. By default,
+ the down-button is placed in the bottom right corner in the
+ Padding rectangle of the widget. Without an explicit size,
+ it occupies half the height of its reference rectangle.
+ The bottom-arrow is placed in the center of the Contents
+ rectangle of the bottom-button.
+
+ See \l{Qt Style Sheets Examples#Customizing QSpinBox}{Customizing QSpinBox}
+ for an example.
+
+ \row
+ \li QSplitter \target qsplitter-widget
+ \li Supports the \l{box model}. The handle of the splitter
+ is styled using the \l{#handle-sub}{::handle} subcontrol.
+
+ See \l{Qt Style Sheets Examples#Customizing QSplitter}{Customizing QSplitter}
+ for an example.
+
+ \row
+ \li QStatusBar \target qstatusbar-widget
+ \li Supports only the \l{Qt Style Sheets Reference#background-prop}
+ {background} property.
+ The frame for individual items can be style using the
+ \l{#item-sub}{::item} subcontrol.
+
+ See \l{Qt Style Sheets Examples#Customizing QStatusBar}{Customizing QStatusBar}
+ for an example.
+
+ \row
+ \li QTabBar \target qtabbar-widget
+ \li Individual tabs may be styled using the \l{#tab-sub}{::tab} subcontrol.
+ Close buttons using the \l{#close-button-sub}{::close-button}
+ The tabs support the
+ \l{#only-one-ps}{:only-one}, \l{#first-ps}{:first},
+ \l{#last-ps}{:last}, \l{#middle-ps}{:middle},
+ \l{#previous-selected-ps}{:previous--selected},
+ \l{#next-selected-ps}{:next-selected},
+ \l{#selected-ps}{:selected} pseudo states.
+
+ The \l{#top-ps}{:top}, \l{#left-ps}{:left}, \l{#right-ps}{:right},
+ \l{#bottom-ps}{:bottom} pseudo states depending on the orientation
+ of the tabs.
+
+ Overlapping tabs for the selected state are created by using
+ negative margins or using the \c{absolute} position scheme.
+
+ The tear indicator of the QTabBar is styled using the
+ \l{#tear-sub}{::tear} subcontrol.
+
+ QTabBar used two QToolButtons for its scrollers that can be styled
+ using the \c{QTabBar QToolButton} selector. To specify the width
+ of the scroll button use the \l{#scroller-sub}{::scroller}
+ subcontrol.
+
+ The alignment of the tabs within the QTabBar is styled
+ using the \l{#Alignment}{alignment} property. \warning
+
+ To change the position of the QTabBar within a QTabWidget, use the
+ \l{#tab-bar-sub}{tab-bar} subcontrol (and set subcontrol-position).
+
+ See \l{Qt Style Sheets Examples#Customizing QTabWidget and QTabBar}{Customizing QTabBar}
+ for an example.
+
+ \row
+ \li QTabWidget \target qtabwidget-widget
+ \li The frame of the tab widget is styled using the
+ \l{#pane-sub}{::pane} subcontrol. The left and right
+ corners are styled using the \l{#left-corner-sub}{::left-corner}
+ and \l{#right-corner-sub}{::right-corner} respectively.
+ The position of the tab bar is controlled using the
+ \l{#tab-bar-sub}{::tab-bar} subcontrol.
+
+ By default, the subcontrols have positions of a QTabWidget in
+ the QWindowsStyle. To place the QTabBar in the center, set the
+ subcontrol-position of the tab-bar subcontrol.
+
+ The \l{#top-ps}{:top}, \l{#left-ps}{:left}, \l{#right-ps}{:right},
+ \l{#bottom-ps}{:bottom} pseudo states depending on the orientation
+ of the tabs.
+
+ See \l{Qt Style Sheets Examples#Customizing QTabWidget and QTabBar}
+ {Customizing QTabWidget} for an example.
+
+ \row
+ \li QTableView \target qtableview-widget
+ \li Supports the \l{box model}. When
+ \l{QAbstractItemView::alternatingRowColors}{alternating row colors}
+ is enabled, the alternating colors can be styled using the
+ \l{#alternate-background-color-prop}{alternate-background-color}
+ property.
+
+ The color and background of the selected item is styled using
+ \l{#selection-color-prop}{selection-color} and
+ \l{#selection-background-color-prop}{selection-background-color}
+ respectively.
+
+ The corner widget in a QTableView is implemented as a QAbstractButton
+ and can be styled using the "QTableView QTableCornerButton::section"
+ selector.
+
+ \warning If you only set a background-color on a QTableCornerButton,
+ the background may not appear unless you set the border property to
+ some value. This is because, by default, the QTableCornerButton draws a
+ native border which completely overlaps the background-color.
+
+ The color of the grid can be specified using the
+ \l{#gridline-color-prop}{gridline-color} property.
+
+ See \l{qabstractscrollarea-widget}{QAbsractScrollArea} to
+ style scrollable backgrounds.
+
+ See \l{Qt Style Sheets Examples#Customizing QTableView}
+ {Customzing QTableView} for an example.
+
+ \row
+ \li QTableWidget \target qtablewidget-widget
+ \li See \l{#qtableview-widget}{QTableView}.
+
+ \row
+ \li QTextEdit \target qtextedit-widget
+ \li Supports the \l{box model}.
+
+ The color and background of selected text is styled using
+ \l{#selection-color-prop}{selection-color} and
+ \l{#selection-background-color-prop}{selection-background-color}
+ respectively.
+
+ See \l{qabstractscrollarea-widget}{QAbsractScrollArea} to
+ style scrollable backgrounds.
+
+ \row
+ \li QTimeEdit \target qtimeedit-widget
+ \li See \l{#qspinbox-widget}{QSpinBox}.
+
+ \row
+ \li QToolBar \target qtoolbar-widget
+ \li Supports the \l{box model}.
+
+ The \l{#top-ps}{:top}, \l{#left-ps}{:left}, \l{#right-ps}{:right},
+ \l{#bottom-ps}{:bottom} pseudo states depending on the area in
+ which the tool bar is grouped.
+
+ The \l{#first-ps}{:first}, \l{#last-ps}{:last}, \l{#middle-ps}{:middle},
+ \l{#only-one-ps}{:only-one} pseudo states indicator the position
+ of the tool bar within a line group (See
+ QStyleOptionToolBar::positionWithinLine).
+
+ The separator of a QToolBar is styled using the
+ \l{#separator-sub}{::separator} subcontrol.
+
+ The handle (to move the toolbar) is styled using the
+ \l{#handle-sub}{::handle} subcontrol.
+
+ See \l{Qt Style Sheets Examples#Customizing QToolBar}{Customizing QToolBar}
+ for an example.
+
+ \row
+ \li QToolButton \target qtoolbutton-widget
+ \li Supports the \l{box model}.
+
+ If the QToolButton has a menu, is
+ \l{#menu-indicator-sub}{::menu-indicator} subcontrol can be used to
+ style the indicator. By default, the menu-indicator is positioned
+ at the bottom right of the Padding rectangle of the widget.
+
+ If the QToolButton is in QToolButton::MenuButtonPopup mode,
+ the \l{#menu-button-sub}{::menu-button} subcontrol is used to draw the
+ menu button. \l{#menu-arrow-sub}{::menu-arrow} subcontrol is used to
+ draw the menu arrow inside the menu-button. By default, it is
+ positioned in the center of the Contents rectangle of the
+ menu-button subcontrol.
+
+ When the QToolButton displays arrows, the \l{#up-arrow-sub}{::up-arrow},
+ \l{#down-arrow-sub}{::down-arrow}, \l{#left-arrow-sub}{::left-arrow}
+ and \l{#right-arrow-sub}{::right-arrow} subcontrols are used.
+
+ \warning If you only set a background-color on a QToolButton, the background
+ will not appear unless you set the border property to some value. This is
+ because, by default, the QToolButton draws a native border which completely
+ overlaps the background-color. For example,
+
+ \snippet code/doc_src_stylesheet.qdoc 31
+
+ See \l{Qt Style Sheets Examples#Customizing QToolButton}{Customizing QToolButton}
+ for an example.
+
+ \row
+ \li QToolBox \target qtoolbox-widget
+ \li Supports the \l{box model}.
+
+ The individual tabs can by styled using the
+ \l{#tab-sub}{::tab} subcontrol. The tabs support the
+ \l{#only-one-ps}{:only-one}, \l{#first-ps}{:first},
+ \l{#last-ps}{:last}, \l{#middle-ps}{:middle},
+ \l{#previous-selected-ps}{:previous-selected},
+ \l{#next-selected-ps}{:next-selected},
+ \l{#selected-ps}{:selected} pseudo states.
+
+ \row
+ \li QToolTip \target qtooltip-widget
+ \li Supports the \l{box model}. The \l{#opacity-prop}{opacity}
+ property controls the opacity of the tooltip.
+
+ See \l{Qt Style Sheets Examples#Customizing QFrame}{Customizing QFrame}
+ for an example (a QToolTip is a QFrame).
+
+ \row
+ \li QTreeView \target qtreeview-widget
+ \li Supports the \l{box model}. When
+ \l{QAbstractItemView::alternatingRowColors}{alternating row colors}
+ is enabled, the alternating colors can be styled using the
+ \l{#alternate-background-color-prop}{alternate-background-color}
+ property.
+
+ The color and background of the selected item is styled using
+ \l{#selection-color-prop}{selection-color} and
+ \l{#selection-background-color-prop}{selection-background-color}
+ respectively.
+
+ The selection behavior is controlled by the
+ \l{#show-decoration-selected-prop}{show-decoration-selected} property.
+
+ The branches of the tree view can be styled using the
+ \l{#branch-sub}{::branch} subcontrol. The
+ ::branch Sub-control supports the \l{open-ps}{:open},
+ \l{closed-ps}{:closed}, \l{has-siblings-ps}{:has-sibling} and
+ \l{has-children-ps}{:has-children} pseudo states.
+
+ Use the \l{#item-sub}{::item} subcontrol for more fine grained
+ control over the items in the QTreeView.
+
+ See \l{qabstractscrollarea-widget}{QAbsractScrollArea} to
+ style scrollable backgrounds.
+
+ See \l{Qt Style Sheets Examples#Customizing QTreeView}{Customizing QTreeView}
+ for an example to style the branches.
+
+ \row
+ \li QTreeWidget \target qtreewidget-widget
+ \li See \l{#qtreeview-widget}{QTreeView}.
+
+ \row
+ \li QWidget \target qwidget-widget
+ \li Supports only the \l{Qt Style Sheets Reference#background-prop}{background},
+ \l{#background-clip-prop}{background-clip} and
+ \l{#background-origin-prop}{background-origin} properties.
+
+ If you subclass from QWidget, you need to provide a paintEvent for your
+ custom QWidget as below:
+ \snippet code/doc_src_stylesheet.cpp 32
+
+ The above code is a no-operation if there is no stylesheet set.
+
+ \warning Make sure you define the Q_OBJECT macro for your custom
+ widget.
+
+ \endtable
+
+ \section1 List of Properties
+
+ The table below lists all the properties supported by Qt Style
+ Sheets. Which values can be given to an property depend on the
+ \l{List of Property Types}{property's type}. Unless otherwise
+ specified, properties below apply to all widgets. Properties
+ marked with an asterisk * are specific to Qt and have no equivalent
+ in CSS2 or CSS3.
+
+ \table 100%
+ \header
+ \li Property
+ \li Type
+ \li Description
+
+ \row
+ \li \b{\c alternate-background-color} \target alternate-background-color-prop
+ \li \l{#Brush}{Brush} \BR
+ \li The \l{QAbstractItemView::alternatingRowColors}
+ {alternate background color} used in QAbstractItemView subclasses.
+
+ If this property is not set, the default value is
+ whatever is set for the palette's
+ \l{QPalette::}{AlternateBase} role.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 33
+
+ See also \l{Qt Style Sheets Reference#background-prop}{background} and
+ \l{#selection-background-color-prop}{selection-background-color}.
+
+ \row
+ \li \b{\c background} \target background-prop
+ \li \l{#Background}{Background}
+ \li Shorthand notation for setting the background. Equivalent
+ to specifying \c background-color, \c background-image, \c
+ background-repeat, and/or \c background-position.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QDialog, QFrame, QGroupBox, QLabel, QLineEdit,
+ QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter,
+ QTextEdit, QToolTip, and plain \l{QWidget}s.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 34
+
+
+ Often, it is required to set a fill pattern similar to the styles
+ in Qt::BrushStyle. You can use the background-color property for
+ Qt::SolidPattern, Qt::RadialGradientPattern, Qt::LinearGradientPattern
+ and Qt::ConicalGradientPattern. The other patterns are easily achieved
+ by creating a background image that contains the pattern.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 35
+
+ See also \l{#background-origin-prop}{background-origin},
+ \l{#selection-background-color-prop}{selection-background-color},
+ \l{#background-clip-prop}{background-clip},
+ \l{#background-attachment-prop}{background-attachment}
+ and \l{#alternate-background-color-prop}{alternate-background-color}.
+
+ \row
+ \li \c background-color \target background-color-prop
+ \li \l{#Brush}{Brush} \BR
+ \li The background color used for the widget.
+
+ Examples:
+
+ \snippet code/doc_src_stylesheet.qdoc 36
+
+ \row
+ \li \c background-image \target background-image-prop
+ \li \l{#Url}{Url}
+ \li The background image used for the widget. Semi-transparent
+ parts of the image let the \c background-color shine
+ through.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 37
+
+ \row
+ \li \c background-repeat \target background-repeat-prop
+ \li \l{#Repeat}{Repeat}
+ \li Whether and how the background image is repeated to fill
+ the \c background-origin rectangle.
+
+ If this property is not specified, the background image
+ is repeated in both directions (\c repeat).
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 38
+
+ \row
+ \li \c background-position
+ \li \l{#Alignment}{Alignment}
+ \li The alignment of the background image within the \c
+ background-origin rectangle.
+
+ If this property is not specified, the alignment is \c
+ top \c left.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 39
+
+ \row
+ \li \b{\c background-attachment} \target background-attachment-prop
+ \li \l{#Attachment}{Attachment}
+ \li Determines whether the background-image in a QAbstractScrollArea
+ is scrolled or fixed with respect to the viewport.
+ By default, the background-image scrolls with the viewport.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 40
+
+ See also \l{Qt Style Sheets Reference#background-prop}{background}
+
+ \row
+ \li \b{\c background-clip} \target background-clip-prop
+ \li \l{#Origin}{Origin}
+ \li The widget's rectangle, in which the \c background is drawn.
+
+ This property specifies the rectangle to which the \c background-color
+ and \c background-image are clipped.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QDialog, QFrame, QGroupBox, QLabel,
+ QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip,
+ and plain \l{QWidget}s.
+
+ If this property is not specified, the default is \c
+ border.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 41
+
+ See also \l{Qt Style Sheets Reference#background-prop}{background},
+ \l{#background-origin-prop}{background-origin} and \l{The Box Model}.
+
+ \row
+ \li \b{\c background-origin} \target background-origin-prop
+ \li \l{#Origin}{Origin}
+ \li The widget's background rectangle, to use in conjunction
+ with \c background-position and \c background-image.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QDialog, QFrame, QGroupBox, QLabel,
+ QPushButton, QRadioButton, QSplitter, QTextEdit, QToolTip,
+ and plain \l{QWidget}s.
+
+ If this property is not specified, the default is \c
+ padding.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 42
+
+ See also \l{Qt Style Sheets Reference#background-prop}{background} and
+ \l{The Box Model}.
+
+ \row
+ \li \b{\c border} \target border-prop
+ \li \l{#Border}{Border}
+ \li Shorthand notation for setting the widget's border. Equivalent
+ to specifying \c border-color, \c border-style, and/or
+ \c border-width.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QFrame, QGroupBox, QLabel, QLineEdit,
+ QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter,
+ QTextEdit, QToolTip, and plain \l{QWidget}s.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 43
+
+ \row
+ \li \c border-top
+ \li \l{#Border}{Border}
+ \li Shorthand notation for setting the widget's top border.
+ Equivalent to specifying \c border-top-color, \c
+ border-top-style, and/or \c border-top-width.
+
+ \row
+ \li \c border-right
+ \li \l{#Border}{Border}
+ \li Shorthand notation for setting the widget's right border.
+ Equivalent to specifying \c border-right-color, \c
+ border-right-style, and/or \c border-right-width.
+
+ \row
+ \li \c border-bottom
+ \li \l{#Border}{Border}
+ \li Shorthand notation for setting the widget's bottom border.
+ Equivalent to specifying \c border-bottom-color, \c
+ border-bottom-style, and/or \c border-bottom-width.
+
+ \row
+ \li \c border-left
+ \li \l{#Border}{Border}
+ \li Shorthand notation for setting the widget's left border.
+ Equivalent to specifying \c border-left-color, \c
+ border-left-style, and/or \c border-left-width.
+
+ \row
+ \li \b{\c border-color} \target border-attrs
+ \target border-color-prop
+ \li \l{#Box Colors}{Box Colors}
+ \li The color of all the border's edges. Equivalent to
+ specifying \c border-top-color, \c border-right-color, \c
+ border-bottom-color, and \c border-left-color.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QFrame, QGroupBox, QLabel, QLineEdit,
+ QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter,
+ QTextEdit, QToolTip, and plain \l{QWidget}s.
+
+ If this property is not specified, it defaults to
+ \l{#color-prop}{color} (i.e., the widget's foreground
+ color).
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 44
+
+ See also \l{Qt Style Sheets Reference#border-style-prop}{border-style},
+ \l{Qt Style Sheets Reference#border-width-prop}{border-width},
+ \l{#border-image-prop}{border-image}, and \l{The Box Model}.
+
+ \row
+ \li \c border-top-color
+ \li \l{#Brush}{Brush} \BR
+ \li The color of the border's top edge.
+
+ \row
+ \li \c border-right-color
+ \li \l{#Brush}{Brush} \BR
+ \li The color of the border's right edge.
+
+ \row
+ \li \c border-bottom-color
+ \li \l{#Brush}{Brush} \BR
+ \li The color of the border's bottom edge.
+
+ \row
+ \li \c border-left-color
+ \li \l{#Brush}{Brush} \BR
+ \li The color of the border's left edge.
+
+ \row
+ \li \b{\c border-image} \target border-image-prop
+ \li \l{#Border Image}{Border Image}
+ \li The image used to fill the border. The image is cut into
+ nine parts and stretched appropriately if necessary. See
+ \l{#Border Image}{Border Image} for details.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QFrame, QGroupBox, QLabel, QLineEdit,
+ QMenu, QMenuBar, QPushButton, QRadioButton, QSplitter,
+ QTextEdit and QToolTip.
+
+ See also \l{#border-color-prop}{border-color},
+ \l{Qt Style Sheets Reference#border-style-prop}{border-style},
+ \l{Qt Style Sheets Reference#border-width-prop}{border-width}, and
+ \l{The Box Model}.
+
+ \row
+ \li \b{\c border-radius} \target border-radius-prop
+ \li \l{#Radius}{Radius}
+ \li The radius of the border's corners. Equivalent to
+ specifying \c border-top-left-radius, \c
+ border-top-right-radius, \c border-bottom-right-radius,
+ and \c border-bottom-left-radius.
+
+ The border-radius clips the element's
+ \l{Qt Style Sheets Reference#background-prop}{background}.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
+ QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit,
+ and QToolTip.
+
+ If this property is not specified, it defaults to 0.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 45
+
+ See also \l{Qt Style Sheets Reference#border-width-prop}{border-width} and
+ \l{The Box Model}.
+
+ \row
+ \li \c border-top-left-radius
+ \li \l{#Radius}{Radius}
+ \li The radius of the border's top-left corner.
+
+ \row
+ \li \c border-top-right-radius
+ \li \l{#Radius}{Radius}
+ \li The radius of the border's top-right corner.
+
+ \row
+ \li \c border-bottom-right-radius
+ \li \l{#Radius}{Radius}
+ \li The radius of the border's bottom-right corner. Setting
+ this property to a positive value results in a rounded
+ corner.
+
+ \row
+ \li \c border-bottom-left-radius
+ \li \l{#Radius}{Radius}
+ \li The radius of the border's bottom-left corner. Setting this
+ property to a positive value results in a rounded corner.
+
+ \row
+ \li \b{\c border-style} \target border-style-prop
+ \li \l {Border Style}
+ \li The style of all the border's edges.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
+ QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit,
+ and QToolTip.
+
+ If this property is not specified, it defaults to \c none.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 46
+
+ See also \l{#border-color-prop}{border-color},
+ \l{Qt Style Sheets Reference#border-style-prop}{border-style},
+ \l{#border-image-prop}{border-image}, and \l{The Box Model}.
+
+ \row
+ \li \c border-top-style
+ \li \l{#Border Style}{Border Style}
+ \li The style of the border's top edge.
+
+ \row
+ \li \c border-right-style
+ \li \l{#Border Style}{Border Style}
+ \li The style of the border's right edge/
+
+ \row
+ \li \c border-bottom-style
+ \li \l{#Border Style}{Border Style}
+ \li The style of the border's bottom edge.
+
+ \row
+ \li \c border-left-style
+ \li \l{#Border Style}{Border Style}
+ \li The style of the border's left edge.
+
+ \row
+ \li \b{\c border-width} \target border-width-prop
+ \li \l{#Box Lengths}{Box Lengths}
+ \li The width of the border. Equivalent to setting \c
+ border-top-width, \c border-right-width, \c
+ border-bottom-width, and \c border-left-width.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
+ QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit,
+ and QToolTip.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 47
+
+ See also \l{#border-color-prop}{border-color},
+ \l{#border-radius-prop}{border-radius},
+ \l{Qt Style Sheets Reference#border-style-prop}{border-style},
+ \l{#border-image-prop}{border-image}, and
+ \l{The Box Model}.
+
+ \row
+ \li \c border-top-width
+ \li \l{#Length}{Length}
+ \li The width of the border's top edge.
+
+ \row
+ \li \c border-right-width
+ \li \l{#Length}{Length}
+ \li The width of the border's right edge.
+
+ \row
+ \li \c border-bottom-width
+ \li \l{#Length}{Length}
+ \li The width of the border's bottom edge.
+
+ \row
+ \li \c border-left-width
+ \li \l{#Length}{Length}
+ \li The width of the border's left edge.
+
+ \row
+ \li \b{\c bottom} \target bottom-prop
+ \li \l{#Length}{Length}
+ \li If \l{#position-prop}{position} is \c relative (the
+ default), moves a \l{subcontrol} by a certain offset up;
+ specifying \tt{bottom: \e{y}} is then equivalent to
+ specifying \tt{\l{Qt Style Sheets Reference#top-prop}{top}: -\e{y}}.
+
+ If \l{#position-prop}{position} is \c absolute, the \c
+ bottom property specifies the subcontrol's bottom edge
+ in relation to the parent's bottom edge (see also
+ \l{Qt Style Sheets Reference#subcontrol-origin-prop}
+ {subcontrol-origin}).
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 48
+
+ See also \l{Qt Style Sheets Reference#left-prop}{left}, \l{#right-prop}{right}, and
+ \l{Qt Style Sheets Reference#top-prop}{top}.
+
+ \row
+ \li \b{\c button-layout} \target button-layout-prop
+ \li \l{#Number}{Number}
+ \li The layout of buttons in a QDialogButtonBox or
+ a QMessageBox. The possible values are 0
+ (\l{QDialogButtonBox::}{WinLayout}), 1
+ (\l{QDialogButtonBox::}{MacLayout}), 2
+ (\l{QDialogButtonBox::}{KdeLayout}), and 3
+ (\l{QDialogButtonBox::}{GnomeLayout}).
+
+ If this property is not specified, it defaults to the
+ value specified by the current style for the
+ \l{QStyle::}{SH_DialogButtonLayout} style hint.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 49
+
+ \row
+ \li \b{\c color} \target color-prop
+ \li \l{#Brush}{Brush} \BR
+ \li The color used to render text.
+
+ This property is supported by all widgets that respect
+ the \l QWidget::palette.
+
+ If this property is not set, the default is whatever is
+ set for in the widget's palette for the
+ QWidget::foregroundRole (typically black).
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 50
+
+ See also \l{Qt Style Sheets Reference#background-prop}{background} and
+ \l{#selection-color-prop}{selection-color}.
+
+ \row
+ \li \b{\c dialogbuttonbox-buttons-have-icons}
+ \li \l{#Boolean}{Boolean}
+ \li Whether the buttons in a QDialogButtonBox show icons
+
+ If this property is set to 1, the buttons of a QDialogButtonBox
+ show icons; if it is set to 0, the icons are not shown.
+
+ See the \l{Qt Style Sheets Reference#list of icons}{List of Icons}
+ section for information on how to set icons.
+
+ \snippet code/doc_src_stylesheet.qdoc 51
+
+ \note Styles defining this property must be applied before the
+ QDialogButtonBox is created; this means that you must apply the
+ style to the parent widget or to the application itself.
+
+ \omit
+ \row
+ \li \b{\c etch-disabled-text}*
+ \li \l{#Boolean}{Boolean}
+ \li Whether disabled text is drawn etched.
+
+ If this property is not specified, it defaults to the
+ value specified by the current style for the
+ \l{QStyle::}{SH_EtchDisabledText} style hint.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 52
+ \endomit
+
+ \row
+ \li \b{\c font} \target font-prop
+ \li \l{#Font}{Font}
+ \li Shorthand notation for setting the text's font. Equivalent
+ to specifying \c font-family, \c font-size, \c font-style,
+ and/or \c font-weight.
+
+ This property is supported by all widgets that respect
+ the \l QWidget::font.
+
+ If this property is not set, the default is the
+ QWidget::font.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 53
+
+ \row
+ \li \c font-family
+ \li String
+ \li The font family.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 54
+
+ \row
+ \li \c font-size
+ \li \l{#Font Size}{Font Size}
+ \li The font size. In this version of Qt, only pt and px metrics are
+ supported.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 55
+
+ \row
+ \li \c font-style
+ \li \l {Font Style}
+ \li The font style.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 56
+
+ \row
+ \li \c font-weight
+ \li \l{#Font Weight}{Font Weight}
+ \li The weight of the font.
+
+ \row
+ \li \b{\c gridline-color}* \target gridline-color-prop
+ \li \l{#Color}{Color} \BR
+ \li The color of the grid line in a QTableView.
+
+ If this property is not specified, it defaults to the
+ value specified by the current style for the
+ \l{QStyle::}{SH_Table_GridLineColor} style hint.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 57
+
+ \row
+ \li \b{\c height} \target height-prop
+ \li \l{#Length}{Length}
+ \li The height of a \l{subcontrol} (or in some case, a widget).
+
+ If this property is not specified, it defaults to a value
+ that depends on the subcontrol/widget and on the current style.
+
+ \warning Unless otherwise specified, this property has no effect
+ when set on widgets. If you want a widget with a fixed height, set
+ the \l{#min-width-prop}{min-height} and
+ \l{#max-width-prop}{max-height} to the same value.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 58
+
+ See also \l{#width-prop}{width}.
+
+ \row
+ \li \b{\c icon-size} \target icon-size-prop
+ \li \l{#Length}{Length}
+ \li The width and height of the icon in a widget.
+
+ The icon size of the following widgets can be set using this
+ property.
+ \list
+ \li QCheckBox
+ \li QListView
+ \li QPushButton
+ \li QRadioButton
+ \li QTabBar
+ \li QToolBar
+ \li QToolBox
+ \li QTreeView
+ \endlist
+
+ \row
+ \li \b{\c image}* \target image-prop
+ \li \l{#Url}{Url}+
+ \li The image that is drawn in the contents rectangle of a
+ \l{subcontrol}.
+
+ The image property accepts a list of \l{#Url}{Url}s or
+ an \c{svg}. The actual image that is drawn is determined
+ using the same algorithm as QIcon (i.e) the image is never scaled
+ up but always scaled down if necessary. If a \c{svg} is specified,
+ the image is scaled to the size of the contents rectangle.
+
+ Setting the image property on sub controls implicitly sets the
+ width and height of the sub-control (unless the image in a SVG).
+
+ In Qt 4.3 and later, the alignment of the
+ image within the rectangle can be specified using
+ \l{image-position-prop}{image-position}.
+
+ This property is for \l{subcontrol}s only--we don't support it for
+ other elements.
+
+ \warning The QIcon SVG plugin is needed to render SVG images.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 59
+
+ \row
+ \li \b{\c image-position} \target image-position-prop
+ \li \l{#Alignment}{alignment}
+ \li In Qt 4.3 and later, the alignment of the image image's position can be specified
+ using relative or absolute position.
+
+ \row
+ \li \b{\c left} \target left-prop
+ \li \l{#Length}{Length}
+ \li If \l{#position-prop}{position} is \c relative (the
+ default), moves a \l{subcontrol} by a certain offset to
+ the right.
+
+ If \l{#position-prop}{position} is \c absolute, the \c
+ left property specifies the subcontrol's left edge in
+ relation to the parent's left edge (see also
+ \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}).
+
+ If this property is not specified, it defaults to \c 0.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 60
+
+ See also \l{#right-prop}{right}, \l{Qt Style Sheets Reference#top-prop}{top}, and
+ \l{#bottom-prop}{bottom}.
+
+ \row
+ \li \b{\c lineedit-password-character*} \target lineedit-password-character-prop
+ \li \l{#Number}{Number}
+ \li The QLineEdit password character as a Unicode number.
+
+ If this property is not specified, it defaults to the
+ value specified by the current style for the
+ \l{QStyle::}{SH_LineEdit_PasswordCharacter} style hint.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 61
+
+ \row
+ \li \b{\c margin} \target margin-prop
+ \li \l {Box Lengths}
+ \li The widget's margins. Equivalent to specifying \c
+ margin-top, \c margin-right, \c margin-bottom, and \c
+ margin-left.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
+ QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit,
+ and QToolTip.
+
+ If this property is not specified, it defaults to \c 0.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 62
+
+ See also \l{Qt Style Sheets Reference#padding-prop}{padding},
+ \l{#spacing-prop}{spacing}, and \l{The Box Model}.
+
+ \row
+ \li \c margin-top
+ \li \l{#Length}{Length}
+ \li The widget's top margin.
+
+ \row
+ \li \c margin-right
+ \li \l{#Length}{Length}
+ \li The widget's right margin.
+
+ \row
+ \li \c margin-bottom
+ \li \l{#Length}{Length}
+ \li The widget's bottom margin.
+
+ \row
+ \li \c margin-left
+ \li \l{#Length}{Length}
+ \li The widget's left margin.
+
+ \row
+ \li \b{\c max-height} \target max-height-prop
+ \li \l{#Length}{Length}
+ \li The widget's or a subcontrol's maximum height.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
+ QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox,
+ QSplitter, QStatusBar, QTextEdit, and QToolTip.
+
+ The value is relative to the contents rect in the \l{The
+ Box Model}{box model}.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 63
+
+ See also \l{#max-width-prop}{max-width}.
+
+ \row
+ \li \b{\c max-width} \target max-width-prop
+ \li \l{#Length}{Length}
+ \li The widget's or a subcontrol's maximum width.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
+ QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox,
+ QSplitter, QStatusBar, QTextEdit, and QToolTip.
+
+ The value is relative to the contents rect in the \l{The
+ Box Model}{box model}.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 64
+
+ See also \l{#max-height-prop}{max-height}.
+
+
+ \row
+ \li \b{\c messagebox-text-interaction-flags*} \target messagebox-text-interaction-flags-prop
+ \li \l{#Number}{Number}
+ \li The interaction behavior for text in a message box.
+ Possible values are based on Qt::TextInteractionFlags.
+
+ If this property is not specified, it defaults to the
+ value specified by the current style for the
+ \l{QStyle::}{SH_MessageBox_TextInteractionFlags} style
+ hint.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 65
+
+ \row
+ \li \b{\c min-height} \target min-height-prop
+ \li \l{#Length}{Length}
+ \li The widget's or a subcontrol's minimum height.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
+ QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox,
+ QSplitter, QStatusBar, QTextEdit, and QToolTip.
+
+ If this property is not specified, the minimum height is
+ derived based on the widget's contents and the style.
+
+ The value is relative to the contents rect in the \l{The
+ Box Model}{box model}.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 66
+
+ See also \l{#min-width-prop}{min-width}.
+
+ \row
+ \li \b{\c min-width} \target min-width-prop
+ \li \l{#Length}{Length}
+ \li The widget's or a subcontrol's minimum width.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
+ QMenuBar, QPushButton, QRadioButton, QSizeGrip, QSpinBox,
+ QSplitter, QStatusBar, QTextEdit, and QToolTip.
+
+ If this property is not specified, the minimum width is
+ derived based on the widget's contents and the style.
+
+ The value is relative to the contents rect in the \l{The
+ Box Model}{box model}.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 67
+
+ See also \l{#min-height-prop}{min-height}.
+
+ \row
+ \li \b{\c opacity*} \target opacity-prop
+ \li \l{#Number}{Number}
+ \li The opacity for a widget. Possible values are from 0
+ (transparent) to 255 (opaque). For the moment, this is
+ only supported for \l{QToolTip}{tooltips}.
+
+ If this property is not specified, it defaults to the
+ value specified by the current style for the
+ \l{QStyle::}{SH_ToolTipLabel_Opacity} style hint.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 68
+
+ \row
+ \li \b{\c padding} \target padding-prop
+ \li \l{#Box Lengths}{Box Lengths}
+ \li The widget's padding. Equivalent to specifying \c
+ padding-top, \c padding-right, \c padding-bottom, and \c
+ padding-left.
+
+ This property is supported by QAbstractItemView
+ subclasses, QAbstractSpinBox subclasses, QCheckBox,
+ QComboBox, QFrame, QGroupBox, QLabel, QLineEdit, QMenu,
+ QMenuBar, QPushButton, QRadioButton, QSplitter, QTextEdit,
+ and QToolTip.
+
+ If this property is not specified, it defaults to \c 0.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 69
+
+ See also \l{#margin-prop}{margin},
+ \l{#spacing-prop}{spacing}, and \l{The Box Model}.
+
+ \row
+ \li \c padding-top
+ \li \l{#Length}{Length}
+ \li The widget's top padding.
+
+ \row
+ \li \c padding-right
+ \li \l{#Length}{Length}
+ \li The widget's right padding.
+
+ \row
+ \li \c padding-bottom
+ \li \l{#Length}{Length}
+ \li The widget's bottom padding.
+
+ \row
+ \li \c padding-left
+ \li \l{#Length}{Length}
+ \li The widget's left padding.
+
+ \row
+ \li \b{\c paint-alternating-row-colors-for-empty-area}
+ \target paint-alternating-row-colors-for-empty-area-prop
+ \li \c bool
+ \li Whether the QTreeView paints alternating row colors for the empty
+ area (i.e the area where there are no items)
+
+ \row
+ \li \b{\c position} \target position-prop
+ \li \c relative \BR
+ | \c absolute
+ \li Whether offsets specified using \l{Qt Style Sheets Reference#left-prop}{left},
+ \l{#right-prop}{right}, \l{Qt Style Sheets Reference#top-prop}{top}, and
+ \l{#bottom-prop}{bottom} are relative or absolute
+ coordinates.
+
+ If this property is not specified, it defaults to \c
+ relative.
+
+ \row
+ \li \b{\c right} \target right-prop
+ \li \l{#Length}{Length}
+ \li If \l{#position-prop}{position} is \c relative (the
+ default), moves a \l{subcontrol} by a certain offset to
+ the left; specifying \tt{right: \e{x}} is then equivalent
+ to specifying \tt{\l{Qt Style Sheets Reference#left-prop}{left}: -\e{x}}.
+
+ If \l{#position-prop}{position} is \c absolute, the \c
+ right property specifies the subcontrol's right edge in
+ relation to the parent's right edge (see also
+ \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}).
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 70
+
+ See also \l{Qt Style Sheets Reference#left-prop}{left}, \l{Qt Style Sheets Reference#top-prop}{top}, and
+ \l{#bottom-prop}{bottom}.
+
+ \row
+ \li \b{\c selection-background-color*} \target selection-background-color-prop
+ \li \l{#Brush}{Brush} \BR
+ \li The background of selected text or items.
+
+ This property is supported by all widgets that respect
+ the \l QWidget::palette and that show selection text.
+
+ If this property is not set, the default value is
+ whatever is set for the palette's
+ \l{QPalette::}{Highlight} role.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 71
+
+ See also \l{#selection-color-prop}{selection-color} and
+ \l{Qt Style Sheets Reference#background-prop}{background}.
+
+ \row
+ \li \b{\c selection-color*} \target selection-color-prop
+ \li \l{#Brush}{Brush} \BR
+ \li The foreground of selected text or items.
+
+ This property is supported by all widgets that respect
+ the \l QWidget::palette and that show selection text.
+
+ If this property is not set, the default value is
+ whatever is set for the palette's
+ \l{QPalette::}{HighlightedText} role.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 72
+
+ See also
+ \l{#selection-background-color-prop}{selection-background-color}
+ and \l{#color-prop}{color}.
+
+ \row
+ \li \b{\c show-decoration-selected*} \target show-decoration-selected-prop
+ \li \l{#Boolean}{Boolean}
+ \li Controls whether selections in a QListView cover the
+ entire row or just the extent of the text.
+
+ If this property is not specified, it defaults to the
+ value specified by the current style for the
+ \l{QStyle::}{SH_ItemView_ShowDecorationSelected} style
+ hint.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 73
+
+ \row
+ \li \b{\c spacing*} \target spacing-prop
+ \li \l{#Length}{Length}
+ \li Internal spacing in the widget.
+
+ This property is supported by QCheckBox, checkable
+ \l{QGroupBox}es, QMenuBar, and QRadioButton.
+
+ If this property is not specified, the default value
+ depends on the widget and on the current style.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 74
+
+ See also \l{Qt Style Sheets Reference#padding-prop}{padding} and
+ \l{#margin-prop}{margin}.
+
+ \row
+ \li \b{\c subcontrol-origin*} \target subcontrol-origin-prop
+ \li \l{#Origin}{Origin}
+ \li The origin rectangle of the \l subcontrol within the
+ parent element.
+
+ If this property is not specified, the default is \c
+ padding.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 75
+
+ See also
+ \l{Qt Style Sheets Reference#subcontrol-position-prop}{subcontrol-position}.
+
+ \row
+ \li \b{\c subcontrol-position*} \target subcontrol-position-prop
+ \li \l{#Alignment}{Alignment}
+ \li The alignment of the \l subcontrol within the origin
+ rectangle specified by \l{Qt Style Sheets Reference#subcontrol-origin-prop}
+ {subcontrol-origin}.
+
+ If this property is not specified, it defaults to a value
+ that depends on the subcontrol.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 76
+
+ See also
+ \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}.
+
+ \row
+ \li \b{\c text-align} \target text-align-prop
+ \li \l{#Alignment}{Alignment}
+ \li The alignment of text and icon within the contents of the widget.
+
+ If this value is not specified, it defaults to the value
+ that depends on the native style.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 77
+
+ This property is currently supported only by QPushButton
+ and QProgressBar.
+
+ \row
+ \li \b{\c text-decoration}
+ \li \c none \BR
+ \c underline \BR
+ \c overline \BR
+ \c line-through
+ \li Additional text effects
+
+ \row
+ \li \b{\c top} \target top-prop
+ \li \l{#Length}{Length}
+ \li If \l{#position-prop}{position} is \c relative (the
+ default), moves a \l{subcontrol} by a certain offset
+ down.
+
+ If \l{#position-prop}{position} is \c absolute, the \c top
+ property specifies the subcontrol's top edge in relation
+ to the parent's top edge (see also
+ \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}).
+
+ If this property is not specified, it defaults to \c 0.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 78
+
+ See also \l{Qt Style Sheets Reference#left-prop}{left}, \l{#right-prop}{right}, and
+ \l{#bottom-prop}{bottom}.
+
+ \row
+ \li \b{\c width} \target width-prop
+ \li \l{#Length}{Length}
+ \li The width of a \l{subcontrol} (or a widget in some cases).
+
+ If this property is not specified, it defaults to a value
+ that depends on the subcontrol/widget and on the current style.
+
+ \warning Unless otherwise specified, this property has no effect
+ when set on widgets. If you want a widget with a fixed width, set
+ the \l{#min-width-prop}{min-width} and
+ \l{#max-width-prop}{max-width} to the same value.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 79
+
+ See also \l{#height-prop}{height}.
+
+ \endtable
+
+ \target list of icons
+ \section1 List of Icons
+
+ Icons used in Qt can be customized using the following properties. Each of
+ the properties listed in this section have the type \l{#Icon}{Icon}.
+
+ Note that for icons to appear in buttons in a QDialogButtonBox, you need to
+ set the dialogbuttonbox-buttons-have-icons property to true. Also, to
+ customize the size of the icons, use the icon-size property.
+
+ \table 100%
+ \header
+ \li Name
+ \li QStyle::StandardPixmap
+
+ \row
+ \li backward-icon
+ \li QStyle::SP_ArrowBack
+
+ \row
+ \li cd-icon
+ \li QStyle::SP_DriveCDIcon
+
+ \row
+ \li computer-icon
+ \li QStyle::SP_ComputerIcon
+
+ \row
+ \li desktop-icon
+ \li QStyle::SP_DesktopIcon
+
+ \row
+ \li dialog-apply-icon
+ \li QStyle::SP_DialogApplyButton
+
+ \row
+ \li dialog-cancel-icon
+ \li QStyle::SP_DialogCancelButton
+
+ \row
+ \li dialog-close-icon
+ \li QStyle::SP_DialogCloseButton
+
+ \row
+ \li dialog-discard-icon
+ \li QStyle::SP_DialogDiscardButton
+
+ \row
+ \li dialog-help-icon
+ \li QStyle::SP_DialogHelpButton
+
+ \row
+ \li dialog-no-icon
+ \li QStyle::SP_DialogNoButton
+
+ \row
+ \li dialog-ok-icon
+ \li QStyle::SP_DialogOkButton
+
+ \row
+ \li dialog-open-icon
+ \li QStyle::SP_DialogOpenButton
+
+ \row
+ \li dialog-reset-icon
+ \li QStyle::SP_DialogResetButton
+
+ \row
+ \li dialog-save-icon
+ \li QStyle::SP_DialogSaveButton
+
+ \row
+ \li dialog-yes-icon
+ \li QStyle::SP_DialogYesButton
+
+ \row
+ \li directory-closed-icon
+ \li QStyle::SP_DirClosedIcon
+
+ \row
+ \li directory-icon
+ \li QStyle::SP_DirIcon
+
+ \row
+ \li directory-link-icon
+ \li QStyle::SP_DirLinkIcon
+
+ \row
+ \li directory-open-icon
+ \li QStyle::SP_DirOpenIcon
+
+ \row
+ \li dockwidget-close-icon
+ \li QStyle::SP_DockWidgetCloseButton
+
+ \row
+ \li downarrow-icon
+ \li QStyle::SP_ArrowDown
+
+ \row
+ \li dvd-icon
+ \li QStyle::SP_DriveDVDIcon
+
+ \row
+ \li file-icon
+ \li QStyle::SP_FileIcon
+
+ \row
+ \li file-link-icon
+ \li QStyle::SP_FileLinkIcon
+
+ \omit
+ \row
+ \li filedialog-backward-icon
+ \li QStyle::SP_FileDialogBack
+ \endomit
+
+ \row
+ \li filedialog-contentsview-icon
+ \li QStyle::SP_FileDialogContentsView
+
+ \row
+ \li filedialog-detailedview-icon
+ \li QStyle::SP_FileDialogDetailedView
+
+ \row
+ \li filedialog-end-icon
+ \li QStyle::SP_FileDialogEnd
+
+ \row
+ \li filedialog-infoview-icon
+ \li QStyle::SP_FileDialogInfoView
+
+ \row
+ \li filedialog-listview-icon
+ \li QStyle::SP_FileDialogListView
+
+ \row
+ \li filedialog-new-directory-icon
+ \li QStyle::SP_FileDialogNewFolder
+
+ \row
+ \li filedialog-parent-directory-icon
+ \li QStyle::SP_FileDialogToParent
+
+ \row
+ \li filedialog-start-icon
+ \li QStyle::SP_FileDialogStart
+
+ \row
+ \li floppy-icon
+ \li QStyle::SP_DriveFDIcon
+
+ \row
+ \li forward-icon
+ \li QStyle::SP_ArrowForward
+
+ \row
+ \li harddisk-icon
+ \li QStyle::SP_DriveHDIcon
+
+ \row
+ \li home-icon
+ \li QStyle::SP_DirHomeIcon
+
+ \row
+ \li leftarrow-icon
+ \li QStyle::SP_ArrowLeft
+
+ \row
+ \li messagebox-critical-icon
+ \li QStyle::SP_MessageBoxCritical
+
+ \row
+ \li messagebox-information-icon
+ \li QStyle::SP_MessageBoxInformation
+
+ \row
+ \li messagebox-question-icon
+ \li QStyle::SP_MessageBoxQuestion
+
+ \row
+ \li messagebox-warning-icon
+ \li QStyle::SP_MessageBoxWarning
+
+ \row
+ \li network-icon
+ \li QStyle::SP_DriveNetIcon
+
+ \row
+ \li rightarrow-icon
+ \li QStyle::SP_ArrowRight
+
+ \row
+ \li titlebar-contexthelp-icon
+ \li QStyle::SP_TitleBarContextHelpButton
+
+ \row
+ \li titlebar-maximize-icon
+ \li QStyle::SP_TitleBarMaxButton
+
+ \row
+ \li titlebar-menu-icon
+ \li QStyle::SP_TitleBarMenuButton
+
+ \row
+ \li titlebar-minimize-icon
+ \li QStyle::SP_TitleBarMinButton
+
+ \row
+ \li titlebar-normal-icon
+ \li QStyle::SP_TitleBarNormalButton
+
+ \row
+ \li titlebar-shade-icon
+ \li QStyle::SP_TitleBarShadeButton
+
+ \row
+ \li titlebar-unshade-icon
+ \li QStyle::SP_TitleBarUnshadeButton
+
+ \row
+ \li trash-icon
+ \li QStyle::SP_TrashIcon
+
+ \row
+ \li uparrow-icon
+ \li QStyle::SP_ArrowUp
+
+ \endtable
+
+ \section1 List of Property Types
+
+ The following table summarizes the syntax and meaning of the
+ different property types.
+
+ \table 100%
+ \header
+ \li Type
+ \li Syntax
+ \li Description
+
+ \row
+ \li \b Alignment \target Alignment
+ \li \{ \c top \BR
+ | \c bottom \BR
+ | \c left \BR
+ | \c right \BR
+ | \c center \}*
+ \li Horizontal and/or vertical alignment.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 80
+
+ \row
+ \li \b Attachment \target Attachment
+ \li \{ \c scroll \BR
+ | \c fixed \}*
+ \li Scroll or fixed attachment.
+
+ \row
+ \li \b Background \target Background
+ \li \{ \l{#Brush}{Brush} \BR
+ | \l{#Url}{Url} \BR
+ | \l{#Repeat}{Repeat} \BR
+ | \l{#Alignment}{Alignment} \}*
+ \li A sequence of \l{#Brush}{Brush}, \l{#Url}{Url},
+ \l{#Repeat}{Repeat}, and \l{#Alignment}{Alignment}.
+
+ \row
+ \li \b Boolean \target Boolean
+ \li 0 | 1
+ \li True (\c 1) or false (\c 0).
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 81
+
+ \row
+ \li \b Border \target Border
+ \li \{ \l{#Border Style}{Border Style} \BR
+ | \l{#Length}{Length} \BR
+ | \l{#Brush}{Brush} \}*
+ \li Shorthand border property.
+
+ \row
+ \li \b{Border Image} \target Border Image
+ \li \c none \BR
+ | \l{Url} \l{Number}\{4\} \BR (\c stretch | \c repeat){0,2}
+ \li A border image is an image that is composed of nine parts
+ (top left, top center, top right, center left, center,
+ center right, bottom left, bottom center, and bottom
+ right). When a border of a certain size is required, the
+ corner parts are used as is, and the top, right, bottom,
+ and left parts are stretched or repeated to produce a
+ border with the desired size.
+
+ See the
+ \l{http://www.w3.org/TR/css3-background/#the-border-image}
+ {CSS3 Draft Specification} for details.
+
+ \row
+ \li \b{Border Style} \target Border Style
+ \li \c dashed \BR
+ | \c dot-dash \BR
+ | \c dot-dot-dash \BR
+ | \c dotted \BR
+ | \c double \BR
+ | \c groove \BR
+ | \c inset \BR
+ | \c outset \BR
+ | \c ridge \BR
+ | \c solid \BR
+ | \c none
+ \li Specifies the pattern used to draw a border.
+ See the \l{http://www.w3.org/TR/css3-background/#border-style}
+ {CSS3 Draft Specification} for details.
+
+ \row
+ \li \b{Box Colors} \target Box Colors
+ \li \l{#Brush}{Brush}\{1,4\}
+ \li One to four occurrences of \l{#Brush}{Brush}, specifying the top,
+ right, bottom, and left edges of a box, respectively. If
+ the left color is not specified, it is taken to be the
+ same as the right color. If the bottom color is not
+ specified, it is taken to be the same as the top color. If
+ the right color is not specified, it is taken to be the
+ same as the top color.
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 82
+
+ \row
+ \li \b{Box Lengths} \target Box Lengths
+ \li \l{#Length}{Length}\{1,4\}
+ \li One to four occurrences of \l{#Length}{Length}, specifying the
+ top, right, bottom, and left edges of a box,
+ respectively. If the left length is not specified, it is
+ taken to be the same as the right length. If the bottom
+ length is not specified, is it taken to be the same as the
+ top length. If the right length is not specified, it is
+ taken to be the same as the top length.
+
+ Examples:
+
+ \snippet code/doc_src_stylesheet.qdoc 83
+
+ \row
+ \li \b{Brush} \target Brush
+ \li \l{#Color}{Color} \BR
+ | \l{Gradient} \BR
+ | \l{PaletteRole}
+ \li Specifies a Color or a Gradient or an entry in the Palette.
+
+ \row
+ \li \b{Color} \target Color
+ \li \tt{rgb(\e{r}, \e{g}, \e{b})} \BR
+ | \tt{rgba(\e{r}, \e{g}, \e{b}, \e{a})} \BR
+ | \tt{hsv(\e{h}, \e{s}, \e{v})} \BR
+ | \tt{hsva(\e{h}, \e{s}, \e{v}, \e{a})} \BR
+ | \tt{#\e{rrggbb}} \BR
+ | \l{QColor::setNamedColor()}{Color Name} \BR
+ \li Specifies a color as RGB (red, green, blue) or RGBA
+ (red, green, blue, alpha) or HSV (hue, saturation, value) or HSVA
+ (hue, saturation, value, alpha) or a named color. The \c rgb() or \c rgba()
+ syntax can be used with integer values between 0 and 255, or with
+ percentages. The value of s, v, and a in \c hsv() or \c hsva() must all
+ be in the range 0-255; the value of h must be in the range 0-359.
+
+ Examples:
+
+ \snippet code/doc_src_stylesheet.qdoc 84
+
+ \note The RGB colors allowed are the same as those allowed with
+ CSS 2.1, as listed
+ \l{http://www.w3.org/TR/CSS21/syndata.html#color-units}{here}.
+
+ \row
+ \li \b{Font} \target Font
+ \li (\l{#Font Style}{Font Style} | \l{#Font Weight}{Font Weight}){0,2} \l{#Font Size}{Font Size} String
+ \li Shorthand font property.
+
+ \row
+ \li \b{Font Size} \target Font Size
+ \li \l{Length}
+ \li The size of a font.
+
+ \row
+ \li \b{Font Style} \target Font Style
+ \li \c normal \BR
+ | \c italic \BR
+ | \c oblique
+ \li The style of a font.
+
+ \row
+ \li \b{Font Weight} \target Font Weight
+ \li \c normal \BR
+ | \c bold \BR
+ | \c 100 \BR
+ | \c 200 \BR
+ ... \BR
+ | \c 900
+ \li The weight of a font.
+
+ \row
+ \li \b{Gradient} \target Gradient
+ \li \c qlineargradient \BR
+ | \c qradialgradient \BR
+ | \c qconicalgradient
+ \li Specifies gradient fills. There are three types of gradient fills:
+
+ \list
+ \li \e{Linear} gradients interpolate colors between start and
+ end points.
+ \li \e{Radial} gradients interpolate colors between a focal
+ point and end points on a circle surrounding it.
+ \li \e{Conical} gradients interpolate colors around a center
+ point.
+ \endlist
+
+ Gradients are specified in Object Bounding Mode. Imagine the box
+ in which the gradient is rendered, to have its top left corner at (0, 0)
+ and its bottom right corner at (1, 1). Gradient parameters are
+ then specified as percentages from 0 to 1. These values are
+ extrapolated to actual box coordinates at runtime. It is possible
+ specify values that lie outside the bounding box (-0.6 or 1.8, for
+ instance).
+
+ \warning The stops have to appear sorted in ascending order.
+
+ Examples:
+
+ \snippet code/doc_src_stylesheet.qdoc 85
+
+ \row
+ \li \b{Icon} \target Icon
+ \li (\l{#Url}{Url} (\c disabled | \c active | \c normal | \c selected)?
+ (\c on | \c off)? )*
+ \li A list of url, QIcon::Mode and QIcon::State.
+
+ Example:
+ \snippet code/doc_src_stylesheet.qdoc 86
+
+ \row
+ \li \b{Length} \target Length
+ \li \l{#Number}{Number} (\c px | \c pt | \c em | \c ex)?
+ \li A number followed by a measurement unit. The CSS standard recommends
+ that user agents must
+ \l{http://www.w3.org/TR/CSS21/syndata.html#illegalvalues}{ignore}
+ a declaration with an illegal value. In Qt, it is mandatory to
+ specify measurement units. For compatibility with earlier versions
+ of Qt, numbers without measurement units are treated as pixels
+ in most contexts. The supported units are:
+
+ \list
+ \li \c px: pixels
+ \li \c pt: the size of one point (i.e., 1/72 of an inch)
+ \li \c em: the em width of the font (i.e., the width of 'M')
+ \li \c ex: the ex width of the font (i.e., the height of 'x')
+ \endlist
+
+ \row
+ \li \b{Number} \target Number
+ \li A decimal integer or a real number
+ \li Examples: \c 0, \c 18, \c +127, \c -255, \c 12.34, \c -.5,
+ \c 0009.
+
+ \row
+ \li \b{Origin} \target Origin
+ \li \c margin \BR
+ | \c border \BR
+ | \c padding \BR
+ | \c content
+ \li Indicates which of four rectangles to use.
+
+ \list
+ \li \c margin: The margin rectangle. The margin falls outside the border.
+ \li \c border: The border rectangle. This is where any border is drawn.
+ \li \c padding: The padding rectangle. Unlike the margins,
+ padding is located inside the border.
+ \li \c content: The content rectangle. This specifies where
+ the actual contents go, excluding any
+ padding, border, or margin.
+ \endlist
+
+ See also \l{The Box Model}.
+
+ \row
+ \li \b{PaletteRole} \target PaletteRole
+ \li \c alternate-base \BR
+ | \c base \BR
+ | \c bright-text \BR
+ | \c button \BR
+ | \c button-text \BR
+ | \c dark \BR
+ | \c highlight \BR
+ | \c highlighted-text \BR
+ | \c light \BR
+ | \c link \BR
+ | \c link-visited \BR
+ | \c mid \BR
+ | \c midlight \BR
+ | \c shadow \BR
+ | \c text \BR
+ | \c window \BR
+ | \c window-text \BR
+ \li These values correspond the \l{QPalette::ColorRole}{Color roles}
+ in the widget's QPalette.
+
+ For example,
+ \snippet code/doc_src_stylesheet.qdoc 87
+
+ \row
+ \li \b{Radius} \target Radius
+ \li \l{#Length}{Length}\{1, 2\}
+ \li One or two occurrences of \l{#Length}{Length}. If only one length is
+ specified, it is used as the radius of the quarter circle
+ defining the corner. If two lengths are specified, the
+ first length is the horizontal radius of a quarter
+ ellipse, whereas the second length is the vertical radius.
+
+ \row
+ \li \b{Repeat} \target Repeat
+ \li \c repeat-x \BR
+ | \c repeat-y \BR
+ | \c repeat \BR
+ | \c no-repeat
+ \li A value indicating the nature of repetition.
+
+ \list
+ \li \c repeat-x: Repeat horizontally.
+ \li \c repeat-y: Repeat vertically.
+ \li \c repeat: Repeat horizontally and vertically.
+ \li \c no-repeat: Don't repeat.
+ \endlist
+
+ \row
+ \li \b{Url} \target Url
+ \li \tt{url(\e{filename})}
+ \li \tt{\e{filename}} is the name of a file on the local disk
+ or stored using \l{the Qt Resource System}. Setting an
+ image implicitly sets the width and height of the element.
+
+ \endtable
+
+ \section1 List of Pseudo-States
+
+ The following pseudo-states are supported:
+
+ \table 100%
+ \header
+ \li Pseudo-State
+ \li Description
+
+ \row \li \c :active \target active
+ \li This state is set when the widget resides in an active window.
+
+ \row
+ \li \c :adjoins-item \target adjoins-item-ps
+ \li This state is set when the \l{#branch-sub}{::branch} of a QTreeView
+ is adjacent to an item.
+
+ \row
+ \li \c :alternate \target alternate-ps
+ \li This state is set for every alternate row whe painting the row of
+ a QAbstractItemView when QAbstractItemView::alternatingRowColors()
+ is set to true.
+
+ \row
+ \li \c :bottom \target bottom-ps
+ \li The item is positioned at the bottom. For example, a QTabBar
+ that has its tabs positioned at the bottom.
+
+ \row
+ \li \c :checked \target checked-ps
+ \li The item is checked. For example, the
+ \l{QAbstractButton::checked}{checked} state of QAbstractButton.
+
+ \row
+ \li \c :closable \target closable-ps
+ \li The items can be closed. For example, the QDockWidget has the
+ QDockWidget::DockWidgetClosable feature turned on.
+
+ \row
+ \li \c :closed \target closed-ps
+ \li The item is in the closed state. For example, an non-expanded
+ item in a QTreeView
+
+ \row
+ \li \c :default \target default-ps
+ \li The item is the default. For example, a
+ \l{QPushButton::default}{default} QPushButton or a default action
+ in a QMenu.
+
+ \row
+ \li \c :disabled \target disabled-ps
+ \li The item is \l{QWidget::enabled}{disabled}.
+
+ \row
+ \li \c :editable \target editable-ps
+ \li The QComboBox is editable.
+
+ \row
+ \li \c :edit-focus \target edit-focus-ps
+ \li The item has edit focus (See QStyle::State_HasEditFocus). This state
+ is available only for Qt Extended applications.
+
+ \row
+ \li \c :enabled \target enabled-ps
+ \li The item is \l{QWidget::enabled}{enabled}.
+
+ \row
+ \li \c :exclusive \target exclusive-ps
+ \li The item is part of an exclusive item group. For example, a menu
+ item in a exclusive QActionGroup.
+
+ \row
+ \li \c :first \target first-ps
+ \li The item is the first (in a list). For example, the first
+ tab in a QTabBar.
+
+ \row
+ \li \c :flat \target flat-ps
+ \li The item is flat. For example, a
+ \l{QPushButton::flat}{flat} QPushButton.
+
+ \row
+ \li \c :floatable \target floatable-ps
+ \li The items can be floated. For example, the QDockWidget has the
+ QDockWidget::DockWidgetFloatable feature turned on.
+
+ \row
+ \li \c :focus \target focus-ps
+ \li The item has \l{QWidget::hasFocus()}{input focus}.
+
+ \row
+ \li \c :has-children \target has-children-ps
+ \li The item has children. For example, an item in a
+ QTreeView that has child items.
+
+ \row
+ \li \c :has-siblings \target has-siblings-ps
+ \li The item has siblings. For example, an item in a
+ QTreeView that siblings.
+
+ \row
+ \li \c :horizontal \target horizontal-ps
+ \li The item has horizontal orientation
+
+ \row
+ \li \c :hover \target hover-ps
+ \li The mouse is hovering over the item.
+
+ \row
+ \li \c :indeterminate \target indeterminate-ps
+ \li The item has indeterminate state. For example, a QCheckBox
+ or QRadioButton is \l{Qt::PartiallyChecked}{partially checked}.
+
+ \row
+ \li \c :last \target last-ps
+ \li The item is the last (in a list). For example, the last
+ tab in a QTabBar.
+
+ \row
+ \li \c :left \target left-ps
+ \li The item is positioned at the left. For example, a QTabBar
+ that has its tabs positioned at the left.
+
+ \row
+ \li \c :maximized \target maximized-ps
+ \li The item is maximized. For example, a maximized QMdiSubWindow.
+
+ \row
+ \li \c :middle \target middle-ps
+ \li The item is in the middle (in a list). For example, a tab
+ that is not in the beginning or the end in a QTabBar.
+
+ \row
+ \li \c :minimized \target minimized-ps
+ \li The item is minimized. For example, a minimized QMdiSubWindow.
+
+ \row
+ \li \c :movable \target movable-ps
+ \li The item can be moved around. For example, the QDockWidget has the
+ QDockWidget::DockWidgetMovable feature turned on.
+
+ \row
+ \li \c :no-frame \target no-frame-ps
+ \li The item has no frame. For example, a frameless QSpinBox
+ or QLineEdit.
+
+ \row
+ \li \c :non-exclusive \target non-exclusive-ps
+ \li The item is part of a non-exclusive item group. For example, a menu
+ item in a non-exclusive QActionGroup.
+
+ \row
+ \li \c :off \target off-ps
+ \li For items that can be toggled, this applies to items
+ in the "off" state.
+
+ \row
+ \li \c :on \target on-ps
+ \li For items that can be toggled, this applies to widgets
+ in the "on" state.
+
+ \row
+ \li \c :only-one \target only-one-ps
+ \li The item is the only one (in a list). For example, a lone tab
+ in a QTabBar.
+
+ \row
+ \li \c :open \target open-ps
+ \li The item is in the open state. For example, an expanded
+ item in a QTreeView, or a QComboBox or QPushButton with
+ an open menu.
+
+ \row
+ \li \c :next-selected \target next-selected-ps
+ \li The next item (in a list) is selected. For example, the
+ selected tab of a QTabBar is next to this item.
+
+ \row
+ \li \c :pressed \target pressed-ps
+ \li The item is being pressed using the mouse.
+
+ \row
+ \li \c :previous-selected \target previous-selected-ps
+ \li The previous item (in a list) is selected. For example, a
+ tab in a QTabBar that is next to the selected tab.
+
+ \row
+ \li \c :read-only \target read-only-ps
+ \li The item is marked read only or non-editable. For example,
+ a read only QLineEdit or a non-editable QComboBox.
+
+ \row
+ \li \c :right \target right-ps
+ \li The item is positioned at the right. For example, a QTabBar
+ that has its tabs positioned at the right.
+
+ \row
+ \li \c :selected \target selected-ps
+ \li The item is selected. For example, the selected tab in
+ a QTabBar or the selected item in a QMenu.
+
+ \row
+ \li \c :top \target top-ps
+ \li The item is positioned at the top. For example, a QTabBar
+ that has its tabs positioned at the top.
+
+ \row
+ \li \c :unchecked \target unchecked-ps
+ \li The item is
+ \l{QAbstractButton::checked}{unchecked}.
+
+ \row
+ \li \c :vertical \target vertical-ps
+ \li The item has vertical orientation.
+
+ \row
+ \li \c :window \target window-ps
+ \li The widget is a window (i.e top level widget)
+
+ \endtable
+
+ \target subcontrols
+ \section1 List of Sub-Controls
+
+ The following subcontrols are available:
+
+ \table 100%
+ \header
+ \li Sub-Control
+ \li Description
+
+ \row
+ \li \c ::add-line \target add-line-sub
+ \li The button to add a line of a QScrollBar.
+
+ \row
+ \li \c ::add-page \target add-page-sub
+ \li The region between the handle (slider) and the \l{#add-line-sub}{add-line}
+ of a QScrollBar.
+
+ \row
+ \li \c ::branch \target branch-sub
+ \li The branch indicator of a QTreeView.
+
+ \row
+ \li \c ::chunk \target chunk-sub
+ \li The progress chunk of a QProgressBar.
+
+ \row
+ \li \c ::close-button \target close-button-sub
+ \li The close button of a QDockWidget or tabs of QTabBar
+
+ \row
+ \li \c ::corner \target corner-sub
+ \li The corner between two scrollbars in a QAbstractScrollArea
+
+ \row
+ \li \c ::down-arrow \target down-arrow-sub
+ \li The down arrow of a QComboBox, QHeaderView (sort indicator),
+ QScrollBar or QSpinBox.
+
+ \row
+ \li \c ::down-button \target down-button-sub
+ \li The down button of a QScrollBar or a QSpinBox.
+
+ \row
+ \li \c ::drop-down \target drop-down-sub
+ \li The drop-down button of a QComboBox.
+
+ \row
+ \li \c ::float-button \target float-button-sub
+ \li The float button of a QDockWidget
+
+ \row
+ \li \c ::groove \target groove-sub
+ \li The groove of a QSlider.
+
+ \row
+ \li \c ::indicator \target indicator-sub
+ \li The indicator of a QAbstractItemView, a QCheckBox, a QRadioButton,
+ a checkable QMenu item or a checkable QGroupBox.
+
+ \row
+ \li \c ::handle \target handle-sub
+ \li The handle (slider) of a QScrollBar, a QSplitter, or a QSlider.
+
+ \row
+ \li \c ::icon \target icon-sub
+ \li The icon of a QAbstractItemView or a QMenu.
+
+ \row
+ \li \c ::item \target item-sub
+ \li An item of a QAbstractItemView, a QMenuBar, a QMenu, or
+ a QStatusBar.
+
+ \row
+ \li \c ::left-arrow \target left-arrow-sub
+ \li The left arrow of a QScrollBar.
+
+ \row
+ \li \c ::left-corner \target left-corner-sub
+ \li The left corner of a QTabWidget. For example, this control can be
+ used to control position the left corner widget in a QTabWidget.
+
+ \row
+ \li \c ::menu-arrow \target menu-arrow-sub
+ \li The arrow of a QToolButton with a menu.
+
+ \row
+ \li \c ::menu-button \target menu-button-sub
+ \li The menu button of a QToolButton.
+
+ \row
+ \li \c ::menu-indicator \target menu-indicator-sub
+ \li The menu indicator of a QPushButton.
+
+ \row
+ \li \c ::right-arrow \target right-arrow-sub
+ \li The right arrow of a QMenu or a QScrollBar.
+
+ \row
+ \li \c ::pane \target pane-sub
+ \li The pane (frame) of a QTabWidget.
+
+ \row
+ \li \c ::right-corner \target right-corner-sub
+ \li The right corner of a QTabWidget. For example, this control can be
+ used to control the position the right corner widget in a QTabWidget.
+
+ \row
+ \li \c ::scroller \target scroller-sub
+ \li The scroller of a QMenu or QTabBar.
+
+ \row
+ \li \c ::section \target section-sub
+ \li The section of a QHeaderView.
+
+ \row
+ \li \c ::separator \target separator-sub
+ \li The separator of a QMenu or in a QMainWindow.
+
+ \row
+ \li \c ::sub-line \target sub-line-sub
+ \li The button to subtract a line of a QScrollBar.
+
+ \row
+ \li \c ::sub-page \target sub-page-sub
+ \li The region between the handle (slider) and the \l{#sub-line-sub}{sub-line}
+ of a QScrollBar.
+
+ \row
+ \li \c ::tab \target tab-sub
+ \li The tab of a QTabBar or QToolBox.
+
+ \row
+ \li \c ::tab-bar \target tab-bar-sub
+ \li The tab bar of a QTabWidget. This subcontrol exists only to
+ control the position of the QTabBar inside the QTabWidget. To
+ style the tabs using the \l{#tab-sub}{::tab} subcontrol.
+
+ \row
+ \li \c ::tear \target tear-sub
+ \li The tear indicator of a QTabBar.
+
+ \row
+ \li \c ::tearoff \target tearoff-sub
+ \li The tear-off indicator of a QMenu.
+
+ \row
+ \li \c ::text \target text-ps
+ \li The text of a QAbstractItemView.
+
+ \row
+ \li \c ::title \target title-sub
+ \li The title of a QGroupBox or a QDockWidget.
+
+ \row
+ \li \c ::up-arrow \target up-arrow-sub
+ \li The up arrow of a QHeaderView (sort indicator), QScrollBar
+ or a QSpinBox.
+
+ \row
+ \li \c ::up-button \target up-button-sub
+ \li The up button of a QSpinBox.
+
+ \endtable
+
+ See \l{Customizing the QPushButton's Menu Indicator Sub-Control}
+ for an example of how to customize a subcontrol.
+ */
+
+/*!
+ \page stylesheet-examples.html
+ \contentspage {Qt Style Sheet}{Contents}
+ \previouspage Qt Style Sheets Reference
+ \title Qt Style Sheets Examples
+
+ We will now see a few examples to get started with using Qt Style Sheets.
+
+ \tableofcontents
+ \section1 Style Sheet Usage
+
+ \section2 Customizing the Foreground and Background Colors
+
+ Let's start by setting yellow as the background color of all
+ \l{QLineEdit}s in an application. This could be achieved like
+ this:
+
+ \snippet code/doc_src_stylesheet.cpp 88
+
+ If we want the property to apply only to the \l{QLineEdit}s that are
+ children (or grandchildren or grand-grandchildren) of a specific dialog,
+ we would rather do this:
+
+ \snippet code/doc_src_stylesheet.cpp 89
+
+ If we want the property to apply only to one specific QLineEdit,
+ we can give it a name using QObject::setObjectName() and use an
+ ID Selector to refer to it:
+
+ \snippet code/doc_src_stylesheet.cpp 90
+
+ Alternatively, we can set the
+ \l{Qt Style Sheets Reference#background-prop}{background-color} property directly on the
+ QLineEdit, omitting the selector:
+
+ \snippet code/doc_src_stylesheet.cpp 91
+
+ To ensure a good contrast, we should also specify a suitable
+ color for the text:
+
+ \snippet code/doc_src_stylesheet.cpp 92
+
+ It might be a good idea to change the colors used for selected
+ text as well:
+
+ \snippet code/doc_src_stylesheet.cpp 93
+
+
+ \section2 Customizing Using Dynamic Properties
+
+ There are many situations where we need to present a form that
+ has mandatory fields. To indicate to the user that the field is
+ mandatory, one effective (albeit esthetically dubious) solution
+ is to use yellow as the background color for those fields. It
+ turns out this is very easy to implement using Qt Style Sheets.
+ First, we would use the following application-wide style sheet:
+
+ \snippet code/doc_src_stylesheet.qdoc 94
+
+ This means that every widget whose \c mandatoryField Qt property
+ is set to true would have a yellow background.
+
+ Then, for each mandatory field widget, we would simply create a
+ \c mandatoryField property on the fly and set it to true. For
+ example:
+
+ \snippet code/doc_src_stylesheet.cpp 95
+
+ \section2 Customizing a QPushButton Using the Box Model
+
+ This time, we will show how to create a red QPushButton. This
+ QPushButton would presumably be connected to a very destructive
+ piece of code.
+
+ First, we are tempted to use this style sheet:
+
+ \snippet code/doc_src_stylesheet.qdoc 96
+
+ However, the result is a boring, flat button with no borders:
+
+ \image stylesheet-redbutton1.png A flat red button
+
+ What happened is this:
+
+ \list
+ \li We have made a request that cannot be satisfied using the
+ native styles alone (e.g., the Windows XP theme engine doesn't
+ let us specify the background color of a button).
+ \li Therefore, the button is rendered using style sheets.
+ \li We haven't specified any values for
+ \l{Qt Style Sheets Reference#border-width-prop}{border-width} and
+ \l{Qt Style Sheets Reference#border-style-prop}{border-style}, so by default we obtain
+ a 0-pixel wide border of style \c none.
+ \endlist
+
+ Let's improve the situation by specifying a border:
+
+ \snippet code/doc_src_stylesheet.qdoc 97
+
+ \image stylesheet-redbutton2.png A red button with a beige border
+
+ Things look already a lot better. But the button looks a bit
+ cramped. Let's specify some spacing between the border and the
+ text using the \l{Qt Style Sheets Reference#padding-prop}{padding}. Additionally, we will
+ enforce a minimum width, round the corners, and specify a larger
+ font to make the button look nicer:
+
+ \snippet code/doc_src_stylesheet.qdoc 98
+
+ \image stylesheet-redbutton3.png A red button with a round beige border and big, bold text
+
+ The only issue remaining is that the button doesn't react when we
+ press it. We can fix this by specifying a slightly different
+ background color and use a different border style.
+
+ \snippet code/doc_src_stylesheet.qdoc 99
+
+ \section2 Customizing the QPushButton's Menu Indicator Sub-Control
+
+ Subcontrols give access to the sub-elements of a widget. For
+ example, a QPushButton associated with a menu (using
+ QPushButton::setMenu()) has a menu indicator. Let's customize
+ the menu indicator for the red push button:
+
+ \snippet code/doc_src_stylesheet.qdoc 100
+
+ By default, the menu indicator is located at the bottom-right
+ corner of the padding rectangle. We can change this by specifying
+ \l{Qt Style Sheets Reference#subcontrol-position-prop}{subcontrol-position} and
+ \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin} to anchor the
+ indicator differently. We can also use \l{Qt Style Sheets Reference#top-prop}{top} and
+ \l{Qt Style Sheets Reference#left-prop}{left} to move the indicator by a few pixels. For
+ example:
+
+ \snippet code/doc_src_stylesheet.qdoc 101
+
+ This positions the \c myindicator.png to the center right of the
+ QPushButton's \l{Qt Style Sheets Reference#padding-prop}{padding} rectangle (see
+ \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin} for more
+ information).
+
+ \section2 Complex Selector Example
+
+ Since red seems to be our favorite color, let's make the text in
+ QLineEdit red by setting the following application-wide
+ stylesheet:
+
+ \snippet code/doc_src_stylesheet.qdoc 102
+
+ However, we would like to give a visual indication that a
+ QLineEdit is read-only by making it appear gray:
+
+ \snippet code/doc_src_stylesheet.qdoc 103
+
+ At some point, our design team comes with the requirement that
+ all \l{QLineEdit}s in the registration form (with the
+ \l{QObject::objectName}{object name} \c registrationDialog) to be
+ brown:
+
+ \snippet code/doc_src_stylesheet.qdoc 104
+
+ A few UI design meetings later, we decide that all our
+ \l{QDialog}s should have brown colored \l{QLineEdit}s:
+
+ \snippet code/doc_src_stylesheet.qdoc 105
+
+ Quiz: What happens if we have a read-only QLineEdit in a QDialog?
+ [Hint: The \l{The Style Sheet Syntax#Conflict Resolution}{Conflict Resolution} section above explains
+ what happens in cases like this.]
+
+ \section1 Customizing specific widgets
+
+ This section provides examples to customize specific widgets using Style Sheets.
+
+ \section2 Customizing QAbstractScrollArea
+
+ The background of any QAbstractScrollArea (Item views, QTextEdit
+ and QTextBrowser) can be set using the background properties. For example,
+ to set a background-image that scrolls with the scroll bar:
+ \snippet code/doc_src_stylesheet.qdoc 106
+
+ If the background-image is to be fixed with the viewport:
+ \snippet code/doc_src_stylesheet.qdoc 107
+
+ \section2 Customizing QCheckBox
+
+ Styling of a QCheckBox is almost identical to styling a QRadioButton. The
+ main difference is that a tristate QCheckBox has an indeterminate state.
+
+ \snippet code/doc_src_stylesheet.qdoc 108
+
+ \section2 Customizing QComboBox
+
+ We will look at an example where the drop down button of a QComboBox
+ appears "merged" with the combo box frame.
+
+ \snippet code/doc_src_stylesheet.qdoc 109
+
+ The pop-up of the QComboBox is a QAbstractItemView and is styled using
+ the descendant selector:
+ \snippet code/doc_src_stylesheet.qdoc 110
+
+ \section2 Customizing QDockWidget
+
+ The title bar and the buttons of a QDockWidget can be customized as
+ follows:
+
+ \snippet code/doc_src_stylesheet.qdoc 111
+
+ If one desires to move the dock widget buttons to the left, the following
+ style sheet can be used:
+
+ \snippet code/doc_src_stylesheet.qdoc 112
+
+ \note To customize the separator (resize handle) of a QDockWidget,
+ use QMainWindow::separator.
+
+ \section2 Customizing QFrame
+
+ A QFrame is styled using the \l{The Box Model}.
+
+ \snippet code/doc_src_stylesheet.qdoc 113
+
+ \section2 Customizing QGroupBox
+
+ Let us look at an example that moves the QGroupBox's title to
+ the center.
+
+ \snippet code/doc_src_stylesheet.qdoc 114
+
+ For a checkable QGroupBox, use the \{#indicator-sub}{::indicator} subcontrol
+ and style it exactly like a QCheckBox (i.e)
+
+ \snippet code/doc_src_stylesheet.qdoc 115
+
+ \section2 Customizing QHeaderView
+
+ QHeaderView is customized as follows:
+
+ \snippet code/doc_src_stylesheet.qdoc 116
+
+ \section2 Customizing QLineEdit
+
+ The frame of a QLineEdit is styled using the \l{The Box Model}. To
+ create a line edit with rounded corners, we can set:
+ \snippet code/doc_src_stylesheet.qdoc 117
+
+ The password character of line edits that have QLineEdit::Password
+ echo mode can be set using:
+ \snippet code/doc_src_stylesheet.qdoc 118
+
+ The background of a read only QLineEdit can be modified as below:
+ \snippet code/doc_src_stylesheet.qdoc 119
+
+ \section2 Customizing QListView
+
+ The background color of alternating rows can be customized using the following
+ style sheet:
+
+ \snippet code/doc_src_stylesheet.qdoc 120
+
+ To provide a special background when you hover over items, we can use the
+ \l{item-sub}{::item} subcontrol. For example,
+
+ \snippet code/doc_src_stylesheet.qdoc 121
+
+ \section2 Customizing QMainWindow
+
+ The separator of a QMainWindow can be styled as follows:
+
+ \snippet code/doc_src_stylesheet.qdoc 122
+
+ \section2 Customizing QMenu
+
+ Individual items of a QMenu are styled using the 'item' subcontrol as
+ follows:
+
+ \snippet code/doc_src_stylesheet.qdoc 123
+
+ For a more advanced customization, use a style sheet as follows:
+
+ \snippet code/doc_src_stylesheet.qdoc 124
+
+ \section2 Customizing QMenuBar
+
+ QMenuBar is styled as follows:
+
+ \snippet code/doc_src_stylesheet.qdoc 125
+
+ \section2 Customizing QProgressBar
+
+ The QProgressBar's \l{stylesheet-reference.html#border-prop}{border},
+ \l{stylesheet-reference.html#chunk-sub}{chunk}, and
+ \l{stylesheet-reference.html#text-align-prop}{text-align} can be customized using
+ style sheets. However, if one property or sub-control is customized,
+ all the other properties or sub-controls must be customized as well.
+
+ \image progressBar-stylesheet.png
+
+ For example, we change the \l{stylesheet-reference.html#border-prop}
+ {border} to grey and the \l{stylesheet-reference.html#chunk-sub}{chunk}
+ to cerulean.
+
+ \snippet code/doc_src_stylesheet.qdoc 126
+
+ This leaves the \l{stylesheet-reference.html#text-align-prop}
+ {text-align}, which we customize by positioning the text in the center of
+ the progress bar.
+
+ \snippet code/doc_src_stylesheet.qdoc 127
+
+ A \l{stylesheet-reference.html#margin-prop}{margin} can be included to
+ obtain more visible chunks.
+
+ \image progressBar2-stylesheet.png
+
+ In the screenshot above, we use a
+ \l{stylesheet-reference.html#margin-prop}{margin} of 0.5 pixels.
+
+ \snippet code/doc_src_stylesheet.qdoc 128
+
+ \section2 Customizing QPushButton
+
+ A QPushButton is styled as follows:
+ \snippet code/doc_src_stylesheet.qdoc 129
+
+ For a QPushButton with a menu, use the
+ \l{Qt Style Sheets Reference#menu-indicator-sub}{::menu-indicator}
+ subcontrol.
+
+ \snippet code/doc_src_stylesheet.qdoc 130
+
+ Checkable QPushButton have the \l{Qt Style Sheets Reference#checked-ps}
+ {:checked} pseudo state set.
+
+ \section2 Customizing QRadioButton
+
+ The indicator of a QRadioButton can be changed using:
+ \snippet code/doc_src_stylesheet.qdoc 131
+
+ \section2 Customizing QScrollBar
+
+ The QScrollBar can be styled using its subcontrols like
+ \l{stylesheet-reference.html#handle-sub}{handle},
+ \l{stylesheet-reference.html#add-line-sub}{add-line},
+ \l{stylesheet-reference.html#sub-line-sub}{sub-line}, and so on. Note that
+ if one property or sub-control is customized, all the other properties or
+ sub-controls must be customized as well.
+
+ \image stylesheet-scrollbar1.png
+
+ The scroll bar above has been styled in aquamarine with a solid grey
+ border.
+
+ \snippet code/doc_src_stylesheet.qdoc 132
+
+ \snippet code/doc_src_stylesheet.qdoc 133
+
+ \snippet code/doc_src_stylesheet.qdoc 134
+
+ The \l{stylesheet-reference.html#left-arrow-sub}{left-arrow} and
+ \l{stylesheet-reference.html#right-arrow-sub}{right-arrow} have a solid grey
+ border with a white background. As an alternative, you could also embed the
+ image of an arrow.
+
+ \snippet code/doc_src_stylesheet.qdoc 135
+
+ If you want the scroll buttons of the scroll bar to be placed together
+ (instead of the edges) like on Mac OS X, you can use the following
+ stylesheet:
+ \snippet code/doc_src_stylesheet.qdoc 136
+
+ The scroll bar using the above stylesheet looks like this:
+ \image stylesheet-scrollbar2.png
+
+
+ To customize a vertical scroll bar use a style sheet similar to the following:
+ \snippet code/doc_src_stylesheet.qdoc 137
+
+ \section2 Customizing QSizeGrip
+
+ QSizeGrip is usually styled by just setting an image.
+
+ \snippet code/doc_src_stylesheet.qdoc 138
+
+ \section2 Customizing QSlider
+
+ You can style horizontal slider as below:
+ \snippet code/doc_src_stylesheet.qdoc 139
+
+ If you want to change the color of the slider parts before and after the handle, you can use the add-page
+ and sub-page subcontrols. For example, for a vertical slider:
+
+ \snippet code/doc_src_stylesheet.qdoc 140
+
+ \section2 Customizing QSpinBox
+
+ QSpinBox can be completely customized as below (the style sheet has commentary inline):
+
+ \snippet code/doc_src_stylesheet.qdoc 141
+
+
+ \section2 Customizing QSplitter
+
+ A QSplitter derives from a QFrame and hence can be styled like a QFrame.
+ The grip or the handle is customized using the
+ \l{Qt Style Sheets Reference#handle-sub}{::handle} subcontrol.
+
+ \snippet code/doc_src_stylesheet.qdoc 142
+
+ \section2 Customizing QStatusBar
+
+ We can provide a background for the status bar and a border for items
+ inside the status bar as follows:
+ \snippet code/doc_src_stylesheet.qdoc 143
+
+ Note that widgets that have been added to the QStatusBar can be styled
+ using the descendant declaration (i.e)
+ \snippet code/doc_src_stylesheet.qdoc 144
+
+ \section2 Customizing QTabWidget and QTabBar
+
+ \image tabWidget-stylesheet1.png
+
+ For the screenshot above, we need a stylesheet as follows:
+
+ \snippet code/doc_src_stylesheet.qdoc 145
+
+ Often we require the tabs to overlap to look like below:
+ \image tabWidget-stylesheet2.png
+
+ For a tab widget that looks like above, we make use of
+ \l{http://www.communitymx.com/content/article.cfm?cid=B0029}
+ {negative margins}. The resulting stylesheet looks like this:
+
+ \snippet code/doc_src_stylesheet.qdoc 146
+
+ To move the tab bar to the center (as below), we require the following stylesheet:
+ \image tabWidget-stylesheet3.png
+
+ \snippet code/doc_src_stylesheet.qdoc 147
+
+ The tear indicator and the scroll buttons can be further customized as follows:
+ \snippet code/doc_src_stylesheet.qdoc 148
+
+ Since Qt 4.6 the close button can be customized as follow:
+ \snippet code/doc_src_stylesheet.qdoc 159
+
+ \section2 Customizing QTableView
+
+ Suppose we'd like our selected item in QTableView to have bubblegum pink
+ fade to white as its background.
+
+ \image tableWidget-stylesheet.png
+
+ This is possible with the
+ \l{stylesheet-reference.html#selection-background-color-prop}
+ {selection-background-color} property and the syntax required is:
+
+ \snippet code/doc_src_stylesheet.qdoc 149
+
+ The corner widget can be customized using the following style sheet
+
+ \snippet code/doc_src_stylesheet.qdoc 150
+
+ \section2 Customizing QToolBar
+
+ The background and the handle of a QToolBar is customized as below:
+ \snippet code/doc_src_stylesheet.qdoc 151
+
+ \section2 Customizing QToolBox
+
+ The tabs of the QToolBox are customized using the 'tab' subcontrol.
+
+ \snippet code/doc_src_stylesheet.qdoc 152
+
+ \section2 Customizing QToolButton
+
+ There are three types of QToolButtons.
+ \list
+ \li The QToolButton has no menu. In this case, the QToolButton is styled
+ exactly like QPushButton. See
+ \l{#Customizing QPushButton}{Customizing QPushButton} for an
+ example.
+
+ \li The QToolButton has a menu and has the QToolButton::popupMode set to
+ QToolButton::DelayedPopup or QToolButton::InstantPopup. In this case,
+ the QToolButton is styled exactly like a QPushButton with a menu.
+ See \l{#Customizing QPushButton}{Customizing QPushButton} for an
+ example of the usage of the menu-indicator pseudo state.
+
+ \li The QToolButton has its QToolButton::popupMode set to
+ QToolButton::MenuButtonPopup. In this case, we style it as follows:
+ \endlist
+
+ \snippet code/doc_src_stylesheet.qdoc 153
+
+
+ \section2 Customizing QToolTip
+
+ QToolTip is customized exactly like a QLabel. In addition, for platforms
+ that support it, the opacity property may be set to adjust the opacity.
+
+ For example,
+ \snippet code/doc_src_stylesheet.qdoc 154
+
+ \section2 Customizing QTreeView
+
+ The background color of alternating rows can be customized using the following
+ style sheet:
+
+ \snippet code/doc_src_stylesheet.qdoc 155
+
+ To provide a special background when you hover over items, we can use the
+ \l{item-sub}{::item} subcontrol. For example,
+ \snippet code/doc_src_stylesheet.qdoc 156
+
+ The branches of a QTreeView are styled using the
+ \l{Qt Style Sheets Reference#branch-sub}{::branch} subcontrol. The
+ following stylesheet color codes the various states when drawing
+ a branch.
+
+ \snippet code/doc_src_stylesheet.qdoc 157
+
+ Colorful, though it is, a more useful example can be made using the
+ following images:
+
+ \table
+ \row
+ \li \inlineimage stylesheet-vline.png
+ \li \inlineimage stylesheet-branch-more.png
+ \li \inlineimage stylesheet-branch-end.png
+ \li \inlineimage stylesheet-branch-closed.png
+ \li \inlineimage stylesheet-branch-open.png
+ \row
+ \li vline.png
+ \li branch-more.png
+ \li branch-end.png
+ \li branch-closed.png
+ \li branch-open.png
+ \endtable
+
+ \snippet code/doc_src_stylesheet.qdoc 158
+
+ The resulting tree view looks like this:
+
+ \image stylesheet-treeview.png
+
+ \sa {Style Sheet Example}, {Supported HTML Subset}, QStyle
+
+
+ \section1 Common mistakes
+
+ This section lists some common mistakes when using stylesheets.
+
+ \section2 QPushButton and images
+
+ When styling a QPushButton, it is often desirable to use an image as the
+ button graphic. It is common to try the
+ \l{Qt Style Sheets Reference#background-image-prop}{background-image}
+ property,
+ but this has a number of drawbacks: For instance, the background will
+ often appear hidden behind the button decoration, because it is not
+ considered a background. In addition, if the button is resized, the
+ entire background will be stretched or tiled, which does not
+ always look good.
+
+ It is better to use the
+ \l{Qt Style Sheets Reference#border-image-prop}{border-image}
+ property, as it will always display the image,
+ regardless of the background (you can combine it with a background if it
+ has alpha values in it), and it has special settings to deal with button
+ resizing.
+
+ Consider the following snippet:
+
+ \snippet stylesheet/common-mistakes.cpp 1
+
+ This will produce a button looking like this:
+
+ \image stylesheet-border-image-normal.png
+
+ The numbers after the url gives the top, right, bottom and left number of
+ pixels, respectively. These numbers correspond to the border and should not
+ stretch when the size changes.
+ Whenever you resize the button, the middle part of the image will stretch
+ in both directions, while the pixels specified in the stylesheet
+ will not. This makes the borders of the button look more natural, like
+ this:
+
+ \table
+ \row
+ \li \inlineimage stylesheet-border-image-stretched.png
+ \row
+ \li With borders
+ \endtable
+
+ \table
+ \row
+ \li \inlineimage stylesheet-border-image-wrong.png
+ \row
+ \li Without borders
+ \endtable
+
+ */
diff --git a/src/widgets/doc/src/widgets-and-layouts/widgets.qdoc b/src/widgets/doc/src/widgets-and-layouts/widgets.qdoc
new file mode 100644
index 0000000000..e80b0fbec0
--- /dev/null
+++ b/src/widgets/doc/src/widgets-and-layouts/widgets.qdoc
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page widgets-and-layouts.html
+ \title Widgets and Layouts
+ \ingroup qt-gui-concepts
+ \brief The primary elements for designing user interfaces in Qt.
+
+ \section1 Widgets
+
+ Widgets are the primary elements for creating user interfaces in Qt.
+ \l{The Widget Classes}{Widgets} can display data and status information,
+ receive user input, and provide a container for other widgets that
+ should be grouped together. A widget that is not embedded in a
+ parent widget is called a \l{Window and Dialog Widgets} {window}.
+
+ \image parent-child-widgets.png A parent widget containing various child widgets.
+
+ The QWidget class provides the basic capability to render to the
+ screen, and to handle user input events. All UI elements that Qt
+ provides are either subclasses of QWidget, or are used in connection
+ with a QWidget subclass. Creating custom widgets is done by
+ subclassing QWidget or a suitable subclass and reimplementing the
+ virtual event handlers.
+
+ \section1 Layouts
+
+ \l{Layout Management}{Layouts} are an elegant and flexible way to
+ automatically arrange child widgets within their container. Each
+ widget reports its size requirements to the layout through the
+ \l{QWidget::}{sizeHint} and \l{QWidget::}{sizePolicy} properties,
+ and the layout distributes the available space accordingly.
+
+ \table
+ \row
+ \li \image qgridlayout-with-5-children.png
+ \li \image qformlayout-with-6-children.png
+ \endtable
+
+ \l{Qt Designer Manual}{\QD} is a powerful tool for interactively creating and
+ arranging widgets in layouts.
+
+ \section1 Widget Styles
+
+ \l{Styles and Style Aware Widgets}{Styles} draw on behalf of
+ widgets and encapsulate the look and feel of a GUI. Qt's built-in
+ widgets use the QStyle class to perform nearly all of their drawing,
+ ensuring that they look exactly like the equivalent native widgets.
+
+ \table
+ \row
+ \li \image windowsxp-tabwidget.png
+ \li \image plastique-tabwidget.png
+ \li \image macintosh-tabwidget.png
+ \endtable
+
+ \l{Qt Style Sheets} are a powerful mechanism that allows you to customize the
+ appearance of widgets, in addition to what is already possible by subclassing QStyle.
+
+ \section1 The Widget Classes
+
+ The following sections list the widget classes. See the \l{Qt Widget
+ Gallery} for some examples.
+
+ \section2 Basic Widgets
+
+ These basic widgets (controls), e.g. buttons, comboboxes and
+ scroll bars, are designed for direct use.
+
+ \table
+ \row
+ \li \image windows-label.png
+ \li \image windowsvista-pushbutton.png
+ \li \image gtk-progressbar.png
+ \row
+ \li \image plastique-combobox.png
+ \li \image macintosh-radiobutton.png
+ \li \image cde-lineedit.png
+ \endtable
+
+ \annotatedlist basicwidgets
+
+ \section2 Advanced Widgets
+
+ Advanced GUI widgets, e.g. tab widgets and progress bars, provide
+ more complex user interface controls.
+
+ \table
+ \row
+ \li \image windowsxp-treeview.png
+ \li \image gtk-calendarwidget.png
+ \li \image qundoview.png
+ \endtable
+
+ \annotatedlist advanced
+
+ \table
+ \row
+ \li \image windowsvista-tabwidget.png
+ \li \image macintosh-groupbox.png
+ \endtable
+
+ \section2 Organizer Widgets
+
+ Classes like splitters, tab bars, button groups, etc are used for
+ organizing and grouping GUI primitives into more complex
+ applications and dialogs.
+
+ \annotatedlist organizers
+
+ \section2 Abstract Widget Classes
+
+ The abstract widget classes are base classes. They are not usable as
+ standalone classes but provide functionality when they are subclassed.
+
+ \annotatedlist abstractwidgets
+*/
+
+/*!
+ \group advanced
+ \title Advanced Widgets
+*/
+
+/*!
+ \group abstractwidgets
+ \title Abstract Widget Classes
+*/
+
+/*!
+ \group basicwidgets
+ \title Basic Widgets
+*/
+
+/*!
+ \group organizers
+ \title Organizers
+*/
diff --git a/src/widgets/doc/src/widgets-tutorial.qdoc b/src/widgets/doc/src/widgets-tutorial.qdoc
new file mode 100644
index 0000000000..37f095d500
--- /dev/null
+++ b/src/widgets/doc/src/widgets-tutorial.qdoc
@@ -0,0 +1,249 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page widgets-tutorial.html
+ \ingroup tutorials
+ \title Widgets Tutorial
+ \brief This tutorial covers basic usage of widgets and layouts, showing how
+ they are used to build GUI applications.
+
+ \section1 Introduction
+
+ Widgets are the basic building blocks for graphical user interface
+ (GUI) applications built with Qt. Each GUI component (e.g.
+ buttons, labels, text editor) is a \l{QWidget}{widget} that is
+ placed somewhere within a user interface window, or is displayed
+ as an independent window. Each type of widge is provided by a
+ subclass of QWidget, which is itself a subclass of QObject.
+
+ QWidget is not an abstract class. It can be used as a container
+ for other widgets, and it can be subclassed with minimal effort to
+ create new, custom widgets. QWidget is often used to create a
+ window inside which other \l{QWidget}s are placed.
+
+ As with \l{QObject}s, \l{QWidget}s can be created with parent
+ objects to indicate ownership, ensuring that objects are deleted
+ when they are no longer used. With widgets, these parent-child
+ relationships have an additional meaning: Each child widget is
+ displayed within the screen area occupied by its parent widget.
+ This means that when you delete a window widget, all the child
+ widgets it contains are also deleted.
+
+ \section1 Writing a main Function
+
+ Many of the GUI examples provided with Qt follow the pattern of
+ having a \c{main.cpp} file, which contains the standard code to
+ initialize the application, plus any number of other source/header
+ files that contain the application logic and custom GUI components.
+
+ A typical \c main() function in \c{main.cpp} looks like this:
+
+ \snippet widgets-tutorial/template.cpp main.cpp body
+
+ First, a QApplication object is constructed, which can be
+ configured with arguments passed in from the command line. After
+ the widgets have been created and shown, QApplication::exec() is
+ called to start Qt's event loop. Control passes to Qt until this
+ function returns. Finally, \c{main()} returns the value returned
+ by QApplication::exec().
+
+ \section1 Simple widget examples
+
+ Each of theses simple widget examples is written entirely within
+ the \c main() function.
+
+ \list
+ \li \l {tutorials/widgets/toplevel} {Creating a window}
+
+ \li \l {tutorials/widgets/childwidget} {Creating child widgets}
+
+ \li \l {tutorials/widgets/windowlayout} {Using layouts}
+
+ \li \l {tutorials/widgets/nestedlayouts} {Nested layouts}
+ \endlist
+
+ \section1 Real world widget examples
+
+ In these \l{Widget examples} {more advanced examples}, the code
+ that creates the widgets and layouts is stored in other files. For
+ example, the GUI for a main window may be created in the
+ constructor of a QMainWindow subclass.
+
+ \section1 Building The Examples
+
+ If you installed a binary package to get Qt, or if you compiled Qt
+ yourself, the examples described in this tutorial should already
+ be built and ready to run. If you wish to modify and recompile
+ them, follow these steps:
+
+ \list 1
+
+ \li From a command prompt, enter the directory containing the
+ example you have modified.
+
+ \li Type \c qmake and press \key{Return}. If this doesn't work,
+ make sure that the executable is on your path, or enter its
+ full location.
+
+ \li On Linux/Unix and Mac OS X, type \c make and press
+ \key{Return}; on Windows with Visual Studio, type \c nmake and
+ press \key{Return}.
+
+ \endlist
+
+ An executable file is created in the current directory. On
+ Windows, this file may be located in a \c debug or \c release
+ subdirectory. You can run this executable to see the example code
+ at work.
+*/
+
+/*!
+ \example tutorials/widgets/toplevel
+ \title Widgets Tutorial - Creating a Window
+
+ If a widget is created without a parent, it is treated as a window, or
+ \e{top-level widget}, when it is shown. Since it has no parent object to
+ ensure that it is deleted when no longer needed, it is up to the
+ developer to keep track of the top-level widgets in an application.
+
+ In the following example, we use QWidget to create and show a window with
+ a default size:
+
+ \div {class="qt-code"}
+ \table
+ \row
+ \li \snippet tutorials/widgets/toplevel/main.cpp main program
+ \li \inlineimage widgets-tutorial-toplevel.png
+ \endtable
+ \enddiv
+
+ To create a real GUI, we need to place widgets inside the window. To do
+ this, we pass a QWidget instance to a widget's constructor, as we will
+ demonstrate in the next part of this tutorial.
+
+*/
+
+/*!
+ \example tutorials/widgets/childwidget
+ \title Widgets Tutorial - Child Widgets
+
+ We can add a child widget to the window created in the previous example by
+ passing \c window as the parent to its constructor. In this case, we add a
+ button to the window and place it in a specific location:
+
+ \div {class="qt-code"}
+ \table
+ \row
+ \li \snippet tutorials/widgets/childwidget/main.cpp main program
+ \li \inlineimage widgets-tutorial-childwidget.png
+ \endtable
+ \enddiv
+
+ The button is now a child of the window and will be deleted when the
+ window is destroyed. Note that hiding or closing the window does not
+ automatically destroy it. It will be destroyed when the example exits.
+*/
+
+/*!
+ \example tutorials/widgets/windowlayout
+ \title Widgets Tutorial - Using Layouts
+
+ Usually, child widgets are arranged inside a window using layout objects
+ rather than by specifying positions and sizes explicitly. Here, we
+ construct a label and line edit widget that we would like to arrange
+ side-by-side.
+
+ \div {class="qt-code"}
+ \table
+ \row
+ \li \snippet tutorials/widgets/windowlayout/main.cpp main program
+ \li \inlineimage widgets-tutorial-windowlayout.png
+ \endtable
+ \enddiv
+
+ The \c layout object we construct manages the positions and sizes of
+ widgets supplied to it with the \l{QHBoxLayout::}{addWidget()} function.
+ The layout itself is supplied to the window itself in the call to
+ \l{QWidget::}{setLayout()}. Layouts are only visible through the effects
+ they have on the widgets (and other layouts) they are responsible for
+ managing.
+
+ In the example above, the ownership of each widget is not immediately
+ clear. Since we construct the widgets and the layout without parent
+ objects, we would expect to see an empty window and two separate windows
+ containing a label and a line edit. However, when we tell the layout to
+ manage the label and line edit and set the layout on the window, both the
+ widgets and the layout itself are ''reparented'' to become children of
+ the window.
+*/
+
+/*!
+ \example tutorials/widgets/nestedlayouts
+ \title Widgets Tutorial - Nested Layouts
+
+ Just as widgets can contain other widgets, layouts can be used to provide
+ different levels of grouping for widgets. Here, we want to display a
+ label alongside a line edit at the top of a window, above a table view
+ showing the results of a query.
+
+ We achieve this by creating two layouts: \c{queryLayout} is a QHBoxLayout
+ that contains QLabel and QLineEdit widgets placed side-by-side;
+ \c{mainLayout} is a QVBoxLayout that contains \c{queryLayout} and a
+ QTableView arranged vertically.
+
+ \div {class="qt-code"}
+ \table
+ \row
+ \li \snippet tutorials/widgets/nestedlayouts/main.cpp first part
+ \snippet tutorials/widgets/nestedlayouts/main.cpp last part
+ \li \inlineimage widgets-tutorial-nestedlayouts.png
+ \endtable
+ \enddiv
+
+ Note that we call the \c{mainLayout}'s \l{QBoxLayout::}{addLayout()}
+ function to insert the \c{queryLayout} above the \c{resultView} table.
+
+ We have omitted the code that sets up the model containing the data shown
+ by the QTableView widget, \c resultView. For completeness, we show this below.
+
+ As well as QHBoxLayout and QVBoxLayout, Qt also provides QGridLayout
+ and QFormLayout classes to help with more complex user interfaces.
+ These can be seen if you run \l{Qt Designer}.
+
+ \section1 Setting up the Model
+
+ In the code above, we did not show where the table's data came from
+ because we wanted to concentrate on the use of layouts. Here, we see
+ that the model holds a number of items corresponding to rows, each of
+ which is set up to contain data for two columns.
+
+ \snippet tutorials/widgets/nestedlayouts/main.cpp set up the model
+
+ The use of models and views is covered in the
+ \l{Item Views Examples} and in the \l{Model/View Programming} overview.
+*/
diff --git a/src/widgets/doc/src/windows-and-dialogs/dialogs.qdoc b/src/widgets/doc/src/windows-and-dialogs/dialogs.qdoc
new file mode 100644
index 0000000000..e1c6de42b8
--- /dev/null
+++ b/src/widgets/doc/src/windows-and-dialogs/dialogs.qdoc
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \group standard-dialogs
+ \ingroup qt-gui-concepts
+ \title Standard Dialogs
+ \brief A list of Qt classes for implementing standard dialogs.
+*/
+
+/*!
+ \page dialogs.html
+ \title Dialog Windows
+ \ingroup qt-gui-concepts
+ \brief An overview over dialog windows.
+
+ \previouspage Application Main Window
+ \contentspage Application Windows and Dialogs
+ \nextpage Desktop Integration
+
+ Dialogs can be \e{modal}, in which case the user is required to provide
+ necessary information before work in the main window
+ can continue, or \e{modeless}. Modeless dialogs do not prevent the user from
+ interacting with any of the other windows in the application.
+
+ Qt provides a set of ready-made dialogs for file, font, color-selection
+ and more.
+
+ \annotatedlist standard-dialogs
+
+ Custom dialogs can be easily created by composing regular widgets into
+ a QDialog. These classes are specifically designed for building custom
+ dialogs:
+
+ \annotatedlist dialog-classes
+*/
diff --git a/src/widgets/doc/src/windows-and-dialogs/mainwindow.qdoc b/src/widgets/doc/src/windows-and-dialogs/mainwindow.qdoc
new file mode 100644
index 0000000000..3c175669fb
--- /dev/null
+++ b/src/widgets/doc/src/windows-and-dialogs/mainwindow.qdoc
@@ -0,0 +1,261 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \group mainwindow-classes
+ \title Main Window and Related Classes
+*/
+
+/*!
+ \page application-windows.html
+ \title Window and Dialog Widgets
+ \brief Windows and Dialogs in Qt.
+ \ingroup qt-gui-concepts
+
+ A \l{Widgets Tutorial}{widget} that is not embedded in a parent widget is called a window.
+ (Usually, windows have a frame and a title bar, although it is also possible to create
+ windows without such decoration using suitable window flags). In Qt, QMainWindow
+ and the various subclasses of QDialog are the most common window types.
+
+ In applications, windows provide the screen space upon which the user
+ interface is built. Windows separate applications visually from each other
+ and usually provide a window decoration that allows the user to resize and
+ position the applications according to his preferences. Windows are typically
+ integrated into the desktop environment and to some degree managed by the
+ window management system that the desktop environment provides. For instance,
+ selected windows of an application are represented in the task bar.
+
+ \section1 Primary and Secondary Windows
+
+ Any QWidget that has no parent will become a window, and will on most platforms
+ be listed in the desktop's task bar. This is usually only wanted for one
+ window in the application, the \e{primary window}.
+
+ In addition, a QWidget that has a parent can become a window by setting the
+ \l{Qt::WindowType}{Qt::WA_Window} flag. Depending on the window management system
+ such \e{secondary windows} are usually stacked on top of their respective parent
+ window, and not have a task bar entry of their own.
+
+ The QMainWindow and the QDialog classes set the Qt::WA_Window flag in their
+ constructor, as they are designed to be used as windows and provide facilities
+ that are not wanted for child widgets.
+
+ \section1 Main Windows and Dialogs
+
+ The \l{Application Main Window} provides the framework for building the
+ application's main user interface, and are created by subclassing QMainWindow.
+ QMainWindow has its own layout to which you can add a \l{QMenuBar}{menu bar},
+ \l{QToolBar}{tool bars}, \l{QDockWidget}{dockable widgets} and a
+ \l{QStatusBar}{status bar}. The center area can be occupied by any kind of
+ QWidget.
+
+ \l{Dialog Windows} are used as secondary windows that present the user with
+ options and choices. Dialogs are created by subclassing QDialog and using
+ \l{Widgets and Layouts}{widgets and layouts} to implement the user interface.
+ In addition, Qt provides a number of ready-made standard dialogs that can be
+ used for standard tasks like file or font selection.
+
+ Both main windows and dialogs can be created with \QD, Qt's visual design tool.
+ Using \QD is a lot faster than hand-coding, and makes it easy to test different
+ design ideas. Creating designs visually and reading the code generated by
+ \l{uic} is a great way to learn Qt!
+
+ \keyword window geometry
+ \section1 Window Geometry
+
+ QWidget provides several functions that deal with a widget's
+ geometry. Some of these functions operate on the pure client area
+ (i.e. the window excluding the window frame), others include the
+ window frame. The differentiation is done in a way that covers the
+ most common usage transparently.
+
+ \list
+ \li \b{Including the window frame:}
+ \l{QWidget::x()}{x()},
+ \l{QWidget::y()}{y()},
+ \l{QWidget::frameGeometry()}{frameGeometry()},
+ \l{QWidget::pos()}{pos()}, and
+ \l{QWidget::move()}{move()}.
+ \li \b{Excluding the window frame:}
+ \l{QWidget::geometry()}{geometry()},
+ \l{QWidget::width()}{width()},
+ \l{QWidget::height()}{height()},
+ \l{QWidget::rect()}{rect()}, and
+ \l{QWidget::size()}{size()}.
+ \endlist
+
+ Note that the distinction only matters for decorated top-level
+ widgets. For all child widgets, the frame geometry is equal to the
+ widget's client geometry.
+
+ This diagram shows most of the functions in use:
+ \img geometry.png Geometry diagram
+
+ \section2 X11 Peculiarities
+
+ On X11, a window does not have a frame until the window manager
+ decorates it. This happens asynchronously at some point in time
+ after calling QWidget::show() and the first paint event the
+ window receives, or it does not happen at all. Bear in mind that
+ X11 is policy-free (others call it flexible). Thus you cannot
+ make any safe assumption about the decoration frame your window
+ will get. Basic rule: There's always one user who uses a window
+ manager that breaks your assumption, and who will complain to
+ you.
+
+ Furthermore, a toolkit cannot simply place windows on the screen. All
+ Qt can do is to send certain hints to the window manager. The window
+ manager, a separate process, may either obey, ignore or misunderstand
+ them. Due to the partially unclear Inter-Client Communication
+ Conventions Manual (ICCCM), window placement is handled quite
+ differently in existing window managers.
+
+ X11 provides no standard or easy way to get the frame geometry
+ once the window is decorated. Qt solves this problem with nifty
+ heuristics and clever code that works on a wide range of window
+ managers that exist today. Don't be surprised if you find one
+ where QWidget::frameGeometry() returns wrong results though.
+
+ Nor does X11 provide a way to maximize a window.
+ QWidget::showMaximized() has to emulate the feature. Its result
+ depends on the result of QWidget::frameGeometry() and the
+ capability of the window manager to do proper window placement,
+ neither of which can be guaranteed.
+*/
+
+/*!
+ \page mainwindow.html
+ \title Application Main Window
+ \ingroup qt-gui-concepts
+ \brief Creating the application window.
+
+ \tableofcontents
+
+ \section1 Overview of the Main Window Classes
+
+ These classes provide everything you need for a typical modern main
+ application window, like the main window itself, menu and tool bars,
+ a status bar, etc.
+
+ \annotatedlist mainwindow-classes
+
+ \section1 The Main Window Classes
+
+ Qt 4 provides the following classes for managing main windows and
+ associated user interface components:
+
+ \list
+ \li QMainWindow remains the central class around which applications
+ can be built. The interface to this class has been simplified, and
+ much of the functionality previously included in this class is now
+ present in the companion QDockWidget and QToolBar classes.
+
+ \li QDockWidget provides a widget that can be used to create
+ detachable tool palettes or helper windows. Dock widgets keep track
+ of their own properties, and they can be moved, closed, and floated
+ as external windows.
+
+ \li QToolBar provides a generic toolbar widget that can hold a
+ number of different action-related widgets, such as buttons,
+ drop-down menus, comboboxes, and spin boxes. The emphasis on a
+ unified action model in Qt 4 means that toolbars cooperate well
+ with menus and keyboard shortcuts.
+ \endlist
+
+ \section1 Example Code
+
+ Using QMainWindow is straightforward. Generally, we subclass
+ QMainWindow and set up menus, toolbars, and dock widgets inside
+ the QMainWindow constructor.
+
+ To add a menu bar to the main window, we simply create the menus, and
+ add them to the main window's menu bar. Note that the
+ QMainWindow::menuBar() function will automatically create the menu bar
+ the first time it is called. You can also call
+ QMainWindow::setMenuBar() to use a custom menu bar in the main window.
+
+ \snippet code/doc_src_qt4-mainwindow.cpp 0
+ \dots
+ \snippet mainwindows/menus/mainwindow.cpp 5
+ \dots
+
+ Once actions have been created, we can add them to the main window
+ components. To begin with, we add them to the pop-up menus:
+
+ \snippet mainwindows/menus/mainwindow.cpp 10
+ \dots
+ \snippet mainwindows/menus/mainwindow.cpp 11
+ \dots
+
+ The QToolBar and QMenu classes use Qt's action system to provide a
+ consistent API. In the above code, some existing actions were added to
+ the file menu with the QMenu::addAction() function. QToolBar also
+ provides this function, making it easy to reuse actions in different
+ parts of the main window. This avoids unnecessary duplication of work.
+
+ We create a toolbar as a child of the main window, and add the desired
+ actions to it:
+
+ \snippet mainwindows/sdi/mainwindow.cpp 0
+ \dots
+ \snippet code/doc_src_qt4-mainwindow.cpp 1
+
+ In this example, the toolbar is restricted to the top and bottom
+ toolbar areas of the main window, and is initially placed in the
+ top tool bar area. We can see that the actions specified by \c
+ newAct and \c openAct will be displayed both on the toolbar and in
+ the file menu.
+
+ QDockWidget is used in a similar way to QToolBar. We create a
+ dock widget as a child of the main window, and add widgets as children
+ of the dock widget:
+
+ \snippet dockwidgets/mainwindow.cpp 0
+
+ In this example, the dock widget can only be placed in the left and
+ right dock areas, and it is initially placed in the left dock area.
+
+ The QMainWindow API allows the programmer to customize which dock
+ widget areas occupy the four corners of the dock widget area. If
+ required, the default can be changed with the
+ QMainWindow::setCorner() function:
+
+ \snippet code/doc_src_qt4-mainwindow.cpp 2
+
+ The following diagram shows the configuration produced by the above code.
+ Note that the left and right dock widgets will occupy the top and bottom
+ corners of the main window in this layout.
+
+ \image mainwindow-docks-example.png
+
+ Once all of the main window components have been set up, the central widget
+ is created and installed by using code similar to the following:
+
+ \snippet code/doc_src_qt4-mainwindow.cpp 3
+
+ The central widget can be any subclass of QWidget.
+*/
diff --git a/src/widgets/effects/qgraphicseffect.cpp b/src/widgets/effects/qgraphicseffect.cpp
index 80c0aff492..5bfa8cc5e5 100644
--- a/src/widgets/effects/qgraphicseffect.cpp
+++ b/src/widgets/effects/qgraphicseffect.cpp
@@ -243,7 +243,7 @@ void QGraphicsEffectSource::draw(QPainter *painter)
For example:
- \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 0
+ \snippet code/src_gui_effects_qgraphicseffect.cpp 0
\sa QGraphicsEffect::draw()
*/
@@ -545,7 +545,7 @@ void QGraphicsEffect::updateBoundingRect()
For example:
- \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 1
+ \snippet code/src_gui_effects_qgraphicseffect.cpp 1
This function should not be called explicitly by the user, since it is
meant for reimplementation purposes only.
@@ -1154,7 +1154,7 @@ void QGraphicsOpacityEffect::setOpacity(qreal opacity)
For example:
- \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 2
+ \snippet code/src_gui_effects_qgraphicseffect.cpp 2
There is no opacity mask by default.
diff --git a/src/widgets/effects/qpixmapfilter.cpp b/src/widgets/effects/qpixmapfilter.cpp
index a141fa9e55..7e42eefef2 100644
--- a/src/widgets/effects/qpixmapfilter.cpp
+++ b/src/widgets/effects/qpixmapfilter.cpp
@@ -198,7 +198,7 @@ QRectF QPixmapFilter::boundingRectFor(const QRectF &rect) const
\endomit
Example:
- \snippet doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp 1
+ \snippet code/src_gui_image_qpixmapfilter.cpp 1
\sa {Pixmap Filters Example}, QPixmapColorizeFilter, QPixmapDropShadowFilter
@@ -1011,7 +1011,7 @@ static void grayscale(const QImage &image, QImage &dest, const QRect& rect = QRe
chosen color. The alpha-channel is not changed.
Example:
- \snippet doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp 0
+ \snippet code/src_gui_image_qpixmapfilter.cpp 0
\sa QPainter::CompositionMode
@@ -1194,7 +1194,7 @@ public:
radius of 1 at an offset of 8 pixels towards the lower right.
Example:
- \snippet doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp 2
+ \snippet code/src_gui_image_qpixmapfilter.cpp 2
\sa QPixmapColorizeFilter, QPixmapConvolutionFilter
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp
index 348d8f2d09..06db3826ea 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp
@@ -64,7 +64,7 @@
Anchors are always set up between edges of an item, where the "center" is also considered to
be an edge. Consider the following example:
- \snippet examples/graphicsview/simpleanchorlayout/main.cpp adding anchors
+ \snippet graphicsview/simpleanchorlayout/main.cpp adding anchors
Here, the right edge of item \c a is anchored to the left edge of item \c b and the bottom
edge of item \c a is anchored to the top edge of item \c b, with the result that
@@ -75,7 +75,7 @@
above. Here, we see how a widget can be anchored to the top-left corner of the enclosing
layout:
- \snippet examples/graphicsview/simpleanchorlayout/main.cpp adding a corner anchor
+ \snippet graphicsview/simpleanchorlayout/main.cpp adding a corner anchor
In cases where anchors are used to match the widths or heights of widgets, it is
convenient to use the addAnchors() function. As with the other functions for specifying
@@ -299,11 +299,11 @@ QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint fi
This is a convenience function, since anchoring corners can be expressed as anchoring
two edges. For instance:
- \snippet examples/graphicsview/simpleanchorlayout/main.cpp adding a corner anchor in two steps
+ \snippet graphicsview/simpleanchorlayout/main.cpp adding a corner anchor in two steps
This can also be achieved with the following line of code:
- \snippet examples/graphicsview/simpleanchorlayout/main.cpp adding a corner anchor
+ \snippet graphicsview/simpleanchorlayout/main.cpp adding a corner anchor
If there is already an anchor between the edge pairs, it will be replaced by the anchors that
this function specifies.
@@ -341,11 +341,11 @@ void QGraphicsAnchorLayout::addCornerAnchors(QGraphicsLayoutItem *firstItem,
For example, the following example anchors the left and right edges of two items
to match their widths:
- \snippet examples/graphicsview/simpleanchorlayout/main.cpp adding anchors to match sizes in two steps
+ \snippet graphicsview/simpleanchorlayout/main.cpp adding anchors to match sizes in two steps
This can also be achieved using the following line of code:
- \snippet examples/graphicsview/simpleanchorlayout/main.cpp adding anchors to match sizes
+ \snippet graphicsview/simpleanchorlayout/main.cpp adding anchors to match sizes
\sa addAnchor(), addCornerAnchors()
*/
diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.cpp b/src/widgets/graphicsview/qgraphicsgridlayout.cpp
index c5e7e83cf4..53d7cbd4be 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicsgridlayout.cpp
@@ -54,7 +54,7 @@
QGraphicsWidget::setLayout(). QGraphicsGridLayout automatically computes
the dimensions of the grid as you add items.
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp 0
+ \snippet code/src_gui_graphicsview_qgraphicsgridlayout.cpp 0
The layout takes ownership of the items. In some cases when the layout
item also inherits from QGraphicsItem (such as QGraphicsWidget) there will be a
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index dab1965da5..1ce914b219 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -90,7 +90,7 @@
by the item, and paint(), which implements the actual painting. For
example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 0
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 0
The boundingRect() function has many different purposes.
QGraphicsScene bases its item index on boundingRect(), and
@@ -277,7 +277,7 @@
classes in Qt are associated with a unique value for Type,
e.g. the value returned by QGraphicsPathItem::type() is 2.
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 18
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 18
*/
/*!
@@ -288,7 +288,7 @@
used in conjunction with a reimplementation of QGraphicsItem::type()
and declaring a Type enum value. Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 1
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 1
\note UserType = 65536
*/
@@ -2133,7 +2133,7 @@ void QGraphicsItem::setToolTip(const QString &toolTip)
An editor item might want to use an I-beam cursor:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 2
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 2
If no cursor has been set, the cursor of the item beneath is used.
@@ -2153,7 +2153,7 @@ QCursor QGraphicsItem::cursor() const
An editor item might want to use an I-beam cursor:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 3
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 3
If no cursor has been set, the cursor of the item beneath is used.
@@ -4146,7 +4146,7 @@ QMatrix QGraphicsItem::sceneMatrix() const
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 4
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 4
Unlike transform(), which returns only an item's local transformation, this
function includes the item's (and any parents') position, and all the transfomation properties.
@@ -4171,7 +4171,7 @@ QTransform QGraphicsItem::sceneTransform() const
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 5
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 5
This function is the same as combining this item's scene transform with
the view's viewport transform, but it also understands the
@@ -4474,7 +4474,7 @@ void QGraphicsItem::resetTransform()
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 6
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 6
\sa setTransform(), transform(), scale(), shear(), translate()
*/
@@ -4500,7 +4500,7 @@ void QGraphicsItem::rotate(qreal angle)
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 7
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 7
\sa setTransform(), transform()
*/
@@ -4787,7 +4787,7 @@ QRectF QGraphicsItem::childrenBoundingRect() const
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 8
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 8
\sa boundingRegion(), shape(), contains(), {The Graphics View Coordinate
System}, prepareGeometryChange()
@@ -4835,7 +4835,7 @@ QRectF QGraphicsItem::sceneBoundingRect() const
may choose to return an elliptic shape for better collision detection. For
example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 9
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 9
The outline of a shape can vary depending on the width and style of the
pen used when drawing. If you want to include this outline in the item's
@@ -5327,7 +5327,7 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)
provided, it points to the widget that is being painted on; otherwise, it
is 0. For cached painting, \a widget is always 0.
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 10
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 10
The painter's pen is 0-width by default, and its pen is initialized to the
QPalette::Text brush from the paint device's palette. The brush is
@@ -5736,7 +5736,7 @@ void QGraphicsItem::update(const QRectF &rect)
by other items, you can map the \a rect to viewport coordinates and scroll the
viewport.
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 19
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 19
\sa boundingRect()
*/
@@ -6515,7 +6515,7 @@ bool QGraphicsItem::isUnderMouse() const
Custom item data is useful for storing arbitrary properties in any
item. Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 11
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 11
Qt does not use this feature for storing data; it is provided solely
for the convenience of the user.
@@ -6572,7 +6572,7 @@ void QGraphicsItem::setData(int key, const QVariant &value)
For example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp QGraphicsItem type
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp QGraphicsItem type
\sa UserType
*/
@@ -6589,7 +6589,7 @@ int QGraphicsItem::type() const
To filter another item's events, install this item as an event filter
for the other item. Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 12
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 12
An item can only filter events for other items in the same
scene. Also, an item cannot filter its own events; instead, you
@@ -6805,7 +6805,7 @@ bool QGraphicsItem::sceneEvent(QEvent *event)
It's common to open a QMenu in response to receiving a context menu
event. Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 13
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 13
The default implementation ignores the event.
@@ -6830,7 +6830,7 @@ void QGraphicsItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
A common implementation of dragEnterEvent accepts or ignores \a event
depending on the associated mime data in \a event. Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 14
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 14
Items do not receive drag and drop events by default; to enable this
feature, call \c setAcceptDrops(true).
@@ -7424,7 +7424,7 @@ void QGraphicsItem::updateMicroFocus()
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 15
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 15
The default implementation does nothing, and returns \a value.
@@ -7519,7 +7519,7 @@ void QGraphicsItem::removeFromIndex()
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 16
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 16
\sa boundingRect()
*/
@@ -10613,11 +10613,11 @@ Qt::TextInteractionFlags QGraphicsTextItem::textInteractionFlags() const
/*!
\since 4.5
- If \a b is true, the \gui Tab key will cause the widget to change focus;
+ If \a b is true, the \uicontrol Tab key will cause the widget to change focus;
otherwise, the tab key will insert a tab into the document.
In some occasions text edits should not allow the user to input tabulators
- or change indentation using the \gui Tab key, as this breaks the focus
+ or change indentation using the \uicontrol Tab key, as this breaks the focus
chain. The default is false.
\sa tabChangesFocus(), ItemIsFocusable, textInteractionFlags()
@@ -10630,7 +10630,7 @@ void QGraphicsTextItem::setTabChangesFocus(bool b)
/*!
\since 4.5
- Returns true if the \gui Tab key will cause the widget to change focus;
+ Returns true if the \uicontrol Tab key will cause the widget to change focus;
otherwise, false is returned.
By default, this behavior is disabled, and this function will return false.
@@ -11010,7 +11010,7 @@ QVariant QGraphicsSimpleTextItem::extension(const QVariant &variant) const
QGraphicsScene::destroyItemGroup(), or you can manually remove all
items from the group by calling removeFromGroup().
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 17
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 17
The operation of adding and removing items preserves the items'
scene-relative position and transformation, as opposed to calling
diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
index f21220b3b1..bb90337c5e 100644
--- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp
+++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
@@ -70,7 +70,7 @@
An example animation with a timeline follows:
- \snippet doc/src/snippets/timeline/main.cpp 0
+ \snippet timeline/main.cpp 0
Note that steps lie between 0.0 and 1.0. It may be necessary to use
\l{QTimeLine::}{setUpdateInterval()}. The default update interval
diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
index 535e2ddf59..f312e2e7ba 100644
--- a/src/widgets/graphicsview/qgraphicslinearlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
@@ -56,7 +56,7 @@
and finally assign the layout to a widget by calling
QGraphicsWidget::setLayout().
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp 0
+ \snippet code/src_gui_graphicsview_qgraphicslinearlayout.cpp 0
You can add widgets, layouts, stretches (addStretch(), insertStretch() or
setStretchFactor()), and spacings (setItemSpacing()) to a linear
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index 4cda3e51fb..b09ddbab41 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -84,7 +84,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp 0
+ \snippet code/src_gui_graphicsview_qgraphicsproxywidget.cpp 0
QGraphicsProxyWidget takes care of automatically embedding popup children
of embedded widgets through creating a child proxy for each popup. This
@@ -104,7 +104,7 @@ QT_BEGIN_NAMESPACE
For example, in the code snippet below, we embed a group box into the proxy:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp 1
+ \snippet code/src_gui_graphicsview_qgraphicsproxywidget.cpp 1
The image below is the output obtained with its contents margin and
contents rect labeled.
@@ -131,7 +131,7 @@ QT_BEGIN_NAMESPACE
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp 2
+ \snippet code/src_gui_graphicsview_qgraphicsproxywidget.cpp 2
QGraphicsProxyWidget maintains symmetry for the following states:
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index 583e6da90a..282c6a2a2a 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -60,7 +60,7 @@
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 0
+ \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 0
Note that QGraphicsScene has no visual appearance of its own; it only
manages the items. You need to create a QGraphicsView widget to visualize
@@ -1715,7 +1715,7 @@ void QGraphicsScene::setSceneRect(const QRectF &rect)
device, such as a QImage (e.g., to take a screenshot), or for printing
with QPrinter. For example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 1
+ \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 1
If \a source is a null rect, this function will use sceneRect() to
determine what to render. If \a target is a null rect, the dimensions of \a
@@ -1866,7 +1866,7 @@ void QGraphicsScene::setItemIndexMethod(ItemIndexMethod method)
granularity of the scene's partitioning. The size of each scene segment is
determined by the following algorithm:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 2
+ \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 2
The BSP tree has an optimal size when each segment contains between 0 and
10 items.
@@ -3146,7 +3146,7 @@ QGraphicsItem *QGraphicsScene::mouseGrabberItem() const
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 3
+ \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 3
QGraphicsScene::render() calls drawBackground() to draw the scene
background. For more detailed control over how the background is drawn,
@@ -3181,7 +3181,7 @@ void QGraphicsScene::setBackgroundBrush(const QBrush &brush)
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 4
+ \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 4
QGraphicsScene::render() calls drawForeground() to draw the scene
foreground. For more detailed control over how the foreground is
@@ -3295,7 +3295,7 @@ void QGraphicsScene::update(const QRectF &rect)
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 5
+ \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 5
Note that QGraphicsView currently supports background caching only (see
QGraphicsView::CacheBackground). This function is equivalent to calling
@@ -5340,7 +5340,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool
Example:
- \snippet doc/src/snippets/graphicssceneadditemsnippet.cpp 0
+ \snippet graphicssceneadditemsnippet.cpp 0
Since Qt 4.6, this function is not called anymore unless
the QGraphicsView::IndirectPainting flag is given as an Optimization
diff --git a/src/widgets/graphicsview/qgraphicssceneevent.cpp b/src/widgets/graphicsview/qgraphicssceneevent.cpp
index 91b6fb08da..580380e19a 100644
--- a/src/widgets/graphicsview/qgraphicssceneevent.cpp
+++ b/src/widgets/graphicsview/qgraphicssceneevent.cpp
@@ -1461,7 +1461,7 @@ void QGraphicsSceneDragDropEvent::setProposedAction(Qt::DropAction action)
Sets the proposed action as accepted, i.e, the drop action
is set to the proposed action. This is equal to:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp 0
+ \snippet code/src_gui_graphicsview_qgraphicssceneevent.cpp 0
When using this function, one should not call \c accept().
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index cabf2eb5a5..3629341d9e 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -62,7 +62,7 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime <
center of the scene and display any items that are visible at this
point. For example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 0
+ \snippet code/src_gui_graphicsview_qgraphicsview.cpp 0
You can explicitly scroll to any position on the scene by using the
scroll bars, or by calling centerOn(). By passing a point to centerOn(),
@@ -1189,7 +1189,7 @@ QSize QGraphicsView::sizeHint() const
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 1
+ \snippet code/src_gui_graphicsview_qgraphicsview.cpp 1
*/
QPainter::RenderHints QGraphicsView::renderHints() const
{
@@ -1472,7 +1472,7 @@ void QGraphicsView::setRubberBandSelectionMode(Qt::ItemSelectionMode mode)
especially with a transformed view. The CacheBackground flag enables
caching of the view's background. For example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 2
+ \snippet code/src_gui_graphicsview_qgraphicsview.cpp 2
The cache is invalidated every time the view is transformed. However, when
scrolling, only partial invalidation is required.
@@ -1727,7 +1727,7 @@ QMatrix QGraphicsView::matrix() const
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 3
+ \snippet code/src_gui_graphicsview_qgraphicsview.cpp 3
To simplify interation with items using a transformed view, QGraphicsView
provides mapTo... and mapFrom... functions that can translate between
@@ -2030,7 +2030,7 @@ void QGraphicsView::fitInView(const QGraphicsItem *item, Qt::AspectRatioMode asp
onto a paint device, such as a QImage (e.g., to take a screenshot), or for
printing to QPrinter. For example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 4
+ \snippet code/src_gui_graphicsview_qgraphicsview.cpp 4
If \a source is a null rect, this function will use viewport()->rect() to
determine what to draw. If \a target is a null rect, the full dimensions
@@ -2155,7 +2155,7 @@ QList<QGraphicsItem *> QGraphicsView::items() const
a subclass in QGraphicsView. \a pos is in untransformed viewport
coordinates, just like QMouseEvent::pos().
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 5
+ \snippet code/src_gui_graphicsview_qgraphicsview.cpp 5
\sa QGraphicsScene::items(), {QGraphicsItem#Sorting}{Sorting}
*/
@@ -2270,7 +2270,7 @@ QList<QGraphicsItem *> QGraphicsView::items(const QPainterPath &path, Qt::ItemSe
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 6
+ \snippet code/src_gui_graphicsview_qgraphicsview.cpp 6
\sa items(), {QGraphicsItem#Sorting}{Sorting}
*/
@@ -3792,7 +3792,7 @@ bool QGraphicsView::isTransformed() const
Example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 7
+ \snippet code/src_gui_graphicsview_qgraphicsview.cpp 7
To simplify interation with items using a transformed view, QGraphicsView
provides mapTo... and mapFrom... functions that can translate between
diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp
index 1f45582442..267d70104d 100644
--- a/src/widgets/graphicsview/qgraphicswidget.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget.cpp
@@ -677,7 +677,7 @@ QRectF QGraphicsWidget::windowFrameRect() const
For example:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp 0
+ \snippet code/src_gui_graphicsview_qgraphicswidget.cpp 0
\sa QStyleOption::initFrom()
*/
@@ -2098,11 +2098,11 @@ QList<QAction *> QGraphicsWidget::actions() const
Note that since the tab order of the \a second widget is changed, you
should order a chain like this:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp 1
+ \snippet code/src_gui_graphicsview_qgraphicswidget.cpp 1
\e not like this:
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp 2
+ \snippet code/src_gui_graphicsview_qgraphicswidget.cpp 2
If \a first is 0, this indicates that \a second should be the first widget
to receive input focus should the scene gain Tab focus (i.e., the user
diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp
index 125beab91b..890eba3407 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.cpp
+++ b/src/widgets/itemviews/qabstractitemdelegate.cpp
@@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE
We create the \c WidgetDelegate class, which inherits from
QStyledItemDelegate. We do the drawing in the paint() function:
- \snippet doc/src/snippets/widgetdelegate.cpp 0
+ \snippet widgetdelegate.cpp 0
Notice that we use a QStyleOptionProgressBar and initialize its
members. We can then use the current QStyle to draw it.
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 2ff039595a..777767ee70 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -308,7 +308,7 @@ void QAbstractItemViewPrivate::_q_scrollerStateChanged()
setVerticalScrollMode(). To set the range of the scroll bars, you
can, for example, reimplement the view's resizeEvent() function:
- \snippet doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp 0
+ \snippet code/src_gui_itemviews_qabstractitemview.cpp 0
Note that the range is not updated until the widget is shown.
@@ -654,7 +654,7 @@ QAbstractItemView::~QAbstractItemView()
views. We recommend that you delete the old selection model if it is no
longer required. This is done with the following code:
- \snippet doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp 2
+ \snippet code/src_gui_itemviews_qabstractitemview.cpp 2
If both the old model and the old selection model do not have parents, or
if their parents are long-lived objects, it may be preferable to call their
@@ -3124,7 +3124,7 @@ void QAbstractItemView::closePersistentEditor(const QModelIndex &index)
deleted. For example, in the code snippet below, the QLineEdit object will
be deleted.
- \snippet doc/src/snippets/code/src_gui_itemviews_qabstractitemview.cpp 1
+ \snippet code/src_gui_itemviews_qabstractitemview.cpp 1
This function should only be used to display static content within the
visible area corresponding to an item of data. If you want to display
diff --git a/src/widgets/itemviews/qdatawidgetmapper.cpp b/src/widgets/itemviews/qdatawidgetmapper.cpp
index 2f7b1f7ecb..4396519810 100644
--- a/src/widgets/itemviews/qdatawidgetmapper.cpp
+++ b/src/widgets/itemviews/qdatawidgetmapper.cpp
@@ -289,7 +289,7 @@ void QDataWidgetMapperPrivate::_q_modelDestroyed()
The following code will map the columns of the model to widgets called \c mySpinBox,
\c myLineEdit and \c{myCountryChooser}:
- \snippet doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp 0
+ \snippet code/src_gui_itemviews_qdatawidgetmapper.cpp 0
After the call to toFirst(), \c mySpinBox displays the value \c{1}, \c myLineEdit
displays \c{Qt Norway} and \c myCountryChooser displays \c{Oslo}. The
@@ -476,7 +476,7 @@ QModelIndex QDataWidgetMapper::rootIndex() const
is mapped to the QLineEdit \c nameLineEdit, and the second is
mapped to the QSpinBox \c{ageSpinBox}:
- \snippet doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp 1
+ \snippet code/src_gui_itemviews_qdatawidgetmapper.cpp 1
\b{Notes:}
\list
@@ -737,7 +737,7 @@ int QDataWidgetMapper::currentIndex() const
with new data whenever the selection of a QTableView named
\c myTableView changes:
- \snippet doc/src/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp 2
+ \snippet code/src_gui_itemviews_qdatawidgetmapper.cpp 2
\sa currentIndex()
*/
diff --git a/src/widgets/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp
index 252192a3fc..f5700746b8 100644
--- a/src/widgets/itemviews/qitemdelegate.cpp
+++ b/src/widgets/itemviews/qitemdelegate.cpp
@@ -401,7 +401,7 @@ QString QItemDelegatePrivate::valueToText(const QVariant &value, const QStyleOpt
For example, a selected item may need to be displayed differently to
unselected items, as shown in the following code:
- \snippet examples/itemviews/pixelator/pixeldelegate.cpp 2
+ \snippet itemviews/pixelator/pixeldelegate.cpp 2
\dots
After painting, you should ensure that the painter is returned to its
@@ -1137,21 +1137,21 @@ QRect QItemDelegate::textRectangle(QPainter * /*painter*/, const QRect &rect,
key press events are handled by default:
\list
- \li \gui Tab
- \li \gui Backtab
- \li \gui Enter
- \li \gui Return
- \li \gui Esc
+ \li \uicontrol Tab
+ \li \uicontrol Backtab
+ \li \uicontrol Enter
+ \li \uicontrol Return
+ \li \uicontrol Esc
\endlist
- In the case of \gui Tab, \gui Backtab, \gui Enter and \gui Return
+ In the case of \uicontrol Tab, \uicontrol Backtab, \uicontrol Enter and \uicontrol Return
key press events, the \a editor's data is comitted to the model
- and the editor is closed. If the \a event is a \gui Tab key press
+ and the editor is closed. If the \a event is a \uicontrol Tab key press
the view will open an editor on the next item in the
- view. Likewise, if the \a event is a \gui Backtab key press the
+ view. Likewise, if the \a event is a \uicontrol Backtab key press the
view will open an editor on the \e previous item in the view.
- If the event is a \gui Esc key press event, the \a editor is
+ If the event is a \uicontrol Esc key press event, the \a editor is
closed \e without committing its data.
\sa commitData(), closeEditor()
diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp
index b4180c18dd..f970a77ab4 100644
--- a/src/widgets/itemviews/qitemeditorfactory.cpp
+++ b/src/widgets/itemviews/qitemeditorfactory.cpp
@@ -339,7 +339,7 @@ void QItemEditorFactory::setDefaultFactory(QItemEditorFactory *factory)
editing data. A property is set as the user property with the USER
keyword:
- \snippet doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp 0
+ \snippet code/src_gui_itemviews_qitemeditorfactory.cpp 0
If the editor does not provide a user property, it must return the
name of the property from valuePropertyName(); delegates will then
@@ -405,7 +405,7 @@ void QItemEditorFactory::setDefaultFactory(QItemEditorFactory *factory)
This way, it is not necessary to subclass
QItemEditorCreatorBase.
- \snippet doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp 1
+ \snippet code/src_gui_itemviews_qitemeditorfactory.cpp 1
The constructor takes the name of the property that contains the
editing data. QItemDelegate can then access the property by name
@@ -456,7 +456,7 @@ void QItemEditorFactory::setDefaultFactory(QItemEditorFactory *factory)
Example:
- \snippet doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp 2
+ \snippet code/src_gui_itemviews_qitemeditorfactory.cpp 2
Setting the \c editorFactory created above in an item delegate via
QItemDelegate::setItemEditorFactory() makes sure that all values of type
@@ -468,7 +468,7 @@ void QItemEditorFactory::setDefaultFactory(QItemEditorFactory *factory)
System}{meta-object system}). You set the user property with
the USER keyword:
- \snippet doc/src/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp 3
+ \snippet code/src_gui_itemviews_qitemeditorfactory.cpp 3
\sa QItemEditorCreatorBase, QItemEditorCreator,
QItemEditorFactory, QItemDelegate, {Color Editor Factory Example}
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index 01cb7b4235..4a17b65328 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -474,7 +474,7 @@ Qt::DropActions QListModel::supportedDropActions() const
List items can be inserted automatically into a list, when they are
constructed, by specifying the list widget:
- \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 2
+ \snippet qlistwidget-using/mainwindow.cpp 2
Alternatively, list items can also be created without a parent widget, and
later inserted into a list using QListWidget::insertItem().
@@ -1154,7 +1154,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
List widgets are constructed in the same way as other widgets:
- \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 0
+ \snippet qlistwidget-using/mainwindow.cpp 0
The selectionMode() of a list widget determines how many of the items in
the list can be selected at the same time, and whether complex selections
@@ -1166,15 +1166,15 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
parent widget and added to the list later. If a list widget already exists
when the items are constructed, the first method is easier to use:
- \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 1
+ \snippet qlistwidget-using/mainwindow.cpp 1
If you need to insert a new item into the list at a particular position,
then it should be constructed without a parent widget. The insertItem()
function should then be used to place it within the list. The list widget
will take ownership of the item.
- \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 6
- \snippet doc/src/snippets/qlistwidget-using/mainwindow.cpp 7
+ \snippet qlistwidget-using/mainwindow.cpp 6
+ \snippet qlistwidget-using/mainwindow.cpp 7
For multiple items, insertItems() can be used instead. The number of items
in the list is found with the count() function. To remove items from the
@@ -1258,7 +1258,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
This signal is emitted when the \a item is activated. The \a item is
activated when the user clicks or double clicks on it, depending on the
system configuration. It is also activated when the user presses the
- activation key (on Windows and X11 this is the \gui Return key, on Mac OS
+ activation key (on Windows and X11 this is the \uicontrol Return key, on Mac OS
X it is \key{Ctrl+0}).
*/
diff --git a/src/widgets/itemviews/qstandarditemmodel.cpp b/src/widgets/itemviews/qstandarditemmodel.cpp
index 5616d76c4a..4f488993f8 100644
--- a/src/widgets/itemviews/qstandarditemmodel.cpp
+++ b/src/widgets/itemviews/qstandarditemmodel.cpp
@@ -1989,11 +1989,11 @@ QDataStream &operator<<(QDataStream &out, const QStandardItem &item)
An example usage of QStandardItemModel to create a table:
- \snippet doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp 0
+ \snippet code/src_gui_itemviews_qstandarditemmodel.cpp 0
An example usage of QStandardItemModel to create a tree:
- \snippet doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp 1
+ \snippet code/src_gui_itemviews_qstandarditemmodel.cpp 1
After setting the model on a view, you typically want to react to user
actions, such as an item being clicked. Since a QAbstractItemView provides
@@ -2005,19 +2005,19 @@ QDataStream &operator<<(QDataStream &out, const QStandardItem &item)
a QAbstractItemView signal, such as QAbstractItemView::clicked(). First
you connect the view's signal to a slot in your class:
- \snippet doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp 2
+ \snippet code/src_gui_itemviews_qstandarditemmodel.cpp 2
When you receive the signal, you call itemFromIndex() on the given model
index to get a pointer to the item:
- \snippet doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp 3
+ \snippet code/src_gui_itemviews_qstandarditemmodel.cpp 3
Conversely, you must obtain the QModelIndex of an item when you want to
invoke a model/view function that takes an index as argument. You can
obtain the index either by using the model's indexFromItem() function, or,
equivalently, by calling QStandardItem::index():
- \snippet doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp 4
+ \snippet code/src_gui_itemviews_qstandarditemmodel.cpp 4
You are, of course, not required to use the item-based approach; you could
instead rely entirely on the QAbstractItemModel interface when working with
diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp
index 02ae80ca0b..fce80341e1 100644
--- a/src/widgets/itemviews/qstyleditemdelegate.cpp
+++ b/src/widgets/itemviews/qstyleditemdelegate.cpp
@@ -603,21 +603,21 @@ void QStyledItemDelegate::setItemEditorFactory(QItemEditorFactory *factory)
key press events are handled by default:
\list
- \li \gui Tab
- \li \gui Backtab
- \li \gui Enter
- \li \gui Return
- \li \gui Esc
+ \li \uicontrol Tab
+ \li \uicontrol Backtab
+ \li \uicontrol Enter
+ \li \uicontrol Return
+ \li \uicontrol Esc
\endlist
- In the case of \gui Tab, \gui Backtab, \gui Enter and \gui Return
+ In the case of \uicontrol Tab, \uicontrol Backtab, \uicontrol Enter and \uicontrol Return
key press events, the \a editor's data is comitted to the model
- and the editor is closed. If the \a event is a \gui Tab key press
+ and the editor is closed. If the \a event is a \uicontrol Tab key press
the view will open an editor on the next item in the
- view. Likewise, if the \a event is a \gui Backtab key press the
+ view. Likewise, if the \a event is a \uicontrol Backtab key press the
view will open an editor on the \e previous item in the view.
- If the event is a \gui Esc key press event, the \a editor is
+ If the event is a \uicontrol Esc key press event, the \a editor is
closed \e without committing its data.
\sa commitData(), closeEditor()
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 7ae74640d6..a50b6f3111 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -979,7 +979,7 @@ QTableWidgetSelectionRange::~QTableWidgetSelectionRange()
Top-level items are constructed without a parent then inserted at the
position specified by a pair of row and column numbers:
- \snippet doc/src/snippets/qtablewidget-using/mainwindow.cpp 3
+ \snippet qtablewidget-using/mainwindow.cpp 3
Each item can have its own background brush which is set with
the setBackground() function. The current background brush can be
@@ -1504,18 +1504,18 @@ QTableWidgetItem &QTableWidgetItem::operator=(const QTableWidgetItem &other)
Table widgets can be constructed with the required numbers of rows and
columns:
- \snippet doc/src/snippets/qtablewidget-using/mainwindow.cpp 0
+ \snippet qtablewidget-using/mainwindow.cpp 0
Alternatively, tables can be constructed without a given size and resized
later:
- \snippet doc/src/snippets/qtablewidget-resizing/mainwindow.cpp 0
- \snippet doc/src/snippets/qtablewidget-resizing/mainwindow.cpp 1
+ \snippet qtablewidget-resizing/mainwindow.cpp 0
+ \snippet qtablewidget-resizing/mainwindow.cpp 1
Items are created ouside the table (with no parent widget) and inserted
into the table with setItem():
- \snippet doc/src/snippets/qtablewidget-resizing/mainwindow.cpp 2
+ \snippet qtablewidget-resizing/mainwindow.cpp 2
If you want to enable sorting in your table widget, do so after you
have populated it with items, otherwise sorting may interfere with
@@ -1530,7 +1530,7 @@ QTableWidgetItem &QTableWidgetItem::operator=(const QTableWidgetItem &other)
construct a table item with an icon and aligned text, and use it as the
header for a particular column:
- \snippet doc/src/snippets/qtablewidget-using/mainwindow.cpp 2
+ \snippet qtablewidget-using/mainwindow.cpp 2
The number of rows in the table can be found with rowCount(), and the
number of columns with columnCount(). The table can be cleared with the
@@ -2267,7 +2267,7 @@ QWidget *QTableWidget::cellWidget(int row, int column) const
deleted. For example, in the code snippet below, the QLineEdit object will
be deleted.
- \snippet doc/src/snippets/code/src_gui_itemviews_qtablewidget.cpp 0
+ \snippet code/src_gui_itemviews_qtablewidget.cpp 0
\sa cellWidget()
*/
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 04835b63b4..44dd4b0761 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -85,8 +85,8 @@ QT_BEGIN_NAMESPACE
model. In the following example, the contents of a directory are
supplied by a QFileSystemModel and displayed as a tree:
- \snippet doc/src/snippets/shareddirmodel/main.cpp 3
- \snippet doc/src/snippets/shareddirmodel/main.cpp 6
+ \snippet shareddirmodel/main.cpp 3
+ \snippet shareddirmodel/main.cpp 6
The model/view architecture ensures that the contents of the tree view
are updated as the model changes.
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index e2d84825f0..d9d6c1434c 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -901,12 +901,12 @@ void QTreeModel::timerEvent(QTimerEvent *ev)
to represent cities of the world, and adds a entry for Oslo as a child
item:
- \snippet doc/src/snippets/qtreewidget-using/mainwindow.cpp 3
+ \snippet qtreewidget-using/mainwindow.cpp 3
Items can be added in a particular order by specifying the item they
follow when they are constructed:
- \snippet doc/src/snippets/qtreewidget-using/mainwindow.cpp 5
+ \snippet qtreewidget-using/mainwindow.cpp 5
Each column in an item can have its own background brush which is set with
the setBackground() function. The current background brush can be
@@ -2355,7 +2355,7 @@ void QTreeWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
In its simplest form, a tree widget can be constructed in the following way:
- \snippet doc/src/snippets/code/src_gui_itemviews_qtreewidget.cpp 0
+ \snippet code/src_gui_itemviews_qtreewidget.cpp 0
Before items can be added to the tree widget, the number of columns must
be set with setColumnCount(). This allows each item to have one or more
diff --git a/src/widgets/itemviews/qtreewidgetitemiterator.cpp b/src/widgets/itemviews/qtreewidgetitemiterator.cpp
index 116860ce89..45fddc7333 100644
--- a/src/widgets/itemviews/qtreewidgetitemiterator.cpp
+++ b/src/widgets/itemviews/qtreewidgetitemiterator.cpp
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
For example, the following code examples each item in a tree, checking the
text in the first column against a user-specified search string:
- \snippet doc/src/snippets/qtreewidgetitemiterator-using/mainwindow.cpp 0
+ \snippet qtreewidgetitemiterator-using/mainwindow.cpp 0
It is also possible to filter out certain types of node by passing certain
\l{IteratorFlag}{flags} to the constructor of QTreeWidgetItemIterator.
diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp
index c4f7995087..f3455d34ad 100644
--- a/src/widgets/kernel/qaction.cpp
+++ b/src/widgets/kernel/qaction.cpp
@@ -235,10 +235,10 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map)
menu and toolbar, then connected to the slot which will perform
the action. For example:
- \snippet examples/mainwindows/application/mainwindow.cpp 19
+ \snippet mainwindows/application/mainwindow.cpp 19
\codeline
- \snippet examples/mainwindows/application/mainwindow.cpp 28
- \snippet examples/mainwindows/application/mainwindow.cpp 31
+ \snippet mainwindows/application/mainwindow.cpp 28
+ \snippet mainwindows/application/mainwindow.cpp 31
We recommend that actions are created as children of the window
they are used in. In most cases actions will be children of
@@ -1037,7 +1037,7 @@ bool QAction::isChecked() const
which indicates that they are unavailable. For example, they might
be displayed using only shades of gray.
- \gui{What's This?} help on disabled actions is still available, provided
+ \uicontrol{What's This?} help on disabled actions is still available, provided
that the QAction::whatsThis property is set.
An action will be disabled when all widgets to which it is added
@@ -1328,7 +1328,7 @@ QAction::SoftKeyRole QAction::softKeyRole() const
the presence (or abscence) of the attribute.
For example:
- \snippet doc/src/snippets/code/src_gui_kernel_qaction.cpp 0
+ \snippet code/src_gui_kernel_qaction.cpp 0
\sa QAction::icon QApplication::setAttribute()
*/
diff --git a/src/widgets/kernel/qactiongroup.cpp b/src/widgets/kernel/qactiongroup.cpp
index 46ca378bbe..2cf8932859 100644
--- a/src/widgets/kernel/qactiongroup.cpp
+++ b/src/widgets/kernel/qactiongroup.cpp
@@ -109,15 +109,15 @@ void QActionGroupPrivate::_q_actionHovered()
\inmodule QtWidgets
In some situations it is useful to group QAction objects together.
- For example, if you have a \gui{Left Align} action, a \gui{Right
- Align} action, a \gui{Justify} action, and a \gui{Center} action,
+ For example, if you have a \uicontrol{Left Align} action, a \uicontrol{Right
+ Align} action, a \uicontrol{Justify} action, and a \uicontrol{Center} action,
only one of these actions should be active at any one time. One
simple way of achieving this is to group the actions together in
an action group.
Here's a example (from the \l{mainwindows/menus}{Menus} example):
- \snippet examples/mainwindows/menus/mainwindow.cpp 6
+ \snippet mainwindows/menus/mainwindow.cpp 6
Here we create a new action group. Since the action group is
exclusive by default, only one of the actions in the group is
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index e3fe157a73..60328c4cf6 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -569,7 +569,7 @@ QApplication::QApplication(int &argc, char **argv, int _internal)
\obsolete
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 0
+ \snippet code/src_gui_kernel_qapplication.cpp 0
*/
QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _internal)
@@ -1099,7 +1099,7 @@ QStyle *QApplication::style()
still the parent of the application object.
Example usage:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 1
+ \snippet code/src_gui_kernel_qapplication.cpp 1
When switching application styles, the color palette is set back to the
initial colors or the system defaults. This is necessary since certain
@@ -1291,7 +1291,7 @@ int QApplication::colorSpec()
Example:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 2
+ \snippet code/src_gui_kernel_qapplication.cpp 2
\sa colorSpec()
*/
@@ -1315,7 +1315,7 @@ void QApplication::setColorSpec(int spec)
Example:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 3
+ \snippet code/src_gui_kernel_qapplication.cpp 3
By default, this property contains a QSize object with zero width and height.
*/
@@ -1668,7 +1668,7 @@ void QApplication::setWindowIcon(const QIcon &icon)
Example:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 4
+ \snippet code/src_gui_kernel_qapplication.cpp 4
\sa allWidgets(), QWidget::isWindow(), QWidget::isHidden()
*/
@@ -1693,7 +1693,7 @@ QWidgetList QApplication::topLevelWidgets()
\note Some of the widgets may be hidden.
Example:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 5
+ \snippet code/src_gui_kernel_qapplication.cpp 5
\sa topLevelWidgets(), QWidget::isVisible()
*/
@@ -1803,10 +1803,10 @@ QFontMetrics QApplication::fontMetrics()
Closes all top-level windows.
This function is particularly useful for applications with many top-level
- windows. It could, for example, be connected to a \gui{Exit} entry in the
- \gui{File} menu:
+ windows. It could, for example, be connected to a \uicontrol{Exit} entry in the
+ \uicontrol{File} menu:
- \snippet examples/mainwindows/mdi/mainwindow.cpp 0
+ \snippet mainwindows/mdi/mainwindow.cpp 0
The windows are closed in random order, until one window does not accept
the close event. The application quits when the last window was
@@ -1843,7 +1843,7 @@ void QApplication::closeAllWindows()
Displays a simple message box about Qt. The message includes the version
number of Qt being used by the application.
- This is useful for inclusion in the \gui Help menu of an application, as
+ This is useful for inclusion in the \uicontrol Help menu of an application, as
shown in the \l{mainwindows/menus}{Menus} example.
This function is a convenience slot for QMessageBox::aboutQt().
@@ -2866,7 +2866,7 @@ void QApplication::setStartDragDistance(int l)
and the current position (e.g. in the mouse move event) is \c currentPos,
you can find out if a drag should be started with code like this:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 7
+ \snippet code/src_gui_kernel_qapplication.cpp 7
Qt uses this value internally, e.g. in QFileDialog.
@@ -3715,7 +3715,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
Here's an example of how an application's QApplication::commitData() might
be implemented:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 8
+ \snippet code/src_gui_kernel_qapplication.cpp 8
If an error occurred within the application while saving its data, you may
want to try allowsErrorInteraction() instead.
@@ -3787,7 +3787,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
If the session manager is capable of restoring sessions it will execute
\a command in order to restore the application. The command defaults to
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 9
+ \snippet code/src_gui_kernel_qapplication.cpp 9
The \c -session option is mandatory; otherwise QApplication cannot tell
whether it has been restored or what the current session identifier is.
@@ -3811,7 +3811,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
To iterate over the list, you can use the \l foreach pseudo-keyword:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 10
+ \snippet code/src_gui_kernel_qapplication.cpp 10
\sa setRestartCommand(), restartHint()
*/
@@ -3832,7 +3832,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
To iterate over the list, you can use the \l foreach pseudo-keyword:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 11
+ \snippet code/src_gui_kernel_qapplication.cpp 11
\sa setDiscardCommand(), restartCommand(), setRestartCommand()
*/
@@ -3960,7 +3960,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
Use the two-argument widgetAt() overload to get the child widget. To get
the top-level widget do this:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 12
+ \snippet code/src_gui_kernel_qapplication.cpp 12
*/
/*!
@@ -3969,7 +3969,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
Use the single-argument widgetAt() overload to get the child widget. To get
the top-level widget do this:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 13
+ \snippet code/src_gui_kernel_qapplication.cpp 13
*/
bool QApplicationPrivate::inPopupMode() const
@@ -4091,7 +4091,7 @@ bool QApplication::keypadNavigationEnabled()
flash time, then hidden for the same amount of time, but this may vary.
The default value on X11 is 1000 milliseconds. On Windows, the
- \gui{Control Panel} value is used and setting this property sets the cursor
+ \uicontrol{Control Panel} value is used and setting this property sets the cursor
flash time for all applications.
We recommend that widgets do not cache this value as it may change at any
diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp
index 7ea77d211c..46c51d1d37 100644
--- a/src/widgets/kernel/qboxlayout.cpp
+++ b/src/widgets/kernel/qboxlayout.cpp
@@ -1239,13 +1239,13 @@ QBoxLayout::Direction QBoxLayout::direction() const
The simplest use of the class is like this:
- \snippet doc/src/snippets/layouts/layouts.cpp 0
- \snippet doc/src/snippets/layouts/layouts.cpp 1
- \snippet doc/src/snippets/layouts/layouts.cpp 2
+ \snippet layouts/layouts.cpp 0
+ \snippet layouts/layouts.cpp 1
+ \snippet layouts/layouts.cpp 2
\codeline
- \snippet doc/src/snippets/layouts/layouts.cpp 3
- \snippet doc/src/snippets/layouts/layouts.cpp 4
- \snippet doc/src/snippets/layouts/layouts.cpp 5
+ \snippet layouts/layouts.cpp 3
+ \snippet layouts/layouts.cpp 4
+ \snippet layouts/layouts.cpp 5
First, we create the widgets we want in the layout. Then, we
create the QHBoxLayout object and add the widgets into the
@@ -1302,13 +1302,13 @@ QHBoxLayout::~QHBoxLayout()
The simplest use of the class is like this:
- \snippet doc/src/snippets/layouts/layouts.cpp 6
- \snippet doc/src/snippets/layouts/layouts.cpp 7
- \snippet doc/src/snippets/layouts/layouts.cpp 8
+ \snippet layouts/layouts.cpp 6
+ \snippet layouts/layouts.cpp 7
+ \snippet layouts/layouts.cpp 8
\codeline
- \snippet doc/src/snippets/layouts/layouts.cpp 9
- \snippet doc/src/snippets/layouts/layouts.cpp 10
- \snippet doc/src/snippets/layouts/layouts.cpp 11
+ \snippet layouts/layouts.cpp 9
+ \snippet layouts/layouts.cpp 10
+ \snippet layouts/layouts.cpp 11
First, we create the widgets we want in the layout. Then, we
create the QVBoxLayout object and add the widgets into the
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index 440f3f1dc2..bc4527a1e0 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -1038,11 +1038,11 @@ QStyle* QFormLayoutPrivate::getStyle() const
creates a QLabel behind the scenes and automatically set up
its buddy. We can then write code like this:
- \snippet doc/src/snippets/code/src_gui_kernel_qformlayout.cpp 0
+ \snippet code/src_gui_kernel_qformlayout.cpp 0
Compare this with the following code, written using QGridLayout:
- \snippet doc/src/snippets/code/src_gui_kernel_qformlayout.cpp 1
+ \snippet code/src_gui_kernel_qformlayout.cpp 1
\endlist
The table below shows the default appearance in different styles.
@@ -1083,7 +1083,7 @@ QStyle* QFormLayoutPrivate::getStyle() const
appearance of QMacStyle on all platforms, but with left-aligned
labels, you could write:
- \snippet doc/src/snippets/code/src_gui_kernel_qformlayout.cpp 2
+ \snippet code/src_gui_kernel_qformlayout.cpp 2
\sa QGridLayout, QBoxLayout, QStackedLayout
*/
diff --git a/src/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp
index 9c7f8736f0..448b6a8cfd 100644
--- a/src/widgets/kernel/qicon.cpp
+++ b/src/widgets/kernel/qicon.cpp
@@ -467,11 +467,11 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
resource, and then use it, allowing Qt to work out all the required
icon styles and sizes. For example:
- \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 0
+ \snippet code/src_gui_image_qicon.cpp 0
To undo a QIcon, simply set a null icon in its place:
- \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 1
+ \snippet code/src_gui_image_qicon.cpp 1
Use the QImageReader::supportedImageFormats() and
QImageWriter::supportedImageFormats() functions to retrieve a
@@ -500,7 +500,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
Provide a method to set a QIcon, and when you draw the icon, choose
whichever pixmap is appropriate for the current state of your widget.
For example:
- \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 2
+ \snippet code/src_gui_image_qicon.cpp 2
You might also make use of the \c Active mode, perhaps making your
widget \c Active when the mouse is over the widget (see \l
@@ -950,12 +950,12 @@ QString QIcon::themeName()
To fetch an icon from the current icon theme:
- \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 3
+ \snippet code/src_gui_image_qicon.cpp 3
Or if you want to provide a guaranteed fallback for platforms that
do not support theme icons, you can use the second argument:
- \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 4
+ \snippet code/src_gui_image_qicon.cpp 4
\note By default, only X11 will support themed icons. In order to
use themed icons on Mac and Windows, you will have to bundle a
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index 8c4e988411..a7760711b6 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -1117,7 +1117,7 @@ bool QLayout::activate()
This function can be used to iterate over a layout. The following
code will draw a rectangle for each layout item in the layout structure of the widget.
- \snippet doc/src/snippets/code/src_gui_kernel_qlayout.cpp 0
+ \snippet code/src_gui_kernel_qlayout.cpp 0
\sa count(), takeAt()
*/
@@ -1134,7 +1134,7 @@ bool QLayout::activate()
The following code fragment shows a safe way to remove all items
from a layout:
- \snippet doc/src/snippets/code/src_gui_kernel_qlayout.cpp 1
+ \snippet code/src_gui_kernel_qlayout.cpp 1
\sa itemAt(), count()
*/
diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp
index 6cf3e1fe42..cf220796c5 100644
--- a/src/widgets/kernel/qlayoutitem.cpp
+++ b/src/widgets/kernel/qlayoutitem.cpp
@@ -392,7 +392,7 @@ int QLayoutItem::minimumHeightForWidth(int w) const
Reimplement this function in layout managers that support height
for width. A typical implementation will look like this:
- \snippet doc/src/snippets/code/src_gui_kernel_qlayoutitem.cpp 0
+ \snippet code/src_gui_kernel_qlayoutitem.cpp 0
Caching is strongly recommended; without it layout will take
exponential time.
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp
index 92f6fbafba..23487073f8 100644
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -284,17 +284,17 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge
objects can be informed when a shortcut is executed. The shortcut
can be set up to contain all the key presses necessary to
describe a keyboard shortcut, including the states of modifier
- keys such as \gui Shift, \gui Ctrl, and \gui Alt.
+ keys such as \uicontrol Shift, \uicontrol Ctrl, and \uicontrol Alt.
\target mnemonic
On certain widgets, using '&' in front of a character will
automatically create a mnemonic (a shortcut) for that character,
- e.g. "E&xit" will create the shortcut \gui Alt+X (use '&&' to
+ e.g. "E&xit" will create the shortcut \uicontrol Alt+X (use '&&' to
display an actual ampersand). The widget might consume and perform
an action on a given shortcut. On X11 the ampersand will not be
shown and the character will be underlined. On Windows, shortcuts
- are normally not displayed until the user presses the \gui Alt
+ are normally not displayed until the user presses the \uicontrol Alt
key, but this is a setting the user can change. On Mac, shortcuts
are disabled by default. Call qt_set_sequence_auto_mnemonic() to
enable them. However, because mnemonic shortcuts do not fit in
@@ -310,7 +310,7 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge
The simplest way to create a shortcut for a particular widget is
to construct the shortcut with a key sequence. For example:
- \snippet doc/src/snippets/code/src_gui_kernel_qshortcut.cpp 0
+ \snippet code/src_gui_kernel_qshortcut.cpp 0
When the user types the \l{QKeySequence}{key sequence}
for a given shortcut, the shortcut's activated() signal is
@@ -449,7 +449,7 @@ QShortcut::~QShortcut()
This is a key sequence with an optional combination of Shift, Ctrl,
and Alt. The key sequence may be supplied in a number of ways:
- \snippet doc/src/snippets/code/src_gui_kernel_qshortcut.cpp 1
+ \snippet code/src_gui_kernel_qshortcut.cpp 1
By default, this property contains an empty key sequence.
*/
diff --git a/src/widgets/kernel/qstackedlayout.cpp b/src/widgets/kernel/qstackedlayout.cpp
index 0d2e7716e5..7db317e2bb 100644
--- a/src/widgets/kernel/qstackedlayout.cpp
+++ b/src/widgets/kernel/qstackedlayout.cpp
@@ -74,17 +74,17 @@ public:
A QStackedLayout can be populated with a number of child widgets
("pages"). For example:
- \snippet doc/src/snippets/qstackedlayout/main.cpp 0
+ \snippet qstackedlayout/main.cpp 0
\codeline
- \snippet doc/src/snippets/qstackedlayout/main.cpp 2
- \snippet doc/src/snippets/qstackedlayout/main.cpp 3
+ \snippet qstackedlayout/main.cpp 2
+ \snippet qstackedlayout/main.cpp 3
QStackedLayout provides no intrinsic means for the user to switch
page. This is typically done through a QComboBox or a QListWidget
that stores the titles of the QStackedLayout's pages. For
example:
- \snippet doc/src/snippets/qstackedlayout/main.cpp 1
+ \snippet qstackedlayout/main.cpp 1
When populating a layout, the widgets are added to an internal
list. The indexOf() function returns the index of a widget in that
diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp
index 907a29f3fb..c1a6ead381 100644
--- a/src/widgets/kernel/qwhatsthis.cpp
+++ b/src/widgets/kernel/qwhatsthis.cpp
@@ -102,7 +102,7 @@ QT_BEGIN_NAMESPACE
simple method to determine whether the text can be rendered as
plain text. See Qt::mightBeRichText() for details.
- \snippet doc/src/snippets/whatsthis/whatsthis.cpp 0
+ \snippet whatsthis/whatsthis.cpp 0
An alternative way to enter "What's This?" mode is to call
createAction(), and add the returned QAction to either a menu or
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 2a8a25e4fc..74612559f0 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -2737,12 +2737,12 @@ void QWidget::overrideWindowState(Qt::WindowStates newstate)
windows, the change is immediate. For example, to toggle between
full-screen and normal mode, use the following code:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 0
+ \snippet code/src_gui_kernel_qwidget.cpp 0
In order to restore and activate a minimized window (while
preserving its maximized and/or full-screen state), use the following:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 1
+ \snippet code/src_gui_kernel_qwidget.cpp 1
Calling this function will hide the widget. You must call show() to make
the widget visible again.
@@ -3535,7 +3535,7 @@ QSize QWidget::maximumSize() const
sizeIncrement.height() pixels vertically, with baseSize() as the
basis. Preferred widget sizes are for non-negative integers \e i
and \e j:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 2
+ \snippet code/src_gui_kernel_qwidget.cpp 2
Note that while you can set the size increment for all widgets, it
only affects windows.
@@ -3946,7 +3946,7 @@ QPoint QWidget::mapFromParent(const QPoint &pos) const
Typical usage is changing the window title:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 3
+ \snippet code/src_gui_kernel_qwidget.cpp 3
\sa isWindow()
*/
@@ -4546,7 +4546,7 @@ void QWidget::unsetLayoutDirection()
objects\endlink for a range of useful shapes.
An editor widget might use an I-beam cursor:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 6
+ \snippet code/src_gui_kernel_qwidget.cpp 6
If no cursor has been set, or after a call to unsetCursor(), the
parent's cursor is used.
@@ -4638,7 +4638,7 @@ void QWidget::unsetCursor()
using \a renderFlags to determine how to render. Rendering
starts at \a targetOffset in the \a target. For example:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 7
+ \snippet code/src_gui_kernel_qwidget.cpp 7
If \a sourceRegion is a null region, this function will use QWidget::rect() as
the region, i.e. the entire widget.
@@ -4646,7 +4646,7 @@ void QWidget::unsetCursor()
Ensure that you call QPainter::end() for the \a target device's
active painter (if any) before rendering. For example:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 8
+ \snippet code/src_gui_kernel_qwidget.cpp 8
\note To obtain the contents of an OpenGL widget, use QGLWidget::grabFrameBuffer()
or QGLWidget::renderPixmap() instead.
@@ -6267,11 +6267,11 @@ bool QWidget::isActiveWindow() const
Note that since the tab order of the \a second widget is changed, you
should order a chain like this:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 9
+ \snippet code/src_gui_kernel_qwidget.cpp 9
\e not like this:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 10
+ \snippet code/src_gui_kernel_qwidget.cpp 10
If \a first or \a second has a focus proxy, setTabOrder()
correctly substitutes the proxy.
@@ -6536,7 +6536,7 @@ void QWidget::setGeometry(const QRect &r)
To save the geometry when the window closes, you can
implement a close event like this:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 11
+ \snippet code/src_gui_kernel_qwidget.cpp 11
See the \l{Window Geometry} documentation for an overview of geometry
issues with windows.
@@ -6595,7 +6595,7 @@ QByteArray QWidget::saveGeometry() const
To restore geometry saved using QSettings, you can use code like
this:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 12
+ \snippet code/src_gui_kernel_qwidget.cpp 12
See the \l{Window Geometry} documentation for an overview of geometry
issues with windows.
@@ -6921,7 +6921,7 @@ void QWidget::setFocusPolicy(Qt::FocusPolicy policy)
widgets. Disabling updates solves this.
Example:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 13
+ \snippet code/src_gui_kernel_qwidget.cpp 13
Disabling a widget implicitly disables all its children. Enabling a widget
enables all child widgets \e except top-level widgets or those that
@@ -8667,7 +8667,7 @@ void QWidget::leaveEvent(QEvent *)
\b{Note for the X11 platform}: It is possible to toggle global double
buffering by calling \c qt_x11_set_global_double_buffer(). For example,
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 14
+ \snippet code/src_gui_kernel_qwidget.cpp 14
\note Generally, you should refrain from calling update() or repaint()
\b{inside} a paintEvent(). For example, calling update() or repaint() on
@@ -9128,7 +9128,7 @@ QLayout *QWidget::layout() const
Example:
- \snippet examples/uitools/textfinder/textfinder.cpp 3b
+ \snippet uitools/textfinder/textfinder.cpp 3b
An alternative to calling this function is to pass this widget to
the layout's constructor.
@@ -11367,7 +11367,7 @@ void QWidget::setMask(const QRegion &newMask)
The following code shows how an image with an alpha channel can be
used to generate a mask for a widget:
- \snippet doc/src/snippets/widget-mask/main.cpp 0
+ \snippet widget-mask/main.cpp 0
The label shown by this code is masked using the image it contains,
giving the appearance that an irregularly-shaped image is being drawn
diff --git a/src/widgets/styles/qdrawutil.cpp b/src/widgets/styles/qdrawutil.cpp
index 15788e34f5..5c1d0ce098 100644
--- a/src/widgets/styles/qdrawutil.cpp
+++ b/src/widgets/styles/qdrawutil.cpp
@@ -86,7 +86,7 @@ QT_BEGIN_NAMESPACE
Alternatively you can use a QFrame widget and apply the
QFrame::setFrameStyle() function to display a shaded line:
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 0
+ \snippet code/src_gui_painting_qdrawutil.cpp 0
\sa qDrawShadeRect(), qDrawShadePanel(), QStyle
*/
@@ -199,7 +199,7 @@ void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
Alternatively you can use a QFrame widget and apply the
QFrame::setFrameStyle() function to display a shaded rectangle:
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 1
+ \snippet code/src_gui_painting_qdrawutil.cpp 1
\sa qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), QStyle
*/
@@ -300,7 +300,7 @@ void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
Alternatively you can use a QFrame widget and apply the
QFrame::setFrameStyle() function to display a shaded panel:
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 2
+ \snippet code/src_gui_painting_qdrawutil.cpp 2
\sa qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), QStyle
*/
@@ -471,7 +471,7 @@ void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
Alternatively you can use a QFrame widget and apply the
QFrame::setFrameStyle() function to display a shaded panel:
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 3
+ \snippet code/src_gui_painting_qdrawutil.cpp 3
\sa qDrawShadePanel(), qDrawWinButton(), QStyle
*/
@@ -507,7 +507,7 @@ void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
Alternatively you can use a QFrame widget and apply the
QFrame::setFrameStyle() function to display a plain rectangle:
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 4
+ \snippet code/src_gui_painting_qdrawutil.cpp 4
\sa qDrawShadeRect(), QStyle
*/
@@ -566,7 +566,7 @@ void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c,
Alternatively you can use a QFrame widget and apply the
QFrame::setFrameStyle() function to display a shaded line:
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 5
+ \snippet code/src_gui_painting_qdrawutil.cpp 5
\sa qDrawShadeRect(), qDrawShadePanel(), QStyle
*/
@@ -605,7 +605,7 @@ void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
Alternatively you can use a QFrame widget and apply the
QFrame::setFrameStyle() function to display a shaded rectangle:
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 6
+ \snippet code/src_gui_painting_qdrawutil.cpp 6
\sa qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), QStyle
*/
@@ -642,7 +642,7 @@ void qDrawShadeRect(QPainter *p, const QRect &r,
Alternatively you can use a QFrame widget and apply the
QFrame::setFrameStyle() function to display a shaded panel:
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 7
+ \snippet code/src_gui_painting_qdrawutil.cpp 7
\sa qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), QStyle
*/
@@ -703,7 +703,7 @@ void qDrawWinButton(QPainter *p, const QRect &r,
Alternatively you can use a QFrame widget and apply the
QFrame::setFrameStyle() function to display a shaded panel:
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 8
+ \snippet code/src_gui_painting_qdrawutil.cpp 8
\sa qDrawShadePanel(), qDrawWinButton(), QStyle
*/
@@ -730,7 +730,7 @@ void qDrawWinPanel(QPainter *p, const QRect &r,
Alternatively you can use a QFrame widget and apply the
QFrame::setFrameStyle() function to display a plain rectangle:
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 9
+ \snippet code/src_gui_painting_qdrawutil.cpp 9
\sa qDrawShadeRect(), QStyle
*/
diff --git a/src/widgets/styles/qproxystyle.cpp b/src/widgets/styles/qproxystyle.cpp
index 5bcd83a6ea..80124872a6 100644
--- a/src/widgets/styles/qproxystyle.cpp
+++ b/src/widgets/styles/qproxystyle.cpp
@@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE
The following example shows how to override the shortcut underline
behavior on any platform:
- \snippet doc/src/snippets/code/src_gui_qproxystyle.cpp 1
+ \snippet code/src_gui_qproxystyle.cpp 1
Warning: The \l {QCommonStyle} {common styles} provided by Qt will
respect this hint, because they call QStyle::proxy(), but there is
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index d78a2ee2fb..b4f24acf84 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -107,7 +107,7 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C
QApplication::setStyle() function. It can also be specified by the
user of the application, using the \c -style command-line option:
- \snippet doc/src/snippets/code/src_gui_styles_qstyle.cpp 0
+ \snippet code/src_gui_styles_qstyle.cpp 0
If no style is specified, Qt will choose the most appropriate
style for the user's platform or desktop environment.
@@ -133,7 +133,7 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C
For example, if you want to draw a focus rectangle on your
widget, you can write:
- \snippet doc/src/snippets/styles/styles.cpp 1
+ \snippet styles/styles.cpp 1
QStyle gets all the information it needs to render the graphical
element from QStyleOption. The widget is passed as the last
@@ -154,15 +154,15 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C
combines a QStyle, a QPainter, and a QWidget. This makes it
possible to write
- \snippet doc/src/snippets/styles/styles.cpp 5
+ \snippet styles/styles.cpp 5
\dots
- \snippet doc/src/snippets/styles/styles.cpp 7
+ \snippet styles/styles.cpp 7
instead of
- \snippet doc/src/snippets/styles/styles.cpp 2
+ \snippet styles/styles.cpp 2
\dots
- \snippet doc/src/snippets/styles/styles.cpp 3
+ \snippet styles/styles.cpp 3
\section1 Creating a Custom Style
@@ -190,16 +190,16 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C
function, so we need to reimplement that function. We need the
following class declaration:
- \snippet doc/src/snippets/customstyle/customstyle.h 0
+ \snippet customstyle/customstyle.h 0
To draw its up and down arrows, QSpinBox uses the
PE_IndicatorSpinUp and PE_IndicatorSpinDown primitive elements.
Here's how to reimplement the drawPrimitive() function to draw
them differently:
- \snippet doc/src/snippets/customstyle/customstyle.cpp 2
- \snippet doc/src/snippets/customstyle/customstyle.cpp 3
- \snippet doc/src/snippets/customstyle/customstyle.cpp 4
+ \snippet customstyle/customstyle.cpp 2
+ \snippet customstyle/customstyle.cpp 3
+ \snippet customstyle/customstyle.cpp 4
Notice that we don't use the \c widget argument, except to pass it
on to the QWindowStyle::drawPrimitive() function. As mentioned
@@ -211,9 +211,9 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C
information, be careful to ensure that it isn't 0 and that it is
of the correct type before using it. For example:
- \snippet doc/src/snippets/customstyle/customstyle.cpp 0
+ \snippet customstyle/customstyle.cpp 0
\dots
- \snippet doc/src/snippets/customstyle/customstyle.cpp 1
+ \snippet customstyle/customstyle.cpp 1
When implementing a custom style, you cannot assume that the
widget is a QSpinBox just because the enum value is called
@@ -233,7 +233,7 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C
QApplication::setStyle() static function before creating the
QApplication object:
- \snippet snippets/customstyle/main.cpp using a custom style
+ \snippet customstyle/main.cpp using a custom style
You can call QApplication::setStyle() at any time, but by calling
it before the constructor, you ensure that the user's preference,
@@ -252,7 +252,7 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C
automatically. To use your new style with existing applications,
simply start the application with the following argument:
- \snippet doc/src/snippets/code/src_gui_styles_qstyle.cpp 1
+ \snippet code/src_gui_styles_qstyle.cpp 1
The application will use the look and feel from the custom style you
implemented.
@@ -306,7 +306,7 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C
We include a small example where we customize the drawing of item
backgrounds.
- \snippet doc/src/snippets/customviewstyle.cpp 0
+ \snippet customviewstyle.cpp 0
The primitive element PE_PanelItemViewItem is responsible for
painting the background of items, and is called from
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index 0b0c6e2393..1da5d786c7 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE
The following code snippet shows how to use a specific
QStyleOption subclass to paint a push button:
- \snippet doc/src/snippets/qstyleoption/main.cpp 0
+ \snippet qstyleoption/main.cpp 0
In our example, the control is a QStyle::CE_PushButton, and
according to the QStyle::drawControl() documentation the
@@ -85,7 +85,7 @@ QT_BEGIN_NAMESPACE
For safety, you can use qstyleoption_cast() to ensure that the
pointer type is correct. For example:
- \snippet doc/src/snippets/qstyleoption/main.cpp 4
+ \snippet qstyleoption/main.cpp 4
The qstyleoption_cast() function will return 0 if the object to
which \c option points is not of the correct type.
@@ -3240,7 +3240,7 @@ QStyleOptionViewItem::QStyleOptionViewItem(int version)
Example:
- \snippet doc/src/snippets/qstyleoption/main.cpp 4
+ \snippet qstyleoption/main.cpp 4
\sa QStyleOption::type, QStyleOption::version
*/
@@ -3958,7 +3958,7 @@ QStyleHintReturnVariant::QStyleHintReturnVariant() : QStyleHintReturn(Version, T
Example:
- \snippet doc/src/snippets/code/src_gui_styles_qstyleoption.cpp 0
+ \snippet code/src_gui_styles_qstyleoption.cpp 0
\sa QStyleHintReturn::type, QStyleHintReturn::version
*/
diff --git a/src/widgets/styles/qstylepainter.cpp b/src/widgets/styles/qstylepainter.cpp
index b15b9d1a38..ff7db79009 100644
--- a/src/widgets/styles/qstylepainter.cpp
+++ b/src/widgets/styles/qstylepainter.cpp
@@ -65,13 +65,13 @@ QT_BEGIN_NAMESPACE
Example using QStyle directly:
- \snippet doc/src/snippets/styles/styles.cpp 1
+ \snippet styles/styles.cpp 1
Example using QStylePainter:
- \snippet doc/src/snippets/styles/styles.cpp 0
- \snippet doc/src/snippets/styles/styles.cpp 4
- \snippet doc/src/snippets/styles/styles.cpp 6
+ \snippet styles/styles.cpp 0
+ \snippet styles/styles.cpp 4
+ \snippet styles/styles.cpp 6
\sa QStyle, QStyleOption
*/
diff --git a/src/widgets/styles/qstyleplugin.cpp b/src/widgets/styles/qstyleplugin.cpp
index 74c29f39c8..b36ffcf181 100644
--- a/src/widgets/styles/qstyleplugin.cpp
+++ b/src/widgets/styles/qstyleplugin.cpp
@@ -83,10 +83,10 @@ QT_BEGIN_NAMESPACE
The style key is usually the class name of the required
style. Note that the keys are case insensitive. For example:
- \snippet doc/src/snippets/qstyleplugin/main.cpp 0
+ \snippet qstyleplugin/main.cpp 0
\codeline
- \snippet doc/src/snippets/qstyleplugin/main.cpp 1
- \snippet doc/src/snippets/qstyleplugin/main.cpp 2
+ \snippet qstyleplugin/main.cpp 1
+ \snippet qstyleplugin/main.cpp 2
\sa keys()
*/
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp
index 91e4a9c3c1..245857b3c3 100644
--- a/src/widgets/util/qcompleter.cpp
+++ b/src/widgets/util/qcompleter.cpp
@@ -62,12 +62,12 @@
For example, here's how to provide auto completions from a simple
word list in a QLineEdit:
- \snippet doc/src/snippets/code/src_gui_util_qcompleter.cpp 0
+ \snippet code/src_gui_util_qcompleter.cpp 0
A QFileSystemModel can be used to provide auto completion of file names.
For example:
- \snippet doc/src/snippets/code/src_gui_util_qcompleter.cpp 1
+ \snippet code/src_gui_util_qcompleter.cpp 1
To set the model on which QCompleter should operate, call
setModel(). By default, QCompleter will attempt to match the \l
@@ -100,7 +100,7 @@
currentCompletion(). You can iterate through the list of
completions as below:
- \snippet doc/src/snippets/code/src_gui_util_qcompleter.cpp 2
+ \snippet code/src_gui_util_qcompleter.cpp 2
completionCount() returns the total number of completions for the
current prefix. completionCount() should be avoided when possible,
diff --git a/src/widgets/util/qundostack.cpp b/src/widgets/util/qundostack.cpp
index 5392dd2f8e..3951017f89 100644
--- a/src/widgets/util/qundostack.cpp
+++ b/src/widgets/util/qundostack.cpp
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
a change to the document with redo() and undo the change with undo(). The
implementations for these functions must be provided in a derived class.
- \snippet doc/src/snippets/code/src_gui_util_qundostack.cpp 0
+ \snippet code/src_gui_util_qundostack.cpp 0
A QUndoCommand has an associated text(). This is a short string
describing what the command does. It is used to update the text
@@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
QUndoCommand objects are owned by the stack they were pushed on.
QUndoStack deletes a command if it has been undone and a new command is pushed. For example:
-\snippet doc/src/snippets/code/src_gui_util_qundostack.cpp 1
+\snippet code/src_gui_util_qundostack.cpp 1
In effect, when a command is pushed, it becomes the top-most command
on the stack.
@@ -93,7 +93,7 @@ QT_BEGIN_NAMESPACE
redo() on all its children. The parent should, however, have a meaningful
text().
- \snippet doc/src/snippets/code/src_gui_util_qundostack.cpp 2
+ \snippet code/src_gui_util_qundostack.cpp 2
Another way to create macros is to use the convenience functions
QUndoStack::beginMacro() and QUndoStack::endMacro().
@@ -182,7 +182,7 @@ int QUndoCommand::id() const
The default implementation returns false.
- \snippet doc/src/snippets/code/src_gui_util_qundostack.cpp 3
+ \snippet code/src_gui_util_qundostack.cpp 3
\sa id() QUndoStack::push()
*/
@@ -943,11 +943,11 @@ QAction *QUndoStack::createRedoAction(QObject *parent, const QString &prefix) co
The stack becomes enabled and appropriate signals are emitted when endMacro()
is called for the outermost macro.
- \snippet doc/src/snippets/code/src_gui_util_qundostack.cpp 4
+ \snippet code/src_gui_util_qundostack.cpp 4
This code is equivalent to:
- \snippet doc/src/snippets/code/src_gui_util_qundostack.cpp 5
+ \snippet code/src_gui_util_qundostack.cpp 5
\sa endMacro()
*/
diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro
index a8be439695..ad1f29259e 100644
--- a/src/widgets/widgets.pro
+++ b/src/widgets/widgets.pro
@@ -15,6 +15,9 @@ unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore
HEADERS += $$QT_SOURCE_TREE/src/widgets/qtwidgetsversion.h
+QMAKE_DOCS = $$PWD/doc/qtwidgets.qdocconf
+QMAKE_DOCS_INDEX = ../../doc
+
include(../qbase.pri)
contains(QT_CONFIG, x11sm):CONFIG += x11sm
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp
index 4e85eae3ff..0c22576f7f 100644
--- a/src/widgets/widgets/qabstractbutton.cpp
+++ b/src/widgets/widgets/qabstractbutton.cpp
@@ -86,7 +86,7 @@ Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets;
ampersand ('&'), QAbstractButton automatically creates a shortcut
key. For example:
- \snippet doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp 0
+ \snippet code/src_gui_widgets_qabstractbutton.cpp 0
The \key Alt+C shortcut is assigned to the button, i.e., when the
user presses \key Alt+C the button will call animateClick(). See
@@ -97,7 +97,7 @@ Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets;
function. This is useful mostly for buttons that do not have any
text, because they have no automatic shortcut.
- \snippet doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp 1
+ \snippet code/src_gui_widgets_qabstractbutton.cpp 1
All of the buttons provided by Qt (QPushButton, QToolButton,
QCheckBox, and QRadioButton) can display both \l text and \l{icon}{icons}.
@@ -1361,7 +1361,7 @@ For example, a slot that reacts to signals emitted by newly checked
buttons but which ignores signals from buttons that have been unchecked
can be implemented using the following pattern:
-\snippet doc/src/snippets/code/src_gui_widgets_qabstractbutton.cpp 2
+\snippet code/src_gui_widgets_qabstractbutton.cpp 2
Button groups can be created using the QButtonGroup class, and
updates to the button states monitored with the
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index dc96321599..d97b03128e 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -130,13 +130,13 @@ QT_BEGIN_NAMESPACE
QWidget::move(). When the area contents or the viewport size
changes, we do the following:
- \snippet doc/src/snippets/myscrollarea.cpp 1
+ \snippet myscrollarea.cpp 1
When the scroll bars change value, we need to update the widget
position, i.e., find the part of the widget that is to be drawn in
the viewport:
- \snippet doc/src/snippets/myscrollarea.cpp 0
+ \snippet myscrollarea.cpp 0
In order to track scroll bar movements, reimplement the virtual
function scrollContentsBy(). In order to fine-tune scrolling
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index 6c556dc870..4d55c9f0af 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -230,7 +230,7 @@ QString QAbstractSpinBox::text() const
to automatically choose one that will enable the image to fit completely
within the display window, you can set up the spin box like this:
- \snippet examples/widgets/spinboxes/window.cpp 3
+ \snippet widgets/spinboxes/window.cpp 3
The user will then be able to choose a scale from 1% to 1000%
or select "Auto" to leave it up to the application to choose. Your code
@@ -275,7 +275,7 @@ void QAbstractSpinBox::setSpecialValueText(const QString &specialValueText)
to the minimum() value and vica versa. Wrapping only make sense if
you have minimum() and maximum() values set.
- \snippet doc/src/snippets/code/src_gui_widgets_qabstractspinbox.cpp 0
+ \snippet code/src_gui_widgets_qabstractspinbox.cpp 0
\sa QSpinBox::minimum(), QSpinBox::maximum()
*/
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index 6618304006..5ac7348217 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -2004,7 +2004,7 @@ void QCalendarWidgetPrivate::_q_editingFinished()
\row \li
\image qcalendarwidget-grid.png
\row \li
- \snippet doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp 0
+ \snippet code/src_gui_widgets_qcalendarwidget.cpp 0
\endtable
Finally, the day in the first column can be altered using the
@@ -2421,7 +2421,7 @@ void QCalendarWidget::showToday()
\li \image qcalendarwidget-minimum.png
\row
\li
- \snippet doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp 1
+ \snippet code/src_gui_widgets_qcalendarwidget.cpp 1
\endtable
By default, the minimum date is the earliest date that the QDate
@@ -2472,7 +2472,7 @@ void QCalendarWidget::setMinimumDate(const QDate &date)
\li \image qcalendarwidget-maximum.png
\row
\li
- \snippet doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp 2
+ \snippet code/src_gui_widgets_qcalendarwidget.cpp 2
\endtable
By default, the maximum date is the last day the QDate class can
@@ -2518,11 +2518,11 @@ void QCalendarWidget::setMaximumDate(const QDate &date)
The date range restricts the user selection, i.e. the user can
only select dates within the specified date range. Note that
- \snippet doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp 3
+ \snippet code/src_gui_widgets_qcalendarwidget.cpp 3
is analogous to
- \snippet doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp 4
+ \snippet code/src_gui_widgets_qcalendarwidget.cpp 4
If either the \a min or \a max parameters are not valid QDate
objects, this function does nothing.
@@ -2641,7 +2641,7 @@ void QCalendarWidget::setVerticalHeaderFormat(QCalendarWidget::VerticalHeaderFor
\li \inlineimage qcalendarwidget-grid.png
\row
\li
- \snippet doc/src/snippets/code/src_gui_widgets_qcalendarwidget.cpp 5
+ \snippet code/src_gui_widgets_qcalendarwidget.cpp 5
\endtable
The default value is false.
diff --git a/src/widgets/widgets/qcheckbox.cpp b/src/widgets/widgets/qcheckbox.cpp
index 13440ac104..a0093800a5 100644
--- a/src/widgets/widgets/qcheckbox.cpp
+++ b/src/widgets/widgets/qcheckbox.cpp
@@ -107,7 +107,7 @@ public:
constructor or with setText(). A shortcut key can be specified by preceding
the preferred character with an ampersand. For example:
- \snippet doc/src/snippets/code/src_gui_widgets_qcheckbox.cpp 0
+ \snippet code/src_gui_widgets_qcheckbox.cpp 0
In this example the shortcut is \e{Alt+A}. See the \l{QShortcut#mnemonic}
{QShortcut} documentation for details (to display an actual ampersand,
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index 0cdb2d1176..4c418bde9e 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE
QDateTimeEdit box. Dates and times appear in accordance with the
format set; see setDisplayFormat().
- \snippet doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp 0
+ \snippet code/src_gui_widgets_qdatetimeedit.cpp 0
Here we've created a new QDateTimeEdit object initialized with
today's date, and restricted the valid date range to today plus or
@@ -397,11 +397,11 @@ void QDateTimeEdit::setMaximumDateTime(const QDateTime &dt)
function call.
\since 4.4
- \snippet doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp 1
+ \snippet code/src_gui_widgets_qdatetimeedit.cpp 1
is analogous to:
- \snippet doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp 2
+ \snippet code/src_gui_widgets_qdatetimeedit.cpp 2
If either \a min or \a max are not valid, this function does
nothing.
@@ -560,11 +560,11 @@ void QDateTimeEdit::clearMaximumTime()
Convenience function to set minimum and maximum date with one
function call.
- \snippet doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp 3
+ \snippet code/src_gui_widgets_qdatetimeedit.cpp 3
is analogous to:
- \snippet doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp 4
+ \snippet code/src_gui_widgets_qdatetimeedit.cpp 4
If either \a min or \a max are not valid, this function does
nothing.
@@ -587,11 +587,11 @@ void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max)
Convenience function to set minimum and maximum time with one
function call.
- \snippet doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp 5
+ \snippet code/src_gui_widgets_qdatetimeedit.cpp 5
is analogous to:
- \snippet doc/src/snippets/code/src_gui_widgets_qdatetimeedit.cpp 6
+ \snippet code/src_gui_widgets_qdatetimeedit.cpp 6
If either \a min or \a max are not valid, this function does
nothing.
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index b787522a50..bcf0753d33 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -86,19 +86,19 @@ QT_BEGIN_NAMESPACE
destructive results.
Most dialogs have buttons that can almost be considered standard (e.g.
- \gui OK and \gui Cancel buttons). It is sometimes convenient to create these
+ \uicontrol OK and \uicontrol Cancel buttons). It is sometimes convenient to create these
buttons in a standard way.
There are a couple ways of using QDialogButtonBox. One ways is to create
the buttons (or button texts) yourself and add them to the button box,
specifying their role.
- \snippet examples/dialogs/extension/finddialog.cpp 1
+ \snippet dialogs/extension/finddialog.cpp 1
Alternatively, QDialogButtonBox provides several standard buttons (e.g. OK, Cancel, Save)
that you can use. They exist as flags so you can OR them together in the constructor.
- \snippet examples/dialogs/tabdialog/tabdialog.cpp 2
+ \snippet dialogs/tabdialog/tabdialog.cpp 2
You can mix and match normal buttons and standard buttons.
@@ -133,6 +133,8 @@ QT_BEGIN_NAMESPACE
\table
\row \li modeless horizontal MacLayout
\li \inlineimage buttonbox-mac-modeless-horizontal.png Screenshot of modeless horizontal MacLayout
+ \row \li modeless vertical MacLayout
+ \li \inlineimage buttonbox-mac-modeless-vertical.png Screenshot of modeless vertical MacLayout
\endtable
When a button is clicked in the button box, the clicked() signal is emitted
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index e40b109455..db45bf4e46 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -1547,7 +1547,7 @@ QAction * QDockWidget::toggleViewAction() const
\li When DockWidgetVerticalTitleBar is set on QDockWidget, the title
bar widget is repositioned accordingly. In resizeEvent(), the title
bar should check what orientation it should assume:
- \snippet doc/src/snippets/code/src_gui_widgets_qdockwidget.cpp 0
+ \snippet code/src_gui_widgets_qdockwidget.cpp 0
\li The title bar widget must have a valid QWidget::sizeHint() and
QWidget::minimumSizeHint(). These functions should take into account
diff --git a/src/widgets/widgets/qframe.cpp b/src/widgets/widgets/qframe.cpp
index b69f65828b..d11ff09a30 100644
--- a/src/widgets/widgets/qframe.cpp
+++ b/src/widgets/widgets/qframe.cpp
@@ -79,7 +79,7 @@ inline void QFramePrivate::init()
screen. QProgressBar has a "sunken" look. QLabel has a flat look.
The frames of widgets like these can be changed.
- \snippet doc/src/snippets/code/src_gui_widgets_qframe.cpp 0
+ \snippet code/src_gui_widgets_qframe.cpp 0
The QFrame class can also be used directly for creating simple
placeholder frames without any contents.
diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp
index d8ad04cd84..343fc85bc9 100644
--- a/src/widgets/widgets/qgroupbox.cpp
+++ b/src/widgets/widgets/qgroupbox.cpp
@@ -169,7 +169,7 @@ void QGroupBoxPrivate::click()
widgets). The following example shows how we can set up a
QGroupBox with a layout:
- \snippet examples/widgets/groupbox/window.cpp 2
+ \snippet widgets/groupbox/window.cpp 2
\table 100%
\row \li \inlineimage windowsxp-groupbox.png Screenshot of a Windows XP style group box
@@ -261,7 +261,7 @@ void QGroupBox::setTitle(const QString &title)
The group box title text will have a keyboard shortcut if the title
contains an ampersand ('&') followed by a letter.
- \snippet doc/src/snippets/code/src_gui_widgets_qgroupbox.cpp 0
+ \snippet code/src_gui_widgets_qgroupbox.cpp 0
In the example above, \key Alt+U moves the keyboard focus to the
group box. See the \l {QShortcut#mnemonic}{QShortcut}
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 4450066df4..99deca4709 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -115,7 +115,7 @@ QT_BEGIN_NAMESPACE
the bottom right corner (both lines being flush with the right
side of the label):
- \snippet doc/src/snippets/code/src_gui_widgets_qlabel.cpp 0
+ \snippet code/src_gui_widgets_qlabel.cpp 0
The properties and functions QLabel inherits from QFrame can also
be used to specify the widget frame to be used for any given label.
@@ -125,7 +125,7 @@ QT_BEGIN_NAMESPACE
mnemonic (see QKeySequence) that will set the keyboard focus to
the other widget (called the QLabel's "buddy"). For example:
- \snippet doc/src/snippets/code/src_gui_widgets_qlabel.cpp 1
+ \snippet code/src_gui_widgets_qlabel.cpp 1
In this example, keyboard focus is transferred to the label's
buddy (the QLineEdit) when the user presses Alt+P. If the buddy
@@ -1150,7 +1150,7 @@ void QLabelPrivate::updateLabel()
In a dialog, you might create two data entry widgets and a label
for each, and set up the geometry layout so each label is just to
the left of its data entry widget (its "buddy"), for example:
- \snippet doc/src/snippets/code/src_gui_widgets_qlabel.cpp 2
+ \snippet code/src_gui_widgets_qlabel.cpp 2
With the code above, the focus jumps to the Name field when the
user presses Alt+N, and to the Phone field when the user presses
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 1ea636ffb2..bbf34b9853 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1980,7 +1980,7 @@ void QLineEdit::dropEvent(QDropEvent* e)
to extend the standard context menu, reimplement this function, call
createStandardContextMenu() and extend the menu returned.
- \snippet doc/src/snippets/code/src_gui_widgets_qlineedit.cpp 0
+ \snippet code/src_gui_widgets_qlineedit.cpp 0
The \a event parameter is used to obtain the position where
the mouse cursor was when the event was generated.
diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
index 1c8e6ba0e8..3aff6ee5d9 100644
--- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
@@ -85,7 +85,7 @@
developer to provide the autorelease pool.
The following is a snippet of subclassing QMacCocoaViewContainer to wrap a NSSearchField.
- \snippet examples/mainwindows/macmainwindow/macmainwindow.mm 0
+ \snippet mainwindows/macmainwindow/macmainwindow.mm 0
*/
diff --git a/src/widgets/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm
index 7974e93d88..e608b4a756 100644
--- a/src/widgets/widgets/qmacnativewidget_mac.mm
+++ b/src/widgets/widgets/qmacnativewidget_mac.mm
@@ -70,11 +70,11 @@
Here is an example of putting a QPushButton into a NSWindow:
- \snippet doc/src/snippets/qmacnativewidget/main.mm 0
+ \snippet qmacnativewidget/main.mm 0
On Carbon, this would do the equivalent:
- \snippet doc/src/snippets/qmacnativewidget/main.mm 1
+ \snippet qmacnativewidget/main.mm 1
Note that QMacNativeWidget requires knowledge of Carbon or Cocoa. All it
does is get the Qt hierarchy into a window not owned by Qt. It is then up
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 7607f2f238..efd5db07ab 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -261,7 +261,7 @@ void QMainWindowPrivate::init()
An example of how to create menus follows:
- \snippet examples/mainwindows/application/mainwindow.cpp 26
+ \snippet mainwindows/application/mainwindow.cpp 26
The \c createPopupMenu() function creates popup menus when the
main window receives context menu events. The default
@@ -288,7 +288,7 @@ void QMainWindowPrivate::init()
An example of toolbar creation follows:
- \snippet examples/mainwindows/application/mainwindow.cpp 29
+ \snippet mainwindows/application/mainwindow.cpp 29
\section2 Creating Dock Widgets
@@ -312,7 +312,7 @@ void QMainWindowPrivate::init()
We give an example of how to create and add dock widgets to a
main window:
- \snippet doc/src/snippets/mainwindowsnippet.cpp 0
+ \snippet mainwindowsnippet.cpp 0
\section2 The Status Bar
@@ -485,7 +485,7 @@ void QMainWindow::setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle)
can then share among all the Mac windows. Create a parent-less
menu bar this way:
- \snippet doc/src/snippets/code/src_gui_widgets_qmenubar.cpp 1
+ \snippet code/src_gui_widgets_qmenubar.cpp 1
\sa setMenuBar()
*/
@@ -1213,7 +1213,7 @@ Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const
To save the geometry when the window closes, you can
implement a close event like this:
- \snippet doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp 0
+ \snippet code/src_gui_widgets_qmainwindow.cpp 0
\sa restoreState(), QWidget::saveGeometry(), QWidget::restoreGeometry()
*/
@@ -1237,7 +1237,7 @@ QByteArray QMainWindow::saveState(int version) const
To restore geometry saved using QSettings, you can use code like
this:
- \snippet doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp 1
+ \snippet code/src_gui_widgets_qmainwindow.cpp 1
\sa saveState(), QWidget::saveGeometry(),
QWidget::restoreGeometry(), restoreDockWidget()
diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp
index eb483ac0fe..b859fc437e 100644
--- a/src/widgets/widgets/qmdiarea.cpp
+++ b/src/widgets/widgets/qmdiarea.cpp
@@ -53,7 +53,7 @@
applications, but can also be placed in any layout. The following
code adds an area to a main window:
- \snippet doc/src/snippets/mdiareasnippets.cpp 0
+ \snippet mdiareasnippets.cpp 0
Unlike the window managers for top-level windows, all window flags
(Qt::WindowFlags) are supported by QMdiArea as long as the flags
@@ -1929,7 +1929,7 @@ void QMdiArea::activatePreviousSubWindow()
\note Once the subwindow has been added, its parent will be the
\e{viewport widget} of the QMdiArea.
- \snippet doc/src/snippets/mdiareasnippets.cpp 1
+ \snippet mdiareasnippets.cpp 1
When you create your own subwindow, you must set the
Qt::WA_DeleteOnClose widget attribute if you want the window to be
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 5dc26f6ee8..955e2e5c8c 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -1990,11 +1990,11 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
In most situations you'll want to specify the position yourself,
for example, the current mouse position:
- \snippet doc/src/snippets/code/src_gui_widgets_qmenu.cpp 0
+ \snippet code/src_gui_widgets_qmenu.cpp 0
or aligned to a widget:
- \snippet doc/src/snippets/code/src_gui_widgets_qmenu.cpp 1
+ \snippet code/src_gui_widgets_qmenu.cpp 1
or in reaction to a QMouseEvent *e:
- \snippet doc/src/snippets/code/src_gui_widgets_qmenu.cpp 2
+ \snippet code/src_gui_widgets_qmenu.cpp 2
*/
QAction *QMenu::exec()
{
@@ -2022,11 +2022,11 @@ QAction *QMenu::exec()
Common usage is to position the menu at the current mouse
position:
- \snippet doc/src/snippets/code/src_gui_widgets_qmenu.cpp 3
+ \snippet code/src_gui_widgets_qmenu.cpp 3
or aligned to a widget:
- \snippet doc/src/snippets/code/src_gui_widgets_qmenu.cpp 4
+ \snippet code/src_gui_widgets_qmenu.cpp 4
or in reaction to a QMouseEvent *e:
- \snippet doc/src/snippets/code/src_gui_widgets_qmenu.cpp 5
+ \snippet code/src_gui_widgets_qmenu.cpp 5
When positioning a menu with exec() or popup(), bear in mind that
you cannot rely on the menu's current size(). For performance
@@ -2074,7 +2074,7 @@ QAction *QMenu::exec(const QPoint &p, QAction *action)
(normally because the user pressed Esc).
This is equivalent to:
- \snippet doc/src/snippets/code/src_gui_widgets_qmenu.cpp 6
+ \snippet code/src_gui_widgets_qmenu.cpp 6
\sa popup(), QWidget::mapToGlobal()
*/
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 11ae61fb90..80b6faa1a0 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -586,7 +586,7 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti
menu items with addMenu(). For example, asuming that \c menubar
is a pointer to a QMenuBar and \c fileMenu is a pointer to a
QMenu, the following statement inserts the menu into the menu bar:
- \snippet doc/src/snippets/code/src_gui_widgets_qmenubar.cpp 0
+ \snippet code/src_gui_widgets_qmenubar.cpp 0
The ampersand in the menu item's text sets Alt+F as a shortcut for
this menu. (You can use "\&\&" to get a real ampersand in the menu
@@ -605,7 +605,7 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti
Example (from the \l{mainwindows/menus}{Menus} example):
- \snippet examples/mainwindows/menus/mainwindow.cpp 9
+ \snippet mainwindows/menus/mainwindow.cpp 9
Menu items may be removed with removeAction().
@@ -619,7 +619,7 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti
of menu bars and their behavior when the user interacts with them.
For example, Windows systems are often configured so that the
underlined character mnemonics that indicate keyboard shortcuts
- for items in the menu bar are only shown when the \gui{Alt} key is
+ for items in the menu bar are only shown when the \uicontrol{Alt} key is
pressed.
\table
@@ -628,13 +628,13 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti
Plastique widget style.
\li The \l{QPlastiqueStyle}{Plastique widget style}, like most
- other styles, handles the \gui{Help} menu in the same way as it
+ other styles, handles the \uicontrol{Help} menu in the same way as it
handles any other menu.
\row \li \inlineimage motif-menubar.png A menu bar shown in the
Motif widget style.
- \li The \l{QMotifStyle}{Motif widget style} treats \gui{Help} menus
+ \li The \l{QMotifStyle}{Motif widget style} treats \uicontrol{Help} menus
in a special way, placing them at right-hand end of the menu bar.
\endtable
@@ -677,7 +677,7 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti
bar, you must create a menu bar that does not have a parent.
Create a parent-less menu bar this way:
- \snippet doc/src/snippets/code/src_gui_widgets_qmenubar.cpp 1
+ \snippet code/src_gui_widgets_qmenubar.cpp 1
\b{Note:} Do \e{not} call QMainWindow::menuBar() to create the
shared menu bar, because that menu bar will have the QMainWindow
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index fad2d4e747..dad0a6b7b6 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -2039,7 +2039,7 @@ bool QPlainTextEdit::focusNextPrevChild(bool next)
Information about the event is passed in the \a event object.
- \snippet doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp 0
+ \snippet code/src_gui_widgets_qplaintextedit.cpp 0
*/
void QPlainTextEdit::contextMenuEvent(QContextMenuEvent *e)
{
@@ -2479,7 +2479,7 @@ QTextCharFormat QPlainTextEdit::currentCharFormat() const
It is equivalent to
- \snippet doc/src/snippets/code/src_gui_widgets_qplaintextedit.cpp 1
+ \snippet code/src_gui_widgets_qplaintextedit.cpp 1
*/
void QPlainTextEdit::insertPlainText(const QString &text)
{
@@ -2528,10 +2528,10 @@ void QPlainTextEdit::print(QPagedPaintDevice *printer) const
#endif
/*! \property QPlainTextEdit::tabChangesFocus
- \brief whether \gui Tab changes focus or is accepted as input
+ \brief whether \uicontrol Tab changes focus or is accepted as input
In some occasions text edits should not allow the user to input
- tabulators or change indentation using the \gui Tab key, as this breaks
+ tabulators or change indentation using the \uicontrol Tab key, as this breaks
the focus chain. The default is false.
*/
diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp
index 291e3548a2..9853924182 100644
--- a/src/widgets/widgets/qpushbutton.cpp
+++ b/src/widgets/widgets/qpushbutton.cpp
@@ -91,7 +91,7 @@ QT_BEGIN_NAMESPACE
preceding the preferred character with an ampersand in the
text. For example:
- \snippet doc/src/snippets/code/src_gui_widgets_qpushbutton.cpp 0
+ \snippet code/src_gui_widgets_qpushbutton.cpp 0
In this example the shortcut is \e{Alt+D}. See the \l
{QShortcut#mnemonic}{QShortcut} documentation for details (to
diff --git a/src/widgets/widgets/qradiobutton.cpp b/src/widgets/widgets/qradiobutton.cpp
index 11cd89bca2..15dbdd4284 100644
--- a/src/widgets/widgets/qradiobutton.cpp
+++ b/src/widgets/widgets/qradiobutton.cpp
@@ -105,7 +105,7 @@ void QRadioButtonPrivate::init()
can be specified by preceding the preferred character with an
ampersand in the text. For example:
- \snippet doc/src/snippets/code/src_gui_widgets_qradiobutton.cpp 0
+ \snippet code/src_gui_widgets_qradiobutton.cpp 0
In this example the shortcut is \e{Alt+c}. See the \l
{QShortcut#mnemonic}{QShortcut} documentation for details (to
diff --git a/src/widgets/widgets/qrubberband.cpp b/src/widgets/widgets/qrubberband.cpp
index 0f95f0188a..8173ffe657 100644
--- a/src/widgets/widgets/qrubberband.cpp
+++ b/src/widgets/widgets/qrubberband.cpp
@@ -112,7 +112,7 @@ void QRubberBand::initStyleOption(QStyleOptionRubberBand *option) const
setGeometry(), move() or resize() to position and size it. A common
pattern is to do this in conjunction with mouse events. For example:
- \snippet doc/src/snippets/code/src_gui_widgets_qrubberband.cpp 0
+ \snippet code/src_gui_widgets_qrubberband.cpp 0
If you pass a parent to QRubberBand's constructor, the rubber band will
display only inside its parent, but stays on top of other child widgets.
diff --git a/src/widgets/widgets/qscrollarea.cpp b/src/widgets/widgets/qscrollarea.cpp
index 84be2d569b..99b4151d8c 100644
--- a/src/widgets/widgets/qscrollarea.cpp
+++ b/src/widgets/widgets/qscrollarea.cpp
@@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE
widget can be viewed. The child widget must be specified with
setWidget(). For example:
- \snippet doc/src/snippets/code/src_gui_widgets_qscrollarea.cpp 0
+ \snippet code/src_gui_widgets_qscrollarea.cpp 0
The code above creates a scroll area (shown in the images below)
containing an image label. When scaling the image, the scroll area
diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp
index 7dcaead2f4..cb88ca1b79 100644
--- a/src/widgets/widgets/qspinbox.cpp
+++ b/src/widgets/widgets/qspinbox.cpp
@@ -168,9 +168,9 @@ public:
for a custom spin box that allows the user to enter icon sizes
(e.g., "32 x 32"):
- \snippet examples/widgets/icons/iconsizespinbox.cpp 1
+ \snippet widgets/icons/iconsizespinbox.cpp 1
\codeline
- \snippet examples/widgets/icons/iconsizespinbox.cpp 2
+ \snippet widgets/icons/iconsizespinbox.cpp 2
See the \l{widgets/icons}{Icons} example for the full source
code.
@@ -238,7 +238,7 @@ void QSpinBox::setValue(int value)
Typical use is to display a unit of measurement or a currency
symbol. For example:
- \snippet doc/src/snippets/code/src_gui_widgets_qspinbox.cpp 0
+ \snippet code/src_gui_widgets_qspinbox.cpp 0
To turn off the prefix display, set this property to an empty
string. The default is no prefix. The prefix is not displayed when
@@ -274,7 +274,7 @@ void QSpinBox::setPrefix(const QString &prefix)
use is to display a unit of measurement or a currency symbol. For
example:
- \snippet doc/src/snippets/code/src_gui_widgets_qspinbox.cpp 1
+ \snippet code/src_gui_widgets_qspinbox.cpp 1
To turn off the suffix display, set this property to an empty
string. The default is no suffix. The suffix is not displayed for
@@ -405,9 +405,9 @@ void QSpinBox::setMaximum(int maximum)
Convenience function to set the \a minimum, and \a maximum values
with a single function call.
- \snippet doc/src/snippets/code/src_gui_widgets_qspinbox.cpp 2
+ \snippet code/src_gui_widgets_qspinbox.cpp 2
is equivalent to:
- \snippet doc/src/snippets/code/src_gui_widgets_qspinbox.cpp 3
+ \snippet code/src_gui_widgets_qspinbox.cpp 3
\sa minimum maximum
*/
@@ -610,7 +610,7 @@ void QDoubleSpinBox::setValue(double value)
Typical use is to display a unit of measurement or a currency
symbol. For example:
- \snippet doc/src/snippets/code/src_gui_widgets_qspinbox.cpp 4
+ \snippet code/src_gui_widgets_qspinbox.cpp 4
To turn off the prefix display, set this property to an empty
string. The default is no prefix. The prefix is not displayed when
@@ -644,7 +644,7 @@ void QDoubleSpinBox::setPrefix(const QString &prefix)
use is to display a unit of measurement or a currency symbol. For
example:
- \snippet doc/src/snippets/code/src_gui_widgets_qspinbox.cpp 5
+ \snippet code/src_gui_widgets_qspinbox.cpp 5
To turn off the suffix display, set this property to an empty
string. The default is no suffix. The suffix is not displayed for
@@ -784,9 +784,9 @@ void QDoubleSpinBox::setMaximum(double maximum)
Note: The maximum and minimum values will be rounded to match the
decimals property.
- \snippet doc/src/snippets/code/src_gui_widgets_qspinbox.cpp 6
+ \snippet code/src_gui_widgets_qspinbox.cpp 6
is equivalent to:
- \snippet doc/src/snippets/code/src_gui_widgets_qspinbox.cpp 7
+ \snippet code/src_gui_widgets_qspinbox.cpp 7
\sa minimum maximum
*/
diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp
index 5a7d6376ca..f3a19c88ec 100644
--- a/src/widgets/widgets/qsplashscreen.cpp
+++ b/src/widgets/widgets/qsplashscreen.cpp
@@ -94,9 +94,9 @@ public:
some initialization tasks are performed before the application's
main window is shown:
- \snippet doc/src/snippets/qsplashscreen/main.cpp 0
+ \snippet qsplashscreen/main.cpp 0
\dots
- \snippet doc/src/snippets/qsplashscreen/main.cpp 1
+ \snippet qsplashscreen/main.cpp 1
The user can hide the splash screen by clicking on it with the
mouse. Since the splash screen is typically displayed before the
@@ -107,7 +107,7 @@ public:
for example, announcing connections established or modules loaded
as the application starts up:
- \snippet doc/src/snippets/code/src_gui_widgets_qsplashscreen.cpp 0
+ \snippet code/src_gui_widgets_qsplashscreen.cpp 0
QSplashScreen supports this with the showMessage() function. If you
wish to do your own drawing you can get a pointer to the pixmap
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index 17e1c39cee..126f819541 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -84,12 +84,12 @@ QT_BEGIN_NAMESPACE
reimplement QSplitter::createHandle() to instantiate the custom splitter
handle. For example, a minimum QSplitter subclass might look like this:
- \snippet doc/src/snippets/splitterhandle/splitter.h 0
+ \snippet splitterhandle/splitter.h 0
The \l{QSplitter::}{createHandle()} implementation simply constructs a
custom splitter handle, called \c Splitter in this example:
- \snippet doc/src/snippets/splitterhandle/splitter.cpp 1
+ \snippet splitterhandle/splitter.cpp 1
Information about a given handle can be obtained using functions like
orientation() and opaqueResize(), and is retrieved from its parent splitter.
@@ -100,7 +100,7 @@ QT_BEGIN_NAMESPACE
needs to perform. A simple subclass might only provide a paintEvent()
implementation:
- \snippet doc/src/snippets/splitterhandle/splitter.cpp 0
+ \snippet splitterhandle/splitter.cpp 0
In this example, a predefined gradient is set up differently depending on
the orientation of the handle. QSplitterHandle provides a reasonable
@@ -888,7 +888,7 @@ QSplitterLayoutStruct *QSplitterPrivate::insertWidget(int index, QWidget *w)
The following example will show a QListView, QTreeView, and
QTextEdit side by side, with two splitter handles:
- \snippet doc/src/snippets/splitter/splitter.cpp 0
+ \snippet splitter/splitter.cpp 0
If a widget is already inside a QSplitter when insertWidget() or
addWidget() is called, it will move to the new position. This can be used
@@ -1569,7 +1569,7 @@ static const qint32 SplitterMagic = 0xff;
for a future session. A version number is stored as part of the data.
Here is an example:
- \snippet doc/src/snippets/splitter/splitter.cpp 1
+ \snippet splitter/splitter.cpp 1
\sa restoreState()
*/
@@ -1604,7 +1604,7 @@ QByteArray QSplitter::saveState() const
Restore the splitters's state:
- \snippet doc/src/snippets/splitter/splitter.cpp 2
+ \snippet splitter/splitter.cpp 2
A failure to restore the splitter's layout may result from either
invalid or out-of-date data in the supplied byte array.
@@ -1657,7 +1657,7 @@ bool QSplitter::restoreState(const QByteArray &state)
This function is provided for convenience. It is equivalent to
- \snippet doc/src/snippets/code/src_gui_widgets_qsplitter.cpp 0
+ \snippet code/src_gui_widgets_qsplitter.cpp 0
\sa setSizes(), widget()
*/
diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp
index 5406f5dcf5..e239f86345 100644
--- a/src/widgets/widgets/qstackedwidget.cpp
+++ b/src/widgets/widgets/qstackedwidget.cpp
@@ -74,16 +74,16 @@ public:
Like QStackedLayout, QStackedWidget can be constructed and
populated with a number of child widgets ("pages"):
- \snippet doc/src/snippets/qstackedwidget/main.cpp 0
- \snippet doc/src/snippets/qstackedwidget/main.cpp 2
- \snippet doc/src/snippets/qstackedwidget/main.cpp 3
+ \snippet qstackedwidget/main.cpp 0
+ \snippet qstackedwidget/main.cpp 2
+ \snippet qstackedwidget/main.cpp 3
QStackedWidget provides no intrinsic means for the user to switch
page. This is typically done through a QComboBox or a QListWidget
that stores the titles of the QStackedWidget's pages. For
example:
- \snippet doc/src/snippets/qstackedwidget/main.cpp 1
+ \snippet qstackedwidget/main.cpp 1
When populating a stacked widget, the widgets are added to an
internal list. The indexOf() function returns the index of a
diff --git a/src/widgets/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp
index 4b9242499c..2b17d7fb83 100644
--- a/src/widgets/widgets/qstatusbar.cpp
+++ b/src/widgets/widgets/qstatusbar.cpp
@@ -186,12 +186,12 @@ QRect QStatusBarPrivate::messageRect() const
Use the showMessage() slot to display a \e temporary message:
- \snippet examples/mainwindows/dockwidgets/mainwindow.cpp 8
+ \snippet mainwindows/dockwidgets/mainwindow.cpp 8
To remove a temporary message, use the clearMessage() slot, or set
a time limit when calling showMessage(). For example:
- \snippet examples/mainwindows/dockwidgets/mainwindow.cpp 3
+ \snippet mainwindows/dockwidgets/mainwindow.cpp 3
Use the currentMessage() function to retrieve the temporary
message currently shown. The QStatusBar class also provide the
@@ -205,7 +205,7 @@ QRect QStatusBarPrivate::messageRect() const
addPermanentWidget() function. Use the removeWidget() function to
remove such messages from the status bar.
- \snippet doc/src/snippets/code/src_gui_widgets_qstatusbar.cpp 0
+ \snippet code/src_gui_widgets_qstatusbar.cpp 0
By default QStatusBar provides a QSizeGrip in the lower-right
corner. You can disable it using the setSizeGripEnabled()
diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp
index 261b96f8af..b8ffced6bb 100644
--- a/src/widgets/widgets/qtextbrowser.cpp
+++ b/src/widgets/widgets/qtextbrowser.cpp
@@ -1170,7 +1170,7 @@ QUrl QTextBrowser::historyUrl(int i) const
\row \li \a{i} > 0 \li \l forward() history
\endtable
- \snippet doc/src/snippets/code/src_gui_widgets_qtextbrowser.cpp 0
+ \snippet code/src_gui_widgets_qtextbrowser.cpp 0
\since 4.4
*/
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index 217fda61dc..7a7b977b89 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -472,12 +472,12 @@ void QTextEditPrivate::_q_ensureVisible(const QRectF &_rect)
For example, to allow the user to drag and drop an image onto a QTextEdit,
you could the implement these functions in the following way:
- \snippet doc/src/snippets/textdocument-imagedrop/textedit.cpp 0
+ \snippet textdocument-imagedrop/textedit.cpp 0
We add support for image MIME types by returning true. For all other
MIME types, we use the default implementation.
- \snippet doc/src/snippets/textdocument-imagedrop/textedit.cpp 1
+ \snippet textdocument-imagedrop/textedit.cpp 1
We unpack the image from the QVariant held by the MIME source and insert
it into the document as a resource.
@@ -1583,7 +1583,7 @@ bool QTextEdit::focusNextPrevChild(bool next)
Information about the event is passed in the \a event object.
- \snippet doc/src/snippets/code/src_gui_widgets_qtextedit.cpp 0
+ \snippet code/src_gui_widgets_qtextedit.cpp 0
*/
void QTextEdit::contextMenuEvent(QContextMenuEvent *e)
{
@@ -2143,7 +2143,7 @@ void QTextEdit::setAutoFormatting(AutoFormatting features)
It is equivalent to
- \snippet doc/src/snippets/code/src_gui_widgets_qtextedit.cpp 1
+ \snippet code/src_gui_widgets_qtextedit.cpp 1
*/
void QTextEdit::insertPlainText(const QString &text)
{
@@ -2157,7 +2157,7 @@ void QTextEdit::insertPlainText(const QString &text)
It is equivalent to:
- \snippet doc/src/snippets/code/src_gui_widgets_qtextedit.cpp 2
+ \snippet code/src_gui_widgets_qtextedit.cpp 2
\note When using this function with a style sheet, the style sheet will
only apply to the current block in the document. In order to apply a style
@@ -2273,10 +2273,10 @@ void QTextEdit::print(QPagedPaintDevice *printer) const
#endif
/*! \property QTextEdit::tabChangesFocus
- \brief whether \gui Tab changes focus or is accepted as input
+ \brief whether \uicontrol Tab changes focus or is accepted as input
In some occasions text edits should not allow the user to input
- tabulators or change indentation using the \gui Tab key, as this breaks
+ tabulators or change indentation using the \uicontrol Tab key, as this breaks
the focus chain. The default is false.
*/