From 38be0d13830efd2d98281c645c3a60afe05ffece Mon Sep 17 00:00:00 2001 From: Qt by Nokia Date: Wed, 27 Apr 2011 12:05:43 +0200 Subject: Initial import from the monolithic Qt. This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12 --- examples/widgets/README | 44 ++ examples/widgets/analogclock/analogclock.cpp | 145 +++++++ examples/widgets/analogclock/analogclock.h | 59 +++ examples/widgets/analogclock/analogclock.pro | 14 + examples/widgets/analogclock/main.cpp | 51 +++ examples/widgets/calculator/button.cpp | 63 +++ examples/widgets/calculator/button.h | 58 +++ examples/widgets/calculator/calculator.cpp | 397 +++++++++++++++++ examples/widgets/calculator/calculator.h | 107 +++++ examples/widgets/calculator/calculator.pro | 16 + examples/widgets/calculator/main.cpp | 51 +++ examples/widgets/calendarwidget/calendarwidget.pro | 14 + examples/widgets/calendarwidget/main.cpp | 51 +++ examples/widgets/calendarwidget/window.cpp | 461 ++++++++++++++++++++ examples/widgets/calendarwidget/window.h | 127 ++++++ examples/widgets/charactermap/charactermap.pro | 13 + examples/widgets/charactermap/characterwidget.cpp | 177 ++++++++ examples/widgets/charactermap/characterwidget.h | 86 ++++ examples/widgets/charactermap/main.cpp | 51 +++ examples/widgets/charactermap/mainwindow.cpp | 195 +++++++++ examples/widgets/charactermap/mainwindow.h | 83 ++++ examples/widgets/codeeditor/codeeditor.cpp | 170 ++++++++ examples/widgets/codeeditor/codeeditor.h | 105 +++++ examples/widgets/codeeditor/codeeditor.pro | 9 + examples/widgets/codeeditor/main.cpp | 55 +++ examples/widgets/digitalclock/digitalclock.cpp | 72 ++++ examples/widgets/digitalclock/digitalclock.h | 59 +++ examples/widgets/digitalclock/digitalclock.pro | 11 + examples/widgets/digitalclock/main.cpp | 51 +++ examples/widgets/groupbox/groupbox.pro | 11 + examples/widgets/groupbox/main.cpp | 51 +++ examples/widgets/groupbox/window.cpp | 189 +++++++++ examples/widgets/groupbox/window.h | 66 +++ examples/widgets/icons/iconpreviewarea.cpp | 141 +++++++ examples/widgets/icons/iconpreviewarea.h | 77 ++++ examples/widgets/icons/icons.pro | 27 ++ examples/widgets/icons/iconsizespinbox.cpp | 70 +++ examples/widgets/icons/iconsizespinbox.h | 59 +++ examples/widgets/icons/imagedelegate.cpp | 105 +++++ examples/widgets/icons/imagedelegate.h | 68 +++ examples/widgets/icons/images/designer.png | Bin 0 -> 4205 bytes examples/widgets/icons/images/find_disabled.png | Bin 0 -> 501 bytes examples/widgets/icons/images/find_normal.png | Bin 0 -> 838 bytes .../widgets/icons/images/monkey_off_128x128.png | Bin 0 -> 7045 bytes examples/widgets/icons/images/monkey_off_16x16.png | Bin 0 -> 683 bytes examples/widgets/icons/images/monkey_off_32x32.png | Bin 0 -> 1609 bytes examples/widgets/icons/images/monkey_off_64x64.png | Bin 0 -> 3533 bytes .../widgets/icons/images/monkey_on_128x128.png | Bin 0 -> 6909 bytes examples/widgets/icons/images/monkey_on_16x16.png | Bin 0 -> 681 bytes examples/widgets/icons/images/monkey_on_32x32.png | Bin 0 -> 1577 bytes examples/widgets/icons/images/monkey_on_64x64.png | Bin 0 -> 3479 bytes .../widgets/icons/images/qt_extended_16x16.png | Bin 0 -> 834 bytes .../widgets/icons/images/qt_extended_32x32.png | Bin 0 -> 1892 bytes .../widgets/icons/images/qt_extended_48x48.png | Bin 0 -> 3672 bytes examples/widgets/icons/main.cpp | 51 +++ examples/widgets/icons/mainwindow.cpp | 442 +++++++++++++++++++ examples/widgets/icons/mainwindow.h | 116 +++++ examples/widgets/imageviewer/imageviewer.cpp | 277 ++++++++++++ examples/widgets/imageviewer/imageviewer.h | 103 +++++ examples/widgets/imageviewer/imageviewer.pro | 15 + examples/widgets/imageviewer/main.cpp | 51 +++ examples/widgets/lineedits/lineedits.pro | 14 + examples/widgets/lineedits/main.cpp | 51 +++ examples/widgets/lineedits/window.cpp | 256 +++++++++++ examples/widgets/lineedits/window.h | 75 ++++ examples/widgets/movie/animation.mng | Bin 0 -> 5464 bytes examples/widgets/movie/main.cpp | 51 +++ examples/widgets/movie/movie.pro | 19 + examples/widgets/movie/movieplayer.cpp | 210 +++++++++ examples/widgets/movie/movieplayer.h | 96 +++++ examples/widgets/scribble/main.cpp | 51 +++ examples/widgets/scribble/mainwindow.cpp | 250 +++++++++++ examples/widgets/scribble/mainwindow.h | 92 ++++ examples/widgets/scribble/scribble.pro | 13 + examples/widgets/scribble/scribblearea.cpp | 215 ++++++++++ examples/widgets/scribble/scribblearea.h | 90 ++++ examples/widgets/shapedclock/main.cpp | 51 +++ examples/widgets/shapedclock/shapedclock.cpp | 158 +++++++ examples/widgets/shapedclock/shapedclock.h | 66 +++ examples/widgets/shapedclock/shapedclock.pro | 14 + examples/widgets/sliders/main.cpp | 51 +++ examples/widgets/sliders/sliders.pro | 13 + examples/widgets/sliders/slidersgroup.cpp | 132 ++++++ examples/widgets/sliders/slidersgroup.h | 78 ++++ examples/widgets/sliders/window.cpp | 145 +++++++ examples/widgets/sliders/window.h | 84 ++++ examples/widgets/softkeys/main.cpp | 50 +++ examples/widgets/softkeys/softkeys.cpp | 188 +++++++++ examples/widgets/softkeys/softkeys.h | 88 ++++ examples/widgets/softkeys/softkeys.pro | 15 + examples/widgets/spinboxes/main.cpp | 51 +++ examples/widgets/spinboxes/spinboxes.pro | 11 + examples/widgets/spinboxes/window.cpp | 251 +++++++++++ examples/widgets/spinboxes/window.h | 81 ++++ examples/widgets/styles/images/woodbackground.png | Bin 0 -> 7691 bytes examples/widgets/styles/images/woodbutton.png | Bin 0 -> 7689 bytes examples/widgets/styles/main.cpp | 53 +++ examples/widgets/styles/norwegianwoodstyle.cpp | 330 +++++++++++++++ examples/widgets/styles/norwegianwoodstyle.h | 78 ++++ examples/widgets/styles/styles.pro | 16 + examples/widgets/styles/styles.qrc | 6 + examples/widgets/styles/widgetgallery.cpp | 275 ++++++++++++ examples/widgets/styles/widgetgallery.h | 121 ++++++ .../widgets/stylesheet/images/checkbox_checked.png | Bin 0 -> 263 bytes .../stylesheet/images/checkbox_checked_hover.png | Bin 0 -> 266 bytes .../stylesheet/images/checkbox_checked_pressed.png | Bin 0 -> 425 bytes .../stylesheet/images/checkbox_unchecked.png | Bin 0 -> 159 bytes .../stylesheet/images/checkbox_unchecked_hover.png | Bin 0 -> 159 bytes .../images/checkbox_unchecked_pressed.png | Bin 0 -> 320 bytes examples/widgets/stylesheet/images/down_arrow.png | Bin 0 -> 175 bytes .../stylesheet/images/down_arrow_disabled.png | Bin 0 -> 174 bytes examples/widgets/stylesheet/images/frame.png | Bin 0 -> 253 bytes examples/widgets/stylesheet/images/pagefold.png | Bin 0 -> 1545 bytes examples/widgets/stylesheet/images/pushbutton.png | Bin 0 -> 533 bytes .../widgets/stylesheet/images/pushbutton_hover.png | Bin 0 -> 525 bytes .../stylesheet/images/pushbutton_pressed.png | Bin 0 -> 513 bytes .../stylesheet/images/radiobutton_checked.png | Bin 0 -> 355 bytes .../images/radiobutton_checked_hover.png | Bin 0 -> 532 bytes .../images/radiobutton_checked_pressed.png | Bin 0 -> 599 bytes .../stylesheet/images/radiobutton_unchecked.png | Bin 0 -> 240 bytes .../images/radiobutton_unchecked_hover.png | Bin 0 -> 492 bytes .../images/radiobutton_unchecked_pressed.png | Bin 0 -> 556 bytes examples/widgets/stylesheet/images/sizegrip.png | Bin 0 -> 129 bytes examples/widgets/stylesheet/images/spindown.png | Bin 0 -> 276 bytes .../widgets/stylesheet/images/spindown_hover.png | Bin 0 -> 268 bytes .../widgets/stylesheet/images/spindown_off.png | Bin 0 -> 249 bytes .../widgets/stylesheet/images/spindown_pressed.png | Bin 0 -> 264 bytes examples/widgets/stylesheet/images/spinup.png | Bin 0 -> 283 bytes .../widgets/stylesheet/images/spinup_hover.png | Bin 0 -> 277 bytes examples/widgets/stylesheet/images/spinup_off.png | Bin 0 -> 274 bytes .../widgets/stylesheet/images/spinup_pressed.png | Bin 0 -> 277 bytes examples/widgets/stylesheet/images/up_arrow.png | Bin 0 -> 197 bytes .../stylesheet/images/up_arrow_disabled.png | Bin 0 -> 172 bytes examples/widgets/stylesheet/layouts/default.ui | 329 +++++++++++++++ examples/widgets/stylesheet/layouts/pagefold.ui | 349 +++++++++++++++ examples/widgets/stylesheet/main.cpp | 53 +++ examples/widgets/stylesheet/mainwindow.cpp | 74 ++++ examples/widgets/stylesheet/mainwindow.h | 66 +++ examples/widgets/stylesheet/mainwindow.ui | 356 ++++++++++++++++ examples/widgets/stylesheet/qss/coffee.qss | 112 +++++ examples/widgets/stylesheet/qss/default.qss | 1 + examples/widgets/stylesheet/qss/pagefold.qss | 299 +++++++++++++ examples/widgets/stylesheet/stylesheet.pro | 16 + examples/widgets/stylesheet/stylesheet.qrc | 39 ++ examples/widgets/stylesheet/stylesheeteditor.cpp | 93 ++++ examples/widgets/stylesheet/stylesheeteditor.h | 67 +++ examples/widgets/stylesheet/stylesheeteditor.ui | 171 ++++++++ examples/widgets/tablet/main.cpp | 60 +++ examples/widgets/tablet/mainwindow.cpp | 274 ++++++++++++ examples/widgets/tablet/mainwindow.h | 113 +++++ examples/widgets/tablet/tablet.pro | 15 + examples/widgets/tablet/tabletapplication.cpp | 56 +++ examples/widgets/tablet/tabletapplication.h | 66 +++ examples/widgets/tablet/tabletcanvas.cpp | 275 ++++++++++++ examples/widgets/tablet/tabletcanvas.h | 114 +++++ examples/widgets/tetrix/main.cpp | 54 +++ examples/widgets/tetrix/tetrix.pro | 18 + examples/widgets/tetrix/tetrixboard.cpp | 408 ++++++++++++++++++ examples/widgets/tetrix/tetrixboard.h | 116 +++++ examples/widgets/tetrix/tetrixpiece.cpp | 145 +++++++ examples/widgets/tetrix/tetrixpiece.h | 75 ++++ examples/widgets/tetrix/tetrixwindow.cpp | 115 +++++ examples/widgets/tetrix/tetrixwindow.h | 76 ++++ examples/widgets/tooltips/images/circle.png | Bin 0 -> 165 bytes examples/widgets/tooltips/images/square.png | Bin 0 -> 94 bytes examples/widgets/tooltips/images/triangle.png | Bin 0 -> 170 bytes examples/widgets/tooltips/main.cpp | 54 +++ examples/widgets/tooltips/shapeitem.cpp | 99 +++++ examples/widgets/tooltips/shapeitem.h | 70 +++ examples/widgets/tooltips/sortingbox.cpp | 301 +++++++++++++ examples/widgets/tooltips/sortingbox.h | 106 +++++ examples/widgets/tooltips/tooltips.pro | 14 + examples/widgets/tooltips/tooltips.qrc | 7 + examples/widgets/validators/ledoff.png | Bin 0 -> 562 bytes examples/widgets/validators/ledon.png | Bin 0 -> 486 bytes examples/widgets/validators/ledwidget.cpp | 62 +++ examples/widgets/validators/ledwidget.h | 64 +++ examples/widgets/validators/localeselector.cpp | 312 ++++++++++++++ examples/widgets/validators/localeselector.h | 60 +++ examples/widgets/validators/main.cpp | 136 ++++++ examples/widgets/validators/validators.pro | 23 + examples/widgets/validators/validators.qrc | 6 + examples/widgets/validators/validators.ui | 468 +++++++++++++++++++++ examples/widgets/widgets.pro | 43 ++ examples/widgets/wiggly/dialog.cpp | 80 ++++ examples/widgets/wiggly/dialog.h | 56 +++ examples/widgets/wiggly/main.cpp | 57 +++ examples/widgets/wiggly/wiggly.pro | 16 + examples/widgets/wiggly/wigglywidget.cpp | 100 +++++ examples/widgets/wiggly/wigglywidget.h | 69 +++ examples/widgets/windowflags/controllerwindow.cpp | 220 ++++++++++ examples/widgets/windowflags/controllerwindow.h | 104 +++++ examples/widgets/windowflags/main.cpp | 51 +++ examples/widgets/windowflags/previewwindow.cpp | 118 ++++++ examples/widgets/windowflags/previewwindow.h | 67 +++ examples/widgets/windowflags/windowflags.pro | 13 + 196 files changed, 15384 insertions(+) create mode 100644 examples/widgets/README create mode 100644 examples/widgets/analogclock/analogclock.cpp create mode 100644 examples/widgets/analogclock/analogclock.h create mode 100644 examples/widgets/analogclock/analogclock.pro create mode 100644 examples/widgets/analogclock/main.cpp create mode 100644 examples/widgets/calculator/button.cpp create mode 100644 examples/widgets/calculator/button.h create mode 100644 examples/widgets/calculator/calculator.cpp create mode 100644 examples/widgets/calculator/calculator.h create mode 100644 examples/widgets/calculator/calculator.pro create mode 100644 examples/widgets/calculator/main.cpp create mode 100644 examples/widgets/calendarwidget/calendarwidget.pro create mode 100644 examples/widgets/calendarwidget/main.cpp create mode 100644 examples/widgets/calendarwidget/window.cpp create mode 100644 examples/widgets/calendarwidget/window.h create mode 100644 examples/widgets/charactermap/charactermap.pro create mode 100644 examples/widgets/charactermap/characterwidget.cpp create mode 100644 examples/widgets/charactermap/characterwidget.h create mode 100644 examples/widgets/charactermap/main.cpp create mode 100644 examples/widgets/charactermap/mainwindow.cpp create mode 100644 examples/widgets/charactermap/mainwindow.h create mode 100644 examples/widgets/codeeditor/codeeditor.cpp create mode 100644 examples/widgets/codeeditor/codeeditor.h create mode 100644 examples/widgets/codeeditor/codeeditor.pro create mode 100644 examples/widgets/codeeditor/main.cpp create mode 100644 examples/widgets/digitalclock/digitalclock.cpp create mode 100644 examples/widgets/digitalclock/digitalclock.h create mode 100644 examples/widgets/digitalclock/digitalclock.pro create mode 100644 examples/widgets/digitalclock/main.cpp create mode 100644 examples/widgets/groupbox/groupbox.pro create mode 100644 examples/widgets/groupbox/main.cpp create mode 100644 examples/widgets/groupbox/window.cpp create mode 100644 examples/widgets/groupbox/window.h create mode 100644 examples/widgets/icons/iconpreviewarea.cpp create mode 100644 examples/widgets/icons/iconpreviewarea.h create mode 100644 examples/widgets/icons/icons.pro create mode 100644 examples/widgets/icons/iconsizespinbox.cpp create mode 100644 examples/widgets/icons/iconsizespinbox.h create mode 100644 examples/widgets/icons/imagedelegate.cpp create mode 100644 examples/widgets/icons/imagedelegate.h create mode 100644 examples/widgets/icons/images/designer.png create mode 100644 examples/widgets/icons/images/find_disabled.png create mode 100644 examples/widgets/icons/images/find_normal.png create mode 100644 examples/widgets/icons/images/monkey_off_128x128.png create mode 100644 examples/widgets/icons/images/monkey_off_16x16.png create mode 100644 examples/widgets/icons/images/monkey_off_32x32.png create mode 100644 examples/widgets/icons/images/monkey_off_64x64.png create mode 100644 examples/widgets/icons/images/monkey_on_128x128.png create mode 100644 examples/widgets/icons/images/monkey_on_16x16.png create mode 100644 examples/widgets/icons/images/monkey_on_32x32.png create mode 100644 examples/widgets/icons/images/monkey_on_64x64.png create mode 100644 examples/widgets/icons/images/qt_extended_16x16.png create mode 100644 examples/widgets/icons/images/qt_extended_32x32.png create mode 100644 examples/widgets/icons/images/qt_extended_48x48.png create mode 100644 examples/widgets/icons/main.cpp create mode 100644 examples/widgets/icons/mainwindow.cpp create mode 100644 examples/widgets/icons/mainwindow.h create mode 100644 examples/widgets/imageviewer/imageviewer.cpp create mode 100644 examples/widgets/imageviewer/imageviewer.h create mode 100644 examples/widgets/imageviewer/imageviewer.pro create mode 100644 examples/widgets/imageviewer/main.cpp create mode 100644 examples/widgets/lineedits/lineedits.pro create mode 100644 examples/widgets/lineedits/main.cpp create mode 100644 examples/widgets/lineedits/window.cpp create mode 100644 examples/widgets/lineedits/window.h create mode 100644 examples/widgets/movie/animation.mng create mode 100644 examples/widgets/movie/main.cpp create mode 100644 examples/widgets/movie/movie.pro create mode 100644 examples/widgets/movie/movieplayer.cpp create mode 100644 examples/widgets/movie/movieplayer.h create mode 100644 examples/widgets/scribble/main.cpp create mode 100644 examples/widgets/scribble/mainwindow.cpp create mode 100644 examples/widgets/scribble/mainwindow.h create mode 100644 examples/widgets/scribble/scribble.pro create mode 100644 examples/widgets/scribble/scribblearea.cpp create mode 100644 examples/widgets/scribble/scribblearea.h create mode 100644 examples/widgets/shapedclock/main.cpp create mode 100644 examples/widgets/shapedclock/shapedclock.cpp create mode 100644 examples/widgets/shapedclock/shapedclock.h create mode 100644 examples/widgets/shapedclock/shapedclock.pro create mode 100644 examples/widgets/sliders/main.cpp create mode 100644 examples/widgets/sliders/sliders.pro create mode 100644 examples/widgets/sliders/slidersgroup.cpp create mode 100644 examples/widgets/sliders/slidersgroup.h create mode 100644 examples/widgets/sliders/window.cpp create mode 100644 examples/widgets/sliders/window.h create mode 100644 examples/widgets/softkeys/main.cpp create mode 100644 examples/widgets/softkeys/softkeys.cpp create mode 100644 examples/widgets/softkeys/softkeys.h create mode 100644 examples/widgets/softkeys/softkeys.pro create mode 100644 examples/widgets/spinboxes/main.cpp create mode 100644 examples/widgets/spinboxes/spinboxes.pro create mode 100644 examples/widgets/spinboxes/window.cpp create mode 100644 examples/widgets/spinboxes/window.h create mode 100644 examples/widgets/styles/images/woodbackground.png create mode 100644 examples/widgets/styles/images/woodbutton.png create mode 100644 examples/widgets/styles/main.cpp create mode 100644 examples/widgets/styles/norwegianwoodstyle.cpp create mode 100644 examples/widgets/styles/norwegianwoodstyle.h create mode 100644 examples/widgets/styles/styles.pro create mode 100644 examples/widgets/styles/styles.qrc create mode 100644 examples/widgets/styles/widgetgallery.cpp create mode 100644 examples/widgets/styles/widgetgallery.h create mode 100644 examples/widgets/stylesheet/images/checkbox_checked.png create mode 100644 examples/widgets/stylesheet/images/checkbox_checked_hover.png create mode 100644 examples/widgets/stylesheet/images/checkbox_checked_pressed.png create mode 100644 examples/widgets/stylesheet/images/checkbox_unchecked.png create mode 100644 examples/widgets/stylesheet/images/checkbox_unchecked_hover.png create mode 100644 examples/widgets/stylesheet/images/checkbox_unchecked_pressed.png create mode 100644 examples/widgets/stylesheet/images/down_arrow.png create mode 100644 examples/widgets/stylesheet/images/down_arrow_disabled.png create mode 100644 examples/widgets/stylesheet/images/frame.png create mode 100644 examples/widgets/stylesheet/images/pagefold.png create mode 100644 examples/widgets/stylesheet/images/pushbutton.png create mode 100644 examples/widgets/stylesheet/images/pushbutton_hover.png create mode 100644 examples/widgets/stylesheet/images/pushbutton_pressed.png create mode 100644 examples/widgets/stylesheet/images/radiobutton_checked.png create mode 100644 examples/widgets/stylesheet/images/radiobutton_checked_hover.png create mode 100644 examples/widgets/stylesheet/images/radiobutton_checked_pressed.png create mode 100644 examples/widgets/stylesheet/images/radiobutton_unchecked.png create mode 100644 examples/widgets/stylesheet/images/radiobutton_unchecked_hover.png create mode 100644 examples/widgets/stylesheet/images/radiobutton_unchecked_pressed.png create mode 100644 examples/widgets/stylesheet/images/sizegrip.png create mode 100644 examples/widgets/stylesheet/images/spindown.png create mode 100644 examples/widgets/stylesheet/images/spindown_hover.png create mode 100644 examples/widgets/stylesheet/images/spindown_off.png create mode 100644 examples/widgets/stylesheet/images/spindown_pressed.png create mode 100644 examples/widgets/stylesheet/images/spinup.png create mode 100644 examples/widgets/stylesheet/images/spinup_hover.png create mode 100644 examples/widgets/stylesheet/images/spinup_off.png create mode 100644 examples/widgets/stylesheet/images/spinup_pressed.png create mode 100644 examples/widgets/stylesheet/images/up_arrow.png create mode 100644 examples/widgets/stylesheet/images/up_arrow_disabled.png create mode 100644 examples/widgets/stylesheet/layouts/default.ui create mode 100644 examples/widgets/stylesheet/layouts/pagefold.ui create mode 100644 examples/widgets/stylesheet/main.cpp create mode 100644 examples/widgets/stylesheet/mainwindow.cpp create mode 100644 examples/widgets/stylesheet/mainwindow.h create mode 100644 examples/widgets/stylesheet/mainwindow.ui create mode 100644 examples/widgets/stylesheet/qss/coffee.qss create mode 100644 examples/widgets/stylesheet/qss/default.qss create mode 100644 examples/widgets/stylesheet/qss/pagefold.qss create mode 100644 examples/widgets/stylesheet/stylesheet.pro create mode 100644 examples/widgets/stylesheet/stylesheet.qrc create mode 100644 examples/widgets/stylesheet/stylesheeteditor.cpp create mode 100644 examples/widgets/stylesheet/stylesheeteditor.h create mode 100644 examples/widgets/stylesheet/stylesheeteditor.ui create mode 100644 examples/widgets/tablet/main.cpp create mode 100644 examples/widgets/tablet/mainwindow.cpp create mode 100644 examples/widgets/tablet/mainwindow.h create mode 100644 examples/widgets/tablet/tablet.pro create mode 100644 examples/widgets/tablet/tabletapplication.cpp create mode 100644 examples/widgets/tablet/tabletapplication.h create mode 100644 examples/widgets/tablet/tabletcanvas.cpp create mode 100644 examples/widgets/tablet/tabletcanvas.h create mode 100644 examples/widgets/tetrix/main.cpp create mode 100644 examples/widgets/tetrix/tetrix.pro create mode 100644 examples/widgets/tetrix/tetrixboard.cpp create mode 100644 examples/widgets/tetrix/tetrixboard.h create mode 100644 examples/widgets/tetrix/tetrixpiece.cpp create mode 100644 examples/widgets/tetrix/tetrixpiece.h create mode 100644 examples/widgets/tetrix/tetrixwindow.cpp create mode 100644 examples/widgets/tetrix/tetrixwindow.h create mode 100644 examples/widgets/tooltips/images/circle.png create mode 100644 examples/widgets/tooltips/images/square.png create mode 100644 examples/widgets/tooltips/images/triangle.png create mode 100644 examples/widgets/tooltips/main.cpp create mode 100644 examples/widgets/tooltips/shapeitem.cpp create mode 100644 examples/widgets/tooltips/shapeitem.h create mode 100644 examples/widgets/tooltips/sortingbox.cpp create mode 100644 examples/widgets/tooltips/sortingbox.h create mode 100644 examples/widgets/tooltips/tooltips.pro create mode 100644 examples/widgets/tooltips/tooltips.qrc create mode 100644 examples/widgets/validators/ledoff.png create mode 100644 examples/widgets/validators/ledon.png create mode 100644 examples/widgets/validators/ledwidget.cpp create mode 100644 examples/widgets/validators/ledwidget.h create mode 100644 examples/widgets/validators/localeselector.cpp create mode 100644 examples/widgets/validators/localeselector.h create mode 100644 examples/widgets/validators/main.cpp create mode 100644 examples/widgets/validators/validators.pro create mode 100644 examples/widgets/validators/validators.qrc create mode 100644 examples/widgets/validators/validators.ui create mode 100644 examples/widgets/widgets.pro create mode 100644 examples/widgets/wiggly/dialog.cpp create mode 100644 examples/widgets/wiggly/dialog.h create mode 100644 examples/widgets/wiggly/main.cpp create mode 100644 examples/widgets/wiggly/wiggly.pro create mode 100644 examples/widgets/wiggly/wigglywidget.cpp create mode 100644 examples/widgets/wiggly/wigglywidget.h create mode 100644 examples/widgets/windowflags/controllerwindow.cpp create mode 100644 examples/widgets/windowflags/controllerwindow.h create mode 100644 examples/widgets/windowflags/main.cpp create mode 100644 examples/widgets/windowflags/previewwindow.cpp create mode 100644 examples/widgets/windowflags/previewwindow.h create mode 100644 examples/widgets/windowflags/windowflags.pro (limited to 'examples/widgets') diff --git a/examples/widgets/README b/examples/widgets/README new file mode 100644 index 0000000000..fd16c67acd --- /dev/null +++ b/examples/widgets/README @@ -0,0 +1,44 @@ +Qt comes with a large range of standard widgets that users of modern +applications have come to expect. + +You can also develop your own custom widgets and controls, and use them +alongside standard widgets. + +It is even possible to provide custom styles and themes for widgets that can +be used to change the appearance of standard widgets and appropriately +written custom widgets. + + +The example launcher provided with Qt can be used to explore each of the +examples in this directory. + +Documentation for these examples can be found via the Tutorial and Examples +link in the main Qt documentation. + + +Finding the Qt Examples and Demos launcher +========================================== + +On Windows: + +The launcher can be accessed via the Windows Start menu. Select the menu +entry entitled "Qt Examples and Demos" entry in the submenu containing +the Qt tools. + +On Mac OS X: + +For the binary distribution, the qtdemo executable is installed in the +/Developer/Applications/Qt directory. For the source distribution, it is +installed alongside the other Qt tools on the path specified when Qt is +configured. + +On Unix/Linux: + +The qtdemo executable is installed alongside the other Qt tools on the path +specified when Qt is configured. + +On all platforms: + +The source code for the launcher can be found in the demos/qtdemo directory +in the Qt package. This example is built at the same time as the Qt libraries, +tools, examples, and demonstrations. diff --git a/examples/widgets/analogclock/analogclock.cpp b/examples/widgets/analogclock/analogclock.cpp new file mode 100644 index 0000000000..5368a2cbe1 --- /dev/null +++ b/examples/widgets/analogclock/analogclock.cpp @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR 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 "analogclock.h" + +//! [0] //! [1] +AnalogClock::AnalogClock(QWidget *parent) +//! [0] //! [2] + : QWidget(parent) +//! [2] //! [3] +{ +//! [3] //! [4] + QTimer *timer = new QTimer(this); +//! [4] //! [5] + connect(timer, SIGNAL(timeout()), this, SLOT(update())); +//! [5] //! [6] + timer->start(1000); +//! [6] + + setWindowTitle(tr("Analog Clock")); + resize(200, 200); +//! [7] +} +//! [1] //! [7] + +//! [8] //! [9] +void AnalogClock::paintEvent(QPaintEvent *) +//! [8] //! [10] +{ + static const QPoint hourHand[3] = { + QPoint(7, 8), + QPoint(-7, 8), + QPoint(0, -40) + }; + static const QPoint minuteHand[3] = { + QPoint(7, 8), + QPoint(-7, 8), + QPoint(0, -70) + }; + + QColor hourColor(127, 0, 127); + QColor minuteColor(0, 127, 127, 191); + + int side = qMin(width(), height()); + QTime time = QTime::currentTime(); +//! [10] + +//! [11] + QPainter painter(this); +//! [11] //! [12] + painter.setRenderHint(QPainter::Antialiasing); +//! [12] //! [13] + painter.translate(width() / 2, height() / 2); +//! [13] //! [14] + painter.scale(side / 200.0, side / 200.0); +//! [9] //! [14] + +//! [15] + painter.setPen(Qt::NoPen); +//! [15] //! [16] + painter.setBrush(hourColor); +//! [16] + +//! [17] //! [18] + painter.save(); +//! [17] //! [19] + painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0))); + painter.drawConvexPolygon(hourHand, 3); + painter.restore(); +//! [18] //! [19] + +//! [20] + painter.setPen(hourColor); +//! [20] //! [21] + + for (int i = 0; i < 12; ++i) { + painter.drawLine(88, 0, 96, 0); + painter.rotate(30.0); + } +//! [21] + +//! [22] + painter.setPen(Qt::NoPen); +//! [22] //! [23] + painter.setBrush(minuteColor); + +//! [24] + painter.save(); + painter.rotate(6.0 * (time.minute() + time.second() / 60.0)); + painter.drawConvexPolygon(minuteHand, 3); + painter.restore(); +//! [23] //! [24] + +//! [25] + painter.setPen(minuteColor); +//! [25] //! [26] + +//! [27] + for (int j = 0; j < 60; ++j) { + if ((j % 5) != 0) + painter.drawLine(92, 0, 96, 0); + painter.rotate(6.0); + } +//! [27] +} +//! [26] diff --git a/examples/widgets/analogclock/analogclock.h b/examples/widgets/analogclock/analogclock.h new file mode 100644 index 0000000000..5da2780f62 --- /dev/null +++ b/examples/widgets/analogclock/analogclock.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR 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 ANALOGCLOCK_H +#define ANALOGCLOCK_H + +#include + +//! [0] +class AnalogClock : public QWidget +{ + Q_OBJECT + +public: + AnalogClock(QWidget *parent = 0); + +protected: + void paintEvent(QPaintEvent *event); +}; +//! [0] + +#endif diff --git a/examples/widgets/analogclock/analogclock.pro b/examples/widgets/analogclock/analogclock.pro new file mode 100644 index 0000000000..3183fe0eab --- /dev/null +++ b/examples/widgets/analogclock/analogclock.pro @@ -0,0 +1,14 @@ +HEADERS = analogclock.h +SOURCES = analogclock.cpp \ + main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/analogclock +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS analogclock.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/analogclock +INSTALLS += target sources + +symbian { + TARGET.UID3 = 0xA000A64F + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) +} diff --git a/examples/widgets/analogclock/main.cpp b/examples/widgets/analogclock/main.cpp new file mode 100644 index 0000000000..0f31f07573 --- /dev/null +++ b/examples/widgets/analogclock/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR 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 "analogclock.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + AnalogClock clock; + clock.show(); + return app.exec(); +} diff --git a/examples/widgets/calculator/button.cpp b/examples/widgets/calculator/button.cpp new file mode 100644 index 0000000000..7bd1783801 --- /dev/null +++ b/examples/widgets/calculator/button.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR 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 "button.h" + +//! [0] +Button::Button(const QString &text, QWidget *parent) + : QToolButton(parent) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + setText(text); +} +//! [0] + +//! [1] +QSize Button::sizeHint() const +//! [1] //! [2] +{ + QSize size = QToolButton::sizeHint(); + size.rheight() += 20; + size.rwidth() = qMax(size.width(), size.height()); + return size; +} +//! [2] diff --git a/examples/widgets/calculator/button.h b/examples/widgets/calculator/button.h new file mode 100644 index 0000000000..385c1db7df --- /dev/null +++ b/examples/widgets/calculator/button.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR 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 BUTTON_H +#define BUTTON_H + +#include + +//! [0] +class Button : public QToolButton +{ + Q_OBJECT + +public: + Button(const QString &text, QWidget *parent = 0); + + QSize sizeHint() const; +}; +//! [0] + +#endif diff --git a/examples/widgets/calculator/calculator.cpp b/examples/widgets/calculator/calculator.cpp new file mode 100644 index 0000000000..991ffc3efc --- /dev/null +++ b/examples/widgets/calculator/calculator.cpp @@ -0,0 +1,397 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR 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 "button.h" +#include "calculator.h" + +//! [0] +Calculator::Calculator(QWidget *parent) + : QDialog(parent) +{ + sumInMemory = 0.0; + sumSoFar = 0.0; + factorSoFar = 0.0; + waitingForOperand = true; +//! [0] + +//! [1] + display = new QLineEdit("0"); +//! [1] //! [2] + display->setReadOnly(true); + display->setAlignment(Qt::AlignRight); + display->setMaxLength(15); + + QFont font = display->font(); + font.setPointSize(font.pointSize() + 8); + display->setFont(font); +//! [2] + +//! [4] + for (int i = 0; i < NumDigitButtons; ++i) { + digitButtons[i] = createButton(QString::number(i), SLOT(digitClicked())); + } + + Button *pointButton = createButton(tr("."), SLOT(pointClicked())); + Button *changeSignButton = createButton(tr("\261"), SLOT(changeSignClicked())); + + Button *backspaceButton = createButton(tr("Backspace"), SLOT(backspaceClicked())); + Button *clearButton = createButton(tr("Clear"), SLOT(clear())); + Button *clearAllButton = createButton(tr("Clear All"), SLOT(clearAll())); + + Button *clearMemoryButton = createButton(tr("MC"), SLOT(clearMemory())); + Button *readMemoryButton = createButton(tr("MR"), SLOT(readMemory())); + Button *setMemoryButton = createButton(tr("MS"), SLOT(setMemory())); + Button *addToMemoryButton = createButton(tr("M+"), SLOT(addToMemory())); + + Button *divisionButton = createButton(tr("\367"), SLOT(multiplicativeOperatorClicked())); + Button *timesButton = createButton(tr("\327"), SLOT(multiplicativeOperatorClicked())); + Button *minusButton = createButton(tr("-"), SLOT(additiveOperatorClicked())); + Button *plusButton = createButton(tr("+"), SLOT(additiveOperatorClicked())); + + Button *squareRootButton = createButton(tr("Sqrt"), SLOT(unaryOperatorClicked())); + Button *powerButton = createButton(tr("x\262"), SLOT(unaryOperatorClicked())); + Button *reciprocalButton = createButton(tr("1/x"), SLOT(unaryOperatorClicked())); + Button *equalButton = createButton(tr("="), SLOT(equalClicked())); +//! [4] + +//! [5] + QGridLayout *mainLayout = new QGridLayout; +//! [5] //! [6] + mainLayout->setSizeConstraint(QLayout::SetFixedSize); + + mainLayout->addWidget(display, 0, 0, 1, 6); + mainLayout->addWidget(backspaceButton, 1, 0, 1, 2); + mainLayout->addWidget(clearButton, 1, 2, 1, 2); + mainLayout->addWidget(clearAllButton, 1, 4, 1, 2); + + mainLayout->addWidget(clearMemoryButton, 2, 0); + mainLayout->addWidget(readMemoryButton, 3, 0); + mainLayout->addWidget(setMemoryButton, 4, 0); + mainLayout->addWidget(addToMemoryButton, 5, 0); + + for (int i = 1; i < NumDigitButtons; ++i) { + int row = ((9 - i) / 3) + 2; + int column = ((i - 1) % 3) + 1; + mainLayout->addWidget(digitButtons[i], row, column); + } + + mainLayout->addWidget(digitButtons[0], 5, 1); + mainLayout->addWidget(pointButton, 5, 2); + mainLayout->addWidget(changeSignButton, 5, 3); + + mainLayout->addWidget(divisionButton, 2, 4); + mainLayout->addWidget(timesButton, 3, 4); + mainLayout->addWidget(minusButton, 4, 4); + mainLayout->addWidget(plusButton, 5, 4); + + mainLayout->addWidget(squareRootButton, 2, 5); + mainLayout->addWidget(powerButton, 3, 5); + mainLayout->addWidget(reciprocalButton, 4, 5); + mainLayout->addWidget(equalButton, 5, 5); + setLayout(mainLayout); + + setWindowTitle(tr("Calculator")); +} +//! [6] + +//! [7] +void Calculator::digitClicked() +{ + Button *clickedButton = qobject_cast