From 97b5b8009254004608feefb903cbf44abaa099f6 Mon Sep 17 00:00:00 2001 From: Casper van Donderen Date: Mon, 7 May 2012 18:49:48 +0200 Subject: Doc: Modularize QtWidgets documentation. This change moves the snippets and images to the modularized directories. Change-Id: Idec1afb9db7ea6add1ca4cf25ec4019d8bce0c4d Reviewed-by: Marius Storm-Olsen --- src/widgets/doc/images/assistant-toolbar.png | Bin 0 -> 6532 bytes .../images/buttonbox-gnomelayout-horizontal.png | Bin 0 -> 4188 bytes .../doc/images/buttonbox-gnomelayout-vertical.png | Bin 0 -> 5027 bytes .../doc/images/buttonbox-kdelayout-horizontal.png | Bin 0 -> 2862 bytes .../doc/images/buttonbox-kdelayout-vertical.png | Bin 0 -> 3298 bytes .../images/buttonbox-mac-modeless-horizontal.png | Bin 0 -> 4123 bytes .../doc/images/buttonbox-mac-modeless-vertical.png | Bin 0 -> 5177 bytes .../doc/images/buttonbox-maclayout-horizontal.png | Bin 0 -> 5409 bytes .../doc/images/buttonbox-maclayout-vertical.png | Bin 0 -> 7340 bytes .../doc/images/buttonbox-winlayout-horizontal.png | Bin 0 -> 2780 bytes .../doc/images/buttonbox-winlayout-vertical.png | Bin 0 -> 3184 bytes src/widgets/doc/images/cde-calendarwidget.png | Bin 0 -> 10187 bytes src/widgets/doc/images/cde-checkbox.png | Bin 0 -> 1331 bytes src/widgets/doc/images/cde-combobox.png | Bin 0 -> 1269 bytes src/widgets/doc/images/cde-dateedit.png | Bin 0 -> 1183 bytes src/widgets/doc/images/cde-datetimeedit.png | Bin 0 -> 1701 bytes src/widgets/doc/images/cde-dial.png | Bin 0 -> 4481 bytes src/widgets/doc/images/cde-doublespinbox.png | Bin 0 -> 1007 bytes src/widgets/doc/images/cde-fontcombobox.png | Bin 0 -> 1603 bytes src/widgets/doc/images/cde-frame.png | Bin 0 -> 2976 bytes src/widgets/doc/images/cde-groupbox.png | Bin 0 -> 2592 bytes src/widgets/doc/images/cde-horizontalscrollbar.png | Bin 0 -> 569 bytes src/widgets/doc/images/cde-label.png | Bin 0 -> 1043 bytes src/widgets/doc/images/cde-lcdnumber.png | Bin 0 -> 538 bytes src/widgets/doc/images/cde-lineedit.png | Bin 0 -> 1355 bytes src/widgets/doc/images/cde-listview.png | Bin 0 -> 5166 bytes src/widgets/doc/images/cde-progressbar.png | Bin 0 -> 934 bytes src/widgets/doc/images/cde-pushbutton.png | Bin 0 -> 1099 bytes src/widgets/doc/images/cde-radiobutton.png | Bin 0 -> 1562 bytes src/widgets/doc/images/cde-slider.png | Bin 0 -> 526 bytes src/widgets/doc/images/cde-spinbox.png | Bin 0 -> 863 bytes src/widgets/doc/images/cde-tableview.png | Bin 0 -> 2467 bytes src/widgets/doc/images/cde-tabwidget.png | Bin 0 -> 2483 bytes src/widgets/doc/images/cde-textedit.png | Bin 0 -> 7374 bytes src/widgets/doc/images/cde-timeedit.png | Bin 0 -> 1248 bytes src/widgets/doc/images/cde-toolbox.png | Bin 0 -> 1813 bytes src/widgets/doc/images/cde-toolbutton.png | Bin 0 -> 1169 bytes src/widgets/doc/images/cde-treeview.png | Bin 0 -> 6703 bytes src/widgets/doc/images/checkboxes-exclusive.png | Bin 0 -> 5079 bytes .../doc/images/checkboxes-non-exclusive.png | Bin 0 -> 5614 bytes .../doc/images/cleanlooks-calendarwidget.png | Bin 0 -> 9748 bytes src/widgets/doc/images/cleanlooks-checkbox.png | Bin 0 -> 1416 bytes src/widgets/doc/images/cleanlooks-combobox.png | Bin 0 -> 2348 bytes src/widgets/doc/images/cleanlooks-dateedit.png | Bin 0 -> 1369 bytes src/widgets/doc/images/cleanlooks-datetimeedit.png | Bin 0 -> 1892 bytes src/widgets/doc/images/cleanlooks-dial.png | Bin 0 -> 4297 bytes .../doc/images/cleanlooks-doublespinbox.png | Bin 0 -> 1141 bytes src/widgets/doc/images/cleanlooks-fontcombobox.png | Bin 0 -> 1835 bytes src/widgets/doc/images/cleanlooks-frame.png | Bin 0 -> 2989 bytes src/widgets/doc/images/cleanlooks-groupbox.png | Bin 0 -> 2630 bytes .../doc/images/cleanlooks-horizontalscrollbar.png | Bin 0 -> 837 bytes src/widgets/doc/images/cleanlooks-label.png | Bin 0 -> 1043 bytes src/widgets/doc/images/cleanlooks-lcdnumber.png | Bin 0 -> 538 bytes src/widgets/doc/images/cleanlooks-lineedit.png | Bin 0 -> 1406 bytes src/widgets/doc/images/cleanlooks-listview.png | Bin 0 -> 5559 bytes src/widgets/doc/images/cleanlooks-progressbar.png | Bin 0 -> 1292 bytes .../doc/images/cleanlooks-pushbutton-menu.png | Bin 0 -> 3177 bytes src/widgets/doc/images/cleanlooks-pushbutton.png | Bin 0 -> 1332 bytes src/widgets/doc/images/cleanlooks-radiobutton.png | Bin 0 -> 1782 bytes src/widgets/doc/images/cleanlooks-slider.png | Bin 0 -> 671 bytes src/widgets/doc/images/cleanlooks-spinbox.png | Bin 0 -> 983 bytes src/widgets/doc/images/cleanlooks-tableview.png | Bin 0 -> 2465 bytes src/widgets/doc/images/cleanlooks-tabwidget.png | Bin 0 -> 5007 bytes src/widgets/doc/images/cleanlooks-textedit.png | Bin 0 -> 7560 bytes src/widgets/doc/images/cleanlooks-timeedit.png | Bin 0 -> 1388 bytes src/widgets/doc/images/cleanlooks-toolbox.png | Bin 0 -> 1445 bytes src/widgets/doc/images/cleanlooks-toolbutton.png | Bin 0 -> 1469 bytes src/widgets/doc/images/cleanlooks-treeview.png | Bin 0 -> 6981 bytes .../doc/images/designer-stylesheet-options.png | Bin 0 -> 18914 bytes .../doc/images/designer-stylesheet-usage.png | Bin 0 -> 8128 bytes .../doc/images/designer-validator-highlighter.png | Bin 0 -> 27153 bytes src/widgets/doc/images/filedialogurls.png | Bin 0 -> 29132 bytes src/widgets/doc/images/frames.png | Bin 0 -> 25735 bytes .../doc/images/graphicsview-ellipseitem-pie.png | Bin 0 -> 6683 bytes .../doc/images/graphicsview-ellipseitem.png | Bin 0 -> 5801 bytes src/widgets/doc/images/graphicsview-items.png | Bin 0 -> 62593 bytes src/widgets/doc/images/graphicsview-pathitem.png | Bin 0 -> 5710 bytes src/widgets/doc/images/graphicsview-pixmapitem.png | Bin 0 -> 10764 bytes .../doc/images/graphicsview-polygonitem.png | Bin 0 -> 5829 bytes src/widgets/doc/images/graphicsview-rectitem.png | Bin 0 -> 3305 bytes src/widgets/doc/images/graphicsview-zorder.png | Bin 0 -> 6724 bytes src/widgets/doc/images/gridlayout.png | Bin 0 -> 1445 bytes src/widgets/doc/images/gtk-calendarwidget.png | Bin 0 -> 16761 bytes src/widgets/doc/images/gtk-checkbox.png | Bin 0 -> 2323 bytes src/widgets/doc/images/gtk-combobox.png | Bin 0 -> 2730 bytes src/widgets/doc/images/gtk-dateedit.png | Bin 0 -> 2163 bytes src/widgets/doc/images/gtk-datetimeedit.png | Bin 0 -> 2923 bytes src/widgets/doc/images/gtk-dial.png | Bin 0 -> 7221 bytes src/widgets/doc/images/gtk-doublespinbox.png | Bin 0 -> 2325 bytes src/widgets/doc/images/gtk-fontcombobox.png | Bin 0 -> 3022 bytes src/widgets/doc/images/gtk-frame.png | Bin 0 -> 2340 bytes src/widgets/doc/images/gtk-groupbox.png | Bin 0 -> 6650 bytes src/widgets/doc/images/gtk-horizontalscrollbar.png | Bin 0 -> 1701 bytes src/widgets/doc/images/gtk-label.png | Bin 0 -> 1582 bytes src/widgets/doc/images/gtk-lcdnumber.png | Bin 0 -> 1193 bytes src/widgets/doc/images/gtk-lineedit.png | Bin 0 -> 2528 bytes src/widgets/doc/images/gtk-listview.png | Bin 0 -> 8493 bytes src/widgets/doc/images/gtk-progressbar.png | Bin 0 -> 2228 bytes src/widgets/doc/images/gtk-pushbutton.png | Bin 0 -> 2153 bytes src/widgets/doc/images/gtk-radiobutton.png | Bin 0 -> 3142 bytes src/widgets/doc/images/gtk-slider.png | Bin 0 -> 1359 bytes src/widgets/doc/images/gtk-spinbox.png | Bin 0 -> 2078 bytes src/widgets/doc/images/gtk-tableview.png | Bin 0 -> 8364 bytes src/widgets/doc/images/gtk-tabwidget.png | Bin 0 -> 8179 bytes src/widgets/doc/images/gtk-textedit.png | Bin 0 -> 12641 bytes src/widgets/doc/images/gtk-timeedit.png | Bin 0 -> 2621 bytes src/widgets/doc/images/gtk-toolbox.png | Bin 0 -> 4240 bytes src/widgets/doc/images/gtk-toolbutton.png | Bin 0 -> 2260 bytes src/widgets/doc/images/gtk-treeview.png | Bin 0 -> 9722 bytes .../doc/images/javastyle/branchindicatorimage.png | Bin 0 -> 18867 bytes src/widgets/doc/images/javastyle/button.png | Bin 0 -> 5475 bytes src/widgets/doc/images/javastyle/checkbox.png | Bin 0 -> 3634 bytes .../doc/images/javastyle/checkboxexample.png | Bin 0 -> 911 bytes src/widgets/doc/images/javastyle/combobox.png | Bin 0 -> 3537 bytes src/widgets/doc/images/javastyle/comboboximage.png | Bin 0 -> 6527 bytes .../images/javastyle/conceptualpushbuttontree.png | Bin 0 -> 3590 bytes src/widgets/doc/images/javastyle/dockwidget.png | Bin 0 -> 7181 bytes .../doc/images/javastyle/dockwidgetimage.png | Bin 0 -> 21774 bytes src/widgets/doc/images/javastyle/groupbox.png | Bin 0 -> 2010 bytes src/widgets/doc/images/javastyle/groupboximage.png | Bin 0 -> 7067 bytes src/widgets/doc/images/javastyle/header.png | Bin 0 -> 4399 bytes src/widgets/doc/images/javastyle/headerimage.png | Bin 0 -> 6474 bytes src/widgets/doc/images/javastyle/menu.png | Bin 0 -> 6508 bytes src/widgets/doc/images/javastyle/menubar.png | Bin 0 -> 4315 bytes src/widgets/doc/images/javastyle/menubarimage.png | Bin 0 -> 4487 bytes src/widgets/doc/images/javastyle/menuimage.png | Bin 0 -> 5584 bytes src/widgets/doc/images/javastyle/progressbar.png | Bin 0 -> 4493 bytes .../doc/images/javastyle/progressbarimage.png | Bin 0 -> 6921 bytes src/widgets/doc/images/javastyle/pushbutton.png | Bin 0 -> 6820 bytes src/widgets/doc/images/javastyle/rubberband.png | Bin 0 -> 765 bytes .../doc/images/javastyle/rubberbandimage.png | Bin 0 -> 6452 bytes src/widgets/doc/images/javastyle/scrollbar.png | Bin 0 -> 7199 bytes .../doc/images/javastyle/scrollbarimage.png | Bin 0 -> 6196 bytes src/widgets/doc/images/javastyle/sizegrip.png | Bin 0 -> 708 bytes src/widgets/doc/images/javastyle/sizegripimage.png | Bin 0 -> 1793 bytes src/widgets/doc/images/javastyle/slider.png | Bin 0 -> 2844 bytes src/widgets/doc/images/javastyle/sliderimage.png | Bin 0 -> 3442 bytes src/widgets/doc/images/javastyle/spinbox.png | Bin 0 -> 2864 bytes src/widgets/doc/images/javastyle/spinboximage.png | Bin 0 -> 4544 bytes src/widgets/doc/images/javastyle/tab.png | Bin 0 -> 12176 bytes src/widgets/doc/images/javastyle/tabwidget.png | Bin 0 -> 4725 bytes src/widgets/doc/images/javastyle/titlebar.png | Bin 0 -> 2609 bytes src/widgets/doc/images/javastyle/titlebarimage.png | Bin 0 -> 6882 bytes src/widgets/doc/images/javastyle/toolbar.png | Bin 0 -> 6303 bytes src/widgets/doc/images/javastyle/toolbarimage.png | Bin 0 -> 8245 bytes src/widgets/doc/images/javastyle/toolbox.png | Bin 0 -> 3211 bytes src/widgets/doc/images/javastyle/toolboximage.png | Bin 0 -> 5580 bytes src/widgets/doc/images/javastyle/toolbutton.png | Bin 0 -> 4487 bytes .../doc/images/javastyle/toolbuttonimage.png | Bin 0 -> 5124 bytes .../doc/images/javastyle/windowstabimage.png | Bin 0 -> 6898 bytes src/widgets/doc/images/licensewizard-flow.png | Bin 0 -> 15306 bytes .../doc/images/macintosh-calendarwidget.png | Bin 0 -> 13560 bytes src/widgets/doc/images/macintosh-checkbox.png | Bin 0 -> 2473 bytes src/widgets/doc/images/macintosh-combobox.png | Bin 0 -> 3273 bytes src/widgets/doc/images/macintosh-dateedit.png | Bin 0 -> 1703 bytes src/widgets/doc/images/macintosh-datetimeedit.png | Bin 0 -> 2633 bytes src/widgets/doc/images/macintosh-dial.png | Bin 0 -> 2563 bytes src/widgets/doc/images/macintosh-doublespinbox.png | Bin 0 -> 2306 bytes src/widgets/doc/images/macintosh-fontcombobox.png | Bin 0 -> 2967 bytes src/widgets/doc/images/macintosh-frame.png | Bin 0 -> 6187 bytes src/widgets/doc/images/macintosh-groupbox.png | Bin 0 -> 6469 bytes .../doc/images/macintosh-horizontalscrollbar.png | Bin 0 -> 2242 bytes src/widgets/doc/images/macintosh-label.png | Bin 0 -> 1450 bytes src/widgets/doc/images/macintosh-lcdnumber.png | Bin 0 -> 492 bytes src/widgets/doc/images/macintosh-lineedit.png | Bin 0 -> 1854 bytes src/widgets/doc/images/macintosh-listview.png | Bin 0 -> 9987 bytes src/widgets/doc/images/macintosh-menu.png | Bin 0 -> 6891 bytes src/widgets/doc/images/macintosh-progressbar.png | Bin 0 -> 1127 bytes src/widgets/doc/images/macintosh-pushbutton.png | Bin 0 -> 2966 bytes src/widgets/doc/images/macintosh-radiobutton.png | Bin 0 -> 2914 bytes src/widgets/doc/images/macintosh-slider.png | Bin 0 -> 1694 bytes src/widgets/doc/images/macintosh-spinbox.png | Bin 0 -> 1964 bytes src/widgets/doc/images/macintosh-tableview.png | Bin 0 -> 10024 bytes src/widgets/doc/images/macintosh-tabwidget.png | Bin 0 -> 9562 bytes src/widgets/doc/images/macintosh-textedit.png | Bin 0 -> 7845 bytes src/widgets/doc/images/macintosh-timeedit.png | Bin 0 -> 2244 bytes src/widgets/doc/images/macintosh-toolbox.png | Bin 0 -> 2576 bytes src/widgets/doc/images/macintosh-toolbutton.png | Bin 0 -> 2003 bytes src/widgets/doc/images/macintosh-treeview.png | Bin 0 -> 11728 bytes src/widgets/doc/images/mainwindow-docks.png | Bin 0 -> 37240 bytes src/widgets/doc/images/mainwindowlayout.png | Bin 0 -> 6782 bytes src/widgets/doc/images/mdi-cascade.png | Bin 0 -> 14590 bytes src/widgets/doc/images/mdi-tile.png | Bin 0 -> 31624 bytes src/widgets/doc/images/motif-calendarwidget.png | Bin 0 -> 9989 bytes src/widgets/doc/images/motif-checkbox.png | Bin 0 -> 1284 bytes src/widgets/doc/images/motif-combobox.png | Bin 0 -> 1276 bytes src/widgets/doc/images/motif-dateedit.png | Bin 0 -> 1214 bytes src/widgets/doc/images/motif-datetimeedit.png | Bin 0 -> 1730 bytes src/widgets/doc/images/motif-dial.png | Bin 0 -> 2017 bytes src/widgets/doc/images/motif-doublespinbox.png | Bin 0 -> 1019 bytes src/widgets/doc/images/motif-fontcombobox.png | Bin 0 -> 1633 bytes src/widgets/doc/images/motif-frame.png | Bin 0 -> 5631 bytes src/widgets/doc/images/motif-groupbox.png | Bin 0 -> 2514 bytes .../doc/images/motif-horizontalscrollbar.png | Bin 0 -> 628 bytes src/widgets/doc/images/motif-label.png | Bin 0 -> 699 bytes src/widgets/doc/images/motif-lcdnumber.png | Bin 0 -> 538 bytes src/widgets/doc/images/motif-lineedit.png | Bin 0 -> 1360 bytes src/widgets/doc/images/motif-listview.png | Bin 0 -> 5189 bytes src/widgets/doc/images/motif-menubar.png | Bin 0 -> 1350 bytes src/widgets/doc/images/motif-progressbar.png | Bin 0 -> 927 bytes src/widgets/doc/images/motif-pushbutton.png | Bin 0 -> 1045 bytes src/widgets/doc/images/motif-radiobutton.png | Bin 0 -> 1545 bytes src/widgets/doc/images/motif-slider.png | Bin 0 -> 543 bytes src/widgets/doc/images/motif-spinbox.png | Bin 0 -> 875 bytes src/widgets/doc/images/motif-tableview.png | Bin 0 -> 3102 bytes src/widgets/doc/images/motif-tabwidget.png | Bin 0 -> 2490 bytes src/widgets/doc/images/motif-textedit.png | Bin 0 -> 7378 bytes src/widgets/doc/images/motif-timeedit.png | Bin 0 -> 1280 bytes src/widgets/doc/images/motif-toolbox.png | Bin 0 -> 1667 bytes src/widgets/doc/images/motif-toolbutton.png | Bin 0 -> 1152 bytes src/widgets/doc/images/motif-treeview.png | Bin 0 -> 6386 bytes src/widgets/doc/images/msgbox1.png | Bin 0 -> 4529 bytes src/widgets/doc/images/msgbox2.png | Bin 0 -> 9175 bytes src/widgets/doc/images/msgbox3.png | Bin 0 -> 9589 bytes src/widgets/doc/images/msgbox4.png | Bin 0 -> 17520 bytes src/widgets/doc/images/pangesture.png | Bin 0 -> 7153 bytes src/widgets/doc/images/parent-child-widgets.png | Bin 0 -> 47824 bytes src/widgets/doc/images/pinchgesture.png | Bin 0 -> 10094 bytes .../doc/images/plastique-calendarwidget.png | Bin 0 -> 9629 bytes src/widgets/doc/images/plastique-checkbox.png | Bin 0 -> 1069 bytes src/widgets/doc/images/plastique-colordialog.png | Bin 0 -> 22595 bytes src/widgets/doc/images/plastique-combobox.png | Bin 0 -> 1714 bytes src/widgets/doc/images/plastique-dateedit.png | Bin 0 -> 1271 bytes src/widgets/doc/images/plastique-datetimeedit.png | Bin 0 -> 1771 bytes src/widgets/doc/images/plastique-dial.png | Bin 0 -> 2995 bytes src/widgets/doc/images/plastique-doublespinbox.png | Bin 0 -> 1102 bytes src/widgets/doc/images/plastique-fontcombobox.png | Bin 0 -> 1904 bytes src/widgets/doc/images/plastique-fontdialog.png | Bin 0 -> 23835 bytes src/widgets/doc/images/plastique-frame.png | Bin 0 -> 5616 bytes src/widgets/doc/images/plastique-groupbox.png | Bin 0 -> 2704 bytes .../doc/images/plastique-horizontalscrollbar.png | Bin 0 -> 868 bytes src/widgets/doc/images/plastique-label.png | Bin 0 -> 696 bytes src/widgets/doc/images/plastique-lcdnumber.png | Bin 0 -> 470 bytes src/widgets/doc/images/plastique-lineedit.png | Bin 0 -> 1015 bytes src/widgets/doc/images/plastique-listview.png | Bin 0 -> 4895 bytes src/widgets/doc/images/plastique-menu.png | Bin 0 -> 3867 bytes src/widgets/doc/images/plastique-menubar.png | Bin 0 -> 1030 bytes src/widgets/doc/images/plastique-progressbar.png | Bin 0 -> 1044 bytes .../doc/images/plastique-progressdialog.png | Bin 0 -> 6311 bytes .../doc/images/plastique-pushbutton-menu.png | Bin 0 -> 3354 bytes src/widgets/doc/images/plastique-pushbutton.png | Bin 0 -> 1409 bytes src/widgets/doc/images/plastique-radiobutton.png | Bin 0 -> 1667 bytes src/widgets/doc/images/plastique-sizegrip.png | Bin 0 -> 8168 bytes src/widgets/doc/images/plastique-slider.png | Bin 0 -> 632 bytes src/widgets/doc/images/plastique-spinbox.png | Bin 0 -> 968 bytes src/widgets/doc/images/plastique-statusbar.png | Bin 0 -> 878 bytes .../doc/images/plastique-tabbar-truncated.png | Bin 0 -> 2986 bytes src/widgets/doc/images/plastique-tabbar.png | Bin 0 -> 2721 bytes src/widgets/doc/images/plastique-tableview.png | Bin 0 -> 6052 bytes src/widgets/doc/images/plastique-tabwidget.png | Bin 0 -> 4705 bytes src/widgets/doc/images/plastique-textedit.png | Bin 0 -> 5141 bytes src/widgets/doc/images/plastique-timeedit.png | Bin 0 -> 1336 bytes src/widgets/doc/images/plastique-toolbox.png | Bin 0 -> 1858 bytes src/widgets/doc/images/plastique-toolbutton.png | Bin 0 -> 1254 bytes src/widgets/doc/images/plastique-treeview.png | Bin 0 -> 8453 bytes src/widgets/doc/images/progressBar-stylesheet.png | Bin 0 -> 455 bytes src/widgets/doc/images/progressBar2-stylesheet.png | Bin 0 -> 494 bytes src/widgets/doc/images/propagation-custom.png | Bin 0 -> 163413 bytes src/widgets/doc/images/propagation-standard.png | Bin 0 -> 83382 bytes src/widgets/doc/images/qcalendarwidget-grid.png | Bin 0 -> 9601 bytes src/widgets/doc/images/qcalendarwidget-maximum.png | Bin 0 -> 9709 bytes src/widgets/doc/images/qcalendarwidget-minimum.png | Bin 0 -> 9770 bytes src/widgets/doc/images/qcolumnview.png | Bin 0 -> 3075 bytes src/widgets/doc/images/qdesktopwidget.png | Bin 0 -> 42328 bytes src/widgets/doc/images/qformlayout-kde.png | Bin 0 -> 1703 bytes src/widgets/doc/images/qformlayout-mac.png | Bin 0 -> 1706 bytes src/widgets/doc/images/qformlayout-qpe.png | Bin 0 -> 1764 bytes src/widgets/doc/images/qformlayout-win.png | Bin 0 -> 1743 bytes .../doc/images/qformlayout-with-6-children.png | Bin 0 -> 3264 bytes .../doc/images/qgraphicsproxywidget-embed.png | Bin 0 -> 2199 bytes .../doc/images/qgridlayout-with-5-children.png | Bin 0 -> 3201 bytes .../doc/images/qhboxlayout-with-5-children.png | Bin 0 -> 2652 bytes src/widgets/doc/images/qmdisubwindowlayout.png | Bin 0 -> 3153 bytes .../doc/images/qscrollarea-noscrollbars.png | Bin 0 -> 54671 bytes .../doc/images/qscrollarea-onescrollbar.png | Bin 0 -> 77476 bytes .../doc/images/qscrollarea-twoscrollbars.png | Bin 0 -> 78046 bytes src/widgets/doc/images/qscrollbar-picture.png | Bin 0 -> 6568 bytes src/widgets/doc/images/qscrollbar-values.png | Bin 0 -> 15902 bytes src/widgets/doc/images/qspinbox-plusminus.png | Bin 0 -> 375 bytes src/widgets/doc/images/qspinbox-updown.png | Bin 0 -> 402 bytes src/widgets/doc/images/qstyle-comboboxes.png | Bin 0 -> 19437 bytes .../doc/images/qstyleoptiontoolbar-position.png | Bin 0 -> 13707 bytes src/widgets/doc/images/qtableview-resized.png | Bin 0 -> 42232 bytes src/widgets/doc/images/qtwizard-aero1.png | Bin 0 -> 11749 bytes src/widgets/doc/images/qtwizard-aero2.png | Bin 0 -> 16560 bytes src/widgets/doc/images/qtwizard-classic1.png | Bin 0 -> 39640 bytes src/widgets/doc/images/qtwizard-classic2.png | Bin 0 -> 8616 bytes src/widgets/doc/images/qtwizard-mac1.png | Bin 0 -> 25478 bytes src/widgets/doc/images/qtwizard-mac2.png | Bin 0 -> 29591 bytes src/widgets/doc/images/qtwizard-macpage.png | Bin 0 -> 23095 bytes src/widgets/doc/images/qtwizard-modern1.png | Bin 0 -> 45093 bytes src/widgets/doc/images/qtwizard-modern2.png | Bin 0 -> 15081 bytes src/widgets/doc/images/qtwizard-nonmacpage.png | Bin 0 -> 26557 bytes src/widgets/doc/images/qundoview.png | Bin 0 -> 5993 bytes .../doc/images/qvboxlayout-with-5-children.png | Bin 0 -> 2974 bytes .../doc/images/simpleanchorlayout-example.png | Bin 0 -> 13463 bytes .../doc/images/stylesheet-border-image-normal.png | Bin 0 -> 5769 bytes .../images/stylesheet-border-image-stretched.png | Bin 0 -> 12170 bytes .../doc/images/stylesheet-border-image-wrong.png | Bin 0 -> 12887 bytes src/widgets/doc/images/stylesheet-boxmodel.png | Bin 0 -> 18144 bytes .../doc/images/stylesheet-branch-closed.png | Bin 0 -> 334 bytes src/widgets/doc/images/stylesheet-branch-end.png | Bin 0 -> 182 bytes src/widgets/doc/images/stylesheet-branch-more.png | Bin 0 -> 136 bytes src/widgets/doc/images/stylesheet-branch-open.png | Bin 0 -> 346 bytes .../doc/images/stylesheet-coffee-cleanlooks.png | Bin 0 -> 14820 bytes src/widgets/doc/images/stylesheet-coffee-xp.png | Bin 0 -> 14200 bytes src/widgets/doc/images/stylesheet-pagefold-mac.png | Bin 0 -> 20618 bytes src/widgets/doc/images/stylesheet-pagefold.png | Bin 0 -> 15989 bytes src/widgets/doc/images/stylesheet-redbutton1.png | Bin 0 -> 378 bytes src/widgets/doc/images/stylesheet-redbutton2.png | Bin 0 -> 410 bytes src/widgets/doc/images/stylesheet-redbutton3.png | Bin 0 -> 664 bytes src/widgets/doc/images/stylesheet-scrollbar1.png | Bin 0 -> 150 bytes src/widgets/doc/images/stylesheet-scrollbar2.png | Bin 0 -> 169 bytes src/widgets/doc/images/stylesheet-treeview.png | Bin 0 -> 2412 bytes src/widgets/doc/images/stylesheet-vline.png | Bin 0 -> 124 bytes src/widgets/doc/images/swipegesture.png | Bin 0 -> 6864 bytes src/widgets/doc/images/system-tray.png | Bin 0 -> 6326 bytes src/widgets/doc/images/tabWidget-stylesheet1.png | Bin 0 -> 1321 bytes src/widgets/doc/images/tabWidget-stylesheet2.png | Bin 0 -> 1434 bytes src/widgets/doc/images/tabWidget-stylesheet3.png | Bin 0 -> 1206 bytes src/widgets/doc/images/tableWidget-stylesheet.png | Bin 0 -> 3478 bytes src/widgets/doc/images/widgetdelegate.png | Bin 0 -> 7449 bytes src/widgets/doc/images/windows-calendarwidget.png | Bin 0 -> 5055 bytes src/widgets/doc/images/windows-checkbox.png | Bin 0 -> 929 bytes src/widgets/doc/images/windows-combobox.png | Bin 0 -> 1002 bytes src/widgets/doc/images/windows-dateedit.png | Bin 0 -> 817 bytes src/widgets/doc/images/windows-datetimeedit.png | Bin 0 -> 1026 bytes src/widgets/doc/images/windows-dial.png | Bin 0 -> 4598 bytes src/widgets/doc/images/windows-doublespinbox.png | Bin 0 -> 762 bytes src/widgets/doc/images/windows-fontcombobox.png | Bin 0 -> 1022 bytes src/widgets/doc/images/windows-frame.png | Bin 0 -> 1837 bytes src/widgets/doc/images/windows-groupbox.png | Bin 0 -> 1617 bytes .../doc/images/windows-horizontalscrollbar.png | Bin 0 -> 566 bytes src/widgets/doc/images/windows-label.png | Bin 0 -> 696 bytes src/widgets/doc/images/windows-lcdnumber.png | Bin 0 -> 491 bytes src/widgets/doc/images/windows-lineedit.png | Bin 0 -> 884 bytes src/widgets/doc/images/windows-listview.png | Bin 0 -> 2781 bytes src/widgets/doc/images/windows-progressbar.png | Bin 0 -> 674 bytes src/widgets/doc/images/windows-pushbutton.png | Bin 0 -> 722 bytes src/widgets/doc/images/windows-radiobutton.png | Bin 0 -> 1005 bytes src/widgets/doc/images/windows-slider.png | Bin 0 -> 485 bytes src/widgets/doc/images/windows-spinbox.png | Bin 0 -> 667 bytes src/widgets/doc/images/windows-tableview.png | Bin 0 -> 1738 bytes src/widgets/doc/images/windows-tabwidget.png | Bin 0 -> 1707 bytes src/widgets/doc/images/windows-textedit.png | Bin 0 -> 3192 bytes src/widgets/doc/images/windows-timeedit.png | Bin 0 -> 873 bytes src/widgets/doc/images/windows-toolbox.png | Bin 0 -> 925 bytes src/widgets/doc/images/windows-toolbutton.png | Bin 0 -> 771 bytes src/widgets/doc/images/windows-treeview.png | Bin 0 -> 2723 bytes .../doc/images/windowsvista-calendarwidget.png | Bin 0 -> 5144 bytes src/widgets/doc/images/windowsvista-checkbox.png | Bin 0 -> 1115 bytes src/widgets/doc/images/windowsvista-combobox.png | Bin 0 -> 1457 bytes src/widgets/doc/images/windowsvista-dateedit.png | Bin 0 -> 855 bytes .../doc/images/windowsvista-datetimeedit.png | Bin 0 -> 1034 bytes src/widgets/doc/images/windowsvista-dial.png | Bin 0 -> 2431 bytes .../doc/images/windowsvista-doublespinbox.png | Bin 0 -> 852 bytes .../doc/images/windowsvista-fontcombobox.png | Bin 0 -> 919 bytes src/widgets/doc/images/windowsvista-frame.png | Bin 0 -> 1800 bytes src/widgets/doc/images/windowsvista-groupbox.png | Bin 0 -> 1991 bytes .../images/windowsvista-horizontalscrollbar.png | Bin 0 -> 1049 bytes src/widgets/doc/images/windowsvista-label.png | Bin 0 -> 599 bytes src/widgets/doc/images/windowsvista-lcdnumber.png | Bin 0 -> 491 bytes src/widgets/doc/images/windowsvista-lineedit.png | Bin 0 -> 873 bytes src/widgets/doc/images/windowsvista-listview.png | Bin 0 -> 6872 bytes .../doc/images/windowsvista-progressbar.png | Bin 0 -> 1437 bytes src/widgets/doc/images/windowsvista-pushbutton.png | Bin 0 -> 1085 bytes .../doc/images/windowsvista-radiobutton.png | Bin 0 -> 1266 bytes src/widgets/doc/images/windowsvista-slider.png | Bin 0 -> 624 bytes src/widgets/doc/images/windowsvista-spinbox.png | Bin 0 -> 767 bytes src/widgets/doc/images/windowsvista-tableview.png | Bin 0 -> 3941 bytes src/widgets/doc/images/windowsvista-tabwidget.png | Bin 0 -> 3286 bytes src/widgets/doc/images/windowsvista-textedit.png | Bin 0 -> 3122 bytes src/widgets/doc/images/windowsvista-timeedit.png | Bin 0 -> 764 bytes src/widgets/doc/images/windowsvista-toolbox.png | Bin 0 -> 891 bytes src/widgets/doc/images/windowsvista-toolbutton.png | Bin 0 -> 981 bytes src/widgets/doc/images/windowsvista-treeview.png | Bin 0 -> 5760 bytes .../doc/images/windowsxp-calendarwidget.png | Bin 0 -> 5009 bytes src/widgets/doc/images/windowsxp-checkbox.png | Bin 0 -> 1006 bytes src/widgets/doc/images/windowsxp-combobox.png | Bin 0 -> 1450 bytes src/widgets/doc/images/windowsxp-dateedit.png | Bin 0 -> 1107 bytes src/widgets/doc/images/windowsxp-datetimeedit.png | Bin 0 -> 1321 bytes src/widgets/doc/images/windowsxp-dial.png | Bin 0 -> 4598 bytes src/widgets/doc/images/windowsxp-doublespinbox.png | Bin 0 -> 1065 bytes src/widgets/doc/images/windowsxp-fontcombobox.png | Bin 0 -> 1408 bytes src/widgets/doc/images/windowsxp-frame.png | Bin 0 -> 1837 bytes src/widgets/doc/images/windowsxp-groupbox.png | Bin 0 -> 2016 bytes .../doc/images/windowsxp-horizontalscrollbar.png | Bin 0 -> 1498 bytes src/widgets/doc/images/windowsxp-label.png | Bin 0 -> 696 bytes src/widgets/doc/images/windowsxp-lcdnumber.png | Bin 0 -> 493 bytes src/widgets/doc/images/windowsxp-lineedit.png | Bin 0 -> 861 bytes src/widgets/doc/images/windowsxp-listview.png | Bin 0 -> 5391 bytes src/widgets/doc/images/windowsxp-menu.png | Bin 0 -> 1442 bytes src/widgets/doc/images/windowsxp-progressbar.png | Bin 0 -> 1007 bytes src/widgets/doc/images/windowsxp-pushbutton.png | Bin 0 -> 1462 bytes src/widgets/doc/images/windowsxp-radiobutton.png | Bin 0 -> 1270 bytes src/widgets/doc/images/windowsxp-slider.png | Bin 0 -> 732 bytes src/widgets/doc/images/windowsxp-spinbox.png | Bin 0 -> 974 bytes src/widgets/doc/images/windowsxp-tableview.png | Bin 0 -> 3204 bytes src/widgets/doc/images/windowsxp-tabwidget.png | Bin 0 -> 5220 bytes src/widgets/doc/images/windowsxp-textedit.png | Bin 0 -> 3159 bytes src/widgets/doc/images/windowsxp-timeedit.png | Bin 0 -> 1172 bytes src/widgets/doc/images/windowsxp-toolbox.png | Bin 0 -> 925 bytes src/widgets/doc/images/windowsxp-toolbutton.png | Bin 0 -> 1549 bytes src/widgets/doc/images/windowsxp-treeview.png | Bin 0 -> 5795 bytes src/widgets/doc/qtwidgets.qdocconf | 92 + src/widgets/doc/snippets/code/doc_src_layout.cpp | 166 + .../doc/snippets/code/doc_src_qt4-styles.cpp | 82 + .../doc/snippets/code/doc_src_qtwidgets.cpp | 43 + .../doc/snippets/code/doc_src_qtwidgets.pro | 43 + src/widgets/doc/snippets/code/doc_src_styles.cpp | 134 + .../doc/snippets/code/doc_src_stylesheet.cpp | 140 + .../doc/snippets/code/doc_src_stylesheet.qdoc | 1866 +++++++++ .../snippets/code/src_gui_dialogs_qfiledialog.cpp | 131 + .../snippets/code/src_gui_dialogs_qfontdialog.cpp | 85 + .../snippets/code/src_gui_dialogs_qmessagebox.cpp | 148 + .../doc/snippets/code/src_gui_dialogs_qwizard.cpp | 80 + .../code/src_gui_effects_qgraphicseffect.cpp | 83 + .../src_gui_graphicsview_qgraphicsgridlayout.cpp | 53 + .../code/src_gui_graphicsview_qgraphicsitem.cpp | 278 ++ .../src_gui_graphicsview_qgraphicslinearlayout.cpp | 53 + .../src_gui_graphicsview_qgraphicsproxywidget.cpp | 87 + .../code/src_gui_graphicsview_qgraphicsscene.cpp | 122 + .../src_gui_graphicsview_qgraphicssceneevent.cpp | 45 + .../code/src_gui_graphicsview_qgraphicsview.cpp | 132 + .../code/src_gui_graphicsview_qgraphicswidget.cpp | 66 + .../doc/snippets/code/src_gui_image_qicon.cpp | 71 + .../snippets/code/src_gui_image_qpixmapfilter.cpp | 62 + .../code/src_gui_itemviews_qabstractitemview.cpp | 58 + .../code/src_gui_itemviews_qdatawidgetmapper.cpp | 63 + .../code/src_gui_itemviews_qitemeditorfactory.cpp | 63 + .../code/src_gui_itemviews_qstandarditemmodel.cpp | 82 + .../code/src_gui_itemviews_qtablewidget.cpp | 45 + .../code/src_gui_itemviews_qtreewidget.cpp | 48 + .../doc/snippets/code/src_gui_kernel_qaction.cpp | 49 + .../snippets/code/src_gui_kernel_qapplication.cpp | 183 + .../snippets/code/src_gui_kernel_qformlayout.cpp | 76 + .../doc/snippets/code/src_gui_kernel_qlayout.cpp | 67 + .../snippets/code/src_gui_kernel_qlayoutitem.cpp | 53 + .../doc/snippets/code/src_gui_kernel_qshortcut.cpp | 55 + .../doc/snippets/code/src_gui_kernel_qwidget.cpp | 137 + .../snippets/code/src_gui_painting_qdrawutil.cpp | 98 + .../doc/snippets/code/src_gui_qproxystyle.cpp | 85 + .../doc/snippets/code/src_gui_styles_qstyle.cpp | 48 + .../snippets/code/src_gui_styles_qstyleoption.cpp | 54 + .../doc/snippets/code/src_gui_util_qcompleter.cpp | 63 + .../doc/snippets/code/src_gui_util_qundostack.cpp | 109 + .../code/src_gui_widgets_qabstractbutton.cpp | 60 + .../code/src_gui_widgets_qabstractspinbox.cpp | 48 + .../code/src_gui_widgets_qcalendarwidget.cpp | 79 + .../snippets/code/src_gui_widgets_qcheckbox.cpp | 43 + .../code/src_gui_widgets_qdatetimeedit.cpp | 79 + .../snippets/code/src_gui_widgets_qdockwidget.cpp | 48 + .../doc/snippets/code/src_gui_widgets_qframe.cpp | 48 + .../snippets/code/src_gui_widgets_qgroupbox.cpp | 43 + .../doc/snippets/code/src_gui_widgets_qlabel.cpp | 64 + .../snippets/code/src_gui_widgets_qlineedit.cpp | 50 + .../snippets/code/src_gui_widgets_qmainwindow.cpp | 59 + .../doc/snippets/code/src_gui_widgets_qmenu.cpp | 77 + .../doc/snippets/code/src_gui_widgets_qmenubar.cpp | 48 + .../code/src_gui_widgets_qplaintextedit.cpp | 55 + .../snippets/code/src_gui_widgets_qpushbutton.cpp | 43 + .../snippets/code/src_gui_widgets_qradiobutton.cpp | 43 + .../snippets/code/src_gui_widgets_qrubberband.cpp | 62 + .../snippets/code/src_gui_widgets_qscrollarea.cpp | 49 + .../doc/snippets/code/src_gui_widgets_qspinbox.cpp | 80 + .../code/src_gui_widgets_qsplashscreen.cpp | 55 + .../snippets/code/src_gui_widgets_qsplitter.cpp | 47 + .../snippets/code/src_gui_widgets_qstatusbar.cpp | 43 + .../snippets/code/src_gui_widgets_qtextbrowser.cpp | 44 + .../snippets/code/src_gui_widgets_qtextedit.cpp | 60 + .../doc/snippets/customstyle/customstyle.cpp | 92 + src/widgets/doc/snippets/customstyle/customstyle.h | 60 + .../doc/snippets/customstyle/customstyle.pro | 2 + src/widgets/doc/snippets/customstyle/main.cpp | 54 + src/widgets/doc/snippets/customviewstyle.cpp | 69 + src/widgets/doc/snippets/dialogs/dialogs.cpp | 268 ++ src/widgets/doc/snippets/filedialogurls.cpp | 61 + .../doc/snippets/graphicssceneadditemsnippet.cpp | 80 + src/widgets/doc/snippets/javastyle.cpp | 2745 ++++++++++++++ src/widgets/doc/snippets/layouts/layouts.cpp | 165 + src/widgets/doc/snippets/mainwindowsnippet.cpp | 92 + src/widgets/doc/snippets/mdiareasnippets.cpp | 97 + src/widgets/doc/snippets/myscrollarea.cpp | 128 + .../doc/snippets/qlistwidget-using/mainwindow.cpp | 158 + src/widgets/doc/snippets/qmacnativewidget/main.mm | 84 + src/widgets/doc/snippets/qsplashscreen/main.cpp | 63 + src/widgets/doc/snippets/qstackedlayout/main.cpp | 89 + src/widgets/doc/snippets/qstackedwidget/main.cpp | 87 + src/widgets/doc/snippets/qstyleoption/main.cpp | 139 + src/widgets/doc/snippets/qstyleplugin/main.cpp | 97 + .../snippets/qtablewidget-resizing/mainwindow.cpp | 115 + .../doc/snippets/qtablewidget-using/mainwindow.cpp | 150 + .../doc/snippets/qtreewidget-using/mainwindow.cpp | 230 ++ .../qtreewidgetitemiterator-using/mainwindow.cpp | 197 + src/widgets/doc/snippets/shareddirmodel/main.cpp | 81 + src/widgets/doc/snippets/splitter/splitter.cpp | 84 + .../doc/snippets/splitterhandle/splitter.cpp | 78 + src/widgets/doc/snippets/splitterhandle/splitter.h | 73 + src/widgets/doc/snippets/styles/styles.cpp | 91 + .../doc/snippets/stylesheet/common-mistakes.cpp | 52 + .../snippets/textdocument-imagedrop/textedit.cpp | 71 + src/widgets/doc/snippets/timeline/main.cpp | 72 + src/widgets/doc/snippets/whatsthis/whatsthis.cpp | 64 + src/widgets/doc/snippets/widget-mask/main.cpp | 54 + src/widgets/doc/snippets/widgetdelegate.cpp | 66 + src/widgets/doc/src/qtwidgets.qdoc | 45 + src/widgets/doc/src/widgets-and-layouts/focus.qdoc | 186 + .../doc/src/widgets-and-layouts/gallery-cde.qdoc | 133 + .../widgets-and-layouts/gallery-cleanlooks.qdoc | 138 + .../doc/src/widgets-and-layouts/gallery-gtk.qdoc | 141 + .../src/widgets-and-layouts/gallery-macintosh.qdoc | 138 + .../doc/src/widgets-and-layouts/gallery-motif.qdoc | 138 + .../src/widgets-and-layouts/gallery-plastique.qdoc | 138 + .../src/widgets-and-layouts/gallery-windows.qdoc | 138 + .../widgets-and-layouts/gallery-windowsvista.qdoc | 138 + .../src/widgets-and-layouts/gallery-windowsxp.qdoc | 138 + .../doc/src/widgets-and-layouts/gallery.qdoc | 84 + .../doc/src/widgets-and-layouts/layout.qdoc | 396 ++ .../doc/src/widgets-and-layouts/styles.qdoc | 2102 +++++++++++ .../doc/src/widgets-and-layouts/stylesheet.qdoc | 3963 ++++++++++++++++++++ .../doc/src/widgets-and-layouts/widgets.qdoc | 162 + 521 files changed, 21111 insertions(+) create mode 100644 src/widgets/doc/images/assistant-toolbar.png create mode 100644 src/widgets/doc/images/buttonbox-gnomelayout-horizontal.png create mode 100644 src/widgets/doc/images/buttonbox-gnomelayout-vertical.png create mode 100644 src/widgets/doc/images/buttonbox-kdelayout-horizontal.png create mode 100644 src/widgets/doc/images/buttonbox-kdelayout-vertical.png create mode 100644 src/widgets/doc/images/buttonbox-mac-modeless-horizontal.png create mode 100644 src/widgets/doc/images/buttonbox-mac-modeless-vertical.png create mode 100644 src/widgets/doc/images/buttonbox-maclayout-horizontal.png create mode 100644 src/widgets/doc/images/buttonbox-maclayout-vertical.png create mode 100644 src/widgets/doc/images/buttonbox-winlayout-horizontal.png create mode 100644 src/widgets/doc/images/buttonbox-winlayout-vertical.png create mode 100644 src/widgets/doc/images/cde-calendarwidget.png create mode 100644 src/widgets/doc/images/cde-checkbox.png create mode 100644 src/widgets/doc/images/cde-combobox.png create mode 100644 src/widgets/doc/images/cde-dateedit.png create mode 100644 src/widgets/doc/images/cde-datetimeedit.png create mode 100644 src/widgets/doc/images/cde-dial.png create mode 100644 src/widgets/doc/images/cde-doublespinbox.png create mode 100644 src/widgets/doc/images/cde-fontcombobox.png create mode 100644 src/widgets/doc/images/cde-frame.png create mode 100644 src/widgets/doc/images/cde-groupbox.png create mode 100644 src/widgets/doc/images/cde-horizontalscrollbar.png create mode 100644 src/widgets/doc/images/cde-label.png create mode 100644 src/widgets/doc/images/cde-lcdnumber.png create mode 100644 src/widgets/doc/images/cde-lineedit.png create mode 100644 src/widgets/doc/images/cde-listview.png create mode 100644 src/widgets/doc/images/cde-progressbar.png create mode 100644 src/widgets/doc/images/cde-pushbutton.png create mode 100644 src/widgets/doc/images/cde-radiobutton.png create mode 100644 src/widgets/doc/images/cde-slider.png create mode 100644 src/widgets/doc/images/cde-spinbox.png create mode 100644 src/widgets/doc/images/cde-tableview.png create mode 100644 src/widgets/doc/images/cde-tabwidget.png create mode 100644 src/widgets/doc/images/cde-textedit.png create mode 100644 src/widgets/doc/images/cde-timeedit.png create mode 100644 src/widgets/doc/images/cde-toolbox.png create mode 100644 src/widgets/doc/images/cde-toolbutton.png create mode 100644 src/widgets/doc/images/cde-treeview.png create mode 100644 src/widgets/doc/images/checkboxes-exclusive.png create mode 100644 src/widgets/doc/images/checkboxes-non-exclusive.png create mode 100644 src/widgets/doc/images/cleanlooks-calendarwidget.png create mode 100644 src/widgets/doc/images/cleanlooks-checkbox.png create mode 100644 src/widgets/doc/images/cleanlooks-combobox.png create mode 100644 src/widgets/doc/images/cleanlooks-dateedit.png create mode 100644 src/widgets/doc/images/cleanlooks-datetimeedit.png create mode 100644 src/widgets/doc/images/cleanlooks-dial.png create mode 100644 src/widgets/doc/images/cleanlooks-doublespinbox.png create mode 100644 src/widgets/doc/images/cleanlooks-fontcombobox.png create mode 100644 src/widgets/doc/images/cleanlooks-frame.png create mode 100644 src/widgets/doc/images/cleanlooks-groupbox.png create mode 100644 src/widgets/doc/images/cleanlooks-horizontalscrollbar.png create mode 100644 src/widgets/doc/images/cleanlooks-label.png create mode 100644 src/widgets/doc/images/cleanlooks-lcdnumber.png create mode 100644 src/widgets/doc/images/cleanlooks-lineedit.png create mode 100644 src/widgets/doc/images/cleanlooks-listview.png create mode 100644 src/widgets/doc/images/cleanlooks-progressbar.png create mode 100644 src/widgets/doc/images/cleanlooks-pushbutton-menu.png create mode 100644 src/widgets/doc/images/cleanlooks-pushbutton.png create mode 100644 src/widgets/doc/images/cleanlooks-radiobutton.png create mode 100644 src/widgets/doc/images/cleanlooks-slider.png create mode 100644 src/widgets/doc/images/cleanlooks-spinbox.png create mode 100644 src/widgets/doc/images/cleanlooks-tableview.png create mode 100644 src/widgets/doc/images/cleanlooks-tabwidget.png create mode 100644 src/widgets/doc/images/cleanlooks-textedit.png create mode 100644 src/widgets/doc/images/cleanlooks-timeedit.png create mode 100644 src/widgets/doc/images/cleanlooks-toolbox.png create mode 100644 src/widgets/doc/images/cleanlooks-toolbutton.png create mode 100644 src/widgets/doc/images/cleanlooks-treeview.png create mode 100644 src/widgets/doc/images/designer-stylesheet-options.png create mode 100644 src/widgets/doc/images/designer-stylesheet-usage.png create mode 100644 src/widgets/doc/images/designer-validator-highlighter.png create mode 100644 src/widgets/doc/images/filedialogurls.png create mode 100644 src/widgets/doc/images/frames.png create mode 100644 src/widgets/doc/images/graphicsview-ellipseitem-pie.png create mode 100644 src/widgets/doc/images/graphicsview-ellipseitem.png create mode 100644 src/widgets/doc/images/graphicsview-items.png create mode 100644 src/widgets/doc/images/graphicsview-pathitem.png create mode 100644 src/widgets/doc/images/graphicsview-pixmapitem.png create mode 100644 src/widgets/doc/images/graphicsview-polygonitem.png create mode 100644 src/widgets/doc/images/graphicsview-rectitem.png create mode 100644 src/widgets/doc/images/graphicsview-zorder.png create mode 100644 src/widgets/doc/images/gridlayout.png create mode 100644 src/widgets/doc/images/gtk-calendarwidget.png create mode 100644 src/widgets/doc/images/gtk-checkbox.png create mode 100644 src/widgets/doc/images/gtk-combobox.png create mode 100644 src/widgets/doc/images/gtk-dateedit.png create mode 100644 src/widgets/doc/images/gtk-datetimeedit.png create mode 100644 src/widgets/doc/images/gtk-dial.png create mode 100644 src/widgets/doc/images/gtk-doublespinbox.png create mode 100644 src/widgets/doc/images/gtk-fontcombobox.png create mode 100644 src/widgets/doc/images/gtk-frame.png create mode 100644 src/widgets/doc/images/gtk-groupbox.png create mode 100644 src/widgets/doc/images/gtk-horizontalscrollbar.png create mode 100644 src/widgets/doc/images/gtk-label.png create mode 100644 src/widgets/doc/images/gtk-lcdnumber.png create mode 100644 src/widgets/doc/images/gtk-lineedit.png create mode 100644 src/widgets/doc/images/gtk-listview.png create mode 100644 src/widgets/doc/images/gtk-progressbar.png create mode 100644 src/widgets/doc/images/gtk-pushbutton.png create mode 100644 src/widgets/doc/images/gtk-radiobutton.png create mode 100644 src/widgets/doc/images/gtk-slider.png create mode 100644 src/widgets/doc/images/gtk-spinbox.png create mode 100644 src/widgets/doc/images/gtk-tableview.png create mode 100644 src/widgets/doc/images/gtk-tabwidget.png create mode 100644 src/widgets/doc/images/gtk-textedit.png create mode 100644 src/widgets/doc/images/gtk-timeedit.png create mode 100644 src/widgets/doc/images/gtk-toolbox.png create mode 100644 src/widgets/doc/images/gtk-toolbutton.png create mode 100644 src/widgets/doc/images/gtk-treeview.png create mode 100644 src/widgets/doc/images/javastyle/branchindicatorimage.png create mode 100644 src/widgets/doc/images/javastyle/button.png create mode 100644 src/widgets/doc/images/javastyle/checkbox.png create mode 100644 src/widgets/doc/images/javastyle/checkboxexample.png create mode 100644 src/widgets/doc/images/javastyle/combobox.png create mode 100644 src/widgets/doc/images/javastyle/comboboximage.png create mode 100644 src/widgets/doc/images/javastyle/conceptualpushbuttontree.png create mode 100644 src/widgets/doc/images/javastyle/dockwidget.png create mode 100644 src/widgets/doc/images/javastyle/dockwidgetimage.png create mode 100644 src/widgets/doc/images/javastyle/groupbox.png create mode 100644 src/widgets/doc/images/javastyle/groupboximage.png create mode 100644 src/widgets/doc/images/javastyle/header.png create mode 100644 src/widgets/doc/images/javastyle/headerimage.png create mode 100644 src/widgets/doc/images/javastyle/menu.png create mode 100644 src/widgets/doc/images/javastyle/menubar.png create mode 100644 src/widgets/doc/images/javastyle/menubarimage.png create mode 100644 src/widgets/doc/images/javastyle/menuimage.png create mode 100644 src/widgets/doc/images/javastyle/progressbar.png create mode 100644 src/widgets/doc/images/javastyle/progressbarimage.png create mode 100644 src/widgets/doc/images/javastyle/pushbutton.png create mode 100644 src/widgets/doc/images/javastyle/rubberband.png create mode 100644 src/widgets/doc/images/javastyle/rubberbandimage.png create mode 100644 src/widgets/doc/images/javastyle/scrollbar.png create mode 100644 src/widgets/doc/images/javastyle/scrollbarimage.png create mode 100644 src/widgets/doc/images/javastyle/sizegrip.png create mode 100644 src/widgets/doc/images/javastyle/sizegripimage.png create mode 100644 src/widgets/doc/images/javastyle/slider.png create mode 100644 src/widgets/doc/images/javastyle/sliderimage.png create mode 100644 src/widgets/doc/images/javastyle/spinbox.png create mode 100644 src/widgets/doc/images/javastyle/spinboximage.png create mode 100644 src/widgets/doc/images/javastyle/tab.png create mode 100644 src/widgets/doc/images/javastyle/tabwidget.png create mode 100644 src/widgets/doc/images/javastyle/titlebar.png create mode 100644 src/widgets/doc/images/javastyle/titlebarimage.png create mode 100644 src/widgets/doc/images/javastyle/toolbar.png create mode 100644 src/widgets/doc/images/javastyle/toolbarimage.png create mode 100644 src/widgets/doc/images/javastyle/toolbox.png create mode 100644 src/widgets/doc/images/javastyle/toolboximage.png create mode 100644 src/widgets/doc/images/javastyle/toolbutton.png create mode 100644 src/widgets/doc/images/javastyle/toolbuttonimage.png create mode 100644 src/widgets/doc/images/javastyle/windowstabimage.png create mode 100644 src/widgets/doc/images/licensewizard-flow.png create mode 100644 src/widgets/doc/images/macintosh-calendarwidget.png create mode 100644 src/widgets/doc/images/macintosh-checkbox.png create mode 100644 src/widgets/doc/images/macintosh-combobox.png create mode 100644 src/widgets/doc/images/macintosh-dateedit.png create mode 100644 src/widgets/doc/images/macintosh-datetimeedit.png create mode 100644 src/widgets/doc/images/macintosh-dial.png create mode 100644 src/widgets/doc/images/macintosh-doublespinbox.png create mode 100644 src/widgets/doc/images/macintosh-fontcombobox.png create mode 100644 src/widgets/doc/images/macintosh-frame.png create mode 100644 src/widgets/doc/images/macintosh-groupbox.png create mode 100644 src/widgets/doc/images/macintosh-horizontalscrollbar.png create mode 100644 src/widgets/doc/images/macintosh-label.png create mode 100644 src/widgets/doc/images/macintosh-lcdnumber.png create mode 100644 src/widgets/doc/images/macintosh-lineedit.png create mode 100644 src/widgets/doc/images/macintosh-listview.png create mode 100644 src/widgets/doc/images/macintosh-menu.png create mode 100644 src/widgets/doc/images/macintosh-progressbar.png create mode 100644 src/widgets/doc/images/macintosh-pushbutton.png create mode 100644 src/widgets/doc/images/macintosh-radiobutton.png create mode 100644 src/widgets/doc/images/macintosh-slider.png create mode 100644 src/widgets/doc/images/macintosh-spinbox.png create mode 100644 src/widgets/doc/images/macintosh-tableview.png create mode 100644 src/widgets/doc/images/macintosh-tabwidget.png create mode 100644 src/widgets/doc/images/macintosh-textedit.png create mode 100644 src/widgets/doc/images/macintosh-timeedit.png create mode 100644 src/widgets/doc/images/macintosh-toolbox.png create mode 100644 src/widgets/doc/images/macintosh-toolbutton.png create mode 100644 src/widgets/doc/images/macintosh-treeview.png create mode 100644 src/widgets/doc/images/mainwindow-docks.png create mode 100644 src/widgets/doc/images/mainwindowlayout.png create mode 100644 src/widgets/doc/images/mdi-cascade.png create mode 100644 src/widgets/doc/images/mdi-tile.png create mode 100644 src/widgets/doc/images/motif-calendarwidget.png create mode 100644 src/widgets/doc/images/motif-checkbox.png create mode 100644 src/widgets/doc/images/motif-combobox.png create mode 100644 src/widgets/doc/images/motif-dateedit.png create mode 100644 src/widgets/doc/images/motif-datetimeedit.png create mode 100644 src/widgets/doc/images/motif-dial.png create mode 100644 src/widgets/doc/images/motif-doublespinbox.png create mode 100644 src/widgets/doc/images/motif-fontcombobox.png create mode 100644 src/widgets/doc/images/motif-frame.png create mode 100644 src/widgets/doc/images/motif-groupbox.png create mode 100644 src/widgets/doc/images/motif-horizontalscrollbar.png create mode 100644 src/widgets/doc/images/motif-label.png create mode 100644 src/widgets/doc/images/motif-lcdnumber.png create mode 100644 src/widgets/doc/images/motif-lineedit.png create mode 100644 src/widgets/doc/images/motif-listview.png create mode 100644 src/widgets/doc/images/motif-menubar.png create mode 100644 src/widgets/doc/images/motif-progressbar.png create mode 100644 src/widgets/doc/images/motif-pushbutton.png create mode 100644 src/widgets/doc/images/motif-radiobutton.png create mode 100644 src/widgets/doc/images/motif-slider.png create mode 100644 src/widgets/doc/images/motif-spinbox.png create mode 100644 src/widgets/doc/images/motif-tableview.png create mode 100644 src/widgets/doc/images/motif-tabwidget.png create mode 100644 src/widgets/doc/images/motif-textedit.png create mode 100644 src/widgets/doc/images/motif-timeedit.png create mode 100644 src/widgets/doc/images/motif-toolbox.png create mode 100644 src/widgets/doc/images/motif-toolbutton.png create mode 100644 src/widgets/doc/images/motif-treeview.png create mode 100644 src/widgets/doc/images/msgbox1.png create mode 100644 src/widgets/doc/images/msgbox2.png create mode 100644 src/widgets/doc/images/msgbox3.png create mode 100644 src/widgets/doc/images/msgbox4.png create mode 100644 src/widgets/doc/images/pangesture.png create mode 100644 src/widgets/doc/images/parent-child-widgets.png create mode 100644 src/widgets/doc/images/pinchgesture.png create mode 100644 src/widgets/doc/images/plastique-calendarwidget.png create mode 100644 src/widgets/doc/images/plastique-checkbox.png create mode 100644 src/widgets/doc/images/plastique-colordialog.png create mode 100644 src/widgets/doc/images/plastique-combobox.png create mode 100644 src/widgets/doc/images/plastique-dateedit.png create mode 100644 src/widgets/doc/images/plastique-datetimeedit.png create mode 100644 src/widgets/doc/images/plastique-dial.png create mode 100644 src/widgets/doc/images/plastique-doublespinbox.png create mode 100644 src/widgets/doc/images/plastique-fontcombobox.png create mode 100644 src/widgets/doc/images/plastique-fontdialog.png create mode 100644 src/widgets/doc/images/plastique-frame.png create mode 100644 src/widgets/doc/images/plastique-groupbox.png create mode 100644 src/widgets/doc/images/plastique-horizontalscrollbar.png create mode 100644 src/widgets/doc/images/plastique-label.png create mode 100644 src/widgets/doc/images/plastique-lcdnumber.png create mode 100644 src/widgets/doc/images/plastique-lineedit.png create mode 100644 src/widgets/doc/images/plastique-listview.png create mode 100644 src/widgets/doc/images/plastique-menu.png create mode 100644 src/widgets/doc/images/plastique-menubar.png create mode 100644 src/widgets/doc/images/plastique-progressbar.png create mode 100644 src/widgets/doc/images/plastique-progressdialog.png create mode 100644 src/widgets/doc/images/plastique-pushbutton-menu.png create mode 100644 src/widgets/doc/images/plastique-pushbutton.png create mode 100644 src/widgets/doc/images/plastique-radiobutton.png create mode 100644 src/widgets/doc/images/plastique-sizegrip.png create mode 100644 src/widgets/doc/images/plastique-slider.png create mode 100644 src/widgets/doc/images/plastique-spinbox.png create mode 100644 src/widgets/doc/images/plastique-statusbar.png create mode 100644 src/widgets/doc/images/plastique-tabbar-truncated.png create mode 100644 src/widgets/doc/images/plastique-tabbar.png create mode 100644 src/widgets/doc/images/plastique-tableview.png create mode 100644 src/widgets/doc/images/plastique-tabwidget.png create mode 100644 src/widgets/doc/images/plastique-textedit.png create mode 100644 src/widgets/doc/images/plastique-timeedit.png create mode 100644 src/widgets/doc/images/plastique-toolbox.png create mode 100644 src/widgets/doc/images/plastique-toolbutton.png create mode 100644 src/widgets/doc/images/plastique-treeview.png create mode 100644 src/widgets/doc/images/progressBar-stylesheet.png create mode 100644 src/widgets/doc/images/progressBar2-stylesheet.png create mode 100644 src/widgets/doc/images/propagation-custom.png create mode 100644 src/widgets/doc/images/propagation-standard.png create mode 100644 src/widgets/doc/images/qcalendarwidget-grid.png create mode 100644 src/widgets/doc/images/qcalendarwidget-maximum.png create mode 100644 src/widgets/doc/images/qcalendarwidget-minimum.png create mode 100644 src/widgets/doc/images/qcolumnview.png create mode 100644 src/widgets/doc/images/qdesktopwidget.png create mode 100644 src/widgets/doc/images/qformlayout-kde.png create mode 100644 src/widgets/doc/images/qformlayout-mac.png create mode 100644 src/widgets/doc/images/qformlayout-qpe.png create mode 100644 src/widgets/doc/images/qformlayout-win.png create mode 100644 src/widgets/doc/images/qformlayout-with-6-children.png create mode 100644 src/widgets/doc/images/qgraphicsproxywidget-embed.png create mode 100644 src/widgets/doc/images/qgridlayout-with-5-children.png create mode 100644 src/widgets/doc/images/qhboxlayout-with-5-children.png create mode 100644 src/widgets/doc/images/qmdisubwindowlayout.png create mode 100644 src/widgets/doc/images/qscrollarea-noscrollbars.png create mode 100644 src/widgets/doc/images/qscrollarea-onescrollbar.png create mode 100644 src/widgets/doc/images/qscrollarea-twoscrollbars.png create mode 100644 src/widgets/doc/images/qscrollbar-picture.png create mode 100644 src/widgets/doc/images/qscrollbar-values.png create mode 100644 src/widgets/doc/images/qspinbox-plusminus.png create mode 100644 src/widgets/doc/images/qspinbox-updown.png create mode 100644 src/widgets/doc/images/qstyle-comboboxes.png create mode 100644 src/widgets/doc/images/qstyleoptiontoolbar-position.png create mode 100644 src/widgets/doc/images/qtableview-resized.png create mode 100644 src/widgets/doc/images/qtwizard-aero1.png create mode 100644 src/widgets/doc/images/qtwizard-aero2.png create mode 100644 src/widgets/doc/images/qtwizard-classic1.png create mode 100644 src/widgets/doc/images/qtwizard-classic2.png create mode 100644 src/widgets/doc/images/qtwizard-mac1.png create mode 100644 src/widgets/doc/images/qtwizard-mac2.png create mode 100644 src/widgets/doc/images/qtwizard-macpage.png create mode 100644 src/widgets/doc/images/qtwizard-modern1.png create mode 100644 src/widgets/doc/images/qtwizard-modern2.png create mode 100644 src/widgets/doc/images/qtwizard-nonmacpage.png create mode 100644 src/widgets/doc/images/qundoview.png create mode 100644 src/widgets/doc/images/qvboxlayout-with-5-children.png create mode 100644 src/widgets/doc/images/simpleanchorlayout-example.png create mode 100644 src/widgets/doc/images/stylesheet-border-image-normal.png create mode 100644 src/widgets/doc/images/stylesheet-border-image-stretched.png create mode 100644 src/widgets/doc/images/stylesheet-border-image-wrong.png create mode 100644 src/widgets/doc/images/stylesheet-boxmodel.png create mode 100644 src/widgets/doc/images/stylesheet-branch-closed.png create mode 100644 src/widgets/doc/images/stylesheet-branch-end.png create mode 100644 src/widgets/doc/images/stylesheet-branch-more.png create mode 100644 src/widgets/doc/images/stylesheet-branch-open.png create mode 100644 src/widgets/doc/images/stylesheet-coffee-cleanlooks.png create mode 100644 src/widgets/doc/images/stylesheet-coffee-xp.png create mode 100644 src/widgets/doc/images/stylesheet-pagefold-mac.png create mode 100644 src/widgets/doc/images/stylesheet-pagefold.png create mode 100644 src/widgets/doc/images/stylesheet-redbutton1.png create mode 100644 src/widgets/doc/images/stylesheet-redbutton2.png create mode 100644 src/widgets/doc/images/stylesheet-redbutton3.png create mode 100644 src/widgets/doc/images/stylesheet-scrollbar1.png create mode 100644 src/widgets/doc/images/stylesheet-scrollbar2.png create mode 100644 src/widgets/doc/images/stylesheet-treeview.png create mode 100644 src/widgets/doc/images/stylesheet-vline.png create mode 100644 src/widgets/doc/images/swipegesture.png create mode 100644 src/widgets/doc/images/system-tray.png create mode 100644 src/widgets/doc/images/tabWidget-stylesheet1.png create mode 100644 src/widgets/doc/images/tabWidget-stylesheet2.png create mode 100644 src/widgets/doc/images/tabWidget-stylesheet3.png create mode 100644 src/widgets/doc/images/tableWidget-stylesheet.png create mode 100644 src/widgets/doc/images/widgetdelegate.png create mode 100644 src/widgets/doc/images/windows-calendarwidget.png create mode 100644 src/widgets/doc/images/windows-checkbox.png create mode 100644 src/widgets/doc/images/windows-combobox.png create mode 100644 src/widgets/doc/images/windows-dateedit.png create mode 100644 src/widgets/doc/images/windows-datetimeedit.png create mode 100644 src/widgets/doc/images/windows-dial.png create mode 100644 src/widgets/doc/images/windows-doublespinbox.png create mode 100644 src/widgets/doc/images/windows-fontcombobox.png create mode 100644 src/widgets/doc/images/windows-frame.png create mode 100644 src/widgets/doc/images/windows-groupbox.png create mode 100644 src/widgets/doc/images/windows-horizontalscrollbar.png create mode 100644 src/widgets/doc/images/windows-label.png create mode 100644 src/widgets/doc/images/windows-lcdnumber.png create mode 100644 src/widgets/doc/images/windows-lineedit.png create mode 100644 src/widgets/doc/images/windows-listview.png create mode 100644 src/widgets/doc/images/windows-progressbar.png create mode 100644 src/widgets/doc/images/windows-pushbutton.png create mode 100644 src/widgets/doc/images/windows-radiobutton.png create mode 100644 src/widgets/doc/images/windows-slider.png create mode 100644 src/widgets/doc/images/windows-spinbox.png create mode 100644 src/widgets/doc/images/windows-tableview.png create mode 100644 src/widgets/doc/images/windows-tabwidget.png create mode 100644 src/widgets/doc/images/windows-textedit.png create mode 100644 src/widgets/doc/images/windows-timeedit.png create mode 100644 src/widgets/doc/images/windows-toolbox.png create mode 100644 src/widgets/doc/images/windows-toolbutton.png create mode 100644 src/widgets/doc/images/windows-treeview.png create mode 100644 src/widgets/doc/images/windowsvista-calendarwidget.png create mode 100644 src/widgets/doc/images/windowsvista-checkbox.png create mode 100644 src/widgets/doc/images/windowsvista-combobox.png create mode 100644 src/widgets/doc/images/windowsvista-dateedit.png create mode 100644 src/widgets/doc/images/windowsvista-datetimeedit.png create mode 100644 src/widgets/doc/images/windowsvista-dial.png create mode 100644 src/widgets/doc/images/windowsvista-doublespinbox.png create mode 100644 src/widgets/doc/images/windowsvista-fontcombobox.png create mode 100644 src/widgets/doc/images/windowsvista-frame.png create mode 100644 src/widgets/doc/images/windowsvista-groupbox.png create mode 100644 src/widgets/doc/images/windowsvista-horizontalscrollbar.png create mode 100644 src/widgets/doc/images/windowsvista-label.png create mode 100644 src/widgets/doc/images/windowsvista-lcdnumber.png create mode 100644 src/widgets/doc/images/windowsvista-lineedit.png create mode 100644 src/widgets/doc/images/windowsvista-listview.png create mode 100644 src/widgets/doc/images/windowsvista-progressbar.png create mode 100644 src/widgets/doc/images/windowsvista-pushbutton.png create mode 100644 src/widgets/doc/images/windowsvista-radiobutton.png create mode 100644 src/widgets/doc/images/windowsvista-slider.png create mode 100644 src/widgets/doc/images/windowsvista-spinbox.png create mode 100644 src/widgets/doc/images/windowsvista-tableview.png create mode 100644 src/widgets/doc/images/windowsvista-tabwidget.png create mode 100644 src/widgets/doc/images/windowsvista-textedit.png create mode 100644 src/widgets/doc/images/windowsvista-timeedit.png create mode 100644 src/widgets/doc/images/windowsvista-toolbox.png create mode 100644 src/widgets/doc/images/windowsvista-toolbutton.png create mode 100644 src/widgets/doc/images/windowsvista-treeview.png create mode 100644 src/widgets/doc/images/windowsxp-calendarwidget.png create mode 100644 src/widgets/doc/images/windowsxp-checkbox.png create mode 100644 src/widgets/doc/images/windowsxp-combobox.png create mode 100644 src/widgets/doc/images/windowsxp-dateedit.png create mode 100644 src/widgets/doc/images/windowsxp-datetimeedit.png create mode 100644 src/widgets/doc/images/windowsxp-dial.png create mode 100644 src/widgets/doc/images/windowsxp-doublespinbox.png create mode 100644 src/widgets/doc/images/windowsxp-fontcombobox.png create mode 100644 src/widgets/doc/images/windowsxp-frame.png create mode 100644 src/widgets/doc/images/windowsxp-groupbox.png create mode 100644 src/widgets/doc/images/windowsxp-horizontalscrollbar.png create mode 100644 src/widgets/doc/images/windowsxp-label.png create mode 100644 src/widgets/doc/images/windowsxp-lcdnumber.png create mode 100644 src/widgets/doc/images/windowsxp-lineedit.png create mode 100644 src/widgets/doc/images/windowsxp-listview.png create mode 100644 src/widgets/doc/images/windowsxp-menu.png create mode 100644 src/widgets/doc/images/windowsxp-progressbar.png create mode 100644 src/widgets/doc/images/windowsxp-pushbutton.png create mode 100644 src/widgets/doc/images/windowsxp-radiobutton.png create mode 100644 src/widgets/doc/images/windowsxp-slider.png create mode 100644 src/widgets/doc/images/windowsxp-spinbox.png create mode 100644 src/widgets/doc/images/windowsxp-tableview.png create mode 100644 src/widgets/doc/images/windowsxp-tabwidget.png create mode 100644 src/widgets/doc/images/windowsxp-textedit.png create mode 100644 src/widgets/doc/images/windowsxp-timeedit.png create mode 100644 src/widgets/doc/images/windowsxp-toolbox.png create mode 100644 src/widgets/doc/images/windowsxp-toolbutton.png create mode 100644 src/widgets/doc/images/windowsxp-treeview.png create mode 100644 src/widgets/doc/qtwidgets.qdocconf create mode 100644 src/widgets/doc/snippets/code/doc_src_layout.cpp create mode 100644 src/widgets/doc/snippets/code/doc_src_qt4-styles.cpp create mode 100644 src/widgets/doc/snippets/code/doc_src_qtwidgets.cpp create mode 100644 src/widgets/doc/snippets/code/doc_src_qtwidgets.pro create mode 100644 src/widgets/doc/snippets/code/doc_src_styles.cpp create mode 100644 src/widgets/doc/snippets/code/doc_src_stylesheet.cpp create mode 100644 src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc create mode 100644 src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_dialogs_qfontdialog.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_dialogs_qmessagebox.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_dialogs_qwizard.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_effects_qgraphicseffect.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsgridlayout.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicslinearlayout.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_image_qicon.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_image_qpixmapfilter.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_itemviews_qabstractitemview.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_itemviews_qdatawidgetmapper.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_itemviews_qitemeditorfactory.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_itemviews_qtablewidget.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_kernel_qaction.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_kernel_qshortcut.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_painting_qdrawutil.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_styles_qstyle.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_styles_qstyleoption.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_util_qundostack.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qabstractbutton.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qabstractspinbox.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qcalendarwidget.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qcheckbox.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qdatetimeedit.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qdockwidget.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qframe.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qgroupbox.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qlabel.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qlineedit.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qmainwindow.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qmenu.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qplaintextedit.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qpushbutton.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qradiobutton.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qrubberband.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qscrollarea.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qspinbox.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qsplitter.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qstatusbar.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qtextbrowser.cpp create mode 100644 src/widgets/doc/snippets/code/src_gui_widgets_qtextedit.cpp create mode 100644 src/widgets/doc/snippets/customstyle/customstyle.cpp create mode 100644 src/widgets/doc/snippets/customstyle/customstyle.h create mode 100644 src/widgets/doc/snippets/customstyle/customstyle.pro create mode 100644 src/widgets/doc/snippets/customstyle/main.cpp create mode 100644 src/widgets/doc/snippets/customviewstyle.cpp create mode 100644 src/widgets/doc/snippets/dialogs/dialogs.cpp create mode 100644 src/widgets/doc/snippets/filedialogurls.cpp create mode 100644 src/widgets/doc/snippets/graphicssceneadditemsnippet.cpp create mode 100644 src/widgets/doc/snippets/javastyle.cpp create mode 100644 src/widgets/doc/snippets/layouts/layouts.cpp create mode 100644 src/widgets/doc/snippets/mainwindowsnippet.cpp create mode 100644 src/widgets/doc/snippets/mdiareasnippets.cpp create mode 100644 src/widgets/doc/snippets/myscrollarea.cpp create mode 100644 src/widgets/doc/snippets/qlistwidget-using/mainwindow.cpp create mode 100644 src/widgets/doc/snippets/qmacnativewidget/main.mm create mode 100644 src/widgets/doc/snippets/qsplashscreen/main.cpp create mode 100644 src/widgets/doc/snippets/qstackedlayout/main.cpp create mode 100644 src/widgets/doc/snippets/qstackedwidget/main.cpp create mode 100644 src/widgets/doc/snippets/qstyleoption/main.cpp create mode 100644 src/widgets/doc/snippets/qstyleplugin/main.cpp create mode 100644 src/widgets/doc/snippets/qtablewidget-resizing/mainwindow.cpp create mode 100644 src/widgets/doc/snippets/qtablewidget-using/mainwindow.cpp create mode 100644 src/widgets/doc/snippets/qtreewidget-using/mainwindow.cpp create mode 100644 src/widgets/doc/snippets/qtreewidgetitemiterator-using/mainwindow.cpp create mode 100644 src/widgets/doc/snippets/shareddirmodel/main.cpp create mode 100644 src/widgets/doc/snippets/splitter/splitter.cpp create mode 100644 src/widgets/doc/snippets/splitterhandle/splitter.cpp create mode 100644 src/widgets/doc/snippets/splitterhandle/splitter.h create mode 100644 src/widgets/doc/snippets/styles/styles.cpp create mode 100644 src/widgets/doc/snippets/stylesheet/common-mistakes.cpp create mode 100644 src/widgets/doc/snippets/textdocument-imagedrop/textedit.cpp create mode 100644 src/widgets/doc/snippets/timeline/main.cpp create mode 100644 src/widgets/doc/snippets/whatsthis/whatsthis.cpp create mode 100644 src/widgets/doc/snippets/widget-mask/main.cpp create mode 100644 src/widgets/doc/snippets/widgetdelegate.cpp create mode 100644 src/widgets/doc/src/qtwidgets.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/focus.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/gallery-cde.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/gallery-cleanlooks.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/gallery-gtk.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/gallery-macintosh.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/gallery-motif.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/gallery-plastique.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/gallery-windows.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/gallery-windowsvista.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/gallery-windowsxp.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/gallery.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/layout.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/styles.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc create mode 100644 src/widgets/doc/src/widgets-and-layouts/widgets.qdoc (limited to 'src/widgets/doc') 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 Binary files /dev/null and b/src/widgets/doc/images/assistant-toolbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/buttonbox-gnomelayout-horizontal.png 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 Binary files /dev/null and b/src/widgets/doc/images/buttonbox-gnomelayout-vertical.png 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 Binary files /dev/null and b/src/widgets/doc/images/buttonbox-kdelayout-horizontal.png 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 Binary files /dev/null and b/src/widgets/doc/images/buttonbox-kdelayout-vertical.png 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 Binary files /dev/null and b/src/widgets/doc/images/buttonbox-mac-modeless-horizontal.png 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 Binary files /dev/null and b/src/widgets/doc/images/buttonbox-mac-modeless-vertical.png 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 Binary files /dev/null and b/src/widgets/doc/images/buttonbox-maclayout-horizontal.png 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 Binary files /dev/null and b/src/widgets/doc/images/buttonbox-maclayout-vertical.png 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 Binary files /dev/null and b/src/widgets/doc/images/buttonbox-winlayout-horizontal.png 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 Binary files /dev/null and b/src/widgets/doc/images/buttonbox-winlayout-vertical.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-calendarwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-checkbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-combobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-dateedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-datetimeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-dial.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-doublespinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-fontcombobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-frame.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-groupbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-horizontalscrollbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-label.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-lcdnumber.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-lineedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-listview.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-progressbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-pushbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-radiobutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-slider.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-spinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-tableview.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-tabwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-textedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-timeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-toolbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-toolbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/cde-treeview.png 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 Binary files /dev/null and b/src/widgets/doc/images/checkboxes-exclusive.png 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 Binary files /dev/null and b/src/widgets/doc/images/checkboxes-non-exclusive.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-calendarwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-checkbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-combobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-dateedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-datetimeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-dial.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-doublespinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-fontcombobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-frame.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-groupbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-horizontalscrollbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-label.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-lcdnumber.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-lineedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-listview.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-progressbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-pushbutton-menu.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-pushbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-radiobutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-slider.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-spinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-tableview.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-tabwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-textedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-timeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-toolbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-toolbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/cleanlooks-treeview.png 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 Binary files /dev/null and b/src/widgets/doc/images/designer-stylesheet-options.png 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 Binary files /dev/null and b/src/widgets/doc/images/designer-stylesheet-usage.png 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 Binary files /dev/null and b/src/widgets/doc/images/designer-validator-highlighter.png differ diff --git a/src/widgets/doc/images/filedialogurls.png b/src/widgets/doc/images/filedialogurls.png new file mode 100644 index 0000000000..7d22ef33ae Binary files /dev/null and b/src/widgets/doc/images/filedialogurls.png differ diff --git a/src/widgets/doc/images/frames.png b/src/widgets/doc/images/frames.png new file mode 100644 index 0000000000..13c08508a2 Binary files /dev/null and b/src/widgets/doc/images/frames.png 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 Binary files /dev/null and b/src/widgets/doc/images/graphicsview-ellipseitem-pie.png 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 Binary files /dev/null and b/src/widgets/doc/images/graphicsview-ellipseitem.png 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 Binary files /dev/null and b/src/widgets/doc/images/graphicsview-items.png 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 Binary files /dev/null and b/src/widgets/doc/images/graphicsview-pathitem.png 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 Binary files /dev/null and b/src/widgets/doc/images/graphicsview-pixmapitem.png 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 Binary files /dev/null and b/src/widgets/doc/images/graphicsview-polygonitem.png 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 Binary files /dev/null and b/src/widgets/doc/images/graphicsview-rectitem.png 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 Binary files /dev/null and b/src/widgets/doc/images/graphicsview-zorder.png differ diff --git a/src/widgets/doc/images/gridlayout.png b/src/widgets/doc/images/gridlayout.png new file mode 100644 index 0000000000..ae76c0487b Binary files /dev/null and b/src/widgets/doc/images/gridlayout.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-calendarwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-checkbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-combobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-dateedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-datetimeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-dial.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-doublespinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-fontcombobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-frame.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-groupbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-horizontalscrollbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-label.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-lcdnumber.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-lineedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-listview.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-progressbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-pushbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-radiobutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-slider.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-spinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-tableview.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-tabwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-textedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-timeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-toolbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-toolbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/gtk-treeview.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/branchindicatorimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/button.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/checkbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/checkboxexample.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/combobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/comboboximage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/conceptualpushbuttontree.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/dockwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/dockwidgetimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/groupbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/groupboximage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/header.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/headerimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/menu.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/menubar.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/menubarimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/menuimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/progressbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/progressbarimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/pushbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/rubberband.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/rubberbandimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/scrollbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/scrollbarimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/sizegrip.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/sizegripimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/slider.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/sliderimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/spinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/spinboximage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/tab.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/tabwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/titlebar.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/titlebarimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/toolbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/toolbarimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/toolbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/toolboximage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/toolbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/toolbuttonimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/javastyle/windowstabimage.png 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 Binary files /dev/null and b/src/widgets/doc/images/licensewizard-flow.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-calendarwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-checkbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-combobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-dateedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-datetimeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-dial.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-doublespinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-fontcombobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-frame.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-groupbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-horizontalscrollbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-label.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-lcdnumber.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-lineedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-listview.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-menu.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-progressbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-pushbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-radiobutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-slider.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-spinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-tableview.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-tabwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-textedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-timeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-toolbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-toolbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/macintosh-treeview.png 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 Binary files /dev/null and b/src/widgets/doc/images/mainwindow-docks.png differ diff --git a/src/widgets/doc/images/mainwindowlayout.png b/src/widgets/doc/images/mainwindowlayout.png new file mode 100644 index 0000000000..4776ce4f1b Binary files /dev/null and b/src/widgets/doc/images/mainwindowlayout.png 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 Binary files /dev/null and b/src/widgets/doc/images/mdi-cascade.png 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 Binary files /dev/null and b/src/widgets/doc/images/mdi-tile.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-calendarwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-checkbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-combobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-dateedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-datetimeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-dial.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-doublespinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-fontcombobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-frame.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-groupbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-horizontalscrollbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-label.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-lcdnumber.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-lineedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-listview.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-menubar.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-progressbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-pushbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-radiobutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-slider.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-spinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-tableview.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-tabwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-textedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-timeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-toolbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-toolbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/motif-treeview.png differ diff --git a/src/widgets/doc/images/msgbox1.png b/src/widgets/doc/images/msgbox1.png new file mode 100644 index 0000000000..1380e20a5f Binary files /dev/null and b/src/widgets/doc/images/msgbox1.png differ diff --git a/src/widgets/doc/images/msgbox2.png b/src/widgets/doc/images/msgbox2.png new file mode 100644 index 0000000000..e7946996e4 Binary files /dev/null and b/src/widgets/doc/images/msgbox2.png differ diff --git a/src/widgets/doc/images/msgbox3.png b/src/widgets/doc/images/msgbox3.png new file mode 100644 index 0000000000..bd81f4d4da Binary files /dev/null and b/src/widgets/doc/images/msgbox3.png differ diff --git a/src/widgets/doc/images/msgbox4.png b/src/widgets/doc/images/msgbox4.png new file mode 100644 index 0000000000..dbe6701cdd Binary files /dev/null and b/src/widgets/doc/images/msgbox4.png differ diff --git a/src/widgets/doc/images/pangesture.png b/src/widgets/doc/images/pangesture.png new file mode 100644 index 0000000000..24caf91d3b Binary files /dev/null and b/src/widgets/doc/images/pangesture.png 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 Binary files /dev/null and b/src/widgets/doc/images/parent-child-widgets.png differ diff --git a/src/widgets/doc/images/pinchgesture.png b/src/widgets/doc/images/pinchgesture.png new file mode 100644 index 0000000000..95614c4052 Binary files /dev/null and b/src/widgets/doc/images/pinchgesture.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-calendarwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-checkbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-colordialog.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-combobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-dateedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-datetimeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-dial.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-doublespinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-fontcombobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-fontdialog.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-frame.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-groupbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-horizontalscrollbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-label.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-lcdnumber.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-lineedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-listview.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-menu.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-menubar.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-progressbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-progressdialog.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-pushbutton-menu.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-pushbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-radiobutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-sizegrip.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-slider.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-spinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-statusbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-tabbar-truncated.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-tabbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-tableview.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-tabwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-textedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-timeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-toolbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-toolbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/plastique-treeview.png 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 Binary files /dev/null and b/src/widgets/doc/images/progressBar-stylesheet.png 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 Binary files /dev/null and b/src/widgets/doc/images/progressBar2-stylesheet.png 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 Binary files /dev/null and b/src/widgets/doc/images/propagation-custom.png 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 Binary files /dev/null and b/src/widgets/doc/images/propagation-standard.png 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 Binary files /dev/null and b/src/widgets/doc/images/qcalendarwidget-grid.png 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 Binary files /dev/null and b/src/widgets/doc/images/qcalendarwidget-maximum.png 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 Binary files /dev/null and b/src/widgets/doc/images/qcalendarwidget-minimum.png differ diff --git a/src/widgets/doc/images/qcolumnview.png b/src/widgets/doc/images/qcolumnview.png new file mode 100644 index 0000000000..1d312bf953 Binary files /dev/null and b/src/widgets/doc/images/qcolumnview.png differ diff --git a/src/widgets/doc/images/qdesktopwidget.png b/src/widgets/doc/images/qdesktopwidget.png new file mode 100644 index 0000000000..02f8e8b5ad Binary files /dev/null and b/src/widgets/doc/images/qdesktopwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/qformlayout-kde.png 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 Binary files /dev/null and b/src/widgets/doc/images/qformlayout-mac.png 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 Binary files /dev/null and b/src/widgets/doc/images/qformlayout-qpe.png 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 Binary files /dev/null and b/src/widgets/doc/images/qformlayout-win.png 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 Binary files /dev/null and b/src/widgets/doc/images/qformlayout-with-6-children.png 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 Binary files /dev/null and b/src/widgets/doc/images/qgraphicsproxywidget-embed.png 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 Binary files /dev/null and b/src/widgets/doc/images/qgridlayout-with-5-children.png 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 Binary files /dev/null and b/src/widgets/doc/images/qhboxlayout-with-5-children.png differ diff --git a/src/widgets/doc/images/qmdisubwindowlayout.png b/src/widgets/doc/images/qmdisubwindowlayout.png new file mode 100644 index 0000000000..ffe5cc3949 Binary files /dev/null and b/src/widgets/doc/images/qmdisubwindowlayout.png 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 Binary files /dev/null and b/src/widgets/doc/images/qscrollarea-noscrollbars.png 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 Binary files /dev/null and b/src/widgets/doc/images/qscrollarea-onescrollbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/qscrollarea-twoscrollbars.png 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 Binary files /dev/null and b/src/widgets/doc/images/qscrollbar-picture.png 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 Binary files /dev/null and b/src/widgets/doc/images/qscrollbar-values.png 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 Binary files /dev/null and b/src/widgets/doc/images/qspinbox-plusminus.png 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 Binary files /dev/null and b/src/widgets/doc/images/qspinbox-updown.png 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 Binary files /dev/null and b/src/widgets/doc/images/qstyle-comboboxes.png 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 Binary files /dev/null and b/src/widgets/doc/images/qstyleoptiontoolbar-position.png 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 Binary files /dev/null and b/src/widgets/doc/images/qtableview-resized.png 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 Binary files /dev/null and b/src/widgets/doc/images/qtwizard-aero1.png 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 Binary files /dev/null and b/src/widgets/doc/images/qtwizard-aero2.png 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 Binary files /dev/null and b/src/widgets/doc/images/qtwizard-classic1.png 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 Binary files /dev/null and b/src/widgets/doc/images/qtwizard-classic2.png 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 Binary files /dev/null and b/src/widgets/doc/images/qtwizard-mac1.png 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 Binary files /dev/null and b/src/widgets/doc/images/qtwizard-mac2.png 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 Binary files /dev/null and b/src/widgets/doc/images/qtwizard-macpage.png 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 Binary files /dev/null and b/src/widgets/doc/images/qtwizard-modern1.png 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 Binary files /dev/null and b/src/widgets/doc/images/qtwizard-modern2.png 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 Binary files /dev/null and b/src/widgets/doc/images/qtwizard-nonmacpage.png differ diff --git a/src/widgets/doc/images/qundoview.png b/src/widgets/doc/images/qundoview.png new file mode 100644 index 0000000000..3bdb1cf2ed Binary files /dev/null and b/src/widgets/doc/images/qundoview.png 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 Binary files /dev/null and b/src/widgets/doc/images/qvboxlayout-with-5-children.png 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 Binary files /dev/null and b/src/widgets/doc/images/simpleanchorlayout-example.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-border-image-normal.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-border-image-stretched.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-border-image-wrong.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-boxmodel.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-branch-closed.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-branch-end.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-branch-more.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-branch-open.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-coffee-cleanlooks.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-coffee-xp.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-pagefold-mac.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-pagefold.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-redbutton1.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-redbutton2.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-redbutton3.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-scrollbar1.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-scrollbar2.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-treeview.png 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 Binary files /dev/null and b/src/widgets/doc/images/stylesheet-vline.png differ diff --git a/src/widgets/doc/images/swipegesture.png b/src/widgets/doc/images/swipegesture.png new file mode 100644 index 0000000000..0b7d35af3a Binary files /dev/null and b/src/widgets/doc/images/swipegesture.png 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 Binary files /dev/null and b/src/widgets/doc/images/system-tray.png 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 Binary files /dev/null and b/src/widgets/doc/images/tabWidget-stylesheet1.png 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 Binary files /dev/null and b/src/widgets/doc/images/tabWidget-stylesheet2.png 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 Binary files /dev/null and b/src/widgets/doc/images/tabWidget-stylesheet3.png 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 Binary files /dev/null and b/src/widgets/doc/images/tableWidget-stylesheet.png differ diff --git a/src/widgets/doc/images/widgetdelegate.png b/src/widgets/doc/images/widgetdelegate.png new file mode 100644 index 0000000000..3df4c4b6a5 Binary files /dev/null and b/src/widgets/doc/images/widgetdelegate.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-calendarwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-checkbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-combobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-dateedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-datetimeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-dial.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-doublespinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-fontcombobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-frame.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-groupbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-horizontalscrollbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-label.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-lcdnumber.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-lineedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-listview.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-progressbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-pushbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-radiobutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-slider.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-spinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-tableview.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-tabwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-textedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-timeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-toolbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-toolbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/windows-treeview.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-calendarwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-checkbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-combobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-dateedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-datetimeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-dial.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-doublespinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-fontcombobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-frame.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-groupbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-horizontalscrollbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-label.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-lcdnumber.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-lineedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-listview.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-progressbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-pushbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-radiobutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-slider.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-spinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-tableview.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-tabwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-textedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-timeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-toolbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-toolbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsvista-treeview.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-calendarwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-checkbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-combobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-dateedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-datetimeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-dial.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-doublespinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-fontcombobox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-frame.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-groupbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-horizontalscrollbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-label.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-lcdnumber.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-lineedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-listview.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-menu.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-progressbar.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-pushbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-radiobutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-slider.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-spinbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-tableview.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-tabwidget.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-textedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-timeedit.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-toolbox.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-toolbutton.png 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 Binary files /dev/null and b/src/widgets/doc/images/windowsxp-treeview.png 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 = \ + " \n" + +HTML.endheader = \ + "\n" \ + +defines = Q_QDOC \ + QT_.*_SUPPORT \ + QT_.*_LIB \ + QT_COMPAT \ + QT_KEYPAD_NAVIGATION \ + QT_NO_EGL \ + Q_WS_.* \ + Q_OS_.* \ + Q_BYTE_ORDER \ + QT_DEPRECATED \ + QT_DEPRECATED_* \ + Q_NO_USING_KEYWORD \ + __cplusplus \ + Q_COMPILER_INITIALIZER_LISTS + +versionsym = QT_VERSION_STR + +codeindent = 1 + +depends += qtcore 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 +#include + +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 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_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(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 +//! [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..7e3c633dd5 --- /dev/null +++ b/src/widgets/doc/snippets/code/doc_src_qtwidgets.pro @@ -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] +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(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 +#include + +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 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(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(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 *itemCreator = + new QItemEditorCreator("myProperty"); + +QItemEditorFactory *factory = new QItemEditorFactory; +//! [1] + + +//! [2] +QItemEditorFactory *editorFactory = new QItemEditorFactory; +QItemEditorCreatorBase *creator = new QStandardItemEditorCreator(); +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 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 +#include + +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(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(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(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 + +#include "customstyle.h" + +CustomStyle::CustomStyle() +{ +//! [0] + QSpinBox *spinBox = qobject_cast(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 + +//! [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 + +#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 + +#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 + +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 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 ", + " is a \n\n" + "Copyright 1991-2003 Such-and-such. " + "\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/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 + +int main(int argv, char **args) +{ + QApplication app(argv, args); + +//![0] + QList 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 + +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/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 + +#include "javastyle.h" +#include + +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(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(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(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(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(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(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(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(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(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(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(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(option); + if (copy.state & State_HasFocus) + copy.state ^= State_HasFocus; + painter->setBrush(Qt::NoBrush); + QWindowsStyle::drawControl(CE_TabBarTabLabel, ©, painter, + widget); + break; + } + case CE_TabBarTabShape: { + const QStyleOptionTab *tab = + qstyleoption_cast(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(widget) || + qobject_cast(widget) || + qobject_cast(widget) || + qobject_cast(widget) || + qobject_cast(widget) || + qobject_cast(widget)) + widget->setAttribute(Qt::WA_Hover, true); +} + +void JavaStyle::unpolish(QWidget *widget) +{ + if (qobject_cast(widget) || + qobject_cast(widget) || + qobject_cast(widget) || + qobject_cast(widget) || + qobject_cast(widget) || + qobject_cast(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(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(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(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(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(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(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(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(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(option); + if (slider->tickPosition == QSlider::TicksBelow) { + return QSize(contentsSize.width(), contentsSize.height() + 15); + } else { + return contentsSize; + } + } + case CT_MenuBarItem: { + const QStyleOptionMenuItem *menuItem = + qstyleoption_cast(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(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 + +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 + +#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 + +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 + +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/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 + +#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 +#include +#import + +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(nativeWidget->winId()); + NSView *contentView = [window contentView]; + [contentView setAutoresizesSubviews:YES]; + [nativeWidgetView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; + [nativeWidgetView setAutoresizesSubviews:YES]; + NSView *pushButtonView = reinterpret_cast(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/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 +#include + +#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 +#include + +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 +#include + +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 +#include + +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(option)) { + QStyleOptionFrameV2 frameOptionV2(*frameOption); + + // draw the frame using frameOptionV2 + } +//! [1] + +//! [2] + if (const QStyleOptionProgressBar *progressBarOption = + qstyleoption_cast(option)) { + QStyleOptionProgressBarV2 progressBarV2(*progressBarOption); + + // draw the progress bar using progressBarV2 + } +//! [2] + +//! [3] + if (const QStyleOptionTab *tabOption = + qstyleoption_cast(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(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 +#include + +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 + +#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/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 +#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 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 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/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 + +#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 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 + +#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/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 + +//! [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/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 + +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 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 + +#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 +#include +#include + +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/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 +#include +#include + +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 + +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(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 +#include + +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/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 + +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 + +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 + +#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/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 ::. 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- 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 +*/ -- cgit v1.2.3