summaryrefslogtreecommitdiffstats
path: root/examples/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets')
-rw-r--r--examples/widgets/CMakeLists.txt10
-rw-r--r--examples/widgets/animation/easing/CMakeLists.txt34
-rw-r--r--examples/widgets/animation/easing/main.cpp1
-rw-r--r--examples/widgets/animation/easing/window.cpp16
-rw-r--r--examples/widgets/animation/easing/window.h5
-rw-r--r--examples/widgets/desktop/screenshot/CMakeLists.txt33
-rw-r--r--examples/widgets/desktop/screenshot/screenshot.cpp2
-rw-r--r--examples/widgets/desktop/systray/CMakeLists.txt33
-rw-r--r--examples/widgets/desktop/systray/doc/images/systemtray-editor.pngbin25407 -> 16137 bytes
-rw-r--r--examples/widgets/desktop/systray/doc/images/systemtray-example.pngbin47588 -> 49858 bytes
-rw-r--r--examples/widgets/desktop/systray/doc/src/systray.qdoc1
-rw-r--r--examples/widgets/desktop/systray/images/bad.pngbin2496 -> 2101 bytes
-rw-r--r--examples/widgets/desktop/systray/images/heart.pngbin25780 -> 1834 bytes
-rw-r--r--examples/widgets/desktop/systray/images/trash.pngbin12128 -> 1285 bytes
-rw-r--r--examples/widgets/desktop/systray/main.cpp2
-rw-r--r--examples/widgets/dialogs/CMakeLists.txt11
-rw-r--r--examples/widgets/dialogs/classwizard/CMakeLists.txt55
-rw-r--r--examples/widgets/dialogs/classwizard/classwizard.cpp394
-rw-r--r--examples/widgets/dialogs/classwizard/classwizard.h119
-rw-r--r--examples/widgets/dialogs/classwizard/classwizard.pro10
-rw-r--r--examples/widgets/dialogs/classwizard/classwizard.qrc11
-rw-r--r--examples/widgets/dialogs/classwizard/images/background.pngbin22578 -> 0 bytes
-rw-r--r--examples/widgets/dialogs/classwizard/images/banner.pngbin3947 -> 0 bytes
-rw-r--r--examples/widgets/dialogs/classwizard/images/logo1.pngbin1619 -> 0 bytes
-rw-r--r--examples/widgets/dialogs/classwizard/images/logo2.pngbin1619 -> 0 bytes
-rw-r--r--examples/widgets/dialogs/classwizard/images/logo3.pngbin1619 -> 0 bytes
-rw-r--r--examples/widgets/dialogs/classwizard/images/watermark1.pngbin14516 -> 0 bytes
-rw-r--r--examples/widgets/dialogs/classwizard/images/watermark2.pngbin14912 -> 0 bytes
-rw-r--r--examples/widgets/dialogs/classwizard/main.cpp28
-rw-r--r--examples/widgets/dialogs/dialogs.pro5
-rw-r--r--examples/widgets/dialogs/extension/CMakeLists.txt37
-rw-r--r--examples/widgets/dialogs/extension/extension.pro9
-rw-r--r--examples/widgets/dialogs/extension/finddialog.cpp77
-rw-r--r--examples/widgets/dialogs/extension/finddialog.h41
-rw-r--r--examples/widgets/dialogs/extension/main.cpp16
-rw-r--r--examples/widgets/dialogs/findfiles/CMakeLists.txt37
-rw-r--r--examples/widgets/dialogs/findfiles/findfiles.pro10
-rw-r--r--examples/widgets/dialogs/findfiles/main.cpp14
-rw-r--r--examples/widgets/dialogs/findfiles/window.cpp264
-rw-r--r--examples/widgets/dialogs/findfiles/window.h50
-rw-r--r--examples/widgets/dialogs/licensewizard/CMakeLists.txt35
-rw-r--r--examples/widgets/dialogs/licensewizard/licensewizard.cpp5
-rw-r--r--examples/widgets/dialogs/licensewizard/main.cpp2
-rw-r--r--examples/widgets/dialogs/standarddialogs/CMakeLists.txt33
-rw-r--r--examples/widgets/dialogs/standarddialogs/dialog.cpp81
-rw-r--r--examples/widgets/dialogs/standarddialogs/dialog.h1
-rw-r--r--examples/widgets/dialogs/standarddialogs/main.mm47
-rw-r--r--examples/widgets/dialogs/tabdialog/CMakeLists.txt33
-rw-r--r--examples/widgets/dialogs/trivialwizard/CMakeLists.txt33
-rw-r--r--examples/widgets/dialogs/trivialwizard/trivialwizard.cpp2
-rw-r--r--examples/widgets/doc/dropsite.qdoc1
-rw-r--r--examples/widgets/doc/images/analogclock-viewport.pngbin29668 -> 176093 bytes
-rw-r--r--examples/widgets/doc/images/calendar-example.pngbin13539 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/draganddroppuzzle-example.pngbin259104 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/echoplugin.pngbin7758 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/echopluginexample.pngbin10610 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/fademessageeffect-example-faded.pngbin81894 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/fademessageeffect-example.pngbin104987 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/fridgemagnets-example.pngbin31707 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/graphicsanchorlayout-example.pngbin24372 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/graphicsflowlayout-example.pngbin18988 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/imagegestures-example.jpgbin38962 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/imagegestures-example.pngbin0 -> 300080 bytes
-rw-r--r--examples/widgets/doc/images/imageviewer-fit_to_window_1.pngbin84584 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/imageviewer-fit_to_window_2.pngbin145998 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/imageviewer-original_size.pngbin61567 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/imageviewer-zoom_in_1.pngbin84559 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/imageviewer-zoom_in_2.pngbin85537 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/itemviewspuzzle-example.pngbin196251 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/mainwindow-demo.pngbin85771 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/mousebutton-buttontester.pngbin17428 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/plugandpaint-plugindialog.pngbin8706 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/plugandpaint.pngbin7540 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/settingseditor-example.pngbin19473 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/stylepluginexample.pngbin5259 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/stylesheet-pagefold.pngbin29118 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/textedit-demo.pngbin46980 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/undodemo.pngbin84941 -> 0 bytes
-rw-r--r--examples/widgets/doc/images/weatheranchorlayout-example.pngbin88805 -> 0 bytes
-rw-r--r--examples/widgets/doc/mousebuttons.qdoc70
-rw-r--r--examples/widgets/doc/src/addressbook-tutorial.qdoc948
-rw-r--r--examples/widgets/doc/src/addressbook.qdoc19
-rw-r--r--examples/widgets/doc/src/affine.qdoc3
-rw-r--r--examples/widgets/doc/src/analogclock.qdoc85
-rw-r--r--examples/widgets/doc/src/application.qdoc371
-rw-r--r--examples/widgets/doc/src/basicdrawing.qdoc1
-rw-r--r--examples/widgets/doc/src/basicgraphicslayouts.qdoc1
-rw-r--r--examples/widgets/doc/src/basiclayouts.qdoc1
-rw-r--r--examples/widgets/doc/src/basicsortfiltermodel.qdoc1
-rw-r--r--examples/widgets/doc/src/blurpicker.qdoc20
-rw-r--r--examples/widgets/doc/src/borderlayout.qdoc46
-rw-r--r--examples/widgets/doc/src/calculator.qdoc1
-rw-r--r--examples/widgets/doc/src/calendar.qdoc202
-rw-r--r--examples/widgets/doc/src/calendarwidget.qdoc1
-rw-r--r--examples/widgets/doc/src/charactermap.qdoc251
-rw-r--r--examples/widgets/doc/src/chart.qdoc58
-rw-r--r--examples/widgets/doc/src/chip.qdoc1
-rw-r--r--examples/widgets/doc/src/classwizard.qdoc167
-rw-r--r--examples/widgets/doc/src/codeeditor.qdoc173
-rw-r--r--examples/widgets/doc/src/collidingmice-example.qdoc1
-rw-r--r--examples/widgets/doc/src/coloreditorfactory.qdoc13
-rw-r--r--examples/widgets/doc/src/combowidgetmapper.qdoc21
-rw-r--r--examples/widgets/doc/src/completer.qdoc5
-rw-r--r--examples/widgets/doc/src/composition.qdoc3
-rw-r--r--examples/widgets/doc/src/concentriccircles.qdoc209
-rw-r--r--examples/widgets/doc/src/cuberhiwidget.qdoc170
-rw-r--r--examples/widgets/doc/src/customsortfiltermodel.qdoc1
-rw-r--r--examples/widgets/doc/src/deform.qdoc1
-rw-r--r--examples/widgets/doc/src/diagramscene.qdoc9
-rw-r--r--examples/widgets/doc/src/digitalclock.qdoc51
-rw-r--r--examples/widgets/doc/src/dirview.qdoc49
-rw-r--r--examples/widgets/doc/src/dockwidgets.qdoc140
-rw-r--r--examples/widgets/doc/src/draganddroppuzzle.qdoc18
-rw-r--r--examples/widgets/doc/src/dragdroprobot.qdoc1
-rw-r--r--examples/widgets/doc/src/draggableicons.qdoc1
-rw-r--r--examples/widgets/doc/src/draggabletext.qdoc1
-rw-r--r--examples/widgets/doc/src/dynamiclayouts.qdoc91
-rw-r--r--examples/widgets/doc/src/easing.qdoc1
-rw-r--r--examples/widgets/doc/src/echoplugin.qdoc181
-rw-r--r--examples/widgets/doc/src/editabletreemodel.qdoc52
-rw-r--r--examples/widgets/doc/src/elasticnodes.qdoc3
-rw-r--r--examples/widgets/doc/src/elidedlabel.qdoc131
-rw-r--r--examples/widgets/doc/src/embeddeddialogs.qdoc15
-rw-r--r--examples/widgets/doc/src/extension.qdoc121
-rw-r--r--examples/widgets/doc/src/fademessage.qdoc15
-rw-r--r--examples/widgets/doc/src/fetchmore.qdoc1
-rw-r--r--examples/widgets/doc/src/findfiles.qdoc269
-rw-r--r--examples/widgets/doc/src/flowlayout.qdoc1
-rw-r--r--examples/widgets/doc/src/fontsampler.qdoc13
-rw-r--r--examples/widgets/doc/src/fridgemagnets.qdoc338
-rw-r--r--examples/widgets/doc/src/frozencolumn.qdoc1
-rw-r--r--examples/widgets/doc/src/gallery.qdoc1
-rw-r--r--examples/widgets/doc/src/gradients.qdoc1
-rw-r--r--examples/widgets/doc/src/graphicsview-anchorlayout.qdoc57
-rw-r--r--examples/widgets/doc/src/graphicsview-flowlayout.qdoc28
-rw-r--r--examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc3
-rw-r--r--examples/widgets/doc/src/graphicsview-weatheranchorlayout.qdoc14
-rw-r--r--examples/widgets/doc/src/groupbox.qdoc1
-rw-r--r--examples/widgets/doc/src/i18n.qdoc16
-rw-r--r--examples/widgets/doc/src/icons.qdoc805
-rw-r--r--examples/widgets/doc/src/imagecomposition.qdoc1
-rw-r--r--examples/widgets/doc/src/imageviewer.qdoc320
-rw-r--r--examples/widgets/doc/src/interview.qdoc15
-rw-r--r--examples/widgets/doc/src/itemviewspuzzle.qdoc19
-rw-r--r--examples/widgets/doc/src/licensewizard.qdoc5
-rw-r--r--examples/widgets/doc/src/lineedits.qdoc1
-rw-r--r--examples/widgets/doc/src/mainwindow.qdoc13
-rw-r--r--examples/widgets/doc/src/mdi.qdoc14
-rw-r--r--examples/widgets/doc/src/menus.qdoc4
-rw-r--r--examples/widgets/doc/src/movie.qdoc16
-rw-r--r--examples/widgets/doc/src/orderform.qdoc1
-rw-r--r--examples/widgets/doc/src/painterpaths.qdoc12
-rw-r--r--examples/widgets/doc/src/pathstroke.qdoc1
-rw-r--r--examples/widgets/doc/src/pixelator.qdoc231
-rw-r--r--examples/widgets/doc/src/plugandpaint.qdoc527
-rw-r--r--examples/widgets/doc/src/regularexpression.qdoc1
-rw-r--r--examples/widgets/doc/src/screenshot.qdoc3
-rw-r--r--examples/widgets/doc/src/scribble.qdoc1
-rw-r--r--examples/widgets/doc/src/sdi.qdoc13
-rw-r--r--examples/widgets/doc/src/settingseditor.qdoc14
-rw-r--r--examples/widgets/doc/src/shapedclock.qdoc76
-rw-r--r--examples/widgets/doc/src/shortcuteditor.qdoc231
-rw-r--r--examples/widgets/doc/src/simpledommodel.qdoc256
-rw-r--r--examples/widgets/doc/src/simplerhiwidget.qdoc204
-rw-r--r--examples/widgets/doc/src/simpletreemodel.qdoc51
-rw-r--r--examples/widgets/doc/src/simplewidgetmapper.qdoc101
-rw-r--r--examples/widgets/doc/src/sliders.qdoc89
-rw-r--r--examples/widgets/doc/src/spinboxdelegate.qdoc117
-rw-r--r--examples/widgets/doc/src/spinboxes.qdoc1
-rw-r--r--examples/widgets/doc/src/spreadsheet.qdoc1
-rw-r--r--examples/widgets/doc/src/standarddialogs.qdoc1
-rw-r--r--examples/widgets/doc/src/stardelegate.qdoc1
-rw-r--r--examples/widgets/doc/src/styleplugin.qdoc114
-rw-r--r--examples/widgets/doc/src/styles.qdoc448
-rw-r--r--examples/widgets/doc/src/stylesheet.qdoc64
-rw-r--r--examples/widgets/doc/src/syntaxhighlighter.qdoc7
-rw-r--r--examples/widgets/doc/src/tabdialog.qdoc1
-rw-r--r--examples/widgets/doc/src/tablet.qdoc7
-rw-r--r--examples/widgets/doc/src/tetrix.qdoc407
-rw-r--r--examples/widgets/doc/src/textedit.qdoc15
-rw-r--r--examples/widgets/doc/src/tooltips.qdoc370
-rw-r--r--examples/widgets/doc/src/transformations.qdoc1
-rw-r--r--examples/widgets/doc/src/treemodelcompleter.qdoc1
-rw-r--r--examples/widgets/doc/src/trivialwizard.qdoc3
-rw-r--r--examples/widgets/doc/src/undo.qdoc20
-rw-r--r--examples/widgets/doc/src/undoframework.qdoc42
-rw-r--r--examples/widgets/doc/src/validators.qdoc11
-rw-r--r--examples/widgets/doc/src/wiggly.qdoc144
-rw-r--r--examples/widgets/doc/src/windowflags.qdoc1
-rw-r--r--examples/widgets/draganddrop/CMakeLists.txt4
-rw-r--r--examples/widgets/draganddrop/draganddrop.pro4
-rw-r--r--examples/widgets/draganddrop/draggableicons/CMakeLists.txt38
-rw-r--r--examples/widgets/draganddrop/draggableicons/draggableicons.pro4
-rw-r--r--examples/widgets/draganddrop/draggableicons/dragwidget.cpp2
-rw-r--r--examples/widgets/draganddrop/draggableicons/main.cpp2
-rw-r--r--examples/widgets/draganddrop/draggabletext/CMakeLists.txt37
-rw-r--r--examples/widgets/draganddrop/draggabletext/draggabletext.pro3
-rw-r--r--examples/widgets/draganddrop/draggabletext/main.cpp2
-rw-r--r--examples/widgets/draganddrop/draggabletext/words.txt64
-rw-r--r--examples/widgets/draganddrop/dropsite/CMakeLists.txt33
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/CMakeLists.txt50
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/draglabel.cpp51
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/draglabel.h27
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp176
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/dragwidget.h28
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/fridgemagnets.pro12
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/fridgemagnets.qrc5
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/main.cpp25
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/words.txt48
-rw-r--r--examples/widgets/draganddrop/puzzle/CMakeLists.txt51
-rw-r--r--examples/widgets/draganddrop/puzzle/example.jpgbin42654 -> 0 bytes
-rw-r--r--examples/widgets/draganddrop/puzzle/main.cpp17
-rw-r--r--examples/widgets/draganddrop/puzzle/mainwindow.cpp118
-rw-r--r--examples/widgets/draganddrop/puzzle/mainwindow.h40
-rw-r--r--examples/widgets/draganddrop/puzzle/pieceslist.cpp87
-rw-r--r--examples/widgets/draganddrop/puzzle/pieceslist.h28
-rw-r--r--examples/widgets/draganddrop/puzzle/puzzle.pro17
-rw-r--r--examples/widgets/draganddrop/puzzle/puzzle.qrc5
-rw-r--r--examples/widgets/draganddrop/puzzle/puzzlewidget.cpp167
-rw-r--r--examples/widgets/draganddrop/puzzle/puzzlewidget.h56
-rw-r--r--examples/widgets/effects/CMakeLists.txt2
-rw-r--r--examples/widgets/effects/blurpicker/CMakeLists.txt58
-rw-r--r--examples/widgets/effects/blurpicker/blureffect.cpp31
-rw-r--r--examples/widgets/effects/blurpicker/blureffect.h29
-rw-r--r--examples/widgets/effects/blurpicker/blurpicker.cpp122
-rw-r--r--examples/widgets/effects/blurpicker/blurpicker.h38
-rw-r--r--examples/widgets/effects/blurpicker/blurpicker.pro9
-rw-r--r--examples/widgets/effects/blurpicker/blurpicker.qrc14
-rw-r--r--examples/widgets/effects/blurpicker/images/README.txt5
-rw-r--r--examples/widgets/effects/blurpicker/images/accessories-calculator.pngbin3760 -> 0 bytes
-rw-r--r--examples/widgets/effects/blurpicker/images/accessories-text-editor.pngbin4746 -> 0 bytes
-rw-r--r--examples/widgets/effects/blurpicker/images/background.jpgbin16259 -> 0 bytes
-rw-r--r--examples/widgets/effects/blurpicker/images/help-browser.pngbin5392 -> 0 bytes
-rw-r--r--examples/widgets/effects/blurpicker/images/internet-group-chat.pngbin2809 -> 0 bytes
-rw-r--r--examples/widgets/effects/blurpicker/images/internet-mail.pngbin3899 -> 0 bytes
-rw-r--r--examples/widgets/effects/blurpicker/images/internet-web-browser.pngbin6376 -> 0 bytes
-rw-r--r--examples/widgets/effects/blurpicker/images/office-calendar.pngbin4010 -> 0 bytes
-rw-r--r--examples/widgets/effects/blurpicker/images/system-users.pngbin5353 -> 0 bytes
-rw-r--r--examples/widgets/effects/blurpicker/main.cpp18
-rw-r--r--examples/widgets/effects/effects.pro5
-rw-r--r--examples/widgets/effects/fademessage/CMakeLists.txt49
-rw-r--r--examples/widgets/effects/fademessage/README2
-rw-r--r--examples/widgets/effects/fademessage/background.jpgbin159108 -> 0 bytes
-rw-r--r--examples/widgets/effects/fademessage/fademessage.cpp91
-rw-r--r--examples/widgets/effects/fademessage/fademessage.h33
-rw-r--r--examples/widgets/effects/fademessage/fademessage.pro9
-rw-r--r--examples/widgets/effects/fademessage/fademessage.qrc5
-rw-r--r--examples/widgets/effects/fademessage/main.cpp18
-rw-r--r--examples/widgets/gallery/CMakeLists.txt33
-rw-r--r--examples/widgets/gestures/CMakeLists.txt4
-rw-r--r--examples/widgets/gestures/imagegestures/CMakeLists.txt33
-rw-r--r--examples/widgets/gestures/imagegestures/doc/src/imagegestures.qdoc3
-rw-r--r--examples/widgets/gestures/imagegestures/imagewidget.cpp38
-rw-r--r--examples/widgets/gestures/imagegestures/imagewidget.h7
-rw-r--r--examples/widgets/graphicsview/CMakeLists.txt6
-rw-r--r--examples/widgets/graphicsview/anchorlayout/CMakeLists.txt36
-rw-r--r--examples/widgets/graphicsview/anchorlayout/anchorlayout.pro9
-rw-r--r--examples/widgets/graphicsview/anchorlayout/main.cpp89
-rw-r--r--examples/widgets/graphicsview/basicgraphicslayouts/CMakeLists.txt33
-rw-r--r--examples/widgets/graphicsview/chip/CMakeLists.txt39
-rw-r--r--examples/widgets/graphicsview/chip/main.cpp2
-rw-r--r--examples/widgets/graphicsview/chip/mainwindow.cpp3
-rw-r--r--examples/widgets/graphicsview/collidingmice/CMakeLists.txt33
-rw-r--r--examples/widgets/graphicsview/diagramscene/CMakeLists.txt33
-rw-r--r--examples/widgets/graphicsview/diagramscene/diagramitem.cpp2
-rw-r--r--examples/widgets/graphicsview/diagramscene/main.cpp2
-rw-r--r--examples/widgets/graphicsview/diagramscene/mainwindow.cpp15
-rw-r--r--examples/widgets/graphicsview/diagramscene/mainwindow.h4
-rw-r--r--examples/widgets/graphicsview/dragdroprobot/CMakeLists.txt33
-rw-r--r--examples/widgets/graphicsview/elasticnodes/CMakeLists.txt33
-rw-r--r--examples/widgets/graphicsview/elasticnodes/graphwidget.cpp4
-rw-r--r--examples/widgets/graphicsview/elasticnodes/node.cpp4
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/CMakeLists.txt51
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/No-Ones-Laughing-3.jpgbin30730 -> 0 bytes
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/customproxy.cpp133
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/customproxy.h39
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.cpp70
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.h33
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.ui88
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/embeddeddialogs.pro18
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/embeddeddialogs.qrc5
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/main.cpp43
-rw-r--r--examples/widgets/graphicsview/flowlayout/CMakeLists.txt38
-rw-r--r--examples/widgets/graphicsview/flowlayout/flowlayout.cpp170
-rw-r--r--examples/widgets/graphicsview/flowlayout/flowlayout.h39
-rw-r--r--examples/widgets/graphicsview/flowlayout/flowlayout.pro10
-rw-r--r--examples/widgets/graphicsview/flowlayout/main.cpp24
-rw-r--r--examples/widgets/graphicsview/flowlayout/window.cpp24
-rw-r--r--examples/widgets/graphicsview/flowlayout/window.h11
-rw-r--r--examples/widgets/graphicsview/graphicsview.pro6
-rw-r--r--examples/widgets/graphicsview/simpleanchorlayout/CMakeLists.txt33
-rw-r--r--examples/widgets/graphicsview/weatheranchorlayout/CMakeLists.txt53
-rw-r--r--examples/widgets/graphicsview/weatheranchorlayout/images/5days.jpgbin5748 -> 0 bytes
-rw-r--r--examples/widgets/graphicsview/weatheranchorlayout/images/details.jpgbin5323 -> 0 bytes
-rw-r--r--examples/widgets/graphicsview/weatheranchorlayout/images/place.jpgbin62438 -> 0 bytes
-rw-r--r--examples/widgets/graphicsview/weatheranchorlayout/images/tabbar.jpgbin849 -> 0 bytes
-rw-r--r--examples/widgets/graphicsview/weatheranchorlayout/images/title.jpgbin3472 -> 0 bytes
-rw-r--r--examples/widgets/graphicsview/weatheranchorlayout/images/weather-few-clouds.pngbin18976 -> 0 bytes
-rw-r--r--examples/widgets/graphicsview/weatheranchorlayout/main.cpp239
-rw-r--r--examples/widgets/graphicsview/weatheranchorlayout/weatheranchorlayout.pro8
-rw-r--r--examples/widgets/graphicsview/weatheranchorlayout/weatheranchorlayout.qrc10
-rw-r--r--examples/widgets/itemviews/CMakeLists.txt17
-rw-r--r--examples/widgets/itemviews/addressbook/CMakeLists.txt33
-rw-r--r--examples/widgets/itemviews/addressbook/addresswidget.cpp6
-rw-r--r--examples/widgets/itemviews/addressbook/addresswidget.h8
-rw-r--r--examples/widgets/itemviews/addressbook/mainwindow.cpp10
-rw-r--r--examples/widgets/itemviews/basicsortfiltermodel/CMakeLists.txt33
-rw-r--r--examples/widgets/itemviews/chart/CMakeLists.txt56
-rw-r--r--examples/widgets/itemviews/chart/chart.pro14
-rw-r--r--examples/widgets/itemviews/chart/chart.qrc5
-rw-r--r--examples/widgets/itemviews/chart/main.cpp16
-rw-r--r--examples/widgets/itemviews/chart/mainwindow.cpp136
-rw-r--r--examples/widgets/itemviews/chart/mainwindow.h34
-rw-r--r--examples/widgets/itemviews/chart/pieview.cpp510
-rw-r--r--examples/widgets/itemviews/chart/pieview.h66
-rw-r--r--examples/widgets/itemviews/chart/qtdata.cht14
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/CMakeLists.txt33
-rw-r--r--examples/widgets/itemviews/combowidgetmapper/CMakeLists.txt33
-rw-r--r--examples/widgets/itemviews/customsortfiltermodel/CMakeLists.txt33
-rw-r--r--examples/widgets/itemviews/dirview/CMakeLists.txt36
-rw-r--r--examples/widgets/itemviews/dirview/dirview.pro8
-rw-r--r--examples/widgets/itemviews/dirview/main.cpp62
-rw-r--r--examples/widgets/itemviews/editabletreemodel/CMakeLists.txt66
-rw-r--r--examples/widgets/itemviews/editabletreemodel/main.cpp7
-rw-r--r--examples/widgets/itemviews/editabletreemodel/mainwindow.cpp9
-rw-r--r--examples/widgets/itemviews/editabletreemodel/test.cpp37
-rw-r--r--examples/widgets/itemviews/editabletreemodel/treeitem.cpp84
-rw-r--r--examples/widgets/itemviews/editabletreemodel/treeitem.h11
-rw-r--r--examples/widgets/itemviews/editabletreemodel/treemodel.cpp108
-rw-r--r--examples/widgets/itemviews/editabletreemodel/treemodel.h22
-rw-r--r--examples/widgets/itemviews/fetchmore/CMakeLists.txt33
-rw-r--r--examples/widgets/itemviews/flattreeview/CMakeLists.txt36
-rw-r--r--examples/widgets/itemviews/flattreeview/flattreeview.pro7
-rw-r--r--examples/widgets/itemviews/flattreeview/main.cpp37
-rw-r--r--examples/widgets/itemviews/frozencolumn/CMakeLists.txt33
-rw-r--r--examples/widgets/itemviews/frozencolumn/main.cpp3
-rw-r--r--examples/widgets/itemviews/interview/CMakeLists.txt51
-rw-r--r--examples/widgets/itemviews/interview/README2
-rw-r--r--examples/widgets/itemviews/interview/images/folder.pngbin3910 -> 0 bytes
-rw-r--r--examples/widgets/itemviews/interview/images/interview.pngbin174 -> 0 bytes
-rw-r--r--examples/widgets/itemviews/interview/images/services.pngbin3749 -> 0 bytes
-rw-r--r--examples/widgets/itemviews/interview/interview.pro16
-rw-r--r--examples/widgets/itemviews/interview/interview.qrc7
-rw-r--r--examples/widgets/itemviews/interview/main.cpp57
-rw-r--r--examples/widgets/itemviews/interview/model.cpp110
-rw-r--r--examples/widgets/itemviews/interview/model.h53
-rw-r--r--examples/widgets/itemviews/itemviews.pro14
-rw-r--r--examples/widgets/itemviews/pixelator/CMakeLists.txt60
-rw-r--r--examples/widgets/itemviews/pixelator/imagemodel.cpp53
-rw-r--r--examples/widgets/itemviews/pixelator/imagemodel.h31
-rw-r--r--examples/widgets/itemviews/pixelator/images.qrc5
-rw-r--r--examples/widgets/itemviews/pixelator/images/qt.pngbin1506 -> 0 bytes
-rw-r--r--examples/widgets/itemviews/pixelator/main.cpp17
-rw-r--r--examples/widgets/itemviews/pixelator/mainwindow.cpp214
-rw-r--r--examples/widgets/itemviews/pixelator/mainwindow.h37
-rw-r--r--examples/widgets/itemviews/pixelator/pixelator.pro16
-rw-r--r--examples/widgets/itemviews/pixelator/pixeldelegate.cpp68
-rw-r--r--examples/widgets/itemviews/pixelator/pixeldelegate.h41
-rw-r--r--examples/widgets/itemviews/puzzle/CMakeLists.txt51
-rw-r--r--examples/widgets/itemviews/puzzle/example.jpgbin42654 -> 0 bytes
-rw-r--r--examples/widgets/itemviews/puzzle/main.cpp17
-rw-r--r--examples/widgets/itemviews/puzzle/mainwindow.cpp115
-rw-r--r--examples/widgets/itemviews/puzzle/mainwindow.h41
-rw-r--r--examples/widgets/itemviews/puzzle/piecesmodel.cpp168
-rw-r--r--examples/widgets/itemviews/puzzle/piecesmodel.h45
-rw-r--r--examples/widgets/itemviews/puzzle/puzzle.pro15
-rw-r--r--examples/widgets/itemviews/puzzle/puzzle.qrc5
-rw-r--r--examples/widgets/itemviews/puzzle/puzzlewidget.cpp163
-rw-r--r--examples/widgets/itemviews/puzzle/puzzlewidget.h56
-rw-r--r--examples/widgets/itemviews/simpledommodel/CMakeLists.txt40
-rw-r--r--examples/widgets/itemviews/simpledommodel/domitem.cpp62
-rw-r--r--examples/widgets/itemviews/simpledommodel/domitem.h29
-rw-r--r--examples/widgets/itemviews/simpledommodel/dommodel.cpp153
-rw-r--r--examples/widgets/itemviews/simpledommodel/dommodel.h38
-rw-r--r--examples/widgets/itemviews/simpledommodel/main.cpp15
-rw-r--r--examples/widgets/itemviews/simpledommodel/mainwindow.cpp47
-rw-r--r--examples/widgets/itemviews/simpledommodel/mainwindow.h33
-rw-r--r--examples/widgets/itemviews/simpledommodel/simpledommodel.pro14
-rw-r--r--examples/widgets/itemviews/simpletreemodel/CMakeLists.txt65
-rw-r--r--examples/widgets/itemviews/simpletreemodel/main.cpp20
-rw-r--r--examples/widgets/itemviews/simpletreemodel/test.cpp35
-rw-r--r--examples/widgets/itemviews/simpletreemodel/treeitem.cpp54
-rw-r--r--examples/widgets/itemviews/simpletreemodel/treeitem.h9
-rw-r--r--examples/widgets/itemviews/simpletreemodel/treemodel.cpp125
-rw-r--r--examples/widgets/itemviews/simpletreemodel/treemodel.h14
-rw-r--r--examples/widgets/itemviews/simplewidgetmapper/CMakeLists.txt37
-rw-r--r--examples/widgets/itemviews/simplewidgetmapper/main.cpp14
-rw-r--r--examples/widgets/itemviews/simplewidgetmapper/simplewidgetmapper.pro10
-rw-r--r--examples/widgets/itemviews/simplewidgetmapper/window.cpp93
-rw-r--r--examples/widgets/itemviews/simplewidgetmapper/window.h47
-rw-r--r--examples/widgets/itemviews/spinboxdelegate/CMakeLists.txt37
-rw-r--r--examples/widgets/itemviews/spinboxdelegate/delegate.cpp66
-rw-r--r--examples/widgets/itemviews/spinboxdelegate/main.cpp48
-rw-r--r--examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.pro10
-rw-r--r--examples/widgets/itemviews/spreadsheet/CMakeLists.txt43
-rw-r--r--examples/widgets/itemviews/spreadsheet/main.cpp4
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheet.cpp2
-rw-r--r--examples/widgets/itemviews/stardelegate/CMakeLists.txt33
-rw-r--r--examples/widgets/itemviews/storageview/CMakeLists.txt37
-rw-r--r--examples/widgets/itemviews/storageview/main.cpp32
-rw-r--r--examples/widgets/itemviews/storageview/storagemodel.cpp164
-rw-r--r--examples/widgets/itemviews/storageview/storagemodel.h46
-rw-r--r--examples/widgets/itemviews/storageview/storageview.pro12
-rw-r--r--examples/widgets/layouts/CMakeLists.txt4
-rw-r--r--examples/widgets/layouts/basiclayouts/CMakeLists.txt33
-rw-r--r--examples/widgets/layouts/basiclayouts/main.cpp4
-rw-r--r--examples/widgets/layouts/borderlayout/CMakeLists.txt38
-rw-r--r--examples/widgets/layouts/borderlayout/borderlayout.cpp171
-rw-r--r--examples/widgets/layouts/borderlayout/borderlayout.h50
-rw-r--r--examples/widgets/layouts/borderlayout/borderlayout.pro11
-rw-r--r--examples/widgets/layouts/borderlayout/main.cpp14
-rw-r--r--examples/widgets/layouts/borderlayout/window.cpp31
-rw-r--r--examples/widgets/layouts/borderlayout/window.h24
-rw-r--r--examples/widgets/layouts/dynamiclayouts/CMakeLists.txt37
-rw-r--r--examples/widgets/layouts/dynamiclayouts/dialog.cpp136
-rw-r--r--examples/widgets/layouts/dynamiclayouts/dialog.h53
-rw-r--r--examples/widgets/layouts/dynamiclayouts/dynamiclayouts.pro10
-rw-r--r--examples/widgets/layouts/dynamiclayouts/main.cpp19
-rw-r--r--examples/widgets/layouts/flowlayout/CMakeLists.txt33
-rw-r--r--examples/widgets/layouts/flowlayout/flowlayout.cpp4
-rw-r--r--examples/widgets/layouts/layouts.pro2
-rw-r--r--examples/widgets/mainwindows/CMakeLists.txt7
-rw-r--r--examples/widgets/mainwindows/application/CMakeLists.txt54
-rw-r--r--examples/widgets/mainwindows/application/application.pro13
-rw-r--r--examples/widgets/mainwindows/application/application.qrc10
-rw-r--r--examples/widgets/mainwindows/application/images/copy.pngbin1338 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/application/images/cut.pngbin1323 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/application/images/new.pngbin852 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/application/images/open.pngbin2073 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/application/images/paste.pngbin1645 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/application/images/save.pngbin2699 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/application/main.cpp32
-rw-r--r--examples/widgets/mainwindows/application/mainwindow.cpp370
-rw-r--r--examples/widgets/mainwindows/application/mainwindow.h55
-rw-r--r--examples/widgets/mainwindows/dockwidgets/CMakeLists.txt65
-rw-r--r--examples/widgets/mainwindows/dockwidgets/dockwidgets.pro12
-rw-r--r--examples/widgets/mainwindows/dockwidgets/dockwidgets.qrc8
-rw-r--r--examples/widgets/mainwindows/dockwidgets/images/new.pngbin977 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/dockwidgets/images/print.pngbin1732 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/dockwidgets/images/save.pngbin1894 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/dockwidgets/images/undo.pngbin1768 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/dockwidgets/main.cpp15
-rw-r--r--examples/widgets/mainwindows/dockwidgets/mainwindow.cpp298
-rw-r--r--examples/widgets/mainwindows/dockwidgets/mainwindow.h46
-rw-r--r--examples/widgets/mainwindows/mainwindow/CMakeLists.txt54
-rw-r--r--examples/widgets/mainwindows/mainwindow/colorswatch.cpp685
-rw-r--r--examples/widgets/mainwindows/mainwindow/colorswatch.h102
-rw-r--r--examples/widgets/mainwindows/mainwindow/main.cpp147
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.cpp444
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.h50
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.pro16
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.qrc8
-rw-r--r--examples/widgets/mainwindows/mainwindow/qt.pngbin2991 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mainwindow/titlebarCenter.pngbin146 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mainwindow/titlebarLeft.pngbin5148 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mainwindow/titlebarRight.pngbin2704 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mainwindow/toolbar.cpp316
-rw-r--r--examples/widgets/mainwindows/mainwindow/toolbar.h72
-rw-r--r--examples/widgets/mainwindows/mainwindows.pro7
-rw-r--r--examples/widgets/mainwindows/mdi/CMakeLists.txt55
-rw-r--r--examples/widgets/mainwindows/mdi/images/copy.pngbin1338 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mdi/images/cut.pngbin1323 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mdi/images/new.pngbin852 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mdi/images/open.pngbin2073 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mdi/images/paste.pngbin1645 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mdi/images/save.pngbin2699 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/mdi/main.cpp31
-rw-r--r--examples/widgets/mainwindows/mdi/mainwindow.cpp461
-rw-r--r--examples/widgets/mainwindows/mdi/mainwindow.h84
-rw-r--r--examples/widgets/mainwindows/mdi/mdi.pro13
-rw-r--r--examples/widgets/mainwindows/mdi/mdi.qrc10
-rw-r--r--examples/widgets/mainwindows/mdi/mdichild.cpp150
-rw-r--r--examples/widgets/mainwindows/mdi/mdichild.h39
-rw-r--r--examples/widgets/mainwindows/menus/CMakeLists.txt33
-rw-r--r--examples/widgets/mainwindows/menus/mainwindow.cpp51
-rw-r--r--examples/widgets/mainwindows/sdi/CMakeLists.txt54
-rw-r--r--examples/widgets/mainwindows/sdi/images/copy.pngbin1338 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/sdi/images/cut.pngbin1323 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/sdi/images/new.pngbin852 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/sdi/images/open.pngbin2073 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/sdi/images/paste.pngbin1645 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/sdi/images/save.pngbin2699 -> 0 bytes
-rw-r--r--examples/widgets/mainwindows/sdi/main.cpp37
-rw-r--r--examples/widgets/mainwindows/sdi/mainwindow.cpp445
-rw-r--r--examples/widgets/mainwindows/sdi/mainwindow.h70
-rw-r--r--examples/widgets/mainwindows/sdi/sdi.pro11
-rw-r--r--examples/widgets/mainwindows/sdi/sdi.qrc10
-rw-r--r--examples/widgets/painting/CMakeLists.txt6
-rw-r--r--examples/widgets/painting/affine/CMakeLists.txt52
-rw-r--r--examples/widgets/painting/affine/main.cpp4
-rw-r--r--examples/widgets/painting/affine/xform.cpp12
-rw-r--r--examples/widgets/painting/basicdrawing/CMakeLists.txt33
-rw-r--r--examples/widgets/painting/basicdrawing/main.cpp2
-rw-r--r--examples/widgets/painting/composition/CMakeLists.txt52
-rw-r--r--examples/widgets/painting/composition/composition.cpp113
-rw-r--r--examples/widgets/painting/composition/composition.h14
-rw-r--r--examples/widgets/painting/concentriccircles/CMakeLists.txt38
-rw-r--r--examples/widgets/painting/concentriccircles/circlewidget.cpp84
-rw-r--r--examples/widgets/painting/concentriccircles/circlewidget.h36
-rw-r--r--examples/widgets/painting/concentriccircles/concentriccircles.pro11
-rw-r--r--examples/widgets/painting/concentriccircles/main.cpp14
-rw-r--r--examples/widgets/painting/concentriccircles/window.cpp56
-rw-r--r--examples/widgets/painting/concentriccircles/window.h33
-rw-r--r--examples/widgets/painting/deform/CMakeLists.txt52
-rw-r--r--examples/widgets/painting/deform/main.cpp2
-rw-r--r--examples/widgets/painting/deform/pathdeform.cpp74
-rw-r--r--examples/widgets/painting/fontsampler/CMakeLists.txt48
-rw-r--r--examples/widgets/painting/fontsampler/fontsampler.pro12
-rw-r--r--examples/widgets/painting/fontsampler/main.cpp14
-rw-r--r--examples/widgets/painting/fontsampler/mainwindow.cpp314
-rw-r--r--examples/widgets/painting/fontsampler/mainwindow.h54
-rw-r--r--examples/widgets/painting/fontsampler/mainwindowbase.ui142
-rw-r--r--examples/widgets/painting/gradients/CMakeLists.txt52
-rw-r--r--examples/widgets/painting/gradients/gradients.cpp16
-rw-r--r--examples/widgets/painting/gradients/main.cpp5
-rw-r--r--examples/widgets/painting/imagecomposition/CMakeLists.txt33
-rw-r--r--examples/widgets/painting/imagecomposition/main.cpp2
-rw-r--r--examples/widgets/painting/painterpaths/CMakeLists.txt35
-rw-r--r--examples/widgets/painting/painterpaths/window.cpp10
-rw-r--r--examples/widgets/painting/painting.pro4
-rw-r--r--examples/widgets/painting/pathstroke/CMakeLists.txt52
-rw-r--r--examples/widgets/painting/pathstroke/main.cpp5
-rw-r--r--examples/widgets/painting/pathstroke/pathstroke.cpp29
-rw-r--r--examples/widgets/painting/shared/CMakeLists.txt18
-rw-r--r--examples/widgets/painting/shared/arthurwidgets.cpp80
-rw-r--r--examples/widgets/painting/shared/arthurwidgets.h17
-rw-r--r--examples/widgets/painting/shared/fbopaintdevice.cpp66
-rw-r--r--examples/widgets/painting/shared/fbopaintdevice.h44
-rw-r--r--examples/widgets/painting/shared/hoverpoints.cpp27
-rw-r--r--examples/widgets/painting/shared/shared.pri6
-rw-r--r--examples/widgets/painting/shared/use_lib.cmake6
-rw-r--r--examples/widgets/painting/transformations/CMakeLists.txt33
-rw-r--r--examples/widgets/qnx/foreignwindows/collector.cpp2
-rw-r--r--examples/widgets/qnx/foreignwindows/collector.h2
-rw-r--r--examples/widgets/qnx/foreignwindows/main.cpp2
-rw-r--r--examples/widgets/rhi/CMakeLists.txt8
-rw-r--r--examples/widgets/rhi/cuberhiwidget/CMakeLists.txt48
-rw-r--r--examples/widgets/rhi/cuberhiwidget/cube.h139
-rw-r--r--examples/widgets/rhi/cuberhiwidget/cuberhiwidget.pro12
-rw-r--r--examples/widgets/rhi/cuberhiwidget/cuberhiwidget.qrc6
-rw-r--r--examples/widgets/rhi/cuberhiwidget/examplewidget.cpp172
-rw-r--r--examples/widgets/rhi/cuberhiwidget/examplewidget.h72
-rw-r--r--examples/widgets/rhi/cuberhiwidget/main.cpp166
-rw-r--r--examples/widgets/rhi/cuberhiwidget/shader_assets/texture.frag.qsbbin0 -> 1042 bytes
-rw-r--r--examples/widgets/rhi/cuberhiwidget/shader_assets/texture.vert.qsbbin0 -> 1161 bytes
-rw-r--r--examples/widgets/rhi/cuberhiwidget/shaders/texture.frag12
-rw-r--r--examples/widgets/rhi/cuberhiwidget/shaders/texture.vert15
-rw-r--r--examples/widgets/rhi/rhi.pro4
-rw-r--r--examples/widgets/rhi/simplerhiwidget/CMakeLists.txt48
-rw-r--r--examples/widgets/rhi/simplerhiwidget/examplewidget.cpp102
-rw-r--r--examples/widgets/rhi/simplerhiwidget/examplewidget.h30
-rw-r--r--examples/widgets/rhi/simplerhiwidget/main.cpp26
-rw-r--r--examples/widgets/rhi/simplerhiwidget/shader_assets/color.frag.qsbbin0 -> 738 bytes
-rw-r--r--examples/widgets/rhi/simplerhiwidget/shader_assets/color.vert.qsbbin0 -> 1091 bytes
-rw-r--r--examples/widgets/rhi/simplerhiwidget/shaders/color.frag10
-rw-r--r--examples/widgets/rhi/simplerhiwidget/shaders/color.vert16
-rw-r--r--examples/widgets/rhi/simplerhiwidget/simplerhiwidget.pro12
-rw-r--r--examples/widgets/rhi/simplerhiwidget/simplerhiwidget.qrc6
-rw-r--r--examples/widgets/richtext/CMakeLists.txt4
-rw-r--r--examples/widgets/richtext/calendar/CMakeLists.txt37
-rw-r--r--examples/widgets/richtext/calendar/calendar.pro10
-rw-r--r--examples/widgets/richtext/calendar/main.cpp15
-rw-r--r--examples/widgets/richtext/calendar/mainwindow.cpp179
-rw-r--r--examples/widgets/richtext/calendar/mainwindow.h36
-rw-r--r--examples/widgets/richtext/orderform/CMakeLists.txt39
-rw-r--r--examples/widgets/richtext/richtext.pro6
-rw-r--r--examples/widgets/richtext/syntaxhighlighter/CMakeLists.txt33
-rw-r--r--examples/widgets/richtext/syntaxhighlighter/highlighter.cpp2
-rw-r--r--examples/widgets/richtext/textedit/CMakeLists.txt111
-rw-r--r--examples/widgets/richtext/textedit/example.html84
-rw-r--r--examples/widgets/richtext/textedit/example.md104
-rw-r--r--examples/widgets/richtext/textedit/images/logo32.pngbin1410 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/checkbox-checked.pngbin1167 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/checkbox.pngbin779 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/editcopy.pngbin1468 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/editcut.pngbin1512 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/editpaste.pngbin1906 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/editredo.pngbin1752 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/editundo.pngbin1746 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/exportpdf.pngbin12637 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/filenew.pngbin1172 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/fileopen.pngbin2168 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/fileprint.pngbin2087 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/filesave.pngbin2699 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/format-indent-less.pngbin1201 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/format-indent-more.pngbin993 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/textbold.pngbin1611 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/textcenter.pngbin1404 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/textitalic.pngbin1164 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/textjustify.pngbin1257 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/textleft.pngbin1235 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/textright.pngbin1406 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/textunder.pngbin1183 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/textundercolor.pngbin6916 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/zoomin.pngbin1696 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/mac/zoomout.pngbin1662 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/checkbox-checked.pngbin1167 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/checkbox.pngbin779 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/editcopy.pngbin1325 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/editcut.pngbin1896 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/editpaste.pngbin1482 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/editredo.pngbin1787 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/editundo.pngbin1768 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/exportpdf.pngbin1215 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/filenew.pngbin768 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/fileopen.pngbin1662 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/fileprint.pngbin1456 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/filesave.pngbin1205 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/format-indent-less.pngbin1201 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/format-indent-more.pngbin993 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/textbold.pngbin1134 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/textcenter.pngbin627 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/textitalic.pngbin829 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/textjustify.pngbin695 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/textleft.pngbin673 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/textright.pngbin677 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/textunder.pngbin971 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/textundercolor.pngbin6916 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/zoomin.pngbin1208 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/zoomout.pngbin1226 -> 0 bytes
-rw-r--r--examples/widgets/richtext/textedit/main.cpp38
-rw-r--r--examples/widgets/richtext/textedit/textedit.cpp851
-rw-r--r--examples/widgets/richtext/textedit/textedit.h103
-rw-r--r--examples/widgets/richtext/textedit/textedit.pro22
-rw-r--r--examples/widgets/richtext/textedit/textedit.qdoc20
-rw-r--r--examples/widgets/richtext/textedit/textedit.qrc54
-rw-r--r--examples/widgets/scroller/CMakeLists.txt1
-rw-r--r--examples/widgets/scroller/graphicsview/CMakeLists.txt36
-rw-r--r--examples/widgets/scroller/graphicsview/graphicsview.pro8
-rw-r--r--examples/widgets/scroller/graphicsview/main.cpp255
-rw-r--r--examples/widgets/scroller/scroller.pro2
-rw-r--r--examples/widgets/tools/CMakeLists.txt16
-rw-r--r--examples/widgets/tools/completer/CMakeLists.txt33
-rw-r--r--examples/widgets/tools/completer/main.cpp2
-rw-r--r--examples/widgets/tools/customcompleter/CMakeLists.txt33
-rw-r--r--examples/widgets/tools/customcompleter/main.cpp2
-rw-r--r--examples/widgets/tools/echoplugin/CMakeLists.txt18
-rw-r--r--examples/widgets/tools/echoplugin/echoplugin.pro5
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/CMakeLists.txt31
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/echointerface.h27
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/echowindow.cpp90
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/echowindow.h42
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/echowindow.pro21
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/main.cpp19
-rw-r--r--examples/widgets/tools/echoplugin/plugin/CMakeLists.txt26
-rw-r--r--examples/widgets/tools/echoplugin/plugin/echoplugin.cpp11
-rw-r--r--examples/widgets/tools/echoplugin/plugin/echoplugin.h23
-rw-r--r--examples/widgets/tools/echoplugin/plugin/echoplugin.json1
-rw-r--r--examples/widgets/tools/echoplugin/plugin/plugin.pro18
-rw-r--r--examples/widgets/tools/i18n/CMakeLists.txt63
-rw-r--r--examples/widgets/tools/i18n/i18n.pro27
-rw-r--r--examples/widgets/tools/i18n/i18n.qrc18
-rw-r--r--examples/widgets/tools/i18n/languagechooser.cpp139
-rw-r--r--examples/widgets/tools/i18n/languagechooser.h49
-rw-r--r--examples/widgets/tools/i18n/main.cpp17
-rw-r--r--examples/widgets/tools/i18n/mainwindow.cpp66
-rw-r--r--examples/widgets/tools/i18n/mainwindow.h39
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_ar.qmbin736 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_ar.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_cs.qmbin796 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_cs.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_de.qmbin848 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_de.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_el.qmbin804 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_el.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_en.qmbin810 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_en.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_eo.qmbin806 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_eo.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_fr.qmbin844 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_fr.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_it.qmbin808 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_it.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_jp.qmbin722 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_jp.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_ko.qmbin690 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_ko.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_no.qmbin804 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_no.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_ru.qmbin806 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_ru.ts59
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_sv.qmbin814 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_sv.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_zh.qmbin700 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_zh.ts57
-rw-r--r--examples/widgets/tools/plugandpaint/CMakeLists.txt18
-rw-r--r--examples/widgets/tools/plugandpaint/app/CMakeLists.txt32
-rw-r--r--examples/widgets/tools/plugandpaint/app/app.pro37
-rw-r--r--examples/widgets/tools/plugandpaint/app/interfaces.h76
-rw-r--r--examples/widgets/tools/plugandpaint/app/main.cpp19
-rw-r--r--examples/widgets/tools/plugandpaint/app/mainwindow.cpp282
-rw-r--r--examples/widgets/tools/plugandpaint/app/mainwindow.h68
-rw-r--r--examples/widgets/tools/plugandpaint/app/paintarea.cpp152
-rw-r--r--examples/widgets/tools/plugandpaint/app/paintarea.h54
-rw-r--r--examples/widgets/tools/plugandpaint/app/plugindialog.cpp118
-rw-r--r--examples/widgets/tools/plugandpaint/app/plugindialog.h38
-rw-r--r--examples/widgets/tools/plugandpaint/plugandpaint.pro7
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt2
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt18
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/basictools.json1
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/basictools.pro17
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp150
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.h54
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt26
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.json1
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.pro17
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp82
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.h28
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/plugins.pro3
-rw-r--r--examples/widgets/tools/regularexpression/CMakeLists.txt33
-rw-r--r--examples/widgets/tools/settingseditor/CMakeLists.txt40
-rw-r--r--examples/widgets/tools/settingseditor/inifiles/licensepage.ini46
-rw-r--r--examples/widgets/tools/settingseditor/inifiles/qsa.ini26
-rw-r--r--examples/widgets/tools/settingseditor/locationdialog.cpp193
-rw-r--r--examples/widgets/tools/settingseditor/locationdialog.h49
-rw-r--r--examples/widgets/tools/settingseditor/main.cpp17
-rw-r--r--examples/widgets/tools/settingseditor/mainwindow.cpp175
-rw-r--r--examples/widgets/tools/settingseditor/mainwindow.h44
-rw-r--r--examples/widgets/tools/settingseditor/settingseditor.pro18
-rw-r--r--examples/widgets/tools/settingseditor/settingstree.cpp231
-rw-r--r--examples/widgets/tools/settingseditor/settingstree.h61
-rw-r--r--examples/widgets/tools/settingseditor/variantdelegate.cpp377
-rw-r--r--examples/widgets/tools/settingseditor/variantdelegate.h53
-rw-r--r--examples/widgets/tools/styleplugin/CMakeLists.txt18
-rw-r--r--examples/widgets/tools/styleplugin/plugin/CMakeLists.txt23
-rw-r--r--examples/widgets/tools/styleplugin/plugin/plugin.pro24
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyle.cpp9
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyle.h19
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyle.json3
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyleplugin.cpp21
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h23
-rw-r--r--examples/widgets/tools/styleplugin/styleplugin.pro3
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/CMakeLists.txt30
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/main.cpp21
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/stylewindow.cpp25
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/stylewindow.h17
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/stylewindow.pro19
-rw-r--r--examples/widgets/tools/tools.pro13
-rw-r--r--examples/widgets/tools/treemodelcompleter/CMakeLists.txt33
-rw-r--r--examples/widgets/tools/treemodelcompleter/main.cpp2
-rw-r--r--examples/widgets/tools/undo/CMakeLists.txt69
-rw-r--r--examples/widgets/tools/undo/commands.cpp130
-rw-r--r--examples/widgets/tools/undo/commands.h76
-rw-r--r--examples/widgets/tools/undo/document.cpp401
-rw-r--r--examples/widgets/tools/undo/document.h86
-rw-r--r--examples/widgets/tools/undo/icons/background.pngbin93 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/blue.pngbin1659 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/circle.pngbin1359 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/exit.pngbin1731 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/fileclose.pngbin1121 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/filenew.pngbin1266 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/fileopen.pngbin1771 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/filesave.pngbin1022 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/green.pngbin1766 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/ok.pngbin979 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/red.pngbin1653 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/main.cpp18
-rw-r--r--examples/widgets/tools/undo/mainwindow.cpp410
-rw-r--r--examples/widgets/tools/undo/mainwindow.h49
-rw-r--r--examples/widgets/tools/undo/mainwindow.ui322
-rw-r--r--examples/widgets/tools/undo/undo.pro17
-rw-r--r--examples/widgets/tools/undo/undo.qrc20
-rw-r--r--examples/widgets/tools/undoframework/CMakeLists.txt40
-rw-r--r--examples/widgets/tools/undoframework/icons/cross.png (renamed from examples/widgets/tools/undoframework/images/cross.png)bin356 -> 356 bytes
-rw-r--r--examples/widgets/tools/undoframework/icons/rectangle.png (renamed from examples/widgets/tools/undo/icons/rectangle.png)bin690 -> 690 bytes
-rw-r--r--examples/widgets/tools/undoframework/icons/redo.png (renamed from examples/widgets/tools/undo/icons/redo.png)bin985 -> 985 bytes
-rw-r--r--examples/widgets/tools/undoframework/icons/remove.png (renamed from examples/widgets/tools/undo/icons/remove.png)bin1833 -> 1833 bytes
-rw-r--r--examples/widgets/tools/undoframework/icons/triangle.png (renamed from examples/widgets/tools/undo/icons/triangle.png)bin850 -> 850 bytes
-rw-r--r--examples/widgets/tools/undoframework/icons/undo.png (renamed from examples/widgets/tools/undo/icons/undo.png)bin962 -> 962 bytes
-rw-r--r--examples/widgets/tools/undoframework/main.cpp2
-rw-r--r--examples/widgets/tools/undoframework/mainwindow.cpp91
-rw-r--r--examples/widgets/tools/undoframework/mainwindow.h4
-rw-r--r--examples/widgets/tools/undoframework/undoframework.qrc8
-rw-r--r--examples/widgets/touch/CMakeLists.txt7
-rw-r--r--examples/widgets/touch/dials/CMakeLists.txt38
-rw-r--r--examples/widgets/touch/dials/dials.pro8
-rw-r--r--examples/widgets/touch/dials/dials.ui77
-rw-r--r--examples/widgets/touch/dials/doc/images/touch-dials-example.pngbin17676 -> 0 bytes
-rw-r--r--examples/widgets/touch/dials/doc/src/touch-dials.qdoc14
-rw-r--r--examples/widgets/touch/dials/main.cpp21
-rw-r--r--examples/widgets/touch/fingerpaint/CMakeLists.txt51
-rw-r--r--examples/widgets/touch/fingerpaint/doc/src/fingerpaint.qdoc18
-rw-r--r--examples/widgets/touch/fingerpaint/fingerpaint.pro13
-rw-r--r--examples/widgets/touch/fingerpaint/main.cpp14
-rw-r--r--examples/widgets/touch/fingerpaint/mainwindow.cpp180
-rw-r--r--examples/widgets/touch/fingerpaint/mainwindow.h51
-rw-r--r--examples/widgets/touch/fingerpaint/scribblearea.cpp190
-rw-r--r--examples/widgets/touch/fingerpaint/scribblearea.h43
-rw-r--r--examples/widgets/touch/knobs/CMakeLists.txt33
-rw-r--r--examples/widgets/touch/knobs/doc/images/touch-knobs-example.pngbin1290 -> 13386 bytes
-rw-r--r--examples/widgets/touch/knobs/doc/src/touch-knobs.qdoc1
-rw-r--r--examples/widgets/touch/knobs/main.cpp1
-rw-r--r--examples/widgets/touch/pinchzoom/CMakeLists.txt50
-rw-r--r--examples/widgets/touch/pinchzoom/doc/images/pinch-zoom-example.pngbin42493 -> 0 bytes
-rw-r--r--examples/widgets/touch/pinchzoom/doc/src/pinchzoom.qdoc14
-rw-r--r--examples/widgets/touch/pinchzoom/graphicsview.cpp48
-rw-r--r--examples/widgets/touch/pinchzoom/graphicsview.h18
-rw-r--r--examples/widgets/touch/pinchzoom/images/cheese.jpgbin3029 -> 0 bytes
-rw-r--r--examples/widgets/touch/pinchzoom/main.cpp47
-rw-r--r--examples/widgets/touch/pinchzoom/mice.qrc5
-rw-r--r--examples/widgets/touch/pinchzoom/mouse.cpp158
-rw-r--r--examples/widgets/touch/pinchzoom/mouse.h33
-rw-r--r--examples/widgets/touch/pinchzoom/pinchzoom.pro16
-rw-r--r--examples/widgets/touch/touch.pro2
-rw-r--r--examples/widgets/tutorials/CMakeLists.txt4
-rw-r--r--examples/widgets/tutorials/addressbook/CMakeLists.txt10
-rw-r--r--examples/widgets/tutorials/addressbook/README40
-rw-r--r--examples/widgets/tutorials/addressbook/addressbook.pro6
-rw-r--r--examples/widgets/tutorials/addressbook/part1/CMakeLists.txt37
-rw-r--r--examples/widgets/tutorials/addressbook/part1/addressbook.cpp30
-rw-r--r--examples/widgets/tutorials/addressbook/part1/addressbook.h29
-rw-r--r--examples/widgets/tutorials/addressbook/part1/main.cpp17
-rw-r--r--examples/widgets/tutorials/addressbook/part1/part1.pro11
-rw-r--r--examples/widgets/tutorials/addressbook/part2/CMakeLists.txt37
-rw-r--r--examples/widgets/tutorials/addressbook/part2/addressbook.cpp123
-rw-r--r--examples/widgets/tutorials/addressbook/part2/addressbook.h47
-rw-r--r--examples/widgets/tutorials/addressbook/part2/main.cpp17
-rw-r--r--examples/widgets/tutorials/addressbook/part2/part2.pro11
-rw-r--r--examples/widgets/tutorials/addressbook/part3/CMakeLists.txt37
-rw-r--r--examples/widgets/tutorials/addressbook/part3/addressbook.cpp182
-rw-r--r--examples/widgets/tutorials/addressbook/part3/addressbook.h49
-rw-r--r--examples/widgets/tutorials/addressbook/part3/main.cpp15
-rw-r--r--examples/widgets/tutorials/addressbook/part3/part3.pro11
-rw-r--r--examples/widgets/tutorials/addressbook/part4/CMakeLists.txt37
-rw-r--r--examples/widgets/tutorials/addressbook/part4/addressbook.cpp258
-rw-r--r--examples/widgets/tutorials/addressbook/part4/addressbook.h62
-rw-r--r--examples/widgets/tutorials/addressbook/part4/main.cpp15
-rw-r--r--examples/widgets/tutorials/addressbook/part4/part4.pro11
-rw-r--r--examples/widgets/tutorials/addressbook/part5/CMakeLists.txt38
-rw-r--r--examples/widgets/tutorials/addressbook/part5/addressbook.cpp283
-rw-r--r--examples/widgets/tutorials/addressbook/part5/addressbook.h65
-rw-r--r--examples/widgets/tutorials/addressbook/part5/finddialog.cpp51
-rw-r--r--examples/widgets/tutorials/addressbook/part5/finddialog.h31
-rw-r--r--examples/widgets/tutorials/addressbook/part5/main.cpp15
-rw-r--r--examples/widgets/tutorials/addressbook/part5/part5.pro13
-rw-r--r--examples/widgets/tutorials/addressbook/part6/CMakeLists.txt38
-rw-r--r--examples/widgets/tutorials/addressbook/part6/addressbook.cpp366
-rw-r--r--examples/widgets/tutorials/addressbook/part6/addressbook.h66
-rw-r--r--examples/widgets/tutorials/addressbook/part6/finddialog.cpp47
-rw-r--r--examples/widgets/tutorials/addressbook/part6/finddialog.h31
-rw-r--r--examples/widgets/tutorials/addressbook/part6/main.cpp15
-rw-r--r--examples/widgets/tutorials/addressbook/part6/part6.pro14
-rw-r--r--examples/widgets/tutorials/addressbook/part7/CMakeLists.txt38
-rw-r--r--examples/widgets/tutorials/addressbook/part7/addressbook.cpp419
-rw-r--r--examples/widgets/tutorials/addressbook/part7/addressbook.h68
-rw-r--r--examples/widgets/tutorials/addressbook/part7/finddialog.cpp47
-rw-r--r--examples/widgets/tutorials/addressbook/part7/finddialog.h31
-rw-r--r--examples/widgets/tutorials/addressbook/part7/main.cpp15
-rw-r--r--examples/widgets/tutorials/addressbook/part7/part7.pro14
-rw-r--r--examples/widgets/tutorials/gettingStarted/CMakeLists.txt1
-rw-r--r--examples/widgets/tutorials/gettingStarted/gettingStarted.pro4
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt8
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/gsqt.pro7
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt36
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part1/main.cpp15
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part1/part1.pro8
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt36
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part2/main.cpp27
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part2/part2.pro8
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt36
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part3/main.cpp61
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part3/part3.pro8
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt36
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part4/main.cpp73
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part4/part4.pro8
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt36
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part5/main.cpp99
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part5/part5.pro8
-rw-r--r--examples/widgets/tutorials/modelview/1_readonly/CMakeLists.txt33
-rw-r--r--examples/widgets/tutorials/modelview/2_formatting/CMakeLists.txt33
-rw-r--r--examples/widgets/tutorials/modelview/3_changingmodel/CMakeLists.txt33
-rw-r--r--examples/widgets/tutorials/modelview/4_headers/CMakeLists.txt33
-rw-r--r--examples/widgets/tutorials/modelview/5_edit/CMakeLists.txt33
-rw-r--r--examples/widgets/tutorials/modelview/6_treeview/CMakeLists.txt33
-rw-r--r--examples/widgets/tutorials/modelview/7_selections/CMakeLists.txt33
-rw-r--r--examples/widgets/tutorials/modelview/CMakeLists.txt2
-rw-r--r--examples/widgets/tutorials/notepad/CMakeLists.txt44
-rw-r--r--examples/widgets/tutorials/notepad/gettingstartedqt.qdoc (renamed from examples/widgets/tutorials/gettingstartedqt.qdoc)19
-rw-r--r--examples/widgets/tutorials/tutorials.pro2
-rw-r--r--examples/widgets/tutorials/widgets/CMakeLists.txt2
-rw-r--r--examples/widgets/tutorials/widgets/childwidget/CMakeLists.txt33
-rw-r--r--examples/widgets/tutorials/widgets/nestedlayouts/CMakeLists.txt33
-rw-r--r--examples/widgets/tutorials/widgets/toplevel/CMakeLists.txt33
-rw-r--r--examples/widgets/tutorials/widgets/windowlayout/CMakeLists.txt33
-rw-r--r--examples/widgets/widgets.pro6
-rw-r--r--examples/widgets/widgets/CMakeLists.txt19
-rw-r--r--examples/widgets/widgets/analogclock/CMakeLists.txt33
-rw-r--r--examples/widgets/widgets/analogclock/analogclock.cpp76
-rw-r--r--examples/widgets/widgets/calculator/CMakeLists.txt33
-rw-r--r--examples/widgets/widgets/calculator/calculator.cpp41
-rw-r--r--examples/widgets/widgets/calculator/calculator.h3
-rw-r--r--examples/widgets/widgets/calendarwidget/CMakeLists.txt33
-rw-r--r--examples/widgets/widgets/charactermap/CMakeLists.txt38
-rw-r--r--examples/widgets/widgets/charactermap/charactermap.pro12
-rw-r--r--examples/widgets/widgets/charactermap/characterwidget.cpp145
-rw-r--r--examples/widgets/widgets/charactermap/characterwidget.h50
-rw-r--r--examples/widgets/widgets/charactermap/mainwindow.cpp264
-rw-r--r--examples/widgets/widgets/charactermap/mainwindow.h50
-rw-r--r--examples/widgets/widgets/codeeditor/CMakeLists.txt37
-rw-r--r--examples/widgets/widgets/codeeditor/codeeditor.cpp134
-rw-r--r--examples/widgets/widgets/codeeditor/codeeditor.h68
-rw-r--r--examples/widgets/widgets/codeeditor/codeeditor.pro8
-rw-r--r--examples/widgets/widgets/codeeditor/main.cpp18
-rw-r--r--examples/widgets/widgets/digitalclock/CMakeLists.txt37
-rw-r--r--examples/widgets/widgets/digitalclock/digitalclock.cpp36
-rw-r--r--examples/widgets/widgets/digitalclock/digitalclock.h22
-rw-r--r--examples/widgets/widgets/digitalclock/digitalclock.pro9
-rw-r--r--examples/widgets/widgets/digitalclock/main.cpp14
-rw-r--r--examples/widgets/widgets/elidedlabel/CMakeLists.txt38
-rw-r--r--examples/widgets/widgets/elidedlabel/elidedlabel.cpp74
-rw-r--r--examples/widgets/widgets/elidedlabel/elidedlabel.h36
-rw-r--r--examples/widgets/widgets/elidedlabel/elidedlabel.pro20
-rw-r--r--examples/widgets/widgets/elidedlabel/main.cpp16
-rw-r--r--examples/widgets/widgets/elidedlabel/testwidget.cpp119
-rw-r--r--examples/widgets/widgets/elidedlabel/testwidget.h38
-rw-r--r--examples/widgets/widgets/groupbox/CMakeLists.txt33
-rw-r--r--examples/widgets/widgets/icons/CMakeLists.txt44
-rw-r--r--examples/widgets/widgets/icons/iconpreviewarea.cpp130
-rw-r--r--examples/widgets/widgets/icons/iconpreviewarea.h47
-rw-r--r--examples/widgets/widgets/icons/icons.pro20
-rw-r--r--examples/widgets/widgets/icons/iconsizespinbox.cpp33
-rw-r--r--examples/widgets/widgets/icons/iconsizespinbox.h22
-rw-r--r--examples/widgets/widgets/icons/imagedelegate.cpp64
-rw-r--r--examples/widgets/widgets/icons/imagedelegate.h31
-rw-r--r--examples/widgets/widgets/icons/images/designer.pngbin3604 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/images/find_disabled.pngbin501 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/images/find_normal.pngbin838 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/images/monkey_off_128x128.pngbin7045 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/images/monkey_off_16x16.pngbin683 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/images/monkey_off_32x32.pngbin1609 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/images/monkey_off_64x64.pngbin3533 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/images/monkey_on_128x128.pngbin6909 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/images/monkey_on_16x16.pngbin681 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/images/monkey_on_32x32.pngbin1577 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/images/monkey_on_64x64.pngbin3479 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/images/qt_extended_16x16.pngbin1263 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/images/qt_extended_32x32.pngbin15518 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/images/qt_extended_48x48.pngbin789 -> 0 bytes
-rw-r--r--examples/widgets/widgets/icons/main.cpp34
-rw-r--r--examples/widgets/widgets/icons/mainwindow.cpp478
-rw-r--r--examples/widgets/widgets/icons/mainwindow.h74
-rw-r--r--examples/widgets/widgets/imageviewer/CMakeLists.txt50
-rw-r--r--examples/widgets/widgets/imageviewer/imageviewer.cpp363
-rw-r--r--examples/widgets/widgets/imageviewer/imageviewer.h74
-rw-r--r--examples/widgets/widgets/imageviewer/imageviewer.pro11
-rw-r--r--examples/widgets/widgets/imageviewer/main.cpp24
-rw-r--r--examples/widgets/widgets/lineedits/CMakeLists.txt33
-rw-r--r--examples/widgets/widgets/mousebuttons/CMakeLists.txt37
-rw-r--r--examples/widgets/widgets/mousebuttons/buttontester.cpp184
-rw-r--r--examples/widgets/widgets/mousebuttons/buttontester.h29
-rw-r--r--examples/widgets/widgets/mousebuttons/main.cpp36
-rw-r--r--examples/widgets/widgets/mousebuttons/mousebuttons.pro16
-rw-r--r--examples/widgets/widgets/movie/CMakeLists.txt37
-rw-r--r--examples/widgets/widgets/movie/animation.gifbin42629 -> 0 bytes
-rw-r--r--examples/widgets/widgets/movie/main.cpp15
-rw-r--r--examples/widgets/widgets/movie/movie.pro12
-rw-r--r--examples/widgets/widgets/movie/movieplayer.cpp180
-rw-r--r--examples/widgets/widgets/movie/movieplayer.h59
-rw-r--r--examples/widgets/widgets/scribble/CMakeLists.txt43
-rw-r--r--examples/widgets/widgets/scribble/mainwindow.cpp2
-rw-r--r--examples/widgets/widgets/shapedclock/CMakeLists.txt33
-rw-r--r--examples/widgets/widgets/shapedclock/shapedclock.cpp69
-rw-r--r--examples/widgets/widgets/shapedclock/shapedclock.h1
-rw-r--r--examples/widgets/widgets/shortcuteditor/CMakeLists.txt40
-rw-r--r--examples/widgets/widgets/shortcuteditor/actionmanager.cpp57
-rw-r--r--examples/widgets/widgets/shortcuteditor/actionmanager.h33
-rw-r--r--examples/widgets/widgets/shortcuteditor/application.cpp15
-rw-r--r--examples/widgets/widgets/shortcuteditor/application.h27
-rw-r--r--examples/widgets/widgets/shortcuteditor/main.cpp (renamed from examples/widgets/widgets/charactermap/main.cpp)7
-rw-r--r--examples/widgets/widgets/shortcuteditor/mainwindow.cpp46
-rw-r--r--examples/widgets/widgets/shortcuteditor/mainwindow.h22
-rw-r--r--examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.cpp71
-rw-r--r--examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h (renamed from examples/widgets/itemviews/spinboxdelegate/delegate.h)15
-rw-r--r--examples/widgets/widgets/shortcuteditor/shortcuteditormodel.cpp273
-rw-r--r--examples/widgets/widgets/shortcuteditor/shortcuteditormodel.h71
-rw-r--r--examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.cpp33
-rw-r--r--examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.h32
-rw-r--r--examples/widgets/widgets/sliders/CMakeLists.txt33
-rw-r--r--examples/widgets/widgets/sliders/slidersgroup.cpp34
-rw-r--r--examples/widgets/widgets/sliders/slidersgroup.h6
-rw-r--r--examples/widgets/widgets/sliders/window.cpp96
-rw-r--r--examples/widgets/widgets/sliders/window.h8
-rw-r--r--examples/widgets/widgets/spinboxes/CMakeLists.txt33
-rw-r--r--examples/widgets/widgets/styles/CMakeLists.txt51
-rw-r--r--examples/widgets/widgets/styles/images/woodbackground.pngbin7691 -> 0 bytes
-rw-r--r--examples/widgets/widgets/styles/images/woodbutton.pngbin7689 -> 0 bytes
-rw-r--r--examples/widgets/widgets/styles/main.cpp19
-rw-r--r--examples/widgets/widgets/styles/norwegianwoodstyle.cpp310
-rw-r--r--examples/widgets/widgets/styles/norwegianwoodstyle.h43
-rw-r--r--examples/widgets/widgets/styles/styles.pro13
-rw-r--r--examples/widgets/widgets/styles/styles.qrc6
-rw-r--r--examples/widgets/widgets/styles/widgetgallery.cpp277
-rw-r--r--examples/widgets/widgets/styles/widgetgallery.h86
-rw-r--r--examples/widgets/widgets/stylesheet/CMakeLists.txt85
-rw-r--r--examples/widgets/widgets/stylesheet/images/checkbox_checked.pngbin263 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/checkbox_checked_hover.pngbin266 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/checkbox_checked_pressed.pngbin425 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/checkbox_unchecked.pngbin159 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/checkbox_unchecked_hover.pngbin159 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/checkbox_unchecked_pressed.pngbin320 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/down_arrow.pngbin175 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/down_arrow_disabled.pngbin174 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/frame.pngbin253 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/pagefold.pngbin1545 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/pushbutton.pngbin533 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/pushbutton_hover.pngbin525 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/pushbutton_pressed.pngbin513 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/radiobutton_checked.pngbin355 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/radiobutton_checked_hover.pngbin532 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/radiobutton_checked_pressed.pngbin599 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/radiobutton_unchecked.pngbin240 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_hover.pngbin492 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_pressed.pngbin556 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/sizegrip.pngbin129 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/spindown.pngbin276 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/spindown_hover.pngbin268 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/spindown_off.pngbin249 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/spindown_pressed.pngbin264 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/spinup.pngbin283 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/spinup_hover.pngbin277 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/spinup_off.pngbin274 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/spinup_pressed.pngbin277 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/up_arrow.pngbin197 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/images/up_arrow_disabled.pngbin172 -> 0 bytes
-rw-r--r--examples/widgets/widgets/stylesheet/layouts/default.ui329
-rw-r--r--examples/widgets/widgets/stylesheet/layouts/pagefold.ui349
-rw-r--r--examples/widgets/widgets/stylesheet/main.cpp16
-rw-r--r--examples/widgets/widgets/stylesheet/mainwindow.cpp40
-rw-r--r--examples/widgets/widgets/stylesheet/mainwindow.h29
-rw-r--r--examples/widgets/widgets/stylesheet/mainwindow.ui356
-rw-r--r--examples/widgets/widgets/stylesheet/qss/coffee.qss112
-rw-r--r--examples/widgets/widgets/stylesheet/qss/default.qss1
-rw-r--r--examples/widgets/widgets/stylesheet/qss/pagefold.qss299
-rw-r--r--examples/widgets/widgets/stylesheet/stylesheet.pro15
-rw-r--r--examples/widgets/widgets/stylesheet/stylesheet.qrc39
-rw-r--r--examples/widgets/widgets/stylesheet/stylesheeteditor.cpp64
-rw-r--r--examples/widgets/widgets/stylesheet/stylesheeteditor.h30
-rw-r--r--examples/widgets/widgets/stylesheet/stylesheeteditor.ui171
-rw-r--r--examples/widgets/widgets/tablet/CMakeLists.txt33
-rw-r--r--examples/widgets/widgets/tetrix/CMakeLists.txt39
-rw-r--r--examples/widgets/widgets/tetrix/main.cpp14
-rw-r--r--examples/widgets/widgets/tetrix/tetrix.pro13
-rw-r--r--examples/widgets/widgets/tetrix/tetrixboard.cpp371
-rw-r--r--examples/widgets/widgets/tetrix/tetrixboard.h79
-rw-r--r--examples/widgets/widgets/tetrix/tetrixpiece.cpp106
-rw-r--r--examples/widgets/widgets/tetrix/tetrixpiece.h38
-rw-r--r--examples/widgets/widgets/tetrix/tetrixwindow.cpp82
-rw-r--r--examples/widgets/widgets/tetrix/tetrixwindow.h38
-rw-r--r--examples/widgets/widgets/tooltips/CMakeLists.txt52
-rw-r--r--examples/widgets/widgets/tooltips/images/circle.pngbin165 -> 0 bytes
-rw-r--r--examples/widgets/widgets/tooltips/images/square.pngbin94 -> 0 bytes
-rw-r--r--examples/widgets/widgets/tooltips/images/triangle.pngbin170 -> 0 bytes
-rw-r--r--examples/widgets/widgets/tooltips/main.cpp16
-rw-r--r--examples/widgets/widgets/tooltips/shapeitem.cpp60
-rw-r--r--examples/widgets/widgets/tooltips/shapeitem.h33
-rw-r--r--examples/widgets/widgets/tooltips/sortingbox.cpp269
-rw-r--r--examples/widgets/widgets/tooltips/sortingbox.h69
-rw-r--r--examples/widgets/widgets/tooltips/tooltips.pro12
-rw-r--r--examples/widgets/widgets/tooltips/tooltips.qrc7
-rw-r--r--examples/widgets/widgets/validators/CMakeLists.txt56
-rw-r--r--examples/widgets/widgets/validators/ledoff.pngbin562 -> 0 bytes
-rw-r--r--examples/widgets/widgets/validators/ledon.pngbin486 -> 0 bytes
-rw-r--r--examples/widgets/widgets/validators/ledwidget.cpp25
-rw-r--r--examples/widgets/widgets/validators/ledwidget.h27
-rw-r--r--examples/widgets/widgets/validators/localeselector.cpp48
-rw-r--r--examples/widgets/widgets/validators/localeselector.h23
-rw-r--r--examples/widgets/widgets/validators/main.cpp18
-rw-r--r--examples/widgets/widgets/validators/validators.pro12
-rw-r--r--examples/widgets/widgets/validators/validators.qrc6
-rw-r--r--examples/widgets/widgets/validators/validators.ui468
-rw-r--r--examples/widgets/widgets/validators/validatorwidget.cpp75
-rw-r--r--examples/widgets/widgets/validators/validatorwidget.h17
-rw-r--r--examples/widgets/widgets/widgets.pro14
-rw-r--r--examples/widgets/widgets/wiggly/CMakeLists.txt38
-rw-r--r--examples/widgets/widgets/wiggly/dialog.cpp27
-rw-r--r--examples/widgets/widgets/wiggly/dialog.h19
-rw-r--r--examples/widgets/widgets/wiggly/main.cpp16
-rw-r--r--examples/widgets/widgets/wiggly/wiggly.pro11
-rw-r--r--examples/widgets/widgets/wiggly/wigglywidget.cpp64
-rw-r--r--examples/widgets/widgets/wiggly/wigglywidget.h32
-rw-r--r--examples/widgets/widgets/windowflags/CMakeLists.txt33
-rw-r--r--examples/widgets/windowcontainer/CMakeLists.txt42
-rw-r--r--examples/widgets/windowcontainer/windowcontainer.cpp136
-rw-r--r--examples/widgets/windowcontainer/windowcontainer.pro9
1084 files changed, 4713 insertions, 45423 deletions
diff --git a/examples/widgets/CMakeLists.txt b/examples/widgets/CMakeLists.txt
index 020cb9719e..42dc87a865 100644
--- a/examples/widgets/CMakeLists.txt
+++ b/examples/widgets/CMakeLists.txt
@@ -1,7 +1,7 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-if(NOT TARGET Qt::Widgets)
+if(NOT TARGET Qt6::Widgets)
return()
endif()
if(QT_FEATURE_animation)
@@ -9,15 +9,14 @@ if(QT_FEATURE_animation)
endif()
add_subdirectory(desktop)
add_subdirectory(dialogs)
-add_subdirectory(effects)
qt_internal_add_example(gallery)
add_subdirectory(gestures)
add_subdirectory(graphicsview)
add_subdirectory(itemviews)
add_subdirectory(layouts)
add_subdirectory(painting)
+add_subdirectory(rhi)
add_subdirectory(richtext)
-add_subdirectory(scroller)
add_subdirectory(tools)
add_subdirectory(touch)
add_subdirectory(tutorials)
@@ -28,6 +27,3 @@ endif()
if(QT_FEATURE_cursor)
add_subdirectory(mainwindows)
endif()
-if(QT_FEATURE_opengl AND TARGET Qt::Gui)
- qt_internal_add_example(windowcontainer)
-endif()
diff --git a/examples/widgets/animation/easing/CMakeLists.txt b/examples/widgets/animation/easing/CMakeLists.txt
index 3549ca73c2..8398f7d3e0 100644
--- a/examples/widgets/animation/easing/CMakeLists.txt
+++ b/examples/widgets/animation/easing/CMakeLists.txt
@@ -1,20 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(easing LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/animation/easing")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(easing
animation.h
form.ui
@@ -27,10 +20,10 @@ set_target_properties(easing PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(easing PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(easing PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -46,7 +39,14 @@ qt_add_resources(easing "easing"
)
install(TARGETS easing
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET easing
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/animation/easing/main.cpp b/examples/widgets/animation/easing/main.cpp
index a1c01698d1..26009a6bf7 100644
--- a/examples/widgets/animation/easing/main.cpp
+++ b/examples/widgets/animation/easing/main.cpp
@@ -6,7 +6,6 @@
int main(int argc, char **argv)
{
- Q_INIT_RESOURCE(easing);
QApplication app(argc, argv);
Window w;
diff --git a/examples/widgets/animation/easing/window.cpp b/examples/widgets/animation/easing/window.cpp
index 11929738ae..d926efc537 100644
--- a/examples/widgets/animation/easing/window.cpp
+++ b/examples/widgets/animation/easing/window.cpp
@@ -42,7 +42,7 @@ Window::Window(QWidget *parent)
startAnimation();
}
-QEasingCurve createEasingCurve(QEasingCurve::Type curveType)
+static QEasingCurve createEasingCurve(QEasingCurve::Type curveType)
{
QEasingCurve curve(curveType);
@@ -72,12 +72,12 @@ void Window::createCurveIcons()
// Skip QEasingCurve::Custom
for (int i = 0; i < QEasingCurve::NCurveTypes - 1; ++i) {
painter.fillRect(QRect(QPoint(0, 0), m_iconSize), brush);
- QEasingCurve curve = createEasingCurve((QEasingCurve::Type) i);
+ QEasingCurve curve = createEasingCurve(static_cast<QEasingCurve::Type>(i));
painter.setPen(QColor(0, 0, 255, 64));
qreal xAxis = m_iconSize.height()/1.5;
qreal yAxis = m_iconSize.width()/3;
- painter.drawLine(0, xAxis, m_iconSize.width(), xAxis);
- painter.drawLine(yAxis, 0, yAxis, m_iconSize.height());
+ painter.drawLine(QLineF(0, xAxis, m_iconSize.width(), xAxis));
+ painter.drawLine(QLineF(yAxis, 0, yAxis, m_iconSize.height()));
qreal curveScale = m_iconSize.height()/2;
@@ -85,18 +85,18 @@ void Window::createCurveIcons()
// start point
painter.setBrush(Qt::red);
- QPoint start(yAxis, xAxis - curveScale * curve.valueForProgress(0));
+ QPoint start(qRound(yAxis), qRound(xAxis - curveScale * curve.valueForProgress(0)));
painter.drawRect(start.x() - 1, start.y() - 1, 3, 3);
// end point
painter.setBrush(Qt::blue);
- QPoint end(yAxis + curveScale, xAxis - curveScale * curve.valueForProgress(1));
+ QPoint end(qRound(yAxis + curveScale), qRound(xAxis - curveScale * curve.valueForProgress(1)));
painter.drawRect(end.x() - 1, end.y() - 1, 3, 3);
QPainterPath curvePath;
curvePath.moveTo(start);
for (qreal t = 0; t <= 1.0; t+=1.0/curveScale) {
- QPoint to;
+ QPointF to;
to.setX(yAxis + curveScale * t);
to.setY(xAxis - curveScale * curve.valueForProgress(t));
curvePath.lineTo(to);
@@ -122,7 +122,7 @@ void Window::startAnimation()
void Window::curveChanged(int row)
{
- QEasingCurve::Type curveType = (QEasingCurve::Type)row;
+ QEasingCurve::Type curveType = static_cast<QEasingCurve::Type>(row);
m_anim->setEasingCurve(createEasingCurve(curveType));
m_anim->setCurrentTime(0);
diff --git a/examples/widgets/animation/easing/window.h b/examples/widgets/animation/easing/window.h
index b454d1853f..ea6bb74667 100644
--- a/examples/widgets/animation/easing/window.h
+++ b/examples/widgets/animation/easing/window.h
@@ -1,6 +1,9 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+#ifndef WINDOW_H
+#define WINDOW_H
+
#include <QtWidgets>
#include "ui_form.h"
@@ -37,3 +40,5 @@ private:
Animation *m_anim;
QSize m_iconSize;
};
+
+#endif // WINDOW_H
diff --git a/examples/widgets/desktop/screenshot/CMakeLists.txt b/examples/widgets/desktop/screenshot/CMakeLists.txt
index da6c858450..4d9b97d114 100644
--- a/examples/widgets/desktop/screenshot/CMakeLists.txt
+++ b/examples/widgets/desktop/screenshot/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(screenshot LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/desktop/screenshot")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(screenshot
main.cpp
screenshot.cpp screenshot.h
@@ -24,14 +18,21 @@ set_target_properties(screenshot PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(screenshot PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(screenshot PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS screenshot
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET screenshot
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/desktop/screenshot/screenshot.cpp b/examples/widgets/desktop/screenshot/screenshot.cpp
index 271ef8c776..5a4ba901b7 100644
--- a/examples/widgets/desktop/screenshot/screenshot.cpp
+++ b/examples/widgets/desktop/screenshot/screenshot.cpp
@@ -62,7 +62,7 @@ void Screenshot::resizeEvent(QResizeEvent * /* event */)
{
QSize scaledSize = originalPixmap.size();
scaledSize.scale(screenshotLabel->size(), Qt::KeepAspectRatio);
- if (scaledSize != screenshotLabel->pixmap(Qt::ReturnByValue).size())
+ if (scaledSize != screenshotLabel->pixmap().size())
updateScreenshotLabel();
}
//! [1]
diff --git a/examples/widgets/desktop/systray/CMakeLists.txt b/examples/widgets/desktop/systray/CMakeLists.txt
index cb9b792278..c42469bf59 100644
--- a/examples/widgets/desktop/systray/CMakeLists.txt
+++ b/examples/widgets/desktop/systray/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(systray LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/desktop/systray")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(systray
main.cpp
window.cpp window.h
@@ -24,10 +18,10 @@ set_target_properties(systray PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(systray PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(systray PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -45,7 +39,14 @@ qt_add_resources(systray "systray"
)
install(TARGETS systray
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET systray
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/desktop/systray/doc/images/systemtray-editor.png b/examples/widgets/desktop/systray/doc/images/systemtray-editor.png
index f7c23db28a..5537c09fde 100644
--- a/examples/widgets/desktop/systray/doc/images/systemtray-editor.png
+++ b/examples/widgets/desktop/systray/doc/images/systemtray-editor.png
Binary files differ
diff --git a/examples/widgets/desktop/systray/doc/images/systemtray-example.png b/examples/widgets/desktop/systray/doc/images/systemtray-example.png
index 98b5c8133e..f2f9f73031 100644
--- a/examples/widgets/desktop/systray/doc/images/systemtray-example.png
+++ b/examples/widgets/desktop/systray/doc/images/systemtray-example.png
Binary files differ
diff --git a/examples/widgets/desktop/systray/doc/src/systray.qdoc b/examples/widgets/desktop/systray/doc/src/systray.qdoc
index 5c4350383d..b0dff58e31 100644
--- a/examples/widgets/desktop/systray/doc/src/systray.qdoc
+++ b/examples/widgets/desktop/systray/doc/src/systray.qdoc
@@ -4,6 +4,7 @@
/*!
\example desktop/systray
\title System Tray Icon Example
+ \examplecategory {Desktop}
\ingroup examples-widgets
\brief The System Tray Icon example shows how to add an icon with a menu
and popup messages to a desktop environment's system tray.
diff --git a/examples/widgets/desktop/systray/images/bad.png b/examples/widgets/desktop/systray/images/bad.png
index c8701a241a..b09de85869 100644
--- a/examples/widgets/desktop/systray/images/bad.png
+++ b/examples/widgets/desktop/systray/images/bad.png
Binary files differ
diff --git a/examples/widgets/desktop/systray/images/heart.png b/examples/widgets/desktop/systray/images/heart.png
index cee1302b7d..5d466b1b89 100644
--- a/examples/widgets/desktop/systray/images/heart.png
+++ b/examples/widgets/desktop/systray/images/heart.png
Binary files differ
diff --git a/examples/widgets/desktop/systray/images/trash.png b/examples/widgets/desktop/systray/images/trash.png
index 4c24db926d..454074f9f2 100644
--- a/examples/widgets/desktop/systray/images/trash.png
+++ b/examples/widgets/desktop/systray/images/trash.png
Binary files differ
diff --git a/examples/widgets/desktop/systray/main.cpp b/examples/widgets/desktop/systray/main.cpp
index d01f813d2f..d13bde11ce 100644
--- a/examples/widgets/desktop/systray/main.cpp
+++ b/examples/widgets/desktop/systray/main.cpp
@@ -10,8 +10,6 @@
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(systray);
-
QApplication app(argc, argv);
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
diff --git a/examples/widgets/dialogs/CMakeLists.txt b/examples/widgets/dialogs/CMakeLists.txt
index 0298fba4f7..3148d3585f 100644
--- a/examples/widgets/dialogs/CMakeLists.txt
+++ b/examples/widgets/dialogs/CMakeLists.txt
@@ -1,14 +1,11 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
if(QT_FEATURE_wizard)
- qt_internal_add_example(classwizard)
qt_internal_add_example(trivialwizard)
+ if(Qt6::PrintSupport)
+ qt_internal_add_example(licensewizard)
+ endif()
endif()
-qt_internal_add_example(extension)
-qt_internal_add_example(findfiles)
qt_internal_add_example(standarddialogs)
qt_internal_add_example(tabdialog)
-if(QT_FEATURE_wizard AND TARGET Qt::PrintSupport)
- qt_internal_add_example(licensewizard)
-endif()
diff --git a/examples/widgets/dialogs/classwizard/CMakeLists.txt b/examples/widgets/dialogs/classwizard/CMakeLists.txt
deleted file mode 100644
index 54de6408f2..0000000000
--- a/examples/widgets/dialogs/classwizard/CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(classwizard LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/classwizard")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(classwizard
- classwizard.cpp classwizard.h
- main.cpp
-)
-
-set_target_properties(classwizard PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(classwizard PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(classwizard_resource_files
- "images/background.png"
- "images/banner.png"
- "images/logo1.png"
- "images/logo2.png"
- "images/logo3.png"
- "images/watermark1.png"
- "images/watermark2.png"
-)
-
-qt_add_resources(classwizard "classwizard"
- PREFIX
- "/"
- FILES
- ${classwizard_resource_files}
-)
-
-install(TARGETS classwizard
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/dialogs/classwizard/classwizard.cpp b/examples/widgets/dialogs/classwizard/classwizard.cpp
deleted file mode 100644
index d3587ce46f..0000000000
--- a/examples/widgets/dialogs/classwizard/classwizard.cpp
+++ /dev/null
@@ -1,394 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-#include "classwizard.h"
-
-//! [0] //! [1]
-ClassWizard::ClassWizard(QWidget *parent)
- : QWizard(parent)
-{
- addPage(new IntroPage);
- addPage(new ClassInfoPage);
- addPage(new CodeStylePage);
- addPage(new OutputFilesPage);
- addPage(new ConclusionPage);
-//! [0]
-
- setPixmap(QWizard::BannerPixmap, QPixmap(":/images/banner.png"));
- setPixmap(QWizard::BackgroundPixmap, QPixmap(":/images/background.png"));
-
- setWindowTitle(tr("Class Wizard"));
-//! [2]
-}
-//! [1] //! [2]
-
-//! [3]
-void ClassWizard::accept()
-//! [3] //! [4]
-{
- QByteArray className = field("className").toByteArray();
- QByteArray baseClass = field("baseClass").toByteArray();
- QByteArray macroName = field("macroName").toByteArray();
- QByteArray baseInclude = field("baseInclude").toByteArray();
-
- QString outputDir = field("outputDir").toString();
- QString header = field("header").toString();
- QString implementation = field("implementation").toString();
-//! [4]
-
- QByteArray block;
-
- if (field("comment").toBool()) {
- block += "/*\n";
- block += " " + header.toLatin1() + '\n';
- block += "*/\n";
- block += '\n';
- }
- if (field("protect").toBool()) {
- block += "#ifndef " + macroName + '\n';
- block += "#define " + macroName + '\n';
- block += '\n';
- }
- if (field("includeBase").toBool()) {
- block += "#include " + baseInclude + '\n';
- block += '\n';
- }
-
- block += "class " + className;
- if (!baseClass.isEmpty())
- block += " : public " + baseClass;
- block += '\n';
- block += "{\n";
-
- /* qmake ignore Q_OBJECT */
-
- if (field("qobjectMacro").toBool()) {
- block += " Q_OBJECT\n";
- block += '\n';
- }
- block += "public:\n";
-
- if (field("qobjectCtor").toBool()) {
- block += " " + className + "(QObject *parent = nullptr);\n";
- } else if (field("qwidgetCtor").toBool()) {
- block += " " + className + "(QWidget *parent = nullptr);\n";
- } else if (field("defaultCtor").toBool()) {
- block += " " + className + "();\n";
- if (field("copyCtor").toBool()) {
- block += " " + className + "(const " + className + " &other);\n";
- block += '\n';
- block += " " + className + " &operator=" + "(const " + className
- + " &other);\n";
- }
- }
- block += "};\n";
-
- if (field("protect").toBool()) {
- block += '\n';
- block += "#endif\n";
- }
-
- QFile headerFile(outputDir + '/' + header);
- if (!headerFile.open(QFile::WriteOnly | QFile::Text)) {
- QMessageBox::warning(nullptr, QObject::tr("Simple Wizard"),
- QObject::tr("Cannot write file %1:\n%2")
- .arg(headerFile.fileName())
- .arg(headerFile.errorString()));
- return;
- }
- headerFile.write(block);
-
- block.clear();
-
- if (field("comment").toBool()) {
- block += "/*\n";
- block += " " + implementation.toLatin1() + '\n';
- block += "*/\n";
- block += '\n';
- }
- block += "#include \"" + header.toLatin1() + "\"\n";
- block += '\n';
-
- if (field("qobjectCtor").toBool()) {
- block += className + "::" + className + "(QObject *parent)\n";
- block += " : " + baseClass + "(parent)\n";
- block += "{\n";
- block += "}\n";
- } else if (field("qwidgetCtor").toBool()) {
- block += className + "::" + className + "(QWidget *parent)\n";
- block += " : " + baseClass + "(parent)\n";
- block += "{\n";
- block += "}\n";
- } else if (field("defaultCtor").toBool()) {
- block += className + "::" + className + "()\n";
- block += "{\n";
- block += " // missing code\n";
- block += "}\n";
-
- if (field("copyCtor").toBool()) {
- block += "\n";
- block += className + "::" + className + "(const " + className
- + " &other)\n";
- block += "{\n";
- block += " *this = other;\n";
- block += "}\n";
- block += '\n';
- block += className + " &" + className + "::operator=(const "
- + className + " &other)\n";
- block += "{\n";
- if (!baseClass.isEmpty())
- block += " " + baseClass + "::operator=(other);\n";
- block += " // missing code\n";
- block += " return *this;\n";
- block += "}\n";
- }
- }
-
- QFile implementationFile(outputDir + '/' + implementation);
- if (!implementationFile.open(QFile::WriteOnly | QFile::Text)) {
- QMessageBox::warning(nullptr, QObject::tr("Simple Wizard"),
- QObject::tr("Cannot write file %1:\n%2")
- .arg(implementationFile.fileName())
- .arg(implementationFile.errorString()));
- return;
- }
- implementationFile.write(block);
-
-//! [5]
- QDialog::accept();
-//! [5] //! [6]
-}
-//! [6]
-
-//! [7]
-IntroPage::IntroPage(QWidget *parent)
- : QWizardPage(parent)
-{
- setTitle(tr("Introduction"));
- setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark1.png"));
-
- label = new QLabel(tr("This wizard will generate a skeleton C++ class "
- "definition, including a few functions. You simply "
- "need to specify the class name and set a few "
- "options to produce a header file and an "
- "implementation file for your new C++ class."));
- label->setWordWrap(true);
-
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(label);
- setLayout(layout);
-}
-//! [7]
-
-//! [8] //! [9]
-ClassInfoPage::ClassInfoPage(QWidget *parent)
- : QWizardPage(parent)
-{
-//! [8]
- setTitle(tr("Class Information"));
- setSubTitle(tr("Specify basic information about the class for which you "
- "want to generate skeleton source code files."));
- setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo1.png"));
-
-//! [10]
- classNameLabel = new QLabel(tr("&Class name:"));
- classNameLineEdit = new QLineEdit;
- classNameLabel->setBuddy(classNameLineEdit);
-
- baseClassLabel = new QLabel(tr("B&ase class:"));
- baseClassLineEdit = new QLineEdit;
- baseClassLabel->setBuddy(baseClassLineEdit);
-
- qobjectMacroCheckBox = new QCheckBox(tr("Generate Q_OBJECT &macro"));
-
-//! [10]
- groupBox = new QGroupBox(tr("C&onstructor"));
-//! [9]
-
- qobjectCtorRadioButton = new QRadioButton(tr("&QObject-style constructor"));
- qwidgetCtorRadioButton = new QRadioButton(tr("Q&Widget-style constructor"));
- defaultCtorRadioButton = new QRadioButton(tr("&Default constructor"));
- copyCtorCheckBox = new QCheckBox(tr("&Generate copy constructor and "
- "operator="));
-
- defaultCtorRadioButton->setChecked(true);
-
- connect(defaultCtorRadioButton, &QAbstractButton::toggled,
- copyCtorCheckBox, &QWidget::setEnabled);
-
-//! [11] //! [12]
- registerField("className*", classNameLineEdit);
- registerField("baseClass", baseClassLineEdit);
- registerField("qobjectMacro", qobjectMacroCheckBox);
-//! [11]
- registerField("qobjectCtor", qobjectCtorRadioButton);
- registerField("qwidgetCtor", qwidgetCtorRadioButton);
- registerField("defaultCtor", defaultCtorRadioButton);
- registerField("copyCtor", copyCtorCheckBox);
-
- QVBoxLayout *groupBoxLayout = new QVBoxLayout;
-//! [12]
- groupBoxLayout->addWidget(qobjectCtorRadioButton);
- groupBoxLayout->addWidget(qwidgetCtorRadioButton);
- groupBoxLayout->addWidget(defaultCtorRadioButton);
- groupBoxLayout->addWidget(copyCtorCheckBox);
- groupBox->setLayout(groupBoxLayout);
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(classNameLabel, 0, 0);
- layout->addWidget(classNameLineEdit, 0, 1);
- layout->addWidget(baseClassLabel, 1, 0);
- layout->addWidget(baseClassLineEdit, 1, 1);
- layout->addWidget(qobjectMacroCheckBox, 2, 0, 1, 2);
- layout->addWidget(groupBox, 3, 0, 1, 2);
- setLayout(layout);
-//! [13]
-}
-//! [13]
-
-//! [14]
-CodeStylePage::CodeStylePage(QWidget *parent)
- : QWizardPage(parent)
-{
- setTitle(tr("Code Style Options"));
- setSubTitle(tr("Choose the formatting of the generated code."));
- setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo2.png"));
-
- commentCheckBox = new QCheckBox(tr("&Start generated files with a "
-//! [14]
- "comment"));
- commentCheckBox->setChecked(true);
-
- protectCheckBox = new QCheckBox(tr("&Protect header file against multiple "
- "inclusions"));
- protectCheckBox->setChecked(true);
-
- macroNameLabel = new QLabel(tr("&Macro name:"));
- macroNameLineEdit = new QLineEdit;
- macroNameLabel->setBuddy(macroNameLineEdit);
-
- includeBaseCheckBox = new QCheckBox(tr("&Include base class definition"));
- baseIncludeLabel = new QLabel(tr("Base class include:"));
- baseIncludeLineEdit = new QLineEdit;
- baseIncludeLabel->setBuddy(baseIncludeLineEdit);
-
- connect(protectCheckBox, &QAbstractButton::toggled,
- macroNameLabel, &QWidget::setEnabled);
- connect(protectCheckBox, &QAbstractButton::toggled,
- macroNameLineEdit, &QWidget::setEnabled);
- connect(includeBaseCheckBox, &QAbstractButton::toggled,
- baseIncludeLabel, &QWidget::setEnabled);
- connect(includeBaseCheckBox, &QAbstractButton::toggled,
- baseIncludeLineEdit, &QWidget::setEnabled);
-
- registerField("comment", commentCheckBox);
- registerField("protect", protectCheckBox);
- registerField("macroName", macroNameLineEdit);
- registerField("includeBase", includeBaseCheckBox);
- registerField("baseInclude", baseIncludeLineEdit);
-
- QGridLayout *layout = new QGridLayout;
- layout->setColumnMinimumWidth(0, 20);
- layout->addWidget(commentCheckBox, 0, 0, 1, 3);
- layout->addWidget(protectCheckBox, 1, 0, 1, 3);
- layout->addWidget(macroNameLabel, 2, 1);
- layout->addWidget(macroNameLineEdit, 2, 2);
- layout->addWidget(includeBaseCheckBox, 3, 0, 1, 3);
- layout->addWidget(baseIncludeLabel, 4, 1);
- layout->addWidget(baseIncludeLineEdit, 4, 2);
-//! [15]
- setLayout(layout);
-}
-//! [15]
-
-//! [16]
-void CodeStylePage::initializePage()
-{
- QString className = field("className").toString();
- macroNameLineEdit->setText(className.toUpper() + "_H");
-
- QString baseClass = field("baseClass").toString();
-
- includeBaseCheckBox->setChecked(!baseClass.isEmpty());
- includeBaseCheckBox->setEnabled(!baseClass.isEmpty());
- baseIncludeLabel->setEnabled(!baseClass.isEmpty());
- baseIncludeLineEdit->setEnabled(!baseClass.isEmpty());
-
- QRegularExpression rx("Q[A-Z].*");
- if (baseClass.isEmpty()) {
- baseIncludeLineEdit->clear();
- } else if (rx.match(baseClass).hasMatch()) {
- baseIncludeLineEdit->setText('<' + baseClass + '>');
- } else {
- baseIncludeLineEdit->setText('"' + baseClass.toLower() + ".h\"");
- }
-}
-//! [16]
-
-OutputFilesPage::OutputFilesPage(QWidget *parent)
- : QWizardPage(parent)
-{
- setTitle(tr("Output Files"));
- setSubTitle(tr("Specify where you want the wizard to put the generated "
- "skeleton code."));
- setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo3.png"));
-
- outputDirLabel = new QLabel(tr("&Output directory:"));
- outputDirLineEdit = new QLineEdit;
- outputDirLabel->setBuddy(outputDirLineEdit);
-
- headerLabel = new QLabel(tr("&Header file name:"));
- headerLineEdit = new QLineEdit;
- headerLabel->setBuddy(headerLineEdit);
-
- implementationLabel = new QLabel(tr("&Implementation file name:"));
- implementationLineEdit = new QLineEdit;
- implementationLabel->setBuddy(implementationLineEdit);
-
- registerField("outputDir*", outputDirLineEdit);
- registerField("header*", headerLineEdit);
- registerField("implementation*", implementationLineEdit);
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(outputDirLabel, 0, 0);
- layout->addWidget(outputDirLineEdit, 0, 1);
- layout->addWidget(headerLabel, 1, 0);
- layout->addWidget(headerLineEdit, 1, 1);
- layout->addWidget(implementationLabel, 2, 0);
- layout->addWidget(implementationLineEdit, 2, 1);
- setLayout(layout);
-}
-
-//! [17]
-void OutputFilesPage::initializePage()
-{
- QString className = field("className").toString();
- headerLineEdit->setText(className.toLower() + ".h");
- implementationLineEdit->setText(className.toLower() + ".cpp");
- outputDirLineEdit->setText(QDir::toNativeSeparators(QDir::tempPath()));
-}
-//! [17]
-
-ConclusionPage::ConclusionPage(QWidget *parent)
- : QWizardPage(parent)
-{
- setTitle(tr("Conclusion"));
- setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark2.png"));
-
- label = new QLabel;
- label->setWordWrap(true);
-
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(label);
- setLayout(layout);
-}
-
-void ConclusionPage::initializePage()
-{
- QString finishText = wizard()->buttonText(QWizard::FinishButton);
- finishText.remove('&');
- label->setText(tr("Click %1 to generate the class skeleton.")
- .arg(finishText));
-}
diff --git a/examples/widgets/dialogs/classwizard/classwizard.h b/examples/widgets/dialogs/classwizard/classwizard.h
deleted file mode 100644
index 61f63b5035..0000000000
--- a/examples/widgets/dialogs/classwizard/classwizard.h
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef CLASSWIZARD_H
-#define CLASSWIZARD_H
-
-#include <QWizard>
-
-QT_BEGIN_NAMESPACE
-class QCheckBox;
-class QGroupBox;
-class QLabel;
-class QLineEdit;
-class QRadioButton;
-QT_END_NAMESPACE
-
-//! [0]
-class ClassWizard : public QWizard
-{
- Q_OBJECT
-
-public:
- ClassWizard(QWidget *parent = nullptr);
-
- void accept() override;
-};
-//! [0]
-
-//! [1]
-class IntroPage : public QWizardPage
-{
- Q_OBJECT
-
-public:
- IntroPage(QWidget *parent = nullptr);
-
-private:
- QLabel *label;
-};
-//! [1]
-
-//! [2]
-class ClassInfoPage : public QWizardPage
-{
- Q_OBJECT
-
-public:
- ClassInfoPage(QWidget *parent = nullptr);
-
-private:
- QLabel *classNameLabel;
- QLabel *baseClassLabel;
- QLineEdit *classNameLineEdit;
- QLineEdit *baseClassLineEdit;
- QCheckBox *qobjectMacroCheckBox;
- QGroupBox *groupBox;
- QRadioButton *qobjectCtorRadioButton;
- QRadioButton *qwidgetCtorRadioButton;
- QRadioButton *defaultCtorRadioButton;
- QCheckBox *copyCtorCheckBox;
-};
-//! [2]
-
-//! [3]
-class CodeStylePage : public QWizardPage
-{
- Q_OBJECT
-
-public:
- CodeStylePage(QWidget *parent = nullptr);
-
-protected:
- void initializePage() override;
-
-private:
- QCheckBox *commentCheckBox;
- QCheckBox *protectCheckBox;
- QCheckBox *includeBaseCheckBox;
- QLabel *macroNameLabel;
- QLabel *baseIncludeLabel;
- QLineEdit *macroNameLineEdit;
- QLineEdit *baseIncludeLineEdit;
-};
-//! [3]
-
-class OutputFilesPage : public QWizardPage
-{
- Q_OBJECT
-
-public:
- OutputFilesPage(QWidget *parent = nullptr);
-
-protected:
- void initializePage() override;
-
-private:
- QLabel *outputDirLabel;
- QLabel *headerLabel;
- QLabel *implementationLabel;
- QLineEdit *outputDirLineEdit;
- QLineEdit *headerLineEdit;
- QLineEdit *implementationLineEdit;
-};
-
-class ConclusionPage : public QWizardPage
-{
- Q_OBJECT
-
-public:
- ConclusionPage(QWidget *parent = nullptr);
-
-protected:
- void initializePage() override;
-
-private:
- QLabel *label;
-};
-
-#endif
diff --git a/examples/widgets/dialogs/classwizard/classwizard.pro b/examples/widgets/dialogs/classwizard/classwizard.pro
deleted file mode 100644
index 3ec321f4e8..0000000000
--- a/examples/widgets/dialogs/classwizard/classwizard.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT += widgets
-
-HEADERS = classwizard.h
-SOURCES = classwizard.cpp \
- main.cpp
-RESOURCES = classwizard.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/dialogs/classwizard
-INSTALLS += target
diff --git a/examples/widgets/dialogs/classwizard/classwizard.qrc b/examples/widgets/dialogs/classwizard/classwizard.qrc
deleted file mode 100644
index 41a5ddc7d1..0000000000
--- a/examples/widgets/dialogs/classwizard/classwizard.qrc
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/background.png</file>
- <file>images/banner.png</file>
- <file>images/logo1.png</file>
- <file>images/logo2.png</file>
- <file>images/logo3.png</file>
- <file>images/watermark1.png</file>
- <file>images/watermark2.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/dialogs/classwizard/images/background.png b/examples/widgets/dialogs/classwizard/images/background.png
deleted file mode 100644
index 44c7badb85..0000000000
--- a/examples/widgets/dialogs/classwizard/images/background.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/dialogs/classwizard/images/banner.png b/examples/widgets/dialogs/classwizard/images/banner.png
deleted file mode 100644
index 3169152b8e..0000000000
--- a/examples/widgets/dialogs/classwizard/images/banner.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/dialogs/classwizard/images/logo1.png b/examples/widgets/dialogs/classwizard/images/logo1.png
deleted file mode 100644
index f9b594aafc..0000000000
--- a/examples/widgets/dialogs/classwizard/images/logo1.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/dialogs/classwizard/images/logo2.png b/examples/widgets/dialogs/classwizard/images/logo2.png
deleted file mode 100644
index 5dcbd4669d..0000000000
--- a/examples/widgets/dialogs/classwizard/images/logo2.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/dialogs/classwizard/images/logo3.png b/examples/widgets/dialogs/classwizard/images/logo3.png
deleted file mode 100644
index 9fd3ea2358..0000000000
--- a/examples/widgets/dialogs/classwizard/images/logo3.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/dialogs/classwizard/images/watermark1.png b/examples/widgets/dialogs/classwizard/images/watermark1.png
deleted file mode 100644
index 0091f5c17a..0000000000
--- a/examples/widgets/dialogs/classwizard/images/watermark1.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/dialogs/classwizard/images/watermark2.png b/examples/widgets/dialogs/classwizard/images/watermark2.png
deleted file mode 100644
index 3b88f2e360..0000000000
--- a/examples/widgets/dialogs/classwizard/images/watermark2.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/dialogs/classwizard/main.cpp b/examples/widgets/dialogs/classwizard/main.cpp
deleted file mode 100644
index f31082b392..0000000000
--- a/examples/widgets/dialogs/classwizard/main.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-#include <QTranslator>
-#include <QLocale>
-#include <QLibraryInfo>
-
-#include "classwizard.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(classwizard);
-
- QApplication app(argc, argv);
-
-#ifndef QT_NO_TRANSLATION
- QString translatorFileName = QLatin1String("qtbase_");
- translatorFileName += QLocale::system().name();
- QTranslator *translator = new QTranslator(&app);
- if (translator->load(translatorFileName, QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
- app.installTranslator(translator);
-#endif
-
- ClassWizard wizard;
- wizard.show();
- return app.exec();
-}
diff --git a/examples/widgets/dialogs/dialogs.pro b/examples/widgets/dialogs/dialogs.pro
index 753308fc55..2493688297 100644
--- a/examples/widgets/dialogs/dialogs.pro
+++ b/examples/widgets/dialogs/dialogs.pro
@@ -1,10 +1,7 @@
QT_FOR_CONFIG += widgets
TEMPLATE = subdirs
-SUBDIRS = classwizard \
- extension \
- findfiles \
- licensewizard \
+SUBDIRS = licensewizard \
standarddialogs \
tabdialog \
trivialwizard
diff --git a/examples/widgets/dialogs/extension/CMakeLists.txt b/examples/widgets/dialogs/extension/CMakeLists.txt
deleted file mode 100644
index 96eab547c6..0000000000
--- a/examples/widgets/dialogs/extension/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(extension LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/extension")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(extension
- finddialog.cpp finddialog.h
- main.cpp
-)
-
-set_target_properties(extension PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(extension PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS extension
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/dialogs/extension/extension.pro b/examples/widgets/dialogs/extension/extension.pro
deleted file mode 100644
index f51052cd56..0000000000
--- a/examples/widgets/dialogs/extension/extension.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QT += widgets
-
-HEADERS = finddialog.h
-SOURCES = finddialog.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/dialogs/extension
-INSTALLS += target
diff --git a/examples/widgets/dialogs/extension/finddialog.cpp b/examples/widgets/dialogs/extension/finddialog.cpp
deleted file mode 100644
index f6b5943467..0000000000
--- a/examples/widgets/dialogs/extension/finddialog.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-#include "finddialog.h"
-
-//! [0]
-FindDialog::FindDialog(QWidget *parent)
- : QDialog(parent)
-{
- label = new QLabel(tr("Find &what:"));
- lineEdit = new QLineEdit;
- label->setBuddy(lineEdit);
-
- caseCheckBox = new QCheckBox(tr("Match &case"));
- fromStartCheckBox = new QCheckBox(tr("Search from &start"));
- fromStartCheckBox->setChecked(true);
-
-//! [1]
- findButton = new QPushButton(tr("&Find"));
- findButton->setDefault(true);
-
- moreButton = new QPushButton(tr("&More"));
- moreButton->setCheckable(true);
-//! [0]
- moreButton->setAutoDefault(false);
-
-//! [1]
-
-//! [2]
- extension = new QWidget;
-
- wholeWordsCheckBox = new QCheckBox(tr("&Whole words"));
- backwardCheckBox = new QCheckBox(tr("Search &backward"));
- searchSelectionCheckBox = new QCheckBox(tr("Search se&lection"));
-//! [2]
-
-//! [3]
- buttonBox = new QDialogButtonBox(Qt::Vertical);
- buttonBox->addButton(findButton, QDialogButtonBox::ActionRole);
- buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole);
-
- connect(moreButton, &QAbstractButton::toggled, extension, &QWidget::setVisible);
-
- QVBoxLayout *extensionLayout = new QVBoxLayout;
- extensionLayout->setContentsMargins(QMargins());
- extensionLayout->addWidget(wholeWordsCheckBox);
- extensionLayout->addWidget(backwardCheckBox);
- extensionLayout->addWidget(searchSelectionCheckBox);
- extension->setLayout(extensionLayout);
-//! [3]
-
-//! [4]
- QHBoxLayout *topLeftLayout = new QHBoxLayout;
- topLeftLayout->addWidget(label);
- topLeftLayout->addWidget(lineEdit);
-
- QVBoxLayout *leftLayout = new QVBoxLayout;
- leftLayout->addLayout(topLeftLayout);
- leftLayout->addWidget(caseCheckBox);
- leftLayout->addWidget(fromStartCheckBox);
-
- QGridLayout *mainLayout = new QGridLayout;
- mainLayout->setSizeConstraint(QLayout::SetFixedSize);
- mainLayout->addLayout(leftLayout, 0, 0);
- mainLayout->addWidget(buttonBox, 0, 1);
- mainLayout->addWidget(extension, 1, 0, 1, 2);
- mainLayout->setRowStretch(2, 1);
-
- setLayout(mainLayout);
-
- setWindowTitle(tr("Extension"));
-//! [4] //! [5]
- extension->hide();
-}
-//! [5]
diff --git a/examples/widgets/dialogs/extension/finddialog.h b/examples/widgets/dialogs/extension/finddialog.h
deleted file mode 100644
index 61bc442f46..0000000000
--- a/examples/widgets/dialogs/extension/finddialog.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef FINDDIALOG_H
-#define FINDDIALOG_H
-
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-class QCheckBox;
-class QDialogButtonBox;
-class QGroupBox;
-class QLabel;
-class QLineEdit;
-class QPushButton;
-QT_END_NAMESPACE
-
-//! [0]
-class FindDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- FindDialog(QWidget *parent = nullptr);
-
-private:
- QLabel *label;
- QLineEdit *lineEdit;
- QCheckBox *caseCheckBox;
- QCheckBox *fromStartCheckBox;
- QCheckBox *wholeWordsCheckBox;
- QCheckBox *searchSelectionCheckBox;
- QCheckBox *backwardCheckBox;
- QDialogButtonBox *buttonBox;
- QPushButton *findButton;
- QPushButton *moreButton;
- QWidget *extension;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/dialogs/extension/main.cpp b/examples/widgets/dialogs/extension/main.cpp
deleted file mode 100644
index 730a0347f4..0000000000
--- a/examples/widgets/dialogs/extension/main.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "finddialog.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- FindDialog dialog;
-
- dialog.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/dialogs/findfiles/CMakeLists.txt b/examples/widgets/dialogs/findfiles/CMakeLists.txt
deleted file mode 100644
index d1c70dc145..0000000000
--- a/examples/widgets/dialogs/findfiles/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(findfiles LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/findfiles")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(findfiles
- main.cpp
- window.cpp window.h
-)
-
-set_target_properties(findfiles PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(findfiles PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS findfiles
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/dialogs/findfiles/findfiles.pro b/examples/widgets/dialogs/findfiles/findfiles.pro
deleted file mode 100644
index 4fb77f0dd7..0000000000
--- a/examples/widgets/dialogs/findfiles/findfiles.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT += widgets
-requires(qtConfig(filedialog))
-
-HEADERS = window.h
-SOURCES = main.cpp \
- window.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/dialogs/findfiles
-INSTALLS += target
diff --git a/examples/widgets/dialogs/findfiles/main.cpp b/examples/widgets/dialogs/findfiles/main.cpp
deleted file mode 100644
index 27409403a5..0000000000
--- a/examples/widgets/dialogs/findfiles/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "window.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- Window window;
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/dialogs/findfiles/window.cpp b/examples/widgets/dialogs/findfiles/window.cpp
deleted file mode 100644
index f3e7253c75..0000000000
--- a/examples/widgets/dialogs/findfiles/window.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-#include "window.h"
-
-//! [17]
-enum { absoluteFileNameRole = Qt::UserRole + 1 };
-//! [17]
-
-//! [18]
-static inline QString fileNameOfItem(const QTableWidgetItem *item)
-{
- return item->data(absoluteFileNameRole).toString();
-}
-//! [18]
-
-//! [14]
-static inline void openFile(const QString &fileName)
-{
- QDesktopServices::openUrl(QUrl::fromLocalFile(fileName));
-}
-//! [14]
-
-//! [0]
-Window::Window(QWidget *parent)
- : QWidget(parent)
-{
- setWindowTitle(tr("Find Files"));
- QPushButton *browseButton = new QPushButton(tr("&Browse..."), this);
- connect(browseButton, &QAbstractButton::clicked, this, &Window::browse);
- findButton = new QPushButton(tr("&Find"), this);
- connect(findButton, &QAbstractButton::clicked, this, &Window::find);
-
- fileComboBox = createComboBox(tr("*"));
- connect(fileComboBox->lineEdit(), &QLineEdit::returnPressed,
- this, &Window::animateFindClick);
- textComboBox = createComboBox();
- connect(textComboBox->lineEdit(), &QLineEdit::returnPressed,
- this, &Window::animateFindClick);
- directoryComboBox = createComboBox(QDir::toNativeSeparators(QDir::currentPath()));
- connect(directoryComboBox->lineEdit(), &QLineEdit::returnPressed,
- this, &Window::animateFindClick);
-
- filesFoundLabel = new QLabel;
-
- createFilesTable();
-
- QGridLayout *mainLayout = new QGridLayout(this);
- mainLayout->addWidget(new QLabel(tr("Named:")), 0, 0);
- mainLayout->addWidget(fileComboBox, 0, 1, 1, 2);
- mainLayout->addWidget(new QLabel(tr("Containing text:")), 1, 0);
- mainLayout->addWidget(textComboBox, 1, 1, 1, 2);
- mainLayout->addWidget(new QLabel(tr("In directory:")), 2, 0);
- mainLayout->addWidget(directoryComboBox, 2, 1);
- mainLayout->addWidget(browseButton, 2, 2);
- mainLayout->addWidget(filesTable, 3, 0, 1, 3);
- mainLayout->addWidget(filesFoundLabel, 4, 0, 1, 2);
- mainLayout->addWidget(findButton, 4, 2);
-//! [0]
-
-//! [1]
- connect(new QShortcut(QKeySequence::Quit, this), &QShortcut::activated,
- qApp, &QApplication::quit);
-//! [1]
-}
-
-//! [2]
-void Window::browse()
-{
- QString directory =
- QDir::toNativeSeparators(QFileDialog::getExistingDirectory(this, tr("Find Files"), QDir::currentPath()));
-
- if (!directory.isEmpty()) {
- if (directoryComboBox->findText(directory) == -1)
- directoryComboBox->addItem(directory);
- directoryComboBox->setCurrentIndex(directoryComboBox->findText(directory));
- }
-}
-//! [2]
-
-static void updateComboBox(QComboBox *comboBox)
-{
- if (comboBox->findText(comboBox->currentText()) == -1)
- comboBox->addItem(comboBox->currentText());
-}
-
-//! [3]
-void Window::find()
-{
- filesTable->setRowCount(0);
-
- QString fileName = fileComboBox->currentText();
- QString text = textComboBox->currentText();
- QString path = QDir::cleanPath(directoryComboBox->currentText());
- currentDir = QDir(path);
-//! [3]
-
- updateComboBox(fileComboBox);
- updateComboBox(textComboBox);
- updateComboBox(directoryComboBox);
-
-//! [4]
- QStringList filter;
- if (!fileName.isEmpty())
- filter << fileName;
- QDirIterator it(path, filter, QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
- QStringList files;
- while (it.hasNext())
- files << it.next();
- if (!text.isEmpty())
- files = findFiles(files, text);
- files.sort();
- showFiles(files);
-}
-//! [4]
-
-void Window::animateFindClick()
-{
- findButton->animateClick();
-}
-
-//! [5]
-QStringList Window::findFiles(const QStringList &files, const QString &text)
-{
- QProgressDialog progressDialog(this);
- progressDialog.setCancelButtonText(tr("&Cancel"));
- progressDialog.setRange(0, files.size());
- progressDialog.setWindowTitle(tr("Find Files"));
-
-//! [5] //! [6]
- QMimeDatabase mimeDatabase;
- QStringList foundFiles;
-
- for (int i = 0; i < files.size(); ++i) {
- progressDialog.setValue(i);
- progressDialog.setLabelText(tr("Searching file number %1 of %n...", nullptr, files.size()).arg(i));
- QCoreApplication::processEvents();
-//! [6]
-
- if (progressDialog.wasCanceled())
- break;
-
-//! [7]
- const QString fileName = files.at(i);
- const QMimeType mimeType = mimeDatabase.mimeTypeForFile(fileName);
- if (mimeType.isValid() && !mimeType.inherits(QStringLiteral("text/plain"))) {
- qWarning() << "Not searching binary file " << QDir::toNativeSeparators(fileName);
- continue;
- }
- QFile file(fileName);
- if (file.open(QIODevice::ReadOnly)) {
- QString line;
- QTextStream in(&file);
- while (!in.atEnd()) {
- if (progressDialog.wasCanceled())
- break;
- line = in.readLine();
- if (line.contains(text, Qt::CaseInsensitive)) {
- foundFiles << files[i];
- break;
- }
- }
- }
- }
- return foundFiles;
-}
-//! [7]
-
-//! [8]
-void Window::showFiles(const QStringList &paths)
-{
- for (const QString &filePath : paths) {
- const QString toolTip = QDir::toNativeSeparators(filePath);
- const QString relativePath = QDir::toNativeSeparators(currentDir.relativeFilePath(filePath));
- const qint64 size = QFileInfo(filePath).size();
- QTableWidgetItem *fileNameItem = new QTableWidgetItem(relativePath);
- fileNameItem->setData(absoluteFileNameRole, QVariant(filePath));
- fileNameItem->setToolTip(toolTip);
- fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable);
- QTableWidgetItem *sizeItem = new QTableWidgetItem(QLocale().formattedDataSize(size));
- sizeItem->setData(absoluteFileNameRole, QVariant(filePath));
- sizeItem->setToolTip(toolTip);
- sizeItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
- sizeItem->setFlags(sizeItem->flags() ^ Qt::ItemIsEditable);
-
- int row = filesTable->rowCount();
- filesTable->insertRow(row);
- filesTable->setItem(row, 0, fileNameItem);
- filesTable->setItem(row, 1, sizeItem);
- }
- filesFoundLabel->setText(tr("%n file(s) found (Double click on a file to open it)", nullptr, paths.size()));
- filesFoundLabel->setWordWrap(true);
-}
-//! [8]
-
-//! [10]
-QComboBox *Window::createComboBox(const QString &text)
-{
- QComboBox *comboBox = new QComboBox;
- comboBox->setEditable(true);
- comboBox->addItem(text);
- comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
- return comboBox;
-}
-//! [10]
-
-//! [11]
-void Window::createFilesTable()
-{
- filesTable = new QTableWidget(0, 2);
- filesTable->setSelectionBehavior(QAbstractItemView::SelectRows);
-
- QStringList labels;
- labels << tr("Filename") << tr("Size");
- filesTable->setHorizontalHeaderLabels(labels);
- filesTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
- filesTable->verticalHeader()->hide();
- filesTable->setShowGrid(false);
-//! [15]
- filesTable->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(filesTable, &QTableWidget::customContextMenuRequested,
- this, &Window::contextMenu);
- connect(filesTable, &QTableWidget::cellActivated,
- this, &Window::openFileOfItem);
-//! [15]
-}
-//! [11]
-
-
-//! [12]
-
-void Window::openFileOfItem(int row, int /* column */)
-{
- const QTableWidgetItem *item = filesTable->item(row, 0);
- openFile(fileNameOfItem(item));
-}
-
-//! [12]
-
-//! [16]
-void Window::contextMenu(const QPoint &pos)
-{
- const QTableWidgetItem *item = filesTable->itemAt(pos);
- if (!item)
- return;
- QMenu menu;
-#ifndef QT_NO_CLIPBOARD
- QAction *copyAction = menu.addAction("Copy Name");
-#endif
- QAction *openAction = menu.addAction("Open");
- QAction *action = menu.exec(filesTable->mapToGlobal(pos));
- if (!action)
- return;
- const QString fileName = fileNameOfItem(item);
- if (action == openAction)
- openFile(fileName);
-#ifndef QT_NO_CLIPBOARD
- else if (action == copyAction)
- QGuiApplication::clipboard()->setText(QDir::toNativeSeparators(fileName));
-#endif
-}
-//! [16]
diff --git a/examples/widgets/dialogs/findfiles/window.h b/examples/widgets/dialogs/findfiles/window.h
deleted file mode 100644
index 2c2e3100c0..0000000000
--- a/examples/widgets/dialogs/findfiles/window.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <QWidget>
-#include <QDir>
-
-QT_BEGIN_NAMESPACE
-class QComboBox;
-class QLabel;
-class QPushButton;
-class QTableWidget;
-class QTableWidgetItem;
-QT_END_NAMESPACE
-
-//! [0]
-class Window : public QWidget
-{
- Q_OBJECT
-
-public:
- Window(QWidget *parent = nullptr);
-
-private slots:
- void browse();
- void find();
- void animateFindClick();
- void openFileOfItem(int row, int column);
- void contextMenu(const QPoint &pos);
-
-private:
- QStringList findFiles(const QStringList &files, const QString &text);
- void showFiles(const QStringList &paths);
- QComboBox *createComboBox(const QString &text = QString());
- void createFilesTable();
-
- QComboBox *fileComboBox;
- QComboBox *textComboBox;
- QComboBox *directoryComboBox;
- QLabel *filesFoundLabel;
- QPushButton *findButton;
- QTableWidget *filesTable;
-
- QDir currentDir;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/dialogs/licensewizard/CMakeLists.txt b/examples/widgets/dialogs/licensewizard/CMakeLists.txt
index 5ba8321782..0cf2d61c8b 100644
--- a/examples/widgets/dialogs/licensewizard/CMakeLists.txt
+++ b/examples/widgets/dialogs/licensewizard/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(licensewizard LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/licensewizard")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui PrintSupport Widgets)
+qt_standard_project_setup()
+
qt_add_executable(licensewizard
licensewizard.cpp licensewizard.h
main.cpp
@@ -24,11 +18,11 @@ set_target_properties(licensewizard PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(licensewizard PUBLIC
- Qt::Core
- Qt::Gui
- Qt::PrintSupport
- Qt::Widgets
+target_link_libraries(licensewizard PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::PrintSupport
+ Qt6::Widgets
)
# Resources:
@@ -45,7 +39,14 @@ qt_add_resources(licensewizard "licensewizard"
)
install(TARGETS licensewizard
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET licensewizard
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/dialogs/licensewizard/licensewizard.cpp b/examples/widgets/dialogs/licensewizard/licensewizard.cpp
index 05888ac67d..67fa46bf07 100644
--- a/examples/widgets/dialogs/licensewizard/licensewizard.cpp
+++ b/examples/widgets/dialogs/licensewizard/licensewizard.cpp
@@ -288,9 +288,12 @@ void ConclusionPage::initializePage()
"You can use this software for 30 days and make one "
"backup, but you are not allowed to distribute it.");
} else if (wizard()->hasVisitedPage(LicenseWizard::Page_Details)) {
+//! [accessField]
+ const QString emailAddress = field("details.email").toString();
licenseText = tr("<u>First-Time License Agreement:</u> "
"You can use this software subject to the license "
- "you will receive by email.");
+ "you will receive by email sent to %1.").arg(emailAddress);
+//! [accessField]
} else {
licenseText = tr("<u>Upgrade License Agreement:</u> "
"This software is licensed under the terms of your "
diff --git a/examples/widgets/dialogs/licensewizard/main.cpp b/examples/widgets/dialogs/licensewizard/main.cpp
index 13e13f0e32..d16b5dc6d1 100644
--- a/examples/widgets/dialogs/licensewizard/main.cpp
+++ b/examples/widgets/dialogs/licensewizard/main.cpp
@@ -10,8 +10,6 @@
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(licensewizard);
-
QApplication app(argc, argv);
#ifndef QT_NO_TRANSLATION
diff --git a/examples/widgets/dialogs/standarddialogs/CMakeLists.txt b/examples/widgets/dialogs/standarddialogs/CMakeLists.txt
index ea502e0657..07e22469ee 100644
--- a/examples/widgets/dialogs/standarddialogs/CMakeLists.txt
+++ b/examples/widgets/dialogs/standarddialogs/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(standarddialogs LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/standarddialogs")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(standarddialogs
dialog.cpp dialog.h
main.cpp
@@ -24,14 +18,21 @@ set_target_properties(standarddialogs PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(standarddialogs PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(standarddialogs PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS standarddialogs
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET standarddialogs
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/dialogs/standarddialogs/dialog.cpp b/examples/widgets/dialogs/standarddialogs/dialog.cpp
index 1775a4231a..67fb615794 100644
--- a/examples/widgets/dialogs/standarddialogs/dialog.cpp
+++ b/examples/widgets/dialogs/standarddialogs/dialog.cpp
@@ -5,16 +5,6 @@
#include "dialog.h"
-#define MESSAGE \
- Dialog::tr("<p>Message boxes have a caption, a text, " \
- "and any number of buttons, each with standard or custom texts." \
- "<p>Click a button to close the message box. Pressing the Esc button " \
- "will activate the detected escape button (if any).")
-#define MESSAGE_DETAILS \
- Dialog::tr("If a message box has detailed text, the user can reveal it " \
- "by pressing the Show Details... button.")
-
-
class DialogOptionsWidget : public QGroupBox
{
public:
@@ -52,7 +42,7 @@ void DialogOptionsWidget::addSpacer()
int DialogOptionsWidget::value() const
{
int result = 0;
- for (const CheckBoxEntry &checkboxEntry : qAsConst(checkBoxEntries)) {
+ for (const CheckBoxEntry &checkboxEntry : std::as_const(checkBoxEntries)) {
if (checkboxEntry.first->isChecked())
result |= checkboxEntry.second;
}
@@ -148,8 +138,6 @@ Dialog::Dialog(QWidget *parent)
warningLabel->setFrameStyle(frameStyle);
QPushButton *warningButton = new QPushButton(tr("QMessageBox::&warning()"));
- errorLabel = new QLabel;
- errorLabel->setFrameStyle(frameStyle);
QPushButton *errorButton =
new QPushButton(tr("QErrorMessage::showM&essage()"));
@@ -203,6 +191,7 @@ Dialog::Dialog(QWidget *parent)
colorDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QColorDialog::DontUseNativeDialog);
colorDialogOptionsWidget->addCheckBox(tr("Show alpha channel") , QColorDialog::ShowAlphaChannel);
colorDialogOptionsWidget->addCheckBox(tr("No buttons") , QColorDialog::NoButtons);
+ colorDialogOptionsWidget->addCheckBox(tr("Hide Color Picker") , QColorDialog::NoEyeDropperButton);
layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 1, 0);
layout->addWidget(colorDialogOptionsWidget, 2, 0, 1 ,2);
@@ -259,7 +248,6 @@ Dialog::Dialog(QWidget *parent)
layout->addWidget(warningButton, 3, 0);
layout->addWidget(warningLabel, 3, 1);
layout->addWidget(errorButton, 4, 0);
- layout->addWidget(errorLabel, 4, 1);
layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 5, 0);
toolbox->addItem(page, tr("Message Boxes"));
@@ -413,10 +401,14 @@ void Dialog::setSaveFileName()
void Dialog::criticalMessage()
{
- QMessageBox::StandardButton reply;
- reply = QMessageBox::critical(this, tr("QMessageBox::critical()"),
- MESSAGE,
- QMessageBox::Abort | QMessageBox::Retry | QMessageBox::Ignore);
+ QMessageBox msgBox(QMessageBox::Critical, tr("QMessageBox::critical()"),
+ tr("Houston, we have a problem"), { }, this);
+ msgBox.setInformativeText(tr("Activating the liquid oxygen stirring fans caused an explosion in one of the tanks. " \
+ "Liquid oxygen levels are getting low. This may jeopardize the moon landing mission."));
+ msgBox.addButton(QMessageBox::Abort);
+ msgBox.addButton(QMessageBox::Retry);
+ msgBox.addButton(QMessageBox::Ignore);
+ int reply = msgBox.exec();
if (reply == QMessageBox::Abort)
criticalLabel->setText(tr("Abort"));
else if (reply == QMessageBox::Retry)
@@ -427,9 +419,12 @@ void Dialog::criticalMessage()
void Dialog::informationMessage()
{
- QMessageBox::StandardButton reply;
- reply = QMessageBox::information(this, tr("QMessageBox::information()"), MESSAGE);
- if (reply == QMessageBox::Ok)
+ QMessageBox msgBox(QMessageBox::Information, tr("QMessageBox::information()"),
+ tr("Elvis has left the building."), { }, this);
+ msgBox.setInformativeText(tr("This phrase was often used by public address announcers at the conclusion " \
+ "of Elvis Presley concerts in order to disperse audiences who lingered in " \
+ "hopes of an encore. It has since become a catchphrase and punchline."));
+ if (msgBox.exec() == QMessageBox::Ok)
informationLabel->setText(tr("OK"));
else
informationLabel->setText(tr("Escape"));
@@ -437,10 +432,15 @@ void Dialog::informationMessage()
void Dialog::questionMessage()
{
- QMessageBox::StandardButton reply;
- reply = QMessageBox::question(this, tr("QMessageBox::question()"),
- MESSAGE,
- QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
+ QMessageBox msgBox(QMessageBox::Question, tr("QMessageBox::question()"),
+ tr("Would you like cheese with that?"), { }, this);
+ msgBox.setInformativeText(tr("A cheeseburger is a hamburger topped with cheese. Traditionally, the slice of " \
+ "cheese is placed on top of the meat patty. The cheese is usually added to the " \
+ "cooking hamburger patty shortly before serving, which allows the cheese to melt."));
+ msgBox.addButton(QMessageBox::Yes);
+ msgBox.addButton(QMessageBox::No);
+ msgBox.addButton(QMessageBox::Cancel);
+ int reply = msgBox.exec();
if (reply == QMessageBox::Yes)
questionLabel->setText(tr("Yes"));
else if (reply == QMessageBox::No)
@@ -452,26 +452,31 @@ void Dialog::questionMessage()
void Dialog::warningMessage()
{
QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"),
- MESSAGE, { }, this);
- msgBox.setDetailedText(MESSAGE_DETAILS);
- msgBox.addButton(tr("Save &Again"), QMessageBox::AcceptRole);
- msgBox.addButton(tr("&Continue"), QMessageBox::RejectRole);
- if (msgBox.exec() == QMessageBox::AcceptRole)
- warningLabel->setText(tr("Save Again"));
+ tr("Delete the only copy of your movie manuscript?"), { }, this);
+ msgBox.setInformativeText(tr("You've been working on this manuscript for 738 days now. Hang in there!"));
+ msgBox.setDetailedText("\"A long time ago in a galaxy far, far away....\"");
+ auto *keepButton = msgBox.addButton(tr("&Keep"), QMessageBox::AcceptRole);
+ auto *deleteButton = msgBox.addButton(tr("Delete"), QMessageBox::DestructiveRole);
+ msgBox.exec();
+ if (msgBox.clickedButton() == keepButton)
+ warningLabel->setText(tr("Keep"));
+ else if (msgBox.clickedButton() == deleteButton)
+ warningLabel->setText(tr("Delete"));
else
- warningLabel->setText(tr("Continue"));
-
+ warningLabel->setText("");
}
void Dialog::errorMessage()
{
errorMessageDialog->showMessage(
tr("This dialog shows and remembers error messages. "
- "If the checkbox is checked (as it is by default), "
- "the shown message will be shown again, "
- "but if the user unchecks the box the message "
+ "If the user chooses to not show the dialog again, the dialog "
"will not appear again if QErrorMessage::showMessage() "
"is called with the same message."));
- errorLabel->setText(tr("If the box is unchecked, the message "
- "won't appear again."));
+ errorMessageDialog->showMessage(
+ tr("You can queue up error messages, and they will be "
+ "shown one after each other. Each message maintains "
+ "its own state for whether it will be shown again "
+ "the next time QErrorMessage::showMessage() is called "
+ "with the same message."));
}
diff --git a/examples/widgets/dialogs/standarddialogs/dialog.h b/examples/widgets/dialogs/standarddialogs/dialog.h
index b316caf529..88d0f7519f 100644
--- a/examples/widgets/dialogs/standarddialogs/dialog.h
+++ b/examples/widgets/dialogs/standarddialogs/dialog.h
@@ -55,7 +55,6 @@ private:
QLabel *informationLabel;
QLabel *questionLabel;
QLabel *warningLabel;
- QLabel *errorLabel;
QErrorMessage *errorMessageDialog;
DialogOptionsWidget *fileDialogOptionsWidget;
DialogOptionsWidget *colorDialogOptionsWidget;
diff --git a/examples/widgets/dialogs/standarddialogs/main.mm b/examples/widgets/dialogs/standarddialogs/main.mm
new file mode 100644
index 0000000000..558ef4e680
--- /dev/null
+++ b/examples/widgets/dialogs/standarddialogs/main.mm
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QApplication>
+#include <QScreen>
+#include <QStyleHints>
+#include <QTranslator>
+#include <QLocale>
+#include <QLibraryInfo>
+
+#include "dialog.h"
+
+#include <AppKit/AppKit.h>
+
+using namespace Qt::StringLiterals;
+
+int main(int argc, char *argv[])
+{
+ [NSApplication sharedApplication];
+ NSApplicationLoad();
+ NSApplicationLoad();
+ [NSApp run];
+
+ QApplication app(argc, argv);
+ //app.setAttribute(Qt::AA_DontUseNativeDialogs);
+
+#if QT_CONFIG(translation)
+ QTranslator translator;
+ if (translator.load(QLocale::system(), u"qtbase"_s, u"_"_s,
+ QLibraryInfo::path(QLibraryInfo::TranslationsPath))) {
+ app.installTranslator(&translator);
+ }
+#endif
+
+ QGuiApplication::setApplicationDisplayName(Dialog::tr("Standard Dialogs"));
+
+ Dialog dialog;
+ if (!QGuiApplication::styleHints()->showIsFullScreen() && !QGuiApplication::styleHints()->showIsMaximized()) {
+ const QRect availableGeometry = dialog.screen()->availableGeometry();
+ dialog.resize(availableGeometry.width() / 3, availableGeometry.height() * 2 / 3);
+ dialog.move((availableGeometry.width() - dialog.width()) / 2,
+ (availableGeometry.height() - dialog.height()) / 2);
+ }
+ dialog.show();
+
+ return app.exec();
+}
diff --git a/examples/widgets/dialogs/tabdialog/CMakeLists.txt b/examples/widgets/dialogs/tabdialog/CMakeLists.txt
index 27f6aa914d..b959a5c3e4 100644
--- a/examples/widgets/dialogs/tabdialog/CMakeLists.txt
+++ b/examples/widgets/dialogs/tabdialog/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(tabdialog LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/tabdialog")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(tabdialog
main.cpp
tabdialog.cpp tabdialog.h
@@ -24,14 +18,21 @@ set_target_properties(tabdialog PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(tabdialog PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(tabdialog PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS tabdialog
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET tabdialog
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/dialogs/trivialwizard/CMakeLists.txt b/examples/widgets/dialogs/trivialwizard/CMakeLists.txt
index b2621da35c..966d99a7aa 100644
--- a/examples/widgets/dialogs/trivialwizard/CMakeLists.txt
+++ b/examples/widgets/dialogs/trivialwizard/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(trivialwizard LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/trivialwizard")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(trivialwizard
trivialwizard.cpp
)
@@ -23,14 +17,21 @@ set_target_properties(trivialwizard PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(trivialwizard PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(trivialwizard PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS trivialwizard
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET trivialwizard
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp b/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp
index 83de13f046..b9321338a4 100644
--- a/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp
+++ b/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp
@@ -86,10 +86,12 @@ int main(int argc, char *argv[])
app.installTranslator(translator);
#endif
+//! [linearAddPage]
QWizard wizard;
wizard.addPage(createIntroPage());
wizard.addPage(createRegistrationPage());
wizard.addPage(createConclusionPage());
+//! [linearAddPage]
wizard.setWindowTitle("Trivial Wizard");
wizard.show();
diff --git a/examples/widgets/doc/dropsite.qdoc b/examples/widgets/doc/dropsite.qdoc
index 5ebf0ff3a4..4c38ffc50d 100644
--- a/examples/widgets/doc/dropsite.qdoc
+++ b/examples/widgets/doc/dropsite.qdoc
@@ -4,6 +4,7 @@
/*!
\example draganddrop/dropsite
\title Drop Site Example
+ \examplecategory {User Interface Components}
\brief The example shows how to distinguish the various MIME formats available
in a drag and drop operation.
diff --git a/examples/widgets/doc/images/analogclock-viewport.png b/examples/widgets/doc/images/analogclock-viewport.png
index 31ce0c3c6e..40e0fc8bb6 100644
--- a/examples/widgets/doc/images/analogclock-viewport.png
+++ b/examples/widgets/doc/images/analogclock-viewport.png
Binary files differ
diff --git a/examples/widgets/doc/images/calendar-example.png b/examples/widgets/doc/images/calendar-example.png
deleted file mode 100644
index 895ce76b09..0000000000
--- a/examples/widgets/doc/images/calendar-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/draganddroppuzzle-example.png b/examples/widgets/doc/images/draganddroppuzzle-example.png
deleted file mode 100644
index ca6844581e..0000000000
--- a/examples/widgets/doc/images/draganddroppuzzle-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/echoplugin.png b/examples/widgets/doc/images/echoplugin.png
deleted file mode 100644
index 6c4fd2f6d8..0000000000
--- a/examples/widgets/doc/images/echoplugin.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/echopluginexample.png b/examples/widgets/doc/images/echopluginexample.png
deleted file mode 100644
index 24e039714f..0000000000
--- a/examples/widgets/doc/images/echopluginexample.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/fademessageeffect-example-faded.png b/examples/widgets/doc/images/fademessageeffect-example-faded.png
deleted file mode 100644
index ea66d2c7f0..0000000000
--- a/examples/widgets/doc/images/fademessageeffect-example-faded.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/fademessageeffect-example.png b/examples/widgets/doc/images/fademessageeffect-example.png
deleted file mode 100644
index 823c85101d..0000000000
--- a/examples/widgets/doc/images/fademessageeffect-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/fridgemagnets-example.png b/examples/widgets/doc/images/fridgemagnets-example.png
deleted file mode 100644
index 2a890aad4e..0000000000
--- a/examples/widgets/doc/images/fridgemagnets-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/graphicsanchorlayout-example.png b/examples/widgets/doc/images/graphicsanchorlayout-example.png
deleted file mode 100644
index 3f35fdb6b7..0000000000
--- a/examples/widgets/doc/images/graphicsanchorlayout-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/graphicsflowlayout-example.png b/examples/widgets/doc/images/graphicsflowlayout-example.png
deleted file mode 100644
index 953d54086a..0000000000
--- a/examples/widgets/doc/images/graphicsflowlayout-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/imagegestures-example.jpg b/examples/widgets/doc/images/imagegestures-example.jpg
deleted file mode 100644
index c8484b4a71..0000000000
--- a/examples/widgets/doc/images/imagegestures-example.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/imagegestures-example.png b/examples/widgets/doc/images/imagegestures-example.png
new file mode 100644
index 0000000000..c83b71574f
--- /dev/null
+++ b/examples/widgets/doc/images/imagegestures-example.png
Binary files differ
diff --git a/examples/widgets/doc/images/imageviewer-fit_to_window_1.png b/examples/widgets/doc/images/imageviewer-fit_to_window_1.png
deleted file mode 100644
index 0fe1ba1c62..0000000000
--- a/examples/widgets/doc/images/imageviewer-fit_to_window_1.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/imageviewer-fit_to_window_2.png b/examples/widgets/doc/images/imageviewer-fit_to_window_2.png
deleted file mode 100644
index 29e3a93bc1..0000000000
--- a/examples/widgets/doc/images/imageviewer-fit_to_window_2.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/imageviewer-original_size.png b/examples/widgets/doc/images/imageviewer-original_size.png
deleted file mode 100644
index c0443eba25..0000000000
--- a/examples/widgets/doc/images/imageviewer-original_size.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/imageviewer-zoom_in_1.png b/examples/widgets/doc/images/imageviewer-zoom_in_1.png
deleted file mode 100644
index 05b0fffecb..0000000000
--- a/examples/widgets/doc/images/imageviewer-zoom_in_1.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/imageviewer-zoom_in_2.png b/examples/widgets/doc/images/imageviewer-zoom_in_2.png
deleted file mode 100644
index 0c36111c03..0000000000
--- a/examples/widgets/doc/images/imageviewer-zoom_in_2.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/itemviewspuzzle-example.png b/examples/widgets/doc/images/itemviewspuzzle-example.png
deleted file mode 100644
index aae6a953ca..0000000000
--- a/examples/widgets/doc/images/itemviewspuzzle-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/mainwindow-demo.png b/examples/widgets/doc/images/mainwindow-demo.png
deleted file mode 100644
index 0e146d156e..0000000000
--- a/examples/widgets/doc/images/mainwindow-demo.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/mousebutton-buttontester.png b/examples/widgets/doc/images/mousebutton-buttontester.png
deleted file mode 100644
index f8f71db59b..0000000000
--- a/examples/widgets/doc/images/mousebutton-buttontester.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/plugandpaint-plugindialog.png b/examples/widgets/doc/images/plugandpaint-plugindialog.png
deleted file mode 100644
index 4b601bd58b..0000000000
--- a/examples/widgets/doc/images/plugandpaint-plugindialog.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/plugandpaint.png b/examples/widgets/doc/images/plugandpaint.png
deleted file mode 100644
index bd5d001f91..0000000000
--- a/examples/widgets/doc/images/plugandpaint.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/settingseditor-example.png b/examples/widgets/doc/images/settingseditor-example.png
deleted file mode 100644
index 7a5be05fd0..0000000000
--- a/examples/widgets/doc/images/settingseditor-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/stylepluginexample.png b/examples/widgets/doc/images/stylepluginexample.png
deleted file mode 100644
index 05d8c6b5cf..0000000000
--- a/examples/widgets/doc/images/stylepluginexample.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/stylesheet-pagefold.png b/examples/widgets/doc/images/stylesheet-pagefold.png
deleted file mode 100644
index d1358f326b..0000000000
--- a/examples/widgets/doc/images/stylesheet-pagefold.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/textedit-demo.png b/examples/widgets/doc/images/textedit-demo.png
deleted file mode 100644
index 3cf2883a12..0000000000
--- a/examples/widgets/doc/images/textedit-demo.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/undodemo.png b/examples/widgets/doc/images/undodemo.png
deleted file mode 100644
index 85c3622738..0000000000
--- a/examples/widgets/doc/images/undodemo.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/images/weatheranchorlayout-example.png b/examples/widgets/doc/images/weatheranchorlayout-example.png
deleted file mode 100644
index 59d3b55b7a..0000000000
--- a/examples/widgets/doc/images/weatheranchorlayout-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/doc/mousebuttons.qdoc b/examples/widgets/doc/mousebuttons.qdoc
deleted file mode 100644
index ecf46dc094..0000000000
--- a/examples/widgets/doc/mousebuttons.qdoc
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// Copyright (C) 2016 Rick Stockton <rickstockton@reno-computerhelp.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/mousebuttons
- \title Mouse Button Tester
-
- \brief The 'Mouse Button Tester' example demonstrates how to reimplement
- mouse events within a custom class. You can also use this program to
- verify that Qt is actually receiving mouse events from your mouse.
-
- Many 'gamer' mouse devices are configured with high-numbered "buttons"
- sending text shortcuts for certain games. With such a mouse, no mouse
- button events occur: The "mouse" sends keystrokes, and the
- 'Mouse Button Tester' Window will not see the event. Receiving no event,
- it will not repaint the Window with new text describing a button event.
-
- And so, in addition to it's use as Qt example code, the program may be
- useful s a mouse device tester. Note that there is another example
- mouse buttons example which provides the same function, written in QML.
-
- This program (the Widget-based example) consists of three classes,
- in addition to the main() parent program:
-
- \list
- \li \c A QPushButton, "Quit".
- \li \c ButtonTester. This is derived from Qt's TextArea class, for
- purpose of customizing/re-implementing the mouse and wheel event
- member functions.
- \li \c A simple QVBoxLayout layout.
- \endlist
-
- First we will review the main program, with it's layout and "Quit"
- QPushButton. Then we will take a look at the \c ButtonTester class.
-
- \section1 The Main Program
-
- Note that the QPushButton, "Quit", is defined directly within the main()
- program, rather than another class. This is a correct way of defining a
- "Quit" QPushButton: A "Quit" Button defined inside another
- class would result in the destructor of that second class being
- called twice. This "Quit" Button uses the traditional Signal/Slot
- connection to invoke termination of the QApp, which will properly destroy
- its child classes before terminating itself.
-
- The remainder of the main() program is concerned with defining the layout,
- and applying a minimum size to the customized ButtonTester.
-
- \section1 ButtonTester Class Definition
-
- The \c ButtonTester class inherits from QTextEdit, and listens for
- mouse events on all possible Qt::MouseButton values. It also listens for
- wheel events from the mouse, and indicates the direction of wheel motion
- ("up", down", "left", or "right"). It prints short debug messages into
- the Window, and also on the console QDebug() stream, when mouse button
- and wheel events occur. Our reimplementation of mousePressEvent(),
- mouseReleaseEvent(), mouseDoubleClickEvent(), and wheelEvent() "drive"
- the program; the other functions simply convert the Qt::MouseButton
- values into text strings.
-
- You should call the ignore() function on any mouse event (or other event)
- which your widget-based classes do not use and consume. This function
- assures that Qt will propagate the event through each parent widget,
- until it is used or propagated to the Window Manager. (Qt attempts to do
- this automatically, but it is better programming practice to explicitly
- invoke the function.)
-
- \image mousebutton-buttontester.png
-*/
diff --git a/examples/widgets/doc/src/addressbook-tutorial.qdoc b/examples/widgets/doc/src/addressbook-tutorial.qdoc
deleted file mode 100644
index 2f7884bee8..0000000000
--- a/examples/widgets/doc/src/addressbook-tutorial.qdoc
+++ /dev/null
@@ -1,948 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \page tutorials-addressbook.html
-
- \title Address Book Tutorial
- \ingroup examples-layout
- \brief An introduction to GUI programming, showing how to put together a
- simple yet fully-functioning application.
-
- This tutorial is an introduction to GUI programming with the Qt
- cross-platform framework.
-
- \image addressbook-tutorial-screenshot.png
-
- \omit
- It doesn't cover everything; the emphasis is on teaching the programming
- philosophy of GUI programming, and Qt's features are introduced as needed.
- Some commonly used features are never used in this tutorial.
- \endomit
-
- In this tutorial, you will learn about some of the basic
- components of Qt, including:
-
- \list
- \li Widgets and layout managers
- \li Container classes
- \li Signals and slots
- \li Input and output devices
- \endlist
-
- Tutorial contents:
-
- \list 1
- \li \l{tutorials/addressbook/part1}{Designing the User Interface}
- \li \l{tutorials/addressbook/part2}{Adding Addresses}
- \li \l{tutorials/addressbook/part3}{Navigating between Entries}
- \li \l{tutorials/addressbook/part4}{Editing and Removing Addresses}
- \li \l{tutorials/addressbook/part5}{Adding a Find Function}
- \li \l{tutorials/addressbook/part6}{Loading and Saving}
- \li \l{tutorials/addressbook/part7}{Additional Features}
- \endlist
-
- The tutorial source code is located in \c{tutorials/addressbook}.
-
- Although this little application does not look much like a
- fully-fledged modern GUI application, it uses many of the basic
- elements that are used in more complex applications. After you
- have worked through this tutorial, we recommend reading the
- \l{mainwindows/application}{Application} example, which presents a
- small GUI application, with menus, toolbars, a status bar, and so
- on.
-*/
-
-/*!
- \example tutorials/addressbook/part1
- \title Part 1 - Designing the User Interface
- \brief Describes how to code the user interface of the Address Book Example.
- This first part covers the design of the basic graphical user
- interface (GUI) for our address book application.
-
- The first step in creating a GUI program is to design the user
- interface. Here the our goal is to set up the labels and input
- fields to implement a basic address book. The figure below is a
- screenshot of the expected output.
-
- \image addressbook-tutorial-part1-screenshot.png
-
- We require two QLabel objects, \c nameLabel and \c addressLabel, as well
- as two input fields, a QLineEdit object, \c nameLine, and a QTextEdit
- object, \c addressText, to enable the user to enter a contact's name and
- address. The widgets used and their positions are shown in the figure
- below.
-
- \image addressbook-tutorial-part1-labeled-screenshot.png
-
- There are three files used to implement this address book:
-
- \list
- \li \c{addressbook.h} - the definition file for the \c AddressBook
- class,
- \li \c{addressbook.cpp} - the implementation file for the
- \c AddressBook class, and
- \li \c{main.cpp} - the file containing a \c main() function, with
- an instance of \c AddressBook.
- \endlist
-
- \section1 Qt Programming - Subclassing
-
- When writing Qt programs, we usually subclass Qt objects to add
- functionality. This is one of the essential concepts behind creating
- custom widgets or collections of standard widgets. Subclassing to
- extend or change the behavior of a widget has the following advantages:
-
- \list
- \li We can write implementations of virtual or pure virtual functions to
- obtain exactly what we need, falling back on the base class's implementation
- when necessary.
- \li It allows us to encapsulate parts of the user interface within a class,
- so that the other parts of the application don't need to know about the
- individual widgets in the user interface.
- \li The subclass can be used to create multiple custom widgets in the same
- application or library, and the code for the subclass can be reused in other
- projects.
- \endlist
-
- Since Qt does not provide a specific address book widget, we subclass a
- standard Qt widget class and add features to it. The \c AddressBook class
- we create in this tutorial can be reused in situations where a basic address
- book widget is needed.
-
- \section1 Defining the AddressBook Class
-
- The \c{tutorials/addressbook/part1/addressbook.h} file is
- used to define the \c AddressBook class.
-
- We start by defining \c AddressBook as a QWidget subclass and declaring
- a constructor. We also use the Q_OBJECT macro to indicate that the class
- uses internationalization and Qt's signals and slots features, even
- if we do not use all of these features at this stage.
-
- \snippet tutorials/addressbook/part1/addressbook.h class definition
-
- The class holds declarations of \c nameLine and \c addressText,
- the private instances of QLineEdit and QTextEdit mentioned
- earlier. The data stored in \c nameLine and \c addressText will
- be needed for many of the address book functions.
-
- We don't include declarations of the QLabel objects we will use
- because we will not need to reference them once they have been
- created. The way Qt tracks the ownership of objects is explained
- in the next section.
-
- The Q_OBJECT macro itself implements some of the more advanced features of Qt.
- For now, it is useful to think of the Q_OBJECT macro as a shortcut which allows
- us to use the \l{QObject::}{tr()} and \l{QObject::}{connect()} functions.
-
- We have now completed the \c addressbook.h file and we move on to
- implement the corresponding \c addressbook.cpp file.
-
- \section1 Implementing the AddressBook Class
-
- The constructor of \c AddressBook accepts a QWidget parameter, \a parent.
- By convention, we pass this parameter to the base class's constructor.
- This concept of ownership, where a parent can have one or more children,
- is useful for grouping widgets in Qt. For example, if you delete a parent,
- all of its children will be deleted as well.
-
- \snippet tutorials/addressbook/part1/addressbook.cpp constructor and input fields
-
- In this constructor, the QLabel objects \c nameLabel and \c
- addressLabel are instantiated, as well as \c nameLine and \c
- addressText. The \l{QObject::tr()}{tr()} function returns a
- translated version of the string, if there is one
- available. Otherwise it returns the string itself. This function
- marks its QString parameter as one that should be translated into
- other languages. It should be used wherever a translatable string
- appears.
-
- When programming with Qt, it is useful to know how layouts work.
- Qt provides three main layout classes: QHBoxLayout, QVBoxLayout
- and QGridLayout to handle the positioning of widgets.
-
- \image addressbook-tutorial-part1-labeled-layout.png
-
- We use a QGridLayout to position our labels and input fields in a
- structured manner. QGridLayout divides the available space into a grid and
- places widgets in the cells we specify with row and column numbers. The
- diagram above shows the layout cells and the position of our widgets, and
- we specify this arrangement using the following code:
-
- \snippet tutorials/addressbook/part1/addressbook.cpp layout
-
- Notice that \c addressLabel is positioned using Qt::AlignTop as an
- additional argument. This is to make sure it is not vertically centered in
- cell (1,0). For a basic overview on Qt Layouts, refer to the
- \l{Layout Management} documentation.
-
- In order to install the layout object onto the widget, we have to invoke
- the widget's \l{QWidget::setLayout()}{setLayout()} function:
-
- \snippet tutorials/addressbook/part1/addressbook.cpp setting the layout
-
- Lastly, we set the widget's title to "Simple Address Book".
-
- \section1 Running the Application
-
- A separate file, \c main.cpp, is used for the \c main() function. Within
- this function, we instantiate a QApplication object, \c app. QApplication
- is responsible for various application-wide resources, such as the default
- font and cursor, and for running an event loop. Hence, there is always one
- QApplication object in every GUI application using Qt.
-
- \snippet tutorials/addressbook/part1/main.cpp main function
-
- We construct a new \c AddressBook widget on the stack and invoke
- its \l{QWidget::show()}{show()} function to display it.
- However, the widget will not be shown until the application's event loop
- is started. We start the event loop by calling the application's
- \l{QApplication::}{exec()} function; the result returned by this function
- is used as the return value from the \c main() function. At this point,
- it becomes apparent why we instantiated \c AddressBook on the stack: It
- will now go out of scope. Therefore, \c AddressBook and all its child widgets
- will be deleted, thus preventing memory leaks.
-*/
-
-/*!
- \example tutorials/addressbook/part2
- \title Part 2 - Adding Addresses
- \brief Describes the code for inserting records in the Address Book Example.
-
- The next step in creating the address book is to implement some
- user interactions.
-
- \image addressbook-tutorial-part2-add-contact.png
-
- We will provide a push button that the user can click to add a new contact.
- Also, some form of data structure is needed to store these contacts in an
- organized way.
-
- \section1 Defining the AddressBook Class
-
- Now that we have the labels and input fields set up, we add push buttons to
- complete the process of adding a contact. This means that our
- \c addressbook.h file now has three QPushButton objects declared and three
- corresponding public slots.
-
- \snippet tutorials/addressbook/part2/addressbook.h slots
-
- A slot is a function that responds to a particular signal. We will discuss
- this concept in further detail when implementing the \c AddressBook class.
- However, for an overview of Qt's signals and slots concept, you can refer
- to the \l{Signals and Slots} document.
-
- Three QPushButton objects (\c addButton, \c submitButton, and
- \c cancelButton) are now included in our private variable declarations,
- along with \c nameLine and \c addressText.
-
- \snippet tutorials/addressbook/part2/addressbook.h pushbutton declaration
-
- We need a container to store our address book contacts, so that we can
- traverse and display them. A QMap object, \c contacts, is used for this
- purpose as it holds a key-value pair: the contact's name as the \e key,
- and the contact's address as the \e{value}.
-
- \snippet tutorials/addressbook/part2/addressbook.h remaining private variables
-
- We also declare two private QString objects, \c oldName and \c oldAddress.
- These objects are needed to hold the name and address of the contact that
- was last displayed, before the user clicked \uicontrol Add. So, when the user clicks
- \uicontrol Cancel, we can revert to displaying the details of the last contact.
-
- \section1 Implementing the AddressBook Class
-
- Within the constructor of \c AddressBook, we set the \c nameLine and
- \c addressText to read-only, so that we can only display but not edit
- existing contact details.
-
- \dots
- \snippet tutorials/addressbook/part2/addressbook.cpp setting readonly 1
- \dots
- \snippet tutorials/addressbook/part2/addressbook.cpp setting readonly 2
-
- Then, we instantiate our push buttons: \c addButton, \c submitButton, and
- \c cancelButton.
-
- \snippet tutorials/addressbook/part2/addressbook.cpp pushbutton declaration
-
- The \c addButton is displayed by invoking the \l{QPushButton::show()}
- {show()} function, while the \c submitButton and \c cancelButton are
- hidden by invoking \l{QPushButton::hide()}{hide()}. These two push
- buttons will only be displayed when the user clicks \uicontrol Add and this is
- handled by the \c addContact() function discussed below.
-
- \snippet tutorials/addressbook/part2/addressbook.cpp connecting signals and slots
-
- We connect the push buttons' \l{QPushButton::clicked()}{clicked()} signal
- to their respective slots. The figure below illustrates this.
-
- \image addressbook-tutorial-part2-signals-and-slots.png
-
- Next, we arrange our push buttons neatly to the right of our address book
- widget, using a QVBoxLayout to line them up vertically.
-
- \snippet tutorials/addressbook/part2/addressbook.cpp vertical layout
-
- The \l{QBoxLayout::addStretch()}{addStretch()} function is used to ensure
- the push buttons are not evenly spaced, but arranged closer to the top of
- the widget. The figure below shows the difference between using
- \l{QBoxLayout::addStretch()}{addStretch()} and not using it.
-
- \image addressbook-tutorial-part2-stretch-effects.png
-
- We then add \c buttonLayout1 to \c mainLayout, using
- \l{QGridLayout::addLayout()}{addLayout()}. This gives us nested layouts
- as \c buttonLayout1 is now a child of \c mainLayout.
-
- \snippet tutorials/addressbook/part2/addressbook.cpp grid layout
-
- Our layout coordinates now look like this:
-
- \image addressbook-tutorial-part2-labeled-layout.png
-
- In the \c addContact() function, we store the last displayed contact
- details in \c oldName and \c oldAddress. Then we clear these input
- fields and turn off the read-only mode. The focus is set on \c nameLine
- and we display \c submitButton and \c cancelButton.
-
- \snippet tutorials/addressbook/part2/addressbook.cpp addContact
-
- The \c submitContact() function can be divided into three parts:
-
- \list 1
- \li We extract the contact's details from \c nameLine and \c addressText
- and store them in QString objects. We also validate to make sure that the
- user did not click \uicontrol Submit with empty input fields; otherwise, a
- QMessageBox is displayed to remind the user for a name and address.
-
- \snippet tutorials/addressbook/part2/addressbook.cpp submitContact part1
-
- \li We then proceed to check if the contact already exists. If it does not
- exist, we add the contact to \c contacts and we display a QMessageBox to
- inform the user that the contact has been added.
-
- \snippet tutorials/addressbook/part2/addressbook.cpp submitContact part2
-
- If the contact already exists, again, we display a QMessageBox to inform
- the user about this, preventing the user from adding duplicate contacts.
- Our \c contacts object is based on key-value pairs of name and address,
- hence, we want to ensure that \e key is unique.
-
- \li Once we have handled both cases mentioned above, we restore the push
- buttons to their normal state with the following code:
-
- \snippet tutorials/addressbook/part2/addressbook.cpp submitContact part3
-
- \endlist
-
- The screenshot below shows the QMessageBox object we use to display
- information messages to the user.
-
- \image addressbook-tutorial-part2-add-successful.png
-
- The \c cancel() function restores the last displayed contact details and
- enables \c addButton, as well as hides \c submitButton and
- \c cancelButton.
-
- \snippet tutorials/addressbook/part2/addressbook.cpp cancel
-
- The general idea behind adding a contact is to give the user the
- flexibility to click \uicontrol Submit or \uicontrol Cancel at any time. The flowchart below
- further explains this concept:
-
- \image addressbook-tutorial-part2-add-flowchart.png
-*/
-
-/*!
- \example tutorials/addressbook/part3
- \title Part 3 - Navigating between Entries
- \brief Explains the code that enables navigating the contacts.
-
- The address book is now about half complete. We should add the
- capability to navigate the contacts, but first we must
- decide what sort of a data structure we need for containing these
- contacts.
-
- In the previous section, we used a QMap of key-value pairs with
- the contact's name as the \e key, and the contact's address as the
- \e value. This works well for our case. However, in order to
- navigate and display each entry, a little bit of enhancement is
- needed.
-
- We enhance the QMap by making it replicate a data structure similar to a
- circularly-linked list, where all elements are connected, including the
- first element and the last element. The figure below illustrates this data
- structure.
-
- \image addressbook-tutorial-part3-linkedlist.png
-
- \section1 Defining the AddressBook Class
-
- To add navigation functions to the address book, we must add two
- more slots to the \c AddressBook class: \c next() and \c
- previous() to the \c addressbook.h file:
-
- \snippet tutorials/addressbook/part3/addressbook.h navigation functions
-
- We also require another two QPushButton objects, so we declare \c nextButton
- and \c previousButton as private variables:
-
- \snippet tutorials/addressbook/part3/addressbook.h navigation pushbuttons
-
- \section1 Implementing the AddressBook Class
-
- In the \c AddressBook constructor in \c addressbook.cpp, we instantiate
- \c nextButton and \c previousButton and disable them by default. This is
- because navigation is only enabled when there is more than one contact
- in the address book.
-
- \snippet tutorials/addressbook/part3/addressbook.cpp navigation pushbuttons
-
- We then connect these push buttons to their respective slots:
-
- \snippet tutorials/addressbook/part3/addressbook.cpp connecting navigation signals
-
- The image below is the expected graphical user interface.
-
- \image addressbook-tutorial-part3-screenshot.png
-
- We follow basic conventions for \c next() and \c previous() functions by
- placing the \c nextButton on the right and the \c previousButton on the
- left. In order to achieve this intuitive layout, we use QHBoxLayout to
- place the widgets side-by-side:
-
- \snippet tutorials/addressbook/part3/addressbook.cpp navigation layout
-
- The QHBoxLayout object, \c buttonLayout2, is then added to \c mainLayout.
-
- \snippet tutorials/addressbook/part3/addressbook.cpp adding navigation layout
-
- The figure below shows the coordinates of the widgets in \c mainLayout.
- \image addressbook-tutorial-part3-labeled-layout.png
-
- Within our \c addContact() function, we have to disable these buttons so
- that the user does not attempt to navigate while adding a contact.
-
- \snippet tutorials/addressbook/part3/addressbook.cpp disabling navigation
-
- Also, in our \c submitContact() function, we enable the navigation
- buttons, \c nextButton and \c previousButton, depending on the size
- of \c contacts. As mentioned earlier, navigation is only enabled when
- there is more than one contact in the address book. The following lines
- of code demonstrates how to do this:
-
- \snippet tutorials/addressbook/part3/addressbook.cpp enabling navigation
-
- We also include these lines of code in the \c cancel() function.
-
- Recall that we intend to emulate a circularly-linked list with our QMap
- object, \c contacts. So, in the \c next() function, we obtain an iterator
- for \c contacts and then:
-
- \list
- \li If the iterator is not at the end of \c contacts, we increment it
- by one.
- \li If the iterator is at the end of \c contacts, we move it to the
- beginning of \c contacts. This gives us the illusion that our QMap is
- working like a circularly-linked list.
- \endlist
-
- \snippet tutorials/addressbook/part3/addressbook.cpp next() function
-
- Once we have iterated to the correct object in \c contacts, we display
- its contents on \c nameLine and \c addressText.
-
- Similarly, for the \c previous() function, we obtain an iterator for
- \c contacts and then:
-
- \list
- \li If the iterator is at the end of \c contacts, we clear the
- display and return.
- \li If the iterator is at the beginning of \c contacts, we move it to
- the end.
- \li We then decrement the iterator by one.
- \endlist
-
- \snippet tutorials/addressbook/part3/addressbook.cpp previous() function
-
- Again, we display the contents of the current object in \c contacts.
-
-*/
-
-/*!
- \example tutorials/addressbook/part4
- \title Part 4 - Editing and Removing Addresses
- \brief Explains how to add edit and remove functionality.
-
- Now we look at ways to modify the contents of contacts stored in
- the address book.
-
- \image addressbook-tutorial-screenshot.png
-
- We now have an address book that not only holds contacts in an
- organized manner, but also allows navigation. It would be
- convenient to include edit and remove functions so that a
- contact's details can be changed when needed. However, this
- requires a little improvement, in the form of enums. We defined
- two modes: \c{AddingMode} and \c{NavigationMode}, but they were
- not defined as enum values. Instead, we enabled and disabled the
- corresponding buttons manually, resulting in multiple lines of
- repeated code.
-
- Here we define the \c Mode enum with three different values:
-
- \list
- \li \c{NavigationMode},
- \li \c{AddingMode}, and
- \li \c{EditingMode}.
- \endlist
-
- \section1 Defining the AddressBook Class
-
- The \c addressbook.h file is updated to contain the \c Mode enum:
-
- \snippet tutorials/addressbook/part4/addressbook.h Mode enum
-
- We also add two new slots, \c editContact() and \c removeContact(), to
- our current list of public slots.
-
- \snippet tutorials/addressbook/part4/addressbook.h edit and remove slots
-
- In order to switch between modes, we introduce the \c updateInterface() function
- to control the enabling and disabling of all QPushButton objects. We also
- add two new push buttons, \c editButton and \c removeButton, for the edit
- and remove functions mentioned earlier.
-
- \snippet tutorials/addressbook/part4/addressbook.h updateInterface() declaration
- \dots
- \snippet tutorials/addressbook/part4/addressbook.h buttons declaration
- \dots
- \snippet tutorials/addressbook/part4/addressbook.h mode declaration
-
- Lastly, we declare \c currentMode to keep track of the enum's current mode.
-
- \section1 Implementing the AddressBook Class
-
- We now implement the mode-changing features of the address
- book. The \c editButton and \c removeButton are instantiated and
- disabled by default. The address book starts with zero contacts
- in memory.
-
- \snippet tutorials/addressbook/part4/addressbook.cpp edit and remove buttons
-
- These buttons are then connected to their respective slots, \c editContact()
- and \c removeContact(), and we add them to \c buttonLayout1.
-
- \snippet tutorials/addressbook/part4/addressbook.cpp connecting edit and remove
- \dots
- \snippet tutorials/addressbook/part4/addressbook.cpp adding edit and remove to the layout
-
- The \c editContact() function stores the contact's old details in
- \c oldName and \c oldAddress, before switching the mode to \c EditingMode.
- In this mode, the \c submitButton and \c cancelButton are both enabled,
- hence, the user can change the contact's details and click either button.
-
- \snippet tutorials/addressbook/part4/addressbook.cpp editContact() function
-
- The \c submitContact() function has been divided in two with an \c{if-else}
- statement. We check \c currentMode to see if it's in \c AddingMode. If it is,
- we proceed with our adding process.
-
- \snippet tutorials/addressbook/part4/addressbook.cpp submitContact() function beginning
- \dots
- \snippet tutorials/addressbook/part4/addressbook.cpp submitContact() function part1
-
- Otherwise, we check to see if \c currentMode is in \c EditingMode. If it
- is, we compare \c oldName with \c name. If the name has changed, we remove
- the old contact from \c contacts and insert the newly updated contact.
-
- \snippet tutorials/addressbook/part4/addressbook.cpp submitContact() function part2
-
- If only the address has changed (i.e., \c oldAddress is not the same as \c address),
- we update the contact's address. Lastly, we set \c currentMode to
- \c NavigationMode. This is an important step as it re-enables all the
- disabled push buttons.
-
- To remove a contact from the address book, we implement the
- \c removeContact() function. This function checks to see if the contact
- exists in \c contacts.
-
- \snippet tutorials/addressbook/part4/addressbook.cpp removeContact() function
-
- If it does, we display a QMessageBox, to confirm the removal with the
- user. Once the user has confirmed, we call \c previous() to ensure that the
- user interface shows another contact, and we remove the contact using \l{QMap}'s
- \l{QMap::remove()}{remove()} function. As a courtesy, we display a QMessageBox
- to inform the user. Both the message boxes used in this function are shown below:
-
- \image addressbook-tutorial-part4-remove.png
-
- \section2 Updating the User Interface
-
- We mentioned the \c updateInterface() function earlier as a means to
- enable and disable the push buttons depending on the current mode.
- The function updates the current mode according to the \c mode argument
- passed to it, assigning it to \c currentMode before checking its value.
-
- Each of the push buttons is then enabled or disabled, depending on the
- current mode. The code for \c AddingMode and \c EditingMode is shown below:
-
- \snippet tutorials/addressbook/part4/addressbook.cpp update interface() part 1
-
- For \c NavigationMode, however, we include conditions within the parameters
- of the QPushButton::setEnabled() function. This is to ensure that
- \c editButton and \c removeButton are enabled when there is at least one
- contact in the address book; \c nextButton and \c previousButton are only
- enabled when there is more than one contact in the address book.
-
- \snippet tutorials/addressbook/part4/addressbook.cpp update interface() part 2
-
- By setting the mode and updating the user interface in the same
- function, we avoid the possibility of the user interface getting
- out of sync with the internal state of the application.
- */
-
-/*!
- \example tutorials/addressbook/part5
- \title Part 5 - Adding a Find Function
- \brief Describes how to add a find function.
-
- Here we look at ways to locate contacts and addresses in the
- address book.
-
- \image addressbook-tutorial-part5-screenshot.png
-
- As we add contacts to our address book, it becomes tedious to
- navigate the list with the \e Next and \e Previous buttons. A \e
- Find function would be more efficient. The screenshot above shows
- the \e Find button and its position on the panel of buttons.
-
- When the user clicks on the \e Find button, it is useful to
- display a dialog that prompts for a contact's name. Qt provides
- QDialog, which we subclass here to implement a \c FindDialog
- class.
-
- \section1 Defining the FindDialog Class
-
- \image addressbook-tutorial-part5-finddialog.png
-
- In order to subclass QDialog, we first include the header for QDialog in
- the \c finddialog.h file. Also, we use forward declaration to declare
- QLineEdit and QPushButton since we will be using those widgets in our
- dialog class.
-
- As in our \c AddressBook class, the \c FindDialog class includes
- the Q_OBJECT macro and its constructor is defined to accept a parent
- QWidget, even though the dialog will be opened as a separate window.
-
- \snippet tutorials/addressbook/part5/finddialog.h FindDialog header
-
- We define a public function, \c getFindText(), to be used by classes that
- instantiate \c FindDialog. This function allows these classes to obtain the
- search string entered by the user. A public slot, \c findClicked(), is also
- defined to handle the search string when the user clicks the \uicontrol Find
- button.
-
- Lastly, we define the private variables, \c findButton, \c lineEdit
- and \c findText, corresponding to the \uicontrol Find button, the line edit
- into which the user types the search string, and an internal string
- used to store the search string for later use.
-
- \section1 Implementing the FindDialog Class
-
- Within the constructor of \c FindDialog, we set up the private variables,
- \c lineEdit, \c findButton and \c findText. We use a QHBoxLayout to
- position the widgets.
-
- \snippet tutorials/addressbook/part5/finddialog.cpp constructor
-
- We set the layout and window title, as well as connect the signals to their
- respective slots. Notice that \c{findButton}'s \l{QPushButton::clicked()}
- {clicked()} signal is connected to \c findClicked() and
- \l{QDialog::accept()}{accept()}. The \l{QDialog::accept()}{accept()} slot
- provided by QDialog hides the dialog and sets the result code to
- \l{QDialog::}{Accepted}. We use this function to help \c{AddressBook}'s
- \c findContact() function know when the \c FindDialog object has been
- closed. We will explain this logic in further detail when discussing the
- \c findContact() function.
-
- \image addressbook-tutorial-part5-signals-and-slots.png
-
- In \c findClicked(), we validate \c lineEdit to ensure that the user
- did not click the \uicontrol Find button without entering a contact's name. Then, we set
- \c findText to the search string, extracted from \c lineEdit. After that,
- we clear the contents of \c lineEdit and hide the dialog.
-
- \snippet tutorials/addressbook/part5/finddialog.cpp findClicked() function
-
- The \c findText variable has a public getter function, \c getFindText(),
- associated with it. Since we only ever set \c findText directly in both the
- constructor and in the \c findClicked() function, we do not create a
- setter function to accompany \c getFindText().
- Because \c getFindText() is public, classes instantiating and using
- \c FindDialog can always access the search string that the user has
- entered and accepted.
-
- \snippet tutorials/addressbook/part5/finddialog.cpp getFindText() function
-
- \section1 Defining the AddressBook Class
-
- To ensure we can use \c FindDialog from within our \c AddressBook class, we
- include \c finddialog.h in the \c addressbook.h file.
-
- \snippet tutorials/addressbook/part5/addressbook.h include finddialog's header
-
- So far, all our address book features have a QPushButton and a
- corresponding slot. Similarly, for the \uicontrol Find feature we have
- \c findButton and \c findContact().
-
- The \c findButton is declared as a private variable and the
- \c findContact() function is declared as a public slot.
-
- \snippet tutorials/addressbook/part5/addressbook.h findContact() declaration
- \dots
- \snippet tutorials/addressbook/part5/addressbook.h findButton declaration
-
- Lastly, we declare the private variable, \c dialog, which we will use to
- refer to an instance of \c FindDialog.
-
- \snippet tutorials/addressbook/part5/addressbook.h FindDialog declaration
-
- Once we have instantiated a dialog, we will want to use it more than once;
- using a private variable allows us to refer to it from more than one place
- in the class.
-
- \section1 Implementing the AddressBook Class
-
- Within the \c AddressBook class's constructor, we instantiate our private
- objects, \c findButton and \c findDialog:
-
- \snippet tutorials/addressbook/part5/addressbook.cpp instantiating findButton
- \dots
- \snippet tutorials/addressbook/part5/addressbook.cpp instantiating FindDialog
-
- Next, we connect the \c{findButton}'s
- \l{QPushButton::clicked()}{clicked()} signal to \c findContact().
-
- \snippet tutorials/addressbook/part5/addressbook.cpp signals and slots for find
-
- Now all that is left is the code for our \c findContact() function:
-
- \snippet tutorials/addressbook/part5/addressbook.cpp findContact() function
-
- We start out by displaying the \c FindDialog instance, \c dialog. This is
- when the user enters a contact name to look up. Once the user clicks
- the dialog's \c findButton, the dialog is hidden and the result code is
- set to QDialog::Accepted. This ensures that
- our \c if statement is always true.
-
- We then proceed to extract the search string, which in this case is
- \c contactName, using \c{FindDialog}'s \c getFindText() function. If the
- contact exists in our address book, we display it immediately. Otherwise,
- we display the QMessageBox shown below to indicate that their search
- failed.
-
- \image addressbook-tutorial-part5-notfound.png
-*/
-
-/*!
- \example tutorials/addressbook/part6
- \title Part 6 - Loading and Saving
- \brief Describes how to add save and load functionality.
-
- This part covers the Qt file handling features we use to write
- loading and saving routines for the address book.
-
- \image addressbook-tutorial-part6-screenshot.png
-
- Although browsing and searching the contact list are useful
- features, our address book is not complete until we can save
- existing contacts and load them again at a later time.
-
- Qt provides a number of classes for \l{Input/Output and Networking}
- {input and output}, but we have chosen to use two which are simple to use
- in combination: QFile and QDataStream.
-
- A QFile object represents a file on disk that can be read from and written
- to. QFile is a subclass of the more general QIODevice class which
- represents many different kinds of devices.
-
- A QDataStream object is used to serialize binary data so that it can be
- stored in a QIODevice and retrieved again later. Reading from a QIODevice
- and writing to it is as simple as opening the stream - with the respective
- device as a parameter - and reading from or writing to it.
-
-
- \section1 Defining the AddressBook Class
-
- We declare two public slots, \c saveToFile() and \c loadFromFile(), as well
- as two QPushButton objects, \c loadButton and \c saveButton.
-
- \snippet tutorials/addressbook/part6/addressbook.h save and load functions declaration
- \dots
- \snippet tutorials/addressbook/part6/addressbook.h save and load buttons declaration
-
- \section1 Implementing the AddressBook Class
-
- In our constructor, we instantiate \c loadButton and \c saveButton.
- Ideally, it would be more user-friendly to set the push buttons' labels
- to "Load contacts from a file" and "Save contacts to a file". However, due
- to the size of our other push buttons, we set the labels to \uicontrol{Load...}
- and \uicontrol{Save...}. Fortunately, Qt provides a simple way to set tooltips with
- \l{QWidget::setToolTip()}{setToolTip()} and we use it in the following way
- for our push buttons:
-
- \snippet tutorials/addressbook/part6/addressbook.cpp tooltip 1
- \dots
- \snippet tutorials/addressbook/part6/addressbook.cpp tooltip 2
-
- Although it is not shown here, just like the other features we implemented,
- we add the push buttons to the layout panel on the right, \c buttonLayout1,
- and we connect the push buttons' \l{QPushButton::clicked()}{clicked()}
- signals to their respective slots.
-
- For the saving feature, we first obtain \c fileName using
- QFileDialog::getSaveFileName(). This is a convenience function provided
- by QFileDialog, which pops up a modal file dialog and allows the user to
- enter a file name or select any existing \c{.abk} file. The \c{.abk} file
- is our Address Book extension that we create when we save contacts.
-
- \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part1
-
- The file dialog that pops up is displayed in the screenshot below:
-
- \image addressbook-tutorial-part6-save.png
-
- If \c fileName is not empty, we create a QFile object, \c file, with
- \c fileName. QFile works with QDataStream as QFile is a QIODevice.
-
- Next, we attempt to open the file in \l{QIODeviceBase::}{WriteOnly} mode.
- If this is unsuccessful, we display a QMessageBox to inform the user.
-
- \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part2
-
- Otherwise, we instantiate a QDataStream object, \c out, to write the open
- file. QDataStream requires that the same version of the stream is used
- for reading and writing. We ensure that this is the case by setting the
- version used to the \l{QDataStream::Qt_4_5}{version introduced with Qt 4.5}
- before serializing the data to \c file.
-
- \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part3
-
- For the loading feature, we also obtain \c fileName using
- QFileDialog::getOpenFileName(). This function, the counterpart to
- QFileDialog::getSaveFileName(), also pops up the modal file dialog and
- allows the user to enter a file name or select any existing \c{.abk} file
- to load it into the address book.
-
- \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part1
-
- On Windows, for example, this function pops up a native file dialog, as
- shown in the following screenshot.
-
- \image addressbook-tutorial-part6-load.png
-
- If \c fileName is not empty, again, we use a QFile object, \c file, and
- attempt to open it in \l{QIODeviceBase::}{ReadOnly} mode. Similar to our
- implementation of \c saveToFile(), if this attempt is unsuccessful, we
- display a QMessageBox to inform the user.
-
- \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part2
-
- Otherwise, we instantiate a QDataStream object, \c in, set its version as
- above and read the serialized data into the \c contacts data structure.
- The \c contacts object is emptied before data is read into it to simplify
- the file reading process. A more advanced method would be to read the
- contacts into a temporary QMap object, and copy over non-duplicate contacts
- into \c contacts.
-
- \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part3
-
- To display the contacts that have been read from the file, we must first
- validate the data obtained to ensure that the file we read from actually
- contains address book contacts. If it does, we display the first contact;
- otherwise, we display a QMessageBox to inform the user about the problem.
- Lastly, we update the interface to enable and disable the push buttons
- accordingly.
-*/
-
-/*!
- \example tutorials/addressbook/part7
- \title Part 7 - Additional Features
- \brief Describes how to export data in VCard format.
-
- This part covers some additional features that make the address
- book more convenient for the frequent user.
-
- \image addressbook-tutorial-part7-screenshot.png
-
- Although our address book is useful in isolation, it would be
- better if we could exchange contact data with other applications.
- The vCard format is a popular file format that can be used for
- this purpose. Here we extend our address book client to allow
- contacts to be exported to vCard \c{.vcf} files.
-
- \section1 Defining the AddressBook Class
-
- We add a QPushButton object, \c exportButton, and a corresponding public
- slot, \c exportAsVCard() to our \c AddressBook class in the
- \c addressbook.h file.
-
- \snippet tutorials/addressbook/part7/addressbook.h exportAsVCard() declaration
- \dots
- \snippet tutorials/addressbook/part7/addressbook.h exportButton declaration
-
- \section1 Implementing the AddressBook Class
-
- Within the \c AddressBook constructor, we connect \c{exportButton}'s
- \l{QPushButton::clicked()}{clicked()} signal to \c exportAsVCard().
- We also add this button to our \c buttonLayout1, the layout responsible
- for our panel of buttons on the right.
-
- In our \c exportAsVCard() function, we start by extracting the contact's
- name into \c name. We declare \c firstName, \c lastName and \c nameList.
- Next, we look for the index of the first white space in \c name. If there
- is a white space, we split the contact's name into \c firstName and
- \c lastName. Then, we replace the space with an underscore ("_").
- Alternately, if there is no white space, we assume that the contact only
- has a first name.
-
- \snippet tutorials/addressbook/part7/addressbook.cpp export function part1
-
- As with the \c saveToFile() function, we open a file dialog to let the user
- choose a location for the file. Using the file name chosen, we create an
- instance of QFile to write to.
-
- We attempt to open the file in \l{QIODeviceBase::}{WriteOnly} mode. If this
- process fails, we display a QMessageBox to inform the user about the
- problem and return. Otherwise, we pass the file as a parameter to a
- QTextStream object, \c out. Like QDataStream, the QTextStream class
- provides functionality to read and write plain text to files. As a result,
- the \c{.vcf} file generated can be opened for editing in a text editor.
-
- \snippet tutorials/addressbook/part7/addressbook.cpp export function part2
-
- We then write out a vCard file with the \c{BEGIN:VCARD} tag, followed by
- the \c{VERSION:2.1} tag. The contact's name is written with the \c{N:}
- tag. For the \c{FN:} tag, which fills in the "File as" property of a vCard,
- we have to check whether the contact has a last name or not. If the contact
- does, we use the details in \c nameList to fill it. Otherwise, we write
- \c firstName only.
-
- \snippet tutorials/addressbook/part7/addressbook.cpp export function part3
-
- We proceed to write the contact's address. The semicolons in the address
- are escaped with "\\", the newlines are replaced with semicolons, and the
- commas are replaced with spaces. Lastly, we write the \c{ADR;HOME:;}
- tag, followed by \c address and then the \c{END:VCARD} tag.
-
- \snippet tutorials/addressbook/part7/addressbook.cpp export function part4
-
- In the end, a QMessageBox is displayed to inform the user that the vCard
- has been successfully exported.
-
- \e{vCard is a trademark of the \l{http://www.imc.org}
- {Internet Mail Consortium}}.
-*/
diff --git a/examples/widgets/doc/src/addressbook.qdoc b/examples/widgets/doc/src/addressbook.qdoc
index 34d269004b..8f2512298b 100644
--- a/examples/widgets/doc/src/addressbook.qdoc
+++ b/examples/widgets/doc/src/addressbook.qdoc
@@ -3,7 +3,8 @@
/*!
\example itemviews/addressbook
- \title Address Book Example
+ \title Address Book
+ \examplecategory {User Interface Components}
\ingroup examples-itemviews
\brief The address book example shows how to use proxy models to display
different views onto data from a single model.
@@ -24,7 +25,7 @@
\c AddDialog. The \c MainWindow class uses \c AddressWidget as
its central widget and provides \uicontrol File and \uicontrol Tools menus.
- \image addressbook-classes.png Diagram for Address Book Example
+ \image addressbook-classes.png Diagram for Address Book example
The \c AddressWidget class is a QTabWidget subclass that is used
to manipulate the 10 tabs displayed in the example: the 9
@@ -381,17 +382,15 @@
respective slots, we also connect \c AddressWidget's
\c selectionChanged() signal to its \c updateActions() slot.
- The \c openFile() function allows the user to choose a file with
- the \l{QFileDialog::getOpenFileName()}{open file dialog}. The chosen
- file has to be a custom \c{.dat} file that contains address book
- contacts. This function is a slot connected to \c openAct in the
- \uicontrol File menu.
+ The \c openFile() function opens a custom \c{addressbook.dat} file that
+ contains address book contacts. This function is a slot connected to
+ \c openAct in the \uicontrol File menu.
\snippet itemviews/addressbook/mainwindow.cpp 2
- The \c saveFile() function allows the user to save a file with
- the \l{QFileDialog::getSaveFileName()}{save file dialog}. This function
- is a slot connected to \c saveAct in the \uicontrol File menu.
+ The \c saveFile() function saves a custom \c{addressbook.dat} file that
+ will contain the address book contacts. This function is a slot connected
+ to \c saveAct in the \uicontrol File menu.
\snippet itemviews/addressbook/mainwindow.cpp 3
diff --git a/examples/widgets/doc/src/affine.qdoc b/examples/widgets/doc/src/affine.qdoc
index accbf9adfa..2ec3a4fc4d 100644
--- a/examples/widgets/doc/src/affine.qdoc
+++ b/examples/widgets/doc/src/affine.qdoc
@@ -4,8 +4,9 @@
/*!
\example painting/affine
\title Affine Transformations
+ \examplecategory {Graphics}
\ingroup examples-painting
- \brief Demonstrates how affine transformations in QPainter works.
+ \brief Demonstrates how affine transformations in QPainter work.
\brief In this example we show Qt's ability to perform affine transformations
on painting operations.
diff --git a/examples/widgets/doc/src/analogclock.qdoc b/examples/widgets/doc/src/analogclock.qdoc
index 09309853b1..8f98f4b7b0 100644
--- a/examples/widgets/doc/src/analogclock.qdoc
+++ b/examples/widgets/doc/src/analogclock.qdoc
@@ -3,7 +3,10 @@
/*!
\example widgets/analogclock
- \title Analog Clock Example
+ \examplecategory {Graphics}
+ \meta tags {widgets}
+
+ \title Analog Clock
\ingroup examples-widgets
\brief The Analog Clock example shows how to draw the contents of a
custom widget.
@@ -17,8 +20,8 @@
\section1 AnalogClock Class Definition
- The \c AnalogClock class provides a clock widget with hour and minute
- hands that is automatically updated every few seconds.
+ The \c AnalogClock class provides a clock widget with hour, minute and
+ second hands that is automatically updated every second.
We subclass \l QWidget and reimplement the standard
\l{QWidget::paintEvent()}{paintEvent()} function to draw the clock face:
@@ -26,19 +29,14 @@
\section1 AnalogClock Class Implementation
- \snippet widgets/analogclock/analogclock.cpp 1
-
When the widget is constructed, we set up a one-second timer to
keep track of the current time, and we connect it to the standard
\l{QWidget::update()}{update()} slot so that the clock face is
updated when the timer emits the \l{QTimer::timeout()}{timeout()}
- signal.
-
- Finally, we resize the widget so that it is displayed at a
+ signal. Finally, we resize the widget so that it is displayed at a
reasonable size.
- \snippet widgets/analogclock/analogclock.cpp 8
- \snippet widgets/analogclock/analogclock.cpp 10
+ \snippet widgets/analogclock/analogclock.cpp 1
The \c paintEvent() function is called whenever the widget's
contents need to be updated. This happens when the widget is
@@ -46,31 +44,37 @@
executed when the widget's \l{QWidget::update()}{update()} slot
is called. Since we connected the timer's
\l{QTimer::timeout()}{timeout()} signal to this slot, it will be
- called at least once every five seconds.
+ called at least once per second.
Before we set up the painter and draw the clock, we first define
- two lists of \l {QPoint}s and two \l{QColor}s that will be used
- for the hour and minute hands. The minute hand's color has an
- alpha component of 191, meaning that it's 75% opaque.
+ three lists of \l {QPoint}s and three \l{QColor}s that will be used
+ for the hour, minute and second hands. We use the
+ \l{QWidget::palette()}{palette()} function to get appropriate colors
+ that fit into the rest of the window, both in light and dark mode.
+ The hour and minute hands are drawn in the foreground color, the
+ second hand is drawn in the accent color.
We also determine the length of the widget's shortest side so that we
can fit the clock face inside the widget. It is also useful to determine
the current time before we start drawing.
- \snippet widgets/analogclock/analogclock.cpp 11
- \snippet widgets/analogclock/analogclock.cpp 12
- \snippet widgets/analogclock/analogclock.cpp 13
- \snippet widgets/analogclock/analogclock.cpp 14
+ \snippet widgets/analogclock/analogclock.cpp 8
+ \snippet widgets/analogclock/analogclock.cpp 10
The contents of custom widgets are drawn with a QPainter.
Painters can be used to draw on any QPaintDevice, but they are
usually used with widgets, so we pass the widget instance to the
painter's constructor.
+ \snippet widgets/analogclock/analogclock.cpp 11
+ \snippet widgets/analogclock/analogclock.cpp 14
+
We call QPainter::setRenderHint() with QPainter::Antialiasing to
turn on antialiasing. This makes drawing of diagonal lines much
smoother.
+ \snippet widgets/analogclock/analogclock.cpp 12
+
The translation moves the origin to the center of the widget, and
the scale operation ensures that the following drawing operations
are scaled to fit within the widget. We use a scale factor that
@@ -78,6 +82,8 @@
ensures that these lie within the length of the widget's shortest
side.
+ \snippet widgets/analogclock/analogclock.cpp 13
+
To make our code simpler, we will draw a fixed size clock face that will
be positioned and scaled so that it lies in the center of the widget.
@@ -88,44 +94,47 @@
\image analogclock-viewport.png
- We draw the hour hand first, using a formula that rotates the coordinate
- system counterclockwise by a number of degrees determined by the current
- hour and minute. This means that the hand will be shown rotated clockwise
- by the required amount.
-
- \snippet widgets/analogclock/analogclock.cpp 15
- \snippet widgets/analogclock/analogclock.cpp 16
-
We set the pen to be Qt::NoPen because we don't want any outline,
and we use a solid brush with the color appropriate for
displaying hours. Brushes are used when filling in polygons and
other geometric shapes.
- \snippet widgets/analogclock/analogclock.cpp 17
- \snippet widgets/analogclock/analogclock.cpp 19
+ \snippet widgets/analogclock/analogclock.cpp 15
+ \snippet widgets/analogclock/analogclock.cpp 16
+ We draw the hour hand first, using a formula that rotates the coordinate
+ system counterclockwise by a number of degrees determined by the current
+ hour and minute. This means that the hand will be shown rotated clockwise
+ by the required amount.
We save and restore the transformation matrix before and after the
rotation because we want to place the minute hand without having to
take into account any previous rotations.
+ \snippet widgets/analogclock/analogclock.cpp 17
+ \snippet widgets/analogclock/analogclock.cpp 19
+
+ We draw markers around the edge of the clock for each hour in the same
+ color as the hour hand. We draw each marker then rotate the coordinate
+ system so that the painter is ready for the next one.
+
\snippet widgets/analogclock/analogclock.cpp 20
- \codeline
+
+ The minute hand is rotated and painted in a similar way to the hour hand.
+
\snippet widgets/analogclock/analogclock.cpp 21
- We draw markers around the edge of the clock for each hour. We
- draw each marker then rotate the coordinate system so that the
- painter is ready for the next one.
+ For the seconds hand we do the same and add two cicles as a visual highlight.
- \snippet widgets/analogclock/analogclock.cpp 22
\snippet widgets/analogclock/analogclock.cpp 23
+ \codeline
+ \snippet widgets/analogclock/analogclock.cpp 24
- The minute hand is rotated in a similar way to the hour hand.
+ Finally, we draw markers around the edge of the clock, indicating
+ minutes and seconds. This time we draw them as lines and therefore
+ set the pen to the respective color.
\snippet widgets/analogclock/analogclock.cpp 25
\codeline
- \snippet widgets/analogclock/analogclock.cpp 26
+ \snippet widgets/analogclock/analogclock.cpp 27
- Again, we draw markers around the edge of the clock, but this
- time to indicate minutes. We skip multiples of 5 to avoid drawing
- minute markers on top of hour markers.
*/
diff --git a/examples/widgets/doc/src/application.qdoc b/examples/widgets/doc/src/application.qdoc
deleted file mode 100644
index 0c6839bf4a..0000000000
--- a/examples/widgets/doc/src/application.qdoc
+++ /dev/null
@@ -1,371 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example mainwindows/application
- \title Qt Widgets - Application Example
- \ingroup examples-mainwindow
-
- \brief The Application example shows how to implement a standard
- widget application with menus, toolbars, and a status bar. The example
- itself is a simple text editor program built around QPlainTextEdit.
-
- \image application.png Screenshot of the Application example
-
- Nearly all of the code for the Application example is in the \c
- MainWindow class, which inherits QMainWindow. QMainWindow
- provides the framework for windows that have menus, toolbars,
- dock windows, and a status bar. The application provides
- \uicontrol{File}, \uicontrol{Edit}, and \uicontrol{Help} entries in the menu
- bar, with the following popup menus:
-
- \image application-menus.png The Application example's menu system
-
- The status bar at the bottom of the main window shows a
- description of the menu item or toolbar button under the cursor.
-
- To keep the example simple, recently opened files aren't shown in
- the \uicontrol{File} menu, even though this feature is desired in 90%
- of applications. Furthermore, this example can only load one file at a
- time. The \l{mainwindows/sdi}{SDI} and \l{mainwindows/mdi}{MDI} examples
- show how to lift these restrictions and how to implement recently opened files
- handling.
-
- \section1 MainWindow Class Definition
-
- Here's the class definition:
-
- \snippet mainwindows/application/mainwindow.h 0
-
- The public API is restricted to the constructor. In the \c
- protected section, we reimplement QWidget::closeEvent() to detect
- when the user attempts to close the window, and warn the user
- about unsaved changes. In the \c{private slots} section, we
- declare slots that correspond to menu entries, as well as a
- mysterious \c documentWasModified() slot. Finally, in the \c
- private section of the class, we have various members that will
- be explained in due time.
-
- \section1 MainWindow Class Implementation
-
- \snippet mainwindows/application/mainwindow.cpp 0
-
- We start by including \c <QtWidgets>, a header file that contains the
- definition of all classes in the Qt Core, Qt GUI and Qt Widgets
- modules. This saves us from the trouble of having to include
- every class individually. We also include \c mainwindow.h.
-
- You might wonder why we don't include \c <QtWidgets> in \c
- mainwindow.h and be done with it. The reason is that including
- such a large header from another header file can rapidly degrade
- performances. Here, it wouldn't do any harm, but it's still
- generally a good idea to include only the header files that are
- strictly necessary from another header file.
-
- \snippet mainwindows/application/mainwindow.cpp 1
- \snippet mainwindows/application/mainwindow.cpp 2
-
- In the constructor, we start by creating a QPlainTextEdit widget as a
- child of the main window (the \c this object). Then we call
- QMainWindow::setCentralWidget() to tell that this is going to be
- the widget that occupies the central area of the main window,
- between the toolbars and the status bar.
-
- Then we call \c createActions() and \c createStatusBar(), two private
- functions that set up the user interface. After that, we call \c
- readSettings() to restore the user's preferences.
-
- We establish a signal-slot connection between the QPlainTextEdit's
- document object and our \c documentWasModified() slot. Whenever
- the user modifies the text in the QPlainTextEdit, we want to update
- the title bar to show that the file was modified.
-
- At the end, we set the window title using the private
- \c setCurrentFile() function. We'll come back to this later.
-
- \target close event handler
- \snippet mainwindows/application/mainwindow.cpp 3
- \snippet mainwindows/application/mainwindow.cpp 4
-
- When the user attempts to close the window, we call the private
- function \c maybeSave() to give the user the possibility to save
- pending changes. The function returns true if the user wants the
- application to close; otherwise, it returns false. In the first
- case, we save the user's preferences to disk and accept the close
- event; in the second case, we ignore the close event, meaning
- that the application will stay up and running as if nothing
- happened.
-
- \snippet mainwindows/application/mainwindow.cpp 5
- \snippet mainwindows/application/mainwindow.cpp 6
-
- The \c newFile() slot is invoked when the user selects
- \uicontrol{File|New} from the menu. We call \c maybeSave() to save any
- pending changes and if the user accepts to go on, we clear the
- QPlainTextEdit and call the private function \c setCurrentFile() to
- update the window title and clear the
- \l{QWidget::windowModified}{windowModified} flag.
-
- \snippet mainwindows/application/mainwindow.cpp 7
- \snippet mainwindows/application/mainwindow.cpp 8
-
- The \c open() slot is invoked when the user clicks
- \uicontrol{File|Open}. We pop up a QFileDialog asking the user to
- choose a file. If the user chooses a file (i.e., \c fileName is
- not an empty string), we call the private function \c loadFile()
- to actually load the file.
-
- \snippet mainwindows/application/mainwindow.cpp 9
- \snippet mainwindows/application/mainwindow.cpp 10
-
- The \c save() slot is invoked when the user clicks
- \uicontrol{File|Save}. If the user hasn't provided a name for the file
- yet, we call \c saveAs(); otherwise, we call the private function
- \c saveFile() to actually save the file.
-
- \snippet mainwindows/application/mainwindow.cpp 11
- \snippet mainwindows/application/mainwindow.cpp 12
-
- In \c saveAs(), we start by popping up a QFileDialog asking the
- user to provide a name. If the user clicks \uicontrol{Cancel}, the
- returned file name is empty, and we do nothing.
-
- \snippet mainwindows/application/mainwindow.cpp 13
- \snippet mainwindows/application/mainwindow.cpp 14
-
- The application's About box is done using one statement, using
- the QMessageBox::about() static function and relying on its
- support for an HTML subset.
-
- The \l{QObject::tr()}{tr()} call around the literal string marks
- the string for translation. It is a good habit to call
- \l{QObject::tr()}{tr()} on all user-visible strings, in case you
- later decide to translate your application to other languages.
- The \l{Internationalization with Qt} overview covers
- \l{QObject::tr()}{tr()} in more detail.
-
- \snippet mainwindows/application/mainwindow.cpp 15
- \snippet mainwindows/application/mainwindow.cpp 16
-
- The \c documentWasModified() slot is invoked each time the text
- in the QPlainTextEdit changes because of user edits. We call
- QWidget::setWindowModified() to make the title bar show that the
- file was modified. How this is done varies on each platform.
-
- \snippet mainwindows/application/mainwindow.cpp 17
- \snippet mainwindows/application/mainwindow.cpp 18
- \dots
- \snippet mainwindows/application/mainwindow.cpp 22
-
- The \c createActions() private function, which is called from the
- \c MainWindow constructor, creates \l{QAction}s and populates
- the menus and two toolbars. The code is very
- repetitive, so we show only the actions corresponding to
- \uicontrol{File|New}, \uicontrol{File|Open}, and \uicontrol{Help|About Qt}.
-
- A QAction is an object that represents one user action, such as
- saving a file or invoking a dialog. An action can be put in a
- QMenu or a QToolBar, or both, or in any other widget that
- reimplements QWidget::actionEvent().
-
- An action has a text that is shown in the menu, an icon, a
- shortcut key, a tooltip, a status tip (shown in the status bar),
- a "What's This?" text, and more. It emits a
- \l{QAction::triggered()}{triggered()} signal whenever the user
- invokes the action (e.g., by clicking the associated menu item or
- toolbar button).
-
- Instances of QAction can be created by passing a parent QObject or
- by using one of the convenience functions of QMenu, QMenuBar or QToolBar.
- We create the actions that are in a menu as well as in a toolbar
- parented on the window to prevent ownership issues. For actions
- that are only in the menu, we use the convenience function
- QMenu::addAction(), which allows us to pass text, icon and the
- target object and its slot member function.
-
- Creating toolbars is very similar to creating menus. The same
- actions that we put in the menus can be reused in the toolbars.
- After creating the action, we add it to the toolbar using
- QToolBar::addAction().
-
- The code above contains one more idiom that must be explained.
- For some of the actions, we specify an icon as a QIcon to the
- QAction constructor. We use QIcon::fromTheme() to obtain
- the correct standard icon from the underlying window system.
- If that fails due to the platform not supporting it, we
- pass a file name as fallback. Here, the file name starts
- with \c{:}. Such file names aren't ordinary file names, but
- rather path in the executable's stored resources. We'll come back
- to this when we review the \c application.qrc file that's part of
- the project.
-
- \snippet mainwindows/application/mainwindow.cpp 23
- \snippet mainwindows/application/mainwindow.cpp 24
-
- The \uicontrol{Edit|Cut} and \uicontrol{Edit|Copy} actions must be available
- only when the QPlainTextEdit contains selected text. We disable them
- by default and connect the QPlainTextEdit::copyAvailable() signal to
- the QAction::setEnabled() slot, ensuring that the actions are
- disabled when the text editor has no selection.
-
- Just before we create the \uicontrol{Help} menu, we call
- QMenuBar::addSeparator(). This has no effect for most widget
- styles (e.g., Windows and \macos styles), but for some
- styles this makes sure that \uicontrol{Help} is pushed to the right
- side of the menu bar.
-
- \snippet mainwindows/application/mainwindow.cpp 32
- \snippet mainwindows/application/mainwindow.cpp 33
-
- QMainWindow::statusBar() returns a pointer to the main window's
- QStatusBar widget. Like with \l{QMainWindow::menuBar()}, the
- widget is automatically created the first time the function is
- called.
-
- \snippet mainwindows/application/mainwindow.cpp 34
- \snippet mainwindows/application/mainwindow.cpp 36
-
- The \c readSettings() function is called from the constructor to
- load the user's preferences and other application settings. The
- QSettings class provides a high-level interface for storing
- settings permanently on disk. On Windows, it uses the (in)famous
- Windows registry; on \macos, it uses the native XML-based
- CFPreferences API; on Unix/X11, it uses text files.
-
- The QSettings constructor takes arguments that identify your
- company and the name of the product. This ensures that the
- settings for different applications are kept separately.
-
- We use QSettings::value() to extract the value of the geometry setting.
- The second argument to QSettings::value() is
- optional and specifies a default value for the setting if there
- exists none. This value is used the first time the application is
- run.
-
- We use QWidget::saveGeometry() and Widget::restoreGeometry() to
- save the position. They use an opaque QByteArray to store
- screen number, geometry and window state.
-
- \snippet mainwindows/application/mainwindow.cpp 37
- \snippet mainwindows/application/mainwindow.cpp 39
-
- The \c writeSettings() function is called from \c closeEvent().
- Writing settings is similar to reading them, except simpler. The
- arguments to the QSettings constructor must be the same as in \c
- readSettings().
-
- \snippet mainwindows/application/mainwindow.cpp 40
- \snippet mainwindows/application/mainwindow.cpp 41
-
- The \c maybeSave() function is called to save pending changes. If
- there are pending changes, it pops up a QMessageBox giving the
- user to save the document. The options are QMessageBox::Yes,
- QMessageBox::No, and QMessageBox::Cancel. The \uicontrol{Yes} button is
- made the default button (the button that is invoked when the user
- presses \uicontrol{Return}) using the QMessageBox::Default flag; the
- \uicontrol{Cancel} button is made the escape button (the button that is
- invoked when the user presses \uicontrol{Esc}) using the
- QMessageBox::Escape flag.
-
- The \c maybeSave() function returns \c true in all cases, except
- when the user clicks \uicontrol{Cancel} or saving the file fails.
- The caller must check the return value and stop whatever it was
- doing if the return value is \c false.
-
- \snippet mainwindows/application/mainwindow.cpp 42
- \snippet mainwindows/application/mainwindow.cpp 43
-
- In \c loadFile(), we use QFile and QTextStream to read in the
- data. The QFile object provides access to the bytes stored in a
- file.
-
- We start by opening the file in read-only mode. The QFile::Text
- flag indicates that the file is a text file, not a binary file.
- On Unix and \macos, this makes no difference, but on Windows,
- it ensures that the "\\r\\n" end-of-line sequence is converted to
- "\\n" when reading.
-
- If we successfully opened the file, we use a QTextStream object
- to read in the data. QTextStream automatically converts the 8-bit
- data into a Unicode QString and supports various encodings. If no
- encoding is specified, QTextStream assumes the file is encoded in
- UTF-8.
-
- Since the call to QTextStream::readAll() might take some time, we
- set the cursor to be Qt::WaitCursor for the entire application
- while it goes on.
-
- At the end, we call the private \c setCurrentFile() function,
- which we'll cover in a moment, and we display the string "File
- loaded" in the status bar for 2 seconds (2000 milliseconds).
-
- \snippet mainwindows/application/mainwindow.cpp 44
- \snippet mainwindows/application/mainwindow.cpp 45
-
- Saving a file is similar to loading one. We use QSaveFile to ensure
- all data are safely written and existing files are not damaged
- should writing fail.
- We use the QFile::Text flag to make sure that on Windows, "\\n"
- is converted into "\\r\\n" to conform to the Windows convention.
-
-
- \snippet mainwindows/application/mainwindow.cpp 46
- \snippet mainwindows/application/mainwindow.cpp 47
-
- The \c setCurrentFile() function is called to reset the state of
- a few variables when a file is loaded or saved, or when the user
- starts editing a new file (in which case \c fileName is empty).
- We update the \c curFile variable, clear the
- QTextDocument::modified flag and the associated \c
- QWidget:windowModified flag, and update the window title to
- contain the new file name (or \c untitled.txt).
-
- The \c strippedName() function call around \c curFile in the
- QWidget::setWindowTitle() call shortens the file name to exclude
- the path. Here's the function:
-
- \snippet mainwindows/application/mainwindow.cpp 48
- \snippet mainwindows/application/mainwindow.cpp 49
-
- \section1 The main() Function
-
- The \c main() function for this application is typical of
- applications that contain one main window:
-
- \snippet mainwindows/application/main.cpp 0
-
- The main function uses QCommandLineParser to check whether some file
- argument was passed to the application and loads it via
- MainWindow::loadFile().
-
- \section1 The Resource File
-
- As you will probably recall, for some of the actions, we
- specified icons with file names starting with \c{:} and mentioned
- that such file names aren't ordinary file names, but path in the
- executable's stored resources. These resources are compiled
-
- The resources associated with an application are specified in a
- \c .qrc file, an XML-based file format that lists files on the
- disk. Here's the \c application.qrc file that's used by the
- Application example:
-
- \quotefile mainwindows/application/application.qrc
-
- The \c .png files listed in the \c application.qrc file are files
- that are part of the Application example's source tree. Paths are
- relative to the directory where the \c application.qrc file is
- located (the \c mainwindows/application directory).
-
- The resource file must be mentioned in the \c application.pro
- file so that \c qmake knows about it:
-
- \snippet mainwindows/application/application.pro 0
-
- \c qmake will produce make rules to generate a file called \c
- qrc_application.cpp that is linked into the application. This
- file contains all the data for the images and other resources as
- static C++ arrays of compressed binary data. See
- \l{resources.html}{The Qt Resource System} for more information
- about resources.
-*/
diff --git a/examples/widgets/doc/src/basicdrawing.qdoc b/examples/widgets/doc/src/basicdrawing.qdoc
index 7413dfc823..0882c0f32f 100644
--- a/examples/widgets/doc/src/basicdrawing.qdoc
+++ b/examples/widgets/doc/src/basicdrawing.qdoc
@@ -4,6 +4,7 @@
/*!
\example painting/basicdrawing
\title Basic Drawing Example
+ \examplecategory {Graphics}
\ingroup examples-painting
\brief The Basic Drawing example shows how to display basic
graphics primitives in a variety of styles using the QPainter
diff --git a/examples/widgets/doc/src/basicgraphicslayouts.qdoc b/examples/widgets/doc/src/basicgraphicslayouts.qdoc
index ce7176bf7f..1add587464 100644
--- a/examples/widgets/doc/src/basicgraphicslayouts.qdoc
+++ b/examples/widgets/doc/src/basicgraphicslayouts.qdoc
@@ -4,6 +4,7 @@
/*!
\example graphicsview/basicgraphicslayouts
\title Basic Graphics Layouts Example
+ \examplecategory {Graphics}
\ingroup examples-graphicsview-layout
\brief Demonstrates how to create basic graphics layout.
diff --git a/examples/widgets/doc/src/basiclayouts.qdoc b/examples/widgets/doc/src/basiclayouts.qdoc
index c55514689d..e6f1cab4d9 100644
--- a/examples/widgets/doc/src/basiclayouts.qdoc
+++ b/examples/widgets/doc/src/basiclayouts.qdoc
@@ -4,6 +4,7 @@
/*!
\example layouts/basiclayouts
\title Basic Layouts Example
+ \examplecategory {User Interface Components}
\brief Shows how to use the standard layout managers.
\e{Basic Layouts} shows how to use the standard layout managers that are
diff --git a/examples/widgets/doc/src/basicsortfiltermodel.qdoc b/examples/widgets/doc/src/basicsortfiltermodel.qdoc
index 969ee0a9d5..c0b8a5f426 100644
--- a/examples/widgets/doc/src/basicsortfiltermodel.qdoc
+++ b/examples/widgets/doc/src/basicsortfiltermodel.qdoc
@@ -4,6 +4,7 @@
/*!
\example itemviews/basicsortfiltermodel
\title Basic Sort/Filter Model Example
+ \examplecategory {User Interface Components}
\ingroup examples-itemviews
\brief The Basic Sort/Filter Model example illustrates how to use
QSortFilterProxyModel to perform basic sorting and filtering.
diff --git a/examples/widgets/doc/src/blurpicker.qdoc b/examples/widgets/doc/src/blurpicker.qdoc
deleted file mode 100644
index 8c9458e51a..0000000000
--- a/examples/widgets/doc/src/blurpicker.qdoc
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example effects/blurpicker
- \title Blur Picker Effect Example
- \ingroup examples-graphicsview-graphicseffects
- \brief Demonstrates how to apply graphical effects on items in the view.
-
- \image blurpickereffect-example.png
-
- The Blur Picker example displays a circle of application icons.
- All icons are blurred, except the one on the bottom left side of
- the screen, which is the one in focus.
- Clicking anywhere on the left side of the screen moves the icon
- circle clockwise to the next icon
- Clicking on the right side advances the circle counterclockwise.
-
- \sa QGraphicsBlurEffect
-*/
diff --git a/examples/widgets/doc/src/borderlayout.qdoc b/examples/widgets/doc/src/borderlayout.qdoc
deleted file mode 100644
index 9ec5e96d78..0000000000
--- a/examples/widgets/doc/src/borderlayout.qdoc
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example layouts/borderlayout
- \title Border Layout Example
- \ingroup examples-layout
- \brief Shows how to arrange child widgets along a border.
-
- \e{Border Layout} implements a layout that arranges child widgets to
- surround the main area.
-
- \image borderlayout-example.png
-
- The constructor of the Window class creates a QTextBrowser object,
- to which a BorderLayout named \c layout is added. The declaration
- of the BorderLayout class is quoted at the end of this document.
-
- \quotefromfile layouts/borderlayout/window.cpp
- \skipto Window::Window()
- \printuntil BorderLayout
-
- Several labeled widgets are added to \c layout with the orientation
- \c {Center}, \c {North}, \c {West}, \c {East 1}, \c {East 2}, and
- \c {South}.
-
- \skipto layout->addWidget
- \printuntil setWindowTitle
-
- createLabel() in class \c Window sets the text of the labeled widgets
- and the style.
-
- \skipto QLabel *Window::createLabel
- \printuntil /^\}/
-
- Class BorderLayout contains all the utilitarian functions for formatting
- the widgets it contains.
-
- \quotefromfile layouts/borderlayout/borderlayout.h
- \skipto class
- \printuntil /^\}/
-
- For more information, visit the \l{Layout Management} page.
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/widgets/doc/src/calculator.qdoc b/examples/widgets/doc/src/calculator.qdoc
index cc015e46a0..c59d3cd161 100644
--- a/examples/widgets/doc/src/calculator.qdoc
+++ b/examples/widgets/doc/src/calculator.qdoc
@@ -4,6 +4,7 @@
/*!
\example widgets/calculator
\title Calculator Example
+ \examplecategory {User Interface Components}
\ingroup examples-widgets
\ingroup examples-layout
\brief The example shows how to use signals and slots to implement the
diff --git a/examples/widgets/doc/src/calendar.qdoc b/examples/widgets/doc/src/calendar.qdoc
deleted file mode 100644
index 218ea5ea0c..0000000000
--- a/examples/widgets/doc/src/calendar.qdoc
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example richtext/calendar
- \title Calendar Example
- \ingroup examples-richtext
- \brief The Calendar example shows how to create rich text content
- and display it using a rich text editor.
-
- \brief The Calendar example shows how to create rich text content and display it using
- a rich text editor.
-
- \image calendar-example.png
-
- Specifically, the example demonstrates the following:
-
- \list
- \li Use of a text editor with a text document
- \li Insertion of tables and frames into a document
- \li Navigation within a table
- \li Insert text in different styles
- \endlist
-
- The rich text editor used to display the document is used within a main window
- application.
-
- \section1 MainWindow Class Definition
-
- The \c MainWindow class provides a text editor widget and some controls to
- allow the user to change the month and year shown. The font size used for the
- text can also be adjusted.
-
- \snippet richtext/calendar/mainwindow.h 0
-
- The private \c insertCalendar() function performs most of the work, relying on
- the \c fontSize and \c selectedDate variables to write useful information to
- the \c editor.
-
- \section1 MainWindow Class Implementation
-
- The \c MainWindow constructor sets up the user interface and initializes
- variables used to generate a calendar for each month.
-
- \snippet richtext/calendar/mainwindow.cpp 0
-
- We begin by setting default values for the selected date that will be highlighted
- in the calendar and the font size to be used. Since we are using a QMainWindow
- for the user interface, we construct a widget for use as the central widget.
-
- The user interface will include a line of controls above the generated calendar;
- we construct a label and a combobox to allow the month to be selected, and a
- spin box for the year. These widgets are configured to provide a reasonable range
- of values for the user to try:
-
- \snippet richtext/calendar/mainwindow.cpp 1
-
- We use the \c selectedDate object to obtain the current month and year, and we
- set these in the combobox and spin box:
-
- The font size is displayed in a spin box which we restrict to a sensible range
- of values:
-
- \snippet richtext/calendar/mainwindow.cpp 2
-
- We construct an editor and use the \c insertCalendar() function to create
- a calendar for it. Each calendar is displayed in the same text editor; in
- this example we use a QTextBrowser since we do not allow the calendar to be
- edited.
-
- The controls used to set the month, year, and font size will not have any
- effect on the appearance of the calendar unless we make some signal-slot
- connections:
-
- \snippet richtext/calendar/mainwindow.cpp 3
-
- The signals are connected to some simple slots in the \c MainWindow class
- which we will describe later.
-
- We create layouts to manage the widgets we constructed:
-
- \snippet richtext/calendar/mainwindow.cpp 4
-
- Finally, the central widget is set for the window.
-
- Each calendar is created for the editor by the \c insertCalendar() function
- which uses the date and font size, defined by the private \a selectedDate
- and \c fontSize variables, to produce a suitable plan for the specified
- month and year.
-
- \snippet richtext/calendar/mainwindow.cpp 5
-
- We begin by clearing the editor's rich text document, and obtain a text
- cursor from the editor that we will use to add content. We also create a
- QDate object based on the currently selected date.
-
- The calendar is made up of a table with a gray background color that contains
- seven columns: one for each day of the week. It is placed in the center of the
- page with equal space to the left and right of it. All of these properties are
- set in a QTextTableFormat object:
-
- \snippet richtext/calendar/mainwindow.cpp 6
-
- Each cell in the table will be padded and spaced to make the text easier to
- read.
-
- We want the columns to have equal widths, so we provide a list containing
- percentage widths for each of them and set the constraints in the
- QTextTableFormat:
-
- \snippet richtext/calendar/mainwindow.cpp 7
-
- The constraints used for the column widths are only useful if the table has
- an appropriate number of columns. With the format for the table defined, we
- construct a new table with one row and seven columns at the current cursor
- position:
-
- \snippet richtext/calendar/mainwindow.cpp 8
-
- We only need one row to start with; more can be added as we need them. Using
- this approach means that we do not need to perform any date calculations
- until we add cells to the table.
-
- When inserting objects into a document with the cursor's insertion functions,
- the cursor is automatically moved inside the newly inserted object. This means
- that we can immediately start modifying the table from within:
-
- \snippet richtext/calendar/mainwindow.cpp 9
-
- Since the table has an outer frame, we obtain the frame and its format so that
- we can customize it. After making the changes we want, we set the frame's format
- using the modified format object. We have given the table an outer border one
- pixel wide.
-
- \snippet richtext/calendar/mainwindow.cpp 10
-
- In a similar way, we obtain the cursor's current character format and
- create customized formats based on it.
-
- We do not set the format on the cursor because this would change the default
- character format; instead, we use the customized formats explicitly when we
- insert text. The following loop inserts the days of the week into the table
- as bold text:
-
- \snippet richtext/calendar/mainwindow.cpp 11
-
- For each day of the week, we obtain an existing table cell in the first row
- (row 0) using the table's \l{QTextTable::cellAt()}{cellAt()} function. Since
- we start counting the days of the week at day 1 (Monday), we subtract 1 from
- \c weekDay to ensure that we obtain the cell for the correct column of the
- table.
-
- Before text can be inserted into a cell, we must obtain a cursor with the
- correct position in the document. The cell provides a function for this
- purpose, and we use this cursor to insert text using the \c boldFormat
- character format that we created earlier:
-
- \snippet richtext/calendar/mainwindow.cpp 12
-
- Inserting text into document objects usually follows the same pattern.
- Each object can provide a new cursor that corresponds to the first valid
- position within itself, and this can be used to insert new content. We
- continue to use this pattern as we insert the days of the month into the
- table.
-
- Since every month has more than seven days, we insert a single row to begin
- and add days until we reach the end of the month. If the current date is
- encountered, it is inserted with a special format (created earlier) that
- makes it stand out:
-
- \snippet richtext/calendar/mainwindow.cpp 13
-
- We add a new row to the table at the end of each week only if the next week
- falls within the currently selected month.
-
- For each calendar that we create, we change the window title to reflect the
- currently selected month and year:
-
- \snippet richtext/calendar/mainwindow.cpp 14
-
- The \c insertCalendar() function relies on up-to-date values for the month,
- year, and font size. These are set in the following slots:
-
- \snippet richtext/calendar/mainwindow.cpp 15
-
- The \c setFontSize() function simply changes the private \c fontSize variable
- before updating the calendar.
-
- \snippet richtext/calendar/mainwindow.cpp 16
-
- The \c setMonth slot is called when the QComboBox used to select the month is
- updated. The value supplied is the currently selected row in the combobox.
- We add 1 to this value to obtain a valid month number, and create a new QDate
- based on the existing one. The calendar is then updated to use this new date.
-
- \snippet richtext/calendar/mainwindow.cpp 17
-
- The \c setYear() slot is called when the QDateTimeEdit used to select the
- year is updated. The value supplied is a QDate object; this makes
- the construction of a new value for \c selectedDate simple. We update the
- calendar afterwards to use this new date.
-*/
diff --git a/examples/widgets/doc/src/calendarwidget.qdoc b/examples/widgets/doc/src/calendarwidget.qdoc
index 6a91f5ef6e..01c6df6926 100644
--- a/examples/widgets/doc/src/calendarwidget.qdoc
+++ b/examples/widgets/doc/src/calendarwidget.qdoc
@@ -3,6 +3,7 @@
/*!
\title Calendar Widget Example
+ \examplecategory {User Interface Components}
\example widgets/calendarwidget
\ingroup examples-widgets
\ingroup examples-layout
diff --git a/examples/widgets/doc/src/charactermap.qdoc b/examples/widgets/doc/src/charactermap.qdoc
deleted file mode 100644
index ee6162302f..0000000000
--- a/examples/widgets/doc/src/charactermap.qdoc
+++ /dev/null
@@ -1,251 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
-\example widgets/charactermap
-\title Character Map Example
-\ingroup examples-widgets
-\brief The Character Map example shows how to create a custom widget that can
-both display its own content and respond to user input.
-
-The example displays an array of characters which the user can click on
-to enter text in a line edit. The contents of the line edit can then be
-copied into the clipboard, and pasted into other applications. The
-purpose behind this sort of tool is to allow users to enter characters
-that may be unavailable or difficult to locate on their keyboards.
-
-\borderedimage charactermap-example.png
-\caption Screenshot of the Character Map example
-
-The example consists of the following classes:
-
-\list
-\li \c CharacterWidget displays the available characters in the current
- font and style.
-\li \c MainWindow provides a standard main window that contains font and
- style information, a view onto the characters, a line edit, and a push
- button for submitting text to the clipboard.
-\endlist
-
-\section1 CharacterWidget Class Definition
-
-The \c CharacterWidget class is used to display an array of characters in
-a user-specified font and style. For flexibility, we subclass QWidget and
-reimplement only the functions that we need to provide basic rendering
-and interaction features.
-
-The class definition looks like this:
-
-\snippet widgets/charactermap/characterwidget.h 0
-
-The widget does not contain any other widgets, so it must provide its own
-size hint to allow its contents to be displayed correctly.
-We reimplement \l{QWidget::paintEvent()} to draw custom content. We also
-reimplement \l{QWidget::mousePressEvent()} to allow the user to interact
-with the widget.
-
-The updateFont() and updateStyle() slots are used to update the font and
-style of the characters in the widget whenever the user changes the
-settings in the application.
-The class defines the characterSelected() signal so that other parts
-of the application are informed whenever the user selects a character in
-the widget.
-As a courtesy, the widget provides a tooltip that shows the current
-character value. We reimplement the \l{QWidget::mouseMoveEvent()} event
-handler and define showToolTip() to enable this feature.
-
-The \c columns, \c displayFont and \c currentKey private data members
-are used to record the number of columns to be shown, the current font,
-and the currently highlighted character in the widget.
-
-\section1 CharacterWidget Class Implementation
-
-Since the widget is to be used as a simple canvas, the constructor just
-calls the base class constructor and defines some default values for
-private data members.
-
-\snippet widgets/charactermap/characterwidget.cpp 0
-
-We initialize \c currentKey with a value of -1 to indicate
-that no character is initially selected. We enable mouse tracking to
-allow us to follow the movement of the cursor across the widget.
-
-The class provides two functions to allow the font and style to be set up.
-Each of these modify the widget's display font and call update():
-
-\snippet widgets/charactermap/characterwidget.cpp 1
-\codeline
-\snippet widgets/charactermap/characterwidget.cpp 2
-
-We use a fixed size font for the display. Similarly, a fixed size hint is
-provided by the sizeHint() function:
-
-\snippet widgets/charactermap/characterwidget.cpp 3
-
-Three standard event functions are implemented so that the widget
-can respond to clicks, provide tooltips, and render the available
-characters. The paintEvent() shows how the contents of the widget are
-arranged and displayed:
-
-\snippet widgets/charactermap/characterwidget.cpp 6
-
-A QPainter is created for the widget and, in all cases, we ensure that the
-widget's background is painted. The painter's font is set to the
-user-specified display font.
-
-The area of the widget that needs to be redrawn is used to determine which
-characters need to be displayed:
-
-\snippet widgets/charactermap/characterwidget.cpp 7
-
-Using integer division, we obtain the row and column numbers of each
-characters that should be displayed, and we draw a square on the widget
-for each character displayed.
-
-\snippet widgets/charactermap/characterwidget.cpp 8
-\snippet widgets/charactermap/characterwidget.cpp 9
-
-The symbols for each character in the array are drawn within each square,
-with the symbol for the most recently selected character displayed in red:
-
-\snippet widgets/charactermap/characterwidget.cpp 10
-
-We do not need to take into account the difference between the area
-displayed in the viewport and the area we are drawing on because
-everything outside the visible area will be clipped.
-
-The mousePressEvent() defines how the widget responds to mouse clicks.
-
-\snippet widgets/charactermap/characterwidget.cpp 5
-
-We are only interested when the user clicks with the left mouse button
-over the widget. When this happens, we calculate which character was
-selected and emit the characterSelected() signal.
-The character's number is found by dividing the x and y-coordinates of
-the click by the size of each character's grid square. Since the number
-of columns in the widget is defined by the \c columns variable, we
-simply multiply the row index by that value and add the column number
-to obtain the character number.
-
-If any other mouse button is pressed, the event is passed on to the
-QWidget base class. This ensures that the event can be handled properly
-by any other interested widgets.
-
-The mouseMoveEvent() maps the mouse cursor's position in global
-coordinates to widget coordinates, and determines the character that
-was clicked by performing the calculation
-
-\snippet widgets/charactermap/characterwidget.cpp 4
-
-The tooltip is given a position defined in global coordinates.
-
-\section1 MainWindow Class Definition
-
-The \c MainWindow class provides a minimal user interface for the example,
-with only a constructor, slots that respond to signals emitted by standard
-widgets, and some convenience functions that are used to set up the user
-interface.
-
-The class definition looks like this:
-
-\snippet widgets/charactermap/mainwindow.h 0
-
-The main window contains various widgets that are used to control how
-the characters will be displayed, and defines the findFonts() function
-for clarity and convenience. The findStyles() slot is used by the widgets
-to determine the styles that are available, insertCharacter() inserts
-a user-selected character into the window's line edit, and
-updateClipboard() synchronizes the clipboard with the contents of the
-line edit.
-
-\section1 MainWindow Class Implementation
-
-In the constructor, we set up the window's central widget and fill it with
-some standard widgets (two comboboxes, a line edit, and a push button).
-We also construct a CharacterWidget custom widget, and add a QScrollArea
-so that we can view its contents:
-
-\snippet widgets/charactermap/mainwindow.cpp 0
-
-QScrollArea provides a viewport onto the \c CharacterWidget when we set
-its widget and handles much of the work needed to provide a scrolling
-viewport.
-
-The font combo box is automatically populated with a list of available
-fonts. We list the available styles for the current font in the style
-combobox using the following function:
-
-\snippet widgets/charactermap/mainwindow.cpp 1
-
-The line edit and push button are used to supply text to the clipboard:
-
-\snippet widgets/charactermap/mainwindow.cpp 2
-
-We also obtain a clipboard object so that we can send text entered by the
-user to other applications.
-
-Most of the signals emitted in the example come from standard widgets.
-We connect these signals to slots in this class, and to the slots provided
-by other widgets.
-
-\snippet widgets/charactermap/mainwindow.cpp 4
-
-The font combobox's
-\l{QFontComboBox::currentFontChanged()}{currentFontChanged()} signal is
-connected to the findStyles() function so that the list of available styles
-can be shown for each font that is used. Since both the font and the style
-can be changed by the user, the font combobox's currentFontChanged() signal
-and the style combobox's
-\l{QComboBox::currentIndexChanged()}{currentIndexChanged()} are connected
-directly to the character widget.
-
-The final two connections allow characters to be selected in the character
-widget, and text to be inserted into the clipboard:
-
-\snippet widgets/charactermap/mainwindow.cpp 5
-
-The character widget emits the characterSelected() custom signal when
-the user clicks on a character, and this is handled by the insertCharacter()
-function in this class. The clipboard is changed when the push button emits
-the clicked() signal, and we handle this with the updateClipboard() function.
-
-The remaining code in the constructor sets up the layout of the central widget,
-and provides a window title:
-
-\snippet widgets/charactermap/mainwindow.cpp 6
-
-The font combobox is automatically populated with a list of available font
-families. The styles that can be used with each font are found by the
-findStyles() function. This function is called whenever the user selects a
-different font in the font combobox.
-
-\snippet widgets/charactermap/mainwindow.cpp 7
-
-We begin by recording the currently selected style, and we clear the
-style combobox so that we can insert the styles associated with the
-current font family.
-
-\snippet widgets/charactermap/mainwindow.cpp 8
-
-We use the font database to collect the styles that are available for the
-current font, and insert them into the style combobox. The current item is
-reset if the original style is not available for this font.
-
-The last two functions are slots that respond to signals from the character
-widget and the main window's push button. The insertCharacter() function is
-used to insert characters from the character widget when the user clicks a
-character:
-
-\snippet widgets/charactermap/mainwindow.cpp 9
-
-The character is inserted into the line edit at the current cursor position.
-
-The main window's "To clipboard" push button is connected to the
-updateClipboard() function so that, when it is clicked, the clipboard is
-updated to contain the contents of the line edit:
-
-\snippet widgets/charactermap/mainwindow.cpp 10
-
-We copy all the text from the line edit to the clipboard, but we do not clear
-the line edit.
-*/
diff --git a/examples/widgets/doc/src/chart.qdoc b/examples/widgets/doc/src/chart.qdoc
deleted file mode 100644
index abb1b3ab7e..0000000000
--- a/examples/widgets/doc/src/chart.qdoc
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example itemviews/chart
- \title Chart Example
- \ingroup examples-itemviews
- \brief The Chart example shows how to create a custom view for the model/view framework.
-
- \image chart-example.png
-
- In this example, the items in a table model are represented as slices in a pie chart,
- relying on the flexibility of the model/view architecture to handle custom editing
- and selection features.
-
- \b{Note that you only need to create a new view class if your data requires a
- specialized representation.} You should first consider using a standard QListView,
- QTableView, or QTreeView with a custom QItemDelegate subclass if you need to
- represent data in a special way.
-
- \omit
- \section1 PieView Class Definition
-
- The \c PieView class is a subclass of QAbstractItemView. The base class provides
- much of the functionality required by view classes, so we only need to provide
- implementations for three public functions: visualRect(), scrollTo(), and
- indexAt(). However, the view needs to maintain strict control over its look and
- feel, so we also provide implementations for a number of other functions:
-
- \snippet itemviews/chart/pieview.h 0
-
-
-
- \section1 PieView Class Implementation
-
- The paint event renders the data from the standard item model as a pie chart.
- We interpret the data in the following way:
-
- \list
- \li Column 0 contains data in two different roles:
- The \l{Qt::ItemDataRole}{DisplayRole} contains a label, and the
- \l{Qt::ItemDataRole}{DecorationRole} contains the color of the pie slice.
- \li Column 1 contains a quantity which we will convert to the angular extent of
- the slice.
- \endlist
-
- The figure is always drawn with the chart on the left and the key on
- the right. This means that we must try and obtain an area that is wider
- than it is tall. We do this by imposing a particular aspect ratio on
- the chart and applying it to the available vertical space. This ensures
- that we always obtain the maximum horizontal space for the aspect ratio
- used.
- We also apply fixed size margin around the figure.
-
- We use logical coordinates to draw the chart and key, and position them
- on the view using viewports.
- \endomit
-*/
diff --git a/examples/widgets/doc/src/chip.qdoc b/examples/widgets/doc/src/chip.qdoc
index a76e11950e..2c69c10f39 100644
--- a/examples/widgets/doc/src/chip.qdoc
+++ b/examples/widgets/doc/src/chip.qdoc
@@ -4,6 +4,7 @@
/*!
\example graphicsview/chip
\title 40000 Chips
+ \examplecategory {Graphics}
\ingroup examples-graphicsview
\brief Visualizes a huge graphic view scene with 40000 chip items.
diff --git a/examples/widgets/doc/src/classwizard.qdoc b/examples/widgets/doc/src/classwizard.qdoc
deleted file mode 100644
index 8494a3c7fb..0000000000
--- a/examples/widgets/doc/src/classwizard.qdoc
+++ /dev/null
@@ -1,167 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example dialogs/classwizard
- \title Class Wizard Example
- \ingroup examples-dialogs
-
- \brief The Class Wizard example shows how to implement linear
- wizards using QWizard.
-
- \image classwizard.png Screenshot of the Class Wizard example
-
- Most wizards have a linear structure, with page 1 followed by
- page 2 and so on until the last page. Some wizards are more
- complex in that they allow different traversal paths based on the
- information provided by the user. The
- \l{dialogs/licensewizard}{License Wizard} example shows how to
- create such wizards.
-
- The Class Wizard example consists of the following classes:
-
- \list
- \li \c ClassWizard inherits QWizard and provides a
- three-step wizard that generates the skeleton of a C++ class
- based on the user's input.
- \li \c IntroPage, \c ClassInfoPage, \c CodeStylePage, \c
- OutputFilesPage, and \c ConclusionPage are QWizardPage
- subclasses that implement the wizard pages.
- \endlist
-
- \section1 ClassWizard Class Definition
-
- \image classwizard-flow.png The Class Wizard pages
-
- We will see how to subclass QWizard to implement our own wizard.
- The concrete wizard class is called \c ClassWizard and provides
- five pages:
-
- \list
- \li The first page is an introduction page, telling the user what
- the wizard is going to do.
- \li The second page asks for a class name and a base class, and
- allows the user to specify whether the class should have a \c
- Q_OBJECT macro and what constructors it should provide.
- \li The third page allows the user to set some options related to the code
- style, such as the macro used to protect the header file from
- multiple inclusion (e.g., \c MYDIALOG_H).
- \li The fourth page allows the user to specify the names of the
- output files.
- \li The fifth page is a conclusion page.
- \endlist
-
- Although the program is just an example, if you press \uicontrol Finish
- (\uicontrol Done on \macos), actual C++ source files will actually be
- generated.
-
- \section1 The ClassWizard Class
-
- Here's the \c ClassWizard definition:
-
- \snippet dialogs/classwizard/classwizard.h 0
-
- The class reimplements QDialog's \l{QDialog::}{accept()} slot.
- This slot is called when the user clicks \uicontrol{Finish}.
-
- Here's the constructor:
-
- \snippet dialogs/classwizard/classwizard.cpp 1
-
- We instantiate the five pages and insert them into the wizard
- using QWizard::addPage(). The order in which they are inserted
- is also the order in which they will be shown later on.
-
- We call QWizard::setPixmap() to set the banner and the
- background pixmaps for all pages. The banner is used as a
- background for the page header when the wizard's style is
- \l{QWizard::}{ModernStyle}; the background is used as the
- dialog's background in \l{QWizard::}{MacStyle}. (See \l{Elements
- of a Wizard Page} for more information.)
-
- \snippet dialogs/classwizard/classwizard.cpp 3
- \snippet dialogs/classwizard/classwizard.cpp 4
- \dots
- \snippet dialogs/classwizard/classwizard.cpp 5
- \snippet dialogs/classwizard/classwizard.cpp 6
-
- If the user clicks \uicontrol Finish, we extract the information from
- the various pages using QWizard::field() and generate the files.
- The code is long and tedious (and has barely anything to do with
- noble art of designing wizards), so most of it is skipped here.
- See the actual example in the Qt distribution for the details if
- you're curious.
-
- \section1 The IntroPage Class
-
- The pages are defined in \c classwizard.h and implemented in \c
- classwizard.cpp, together with \c ClassWizard. We will start with
- the easiest page:
-
- \snippet dialogs/classwizard/classwizard.h 1
- \codeline
- \snippet dialogs/classwizard/classwizard.cpp 7
-
- A page inherits from QWizardPage. We set a
- \l{QWizardPage::}{title} and a
- \l{QWizard::WatermarkPixmap}{watermark pixmap}. By not setting
- any \l{QWizardPage::}{subTitle}, we ensure that no header is
- displayed for this page. (On Windows, it is customary for wizards
- to display a watermark pixmap on the first and last pages, and to
- have a header on the other pages.)
-
- Then we create a QLabel and add it to a layout.
-
- \section1 The ClassInfoPage Class
-
- The second page is defined and implemented as follows:
-
- \snippet dialogs/classwizard/classwizard.h 2
- \codeline
- \snippet dialogs/classwizard/classwizard.cpp 9
- \dots
- \snippet dialogs/classwizard/classwizard.cpp 12
- \dots
- \snippet dialogs/classwizard/classwizard.cpp 13
-
- First, we set the page's \l{QWizardPage::}{title},
- \l{QWizardPage::}{subTitle}, and \l{QWizard::LogoPixmap}{logo
- pixmap}. The logo pixmap is displayed in the page's header in
- \l{QWizard::}{ClassicStyle} and \l{QWizard::}{ModernStyle}.
-
- Then we create the child widgets, create \l{Registering and Using
- Fields}{wizard fields} associated with them, and put them into
- layouts. The \c className field is created with an asterisk (\c
- *) next to its name. This makes it a \l{mandatory fields}{mandatory field}, that
- is, a field that must be filled before the user can press the
- \uicontrol Next button (\uicontrol Continue on \macos). The fields' values
- can be accessed from any other page using QWizardPage::field(),
- or from the wizard code using QWizard::field().
-
- \section1 The CodeStylePage Class
-
- The third page is defined and implemented as follows:
-
- \snippet dialogs/classwizard/classwizard.h 3
- \codeline
- \snippet dialogs/classwizard/classwizard.cpp 14
- \dots
- \snippet dialogs/classwizard/classwizard.cpp 15
- \codeline
- \snippet dialogs/classwizard/classwizard.cpp 16
-
- The code in the constructor is very similar to what we did for \c
- ClassInfoPage, so we skipped most of it.
-
- The \c initializePage() function is what makes this class
- interesting. It is reimplemented from QWizardPage and is used to
- initialize some of the page's fields with values from the
- previous page (namely, \c className and \c baseClass). For
- example, if the class name on page 2 is \c SuperDuperWidget, the
- default macro name on page 3 is \c SUPERDUPERWIDGET_H.
-
- The \c OutputFilesPage and \c ConclusionPage classes are very
- similar to \c CodeStylePage, so we won't review them here.
-
- \sa QWizard, {License Wizard Example}, {Trivial Wizard Example}
-*/
diff --git a/examples/widgets/doc/src/codeeditor.qdoc b/examples/widgets/doc/src/codeeditor.qdoc
deleted file mode 100644
index 80c11db69d..0000000000
--- a/examples/widgets/doc/src/codeeditor.qdoc
+++ /dev/null
@@ -1,173 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/codeeditor
- \title Code Editor Example
- \ingroup examples-widgets
- \brief The Code Editor example shows how to create a simple editor that
- has line numbers and that highlights the current line.
-
- \borderedimage codeeditor-example.png
-
- As can be seen from the image, the editor displays the line
- numbers in an area to the left of the area for editing. The editor
- will highlight the line containing the cursor.
-
- We implement the editor in \c CodeEditor, which is a widget that
- inherits QPlainTextEdit. We keep a separate widget in \c
- CodeEditor (\c LineNumberArea) onto which we draw the line
- numbers.
-
- QPlainTextEdit inherits from QAbstractScrollArea, and editing
- takes place within its \l{QAbstractScrollArea::}{viewport()}'s
- margins. We make room for our line number area by setting the left
- margin of the viewport to the size we need to draw the line
- numbers.
-
- When it comes to editing code, we prefer QPlainTextEdit over
- QTextEdit because it is optimized for handling plain text. See
- the QPlainTextEdit class description for details.
-
- QPlainTextEdit lets us add selections in addition to the
- selection the user can make with the mouse or keyboard. We use
- this functionality to highlight the current line. More on this
- later.
-
- We will now move on to the definitions and implementations of \c
- CodeEditor and \c LineNumberArea. Let's start with the \c
- LineNumberArea class.
-
- \section1 The LineNumberArea Class
-
- We paint the line numbers on this widget, and place it over the \c
- CodeEditor's \l{QAbstractScrollArea::}{viewport()}'s left margin
- area.
-
- We need to use protected functions in QPlainTextEdit while
- painting the area. So to keep things simple, we paint the area in
- the \c CodeEditor class. The area also asks the editor to
- calculate its size hint.
-
- Note that we could simply paint the line numbers directly on the
- code editor, and drop the LineNumberArea class. However, the
- QWidget class helps us to \l{QWidget::}{scroll()} its contents.
- Also, having a separate widget is the right choice if we wish to
- extend the editor with breakpoints or other code editor features.
- The widget would then help in the handling of mouse events.
-
- \snippet widgets/codeeditor/codeeditor.h extraarea
-
- \section1 CodeEditor Class Definition
-
- Here is the code editor's class definition:
-
- \snippet widgets/codeeditor/codeeditor.h codeeditordefinition
-
- In the editor we resize and draw the line numbers on the \c
- LineNumberArea. We need to do this when the number of lines in the
- editor changes, and when the editor's viewport() is scrolled. Of
- course, it is also done when the editor's size changes. We do
- this in \c updateLineNumberWidth() and \c updateLineNumberArea().
-
- Whenever, the cursor's position changes, we highlight the current
- line in \c highlightCurrentLine().
-
- \section1 CodeEditor Class Implementation
-
- We will now go through the code editors implementation, starting
- off with the constructor.
-
- \snippet widgets/codeeditor/codeeditor.cpp constructor
-
- In the constructor we connect our slots to signals in
- QPlainTextEdit. It is necessary to calculate the line number area
- width and highlight the first line when the editor is created.
-
- \snippet widgets/codeeditor/codeeditor.cpp extraAreaWidth
-
- The \c lineNumberAreaWidth() function calculates the width of the
- \c LineNumberArea widget. We take the number of digits in the last
- line of the editor and multiply that with the maximum width of a
- digit.
-
- \snippet widgets/codeeditor/codeeditor.cpp slotUpdateExtraAreaWidth
-
- When we update the width of the line number area, we simply call
- QAbstractScrollArea::setViewportMargins().
-
- \snippet widgets/codeeditor/codeeditor.cpp slotUpdateRequest
-
- This slot is invoked when the editors viewport has been scrolled.
- The QRect given as argument is the part of the editing area that
- is do be updated (redrawn). \c dy holds the number of pixels the
- view has been scrolled vertically.
-
- \snippet widgets/codeeditor/codeeditor.cpp resizeEvent
-
- When the size of the editor changes, we also need to resize the
- line number area.
-
- \snippet widgets/codeeditor/codeeditor.cpp cursorPositionChanged
-
- When the cursor position changes, we highlight the current line,
- i.e., the line containing the cursor.
-
- QPlainTextEdit gives the possibility to have more than one
- selection at the same time. we can set the character format
- (QTextCharFormat) of these selections. We clear the cursors
- selection before setting the new new
- QPlainTextEdit::ExtraSelection, else several lines would get
- highlighted when the user selects multiple lines with the mouse.
- \omit ask someone how this works \endomit
-
- One sets the selection with a text cursor. When using the
- FullWidthSelection property, the current cursor text block (line)
- will be selected. If you want to select just a portion of the text
- block, the cursor should be moved with QTextCursor::movePosition()
- from a position set with \l{QTextCursor::}{setPosition()}.
-
- \snippet widgets/codeeditor/codeeditor.cpp extraAreaPaintEvent_0
-
- The \c lineNumberAreaPaintEvent() is called from \c LineNumberArea
- whenever it receives a paint event. We start off by painting the
- widget's background.
-
- \snippet widgets/codeeditor/codeeditor.cpp extraAreaPaintEvent_1
-
- We will now loop through all visible lines and paint the line
- numbers in the extra area for each line. Notice that in a plain
- text edit each line will consist of one QTextBlock; though, if
- line wrapping is enabled, a line may span several rows in the text
- edit's viewport.
-
- We get the top and bottom y-coordinate of the first text block,
- and adjust these values by the height of the current text block in
- each iteration in the loop.
-
- \snippet widgets/codeeditor/codeeditor.cpp extraAreaPaintEvent_2
-
- Notice that we check if the block is visible in addition to check
- if it is in the areas viewport - a block can, for example, be
- hidden by a window placed over the text edit.
-
- \section1 Suggestions for Extending the Code Editor
-
- No self-respecting code editor is without a syntax
- highligther; the \l{Syntax Highlighter Example} shows how to
- create one.
-
- In addition to line numbers, you can add more to the extra area,
- for instance, break points.
-
- QSyntaxHighlighter gives the possibility to add user data to each
- text block with
- \l{QSyntaxHighlighter::}{setCurrentBlockUserData()}. This can be
- used to implement parenthesis matching. In the \c
- highlightCurrentLine(), the data of the currentBlock() can be
- fetched with QTextBlock::userData(). Matching parentheses can be
- highlighted with an extra selection. The "Matching Parentheses
- with QSyntaxHighlighter" article in Qt Quarterly 31 implements
- this. You find it here: \l{http://doc.qt.io/archives/qq/}.
-
-*/
diff --git a/examples/widgets/doc/src/collidingmice-example.qdoc b/examples/widgets/doc/src/collidingmice-example.qdoc
index 4f6859406e..a1b8e0e141 100644
--- a/examples/widgets/doc/src/collidingmice-example.qdoc
+++ b/examples/widgets/doc/src/collidingmice-example.qdoc
@@ -4,6 +4,7 @@
/*!
\example graphicsview/collidingmice
\title Colliding Mice Example
+ \examplecategory {Graphics}
\brief Demonstrates how to animate items on a graphics view.
\ingroup examples-graphicsview
diff --git a/examples/widgets/doc/src/coloreditorfactory.qdoc b/examples/widgets/doc/src/coloreditorfactory.qdoc
index a7da4d6847..f43a7eb95c 100644
--- a/examples/widgets/doc/src/coloreditorfactory.qdoc
+++ b/examples/widgets/doc/src/coloreditorfactory.qdoc
@@ -4,15 +4,16 @@
/*!
\example itemviews/coloreditorfactory
\title Color Editor Factory Example
+ \examplecategory {User Interface Components}
\ingroup examples-itemviews
\brief This example shows how to create an editor that can be used by
- a QItemDelegate.
+ a QStyledItemDelegate.
\image coloreditorfactoryimage.png
When editing data in a QListView, QTableView, or QTreeView,
editors are created and displayed by a \l{Delegate
- Classes}{delegate}. QItemDelegate, which is the default delegate
+ Classes}{delegate}. QStyledItemDelegate, which is the default delegate
used by Qt's \l{View Classes}{item views}, uses a
QItemEditorFactory to create editors for it. A unique instance
provided by QItemEditorFactory is by default installed on all
@@ -26,7 +27,7 @@
In this example, we will create an editor (implemented in the \c
ColorListEditor class) that can edit the QColor data type and be
- used by \l{QItemDelegate}s. We do this by creating a new
+ used by \l{QStyledItemDelegate}s. We do this by creating a new
QItemEditorCreatorBase that produces \c ColorListEditors and
register it with a new factory, which we set as the default editor
item factory (the unique factory instance). To test our editor, we
@@ -66,7 +67,7 @@
\snippet itemviews/coloreditorfactory/colorlisteditor.h 0
- QItemDelegate manages the interaction between the editor and
+ QStyledItemDelegate manages the interaction between the editor and
the model, i.e., it retrieves data to edit from the model and
store data from the editor in the model. The data that is edited
by an editor is stored in the editor's user data property, and the
@@ -105,7 +106,7 @@
usually sufficient to provide custom editors. Further
customization is achieved by subclassing QItemEditorFactory
and QItemEditorCreatorBase. It is also possible to subclass
- QItemDelegate if you don't wish to use a factory at all.
+ QStyledItemDelegate if you don't wish to use a factory at all.
Possible suggestions are:
@@ -127,5 +128,5 @@
In this example, we use a standard QVariant data type. You can
also use custom types. In the \l{Star Delegate Example}, we
show how to store a custom data type in a QVariant and paint
- and edit it in a class that inherits QItemDelegate.
+ and edit it in a class that inherits QStyledItemDelegate.
*/
diff --git a/examples/widgets/doc/src/combowidgetmapper.qdoc b/examples/widgets/doc/src/combowidgetmapper.qdoc
index 2f53bfd11b..aae546005c 100644
--- a/examples/widgets/doc/src/combowidgetmapper.qdoc
+++ b/examples/widgets/doc/src/combowidgetmapper.qdoc
@@ -4,20 +4,14 @@
/*!
\example itemviews/combowidgetmapper
\title Combo Widget Mapper Example
+ \examplecategory {User Interface Components}
\ingroup examples-itemviews
\brief The Combo Widget Mapper example shows how to use a custom delegate to
map information from a model to specific widgets on a form.
\image combowidgetmapper-example.png
- In the \l{Simple Widget Mapper Example}, we showed the basic use of a
- widget mapper to relate data exposed by a model to simple input widgets
- in a user interface. However, sometimes we want to use input widgets that
- expose data as choices to the user, such as QComboBox, and we need a way
- to relate their input to the values stored in the model.
-
- This example is very similar to the \l{Simple Widget Mapper Example}.
- Again, we create a \c Window class with an almost identical user interface,
+ We create a \c Window class with an almost identical user interface,
except that, instead of providing a spin box so that each person's age
can be entered, we provide a combo box to allow their addresses to be
classified as "Home", "Work" or "Other".
@@ -65,8 +59,7 @@
interfering with the other input widgets. The implementation is shown later.
\endomit
- The rest of the constructor is very similar to that of the
- \l{Simple Widget Mapper Example}:
+ The rest of the constructor sets up connections and layouts:
\snippet itemviews/combowidgetmapper/window.cpp Set up connections and layouts
@@ -95,7 +88,7 @@
\section1 Delegate Class Definition and Implementation
The delegate we use to mediate interaction between the widget mapper and
- the input widgets is a small QItemDelegate subclass:
+ the input widgets is a small QStyledItemDelegate subclass:
\snippet itemviews/combowidgetmapper/delegate.h Delegate class definition
@@ -106,7 +99,7 @@
Since we only provide an empty implementation of the constructor, we
concentrate on the other two functions.
- The \l{QItemDelegate::}{setEditorData()} implementation takes the data
+ The \l{QStyledItemDelegate::}{setEditorData()} implementation takes the data
referred to by the model index supplied and processes it according to
the presence of a \c currentIndex property in the editor widget:
@@ -118,10 +111,10 @@
values needed for the \c currentIndex property.
As a result, instead of showing "0", "1" or "2" in the combo box, one of
- its predefined set of items is shown. We call QItemDelegate::setEditorData()
+ its predefined set of items is shown. We call QStyledItemDelegate::setEditorData()
for widgets without the \c currentIndex property.
- The \l{QItemDelegate::}{setModelData()} implementation performs the reverse
+ The \l{QStyledItemDelegate::}{setModelData()} implementation performs the reverse
process, taking the value stored in the widget's \c currentIndex property
and storing it back in the model:
diff --git a/examples/widgets/doc/src/completer.qdoc b/examples/widgets/doc/src/completer.qdoc
index a64d7e1e79..f3e4fe8f0e 100644
--- a/examples/widgets/doc/src/completer.qdoc
+++ b/examples/widgets/doc/src/completer.qdoc
@@ -4,6 +4,7 @@
/*!
\example tools/completer
\title Completer Example
+ \examplecategory {User Interface Components}
\ingroup examples-widgets-tools
\brief The Completer example shows how to provide string-completion facilities
@@ -45,7 +46,7 @@
\snippet tools/completer/fsmodel.cpp 0
As mentioned earlier, the \c data() function is reimplemented in order to
- get it to return the entire file parth for the display role. For example,
+ get it to return the entire file path for the display role. For example,
with a QFileSystemModel, you will see "Program Files" in the view. However, with
\c FileSystemModel, you will see "C:\\Program Files".
@@ -201,7 +202,7 @@
\snippet tools/completer/mainwindow.cpp 14
- The \c changeMaxVisible() update the maximum number of visible items in
+ The \c changeMaxVisible() updates the maximum number of visible items in
the completer.
\snippet tools/completer/mainwindow.cpp 15
diff --git a/examples/widgets/doc/src/composition.qdoc b/examples/widgets/doc/src/composition.qdoc
index 99fc066110..a8adcd2549 100644
--- a/examples/widgets/doc/src/composition.qdoc
+++ b/examples/widgets/doc/src/composition.qdoc
@@ -4,6 +4,7 @@
/*!
\example painting/composition
\title Composition Modes
+ \examplecategory {Graphics}
\ingroup examples-painting
\brief Demonstrates how Composition Modes work in QPainter.
@@ -18,5 +19,5 @@
drawn on top of the destination.
In addition to these standard modes, Qt defines the complete set of composition modes
- as defined by X. Porter and Y. Duff. See the QPainter documentation for details.
+ as defined by T. Porter and T. Duff. See the QPainter documentation for details.
*/
diff --git a/examples/widgets/doc/src/concentriccircles.qdoc b/examples/widgets/doc/src/concentriccircles.qdoc
deleted file mode 100644
index ffdb09869f..0000000000
--- a/examples/widgets/doc/src/concentriccircles.qdoc
+++ /dev/null
@@ -1,209 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example painting/concentriccircles
- \title Concentric Circles Example
- \ingroup examples-painting
- \brief Demonstrates the improved quality that antialiasing and floating point precision gives.
-
- \brief The Concentric Circles example shows the improved rendering
- quality that can be obtained using floating point precision and
- anti-aliasing when drawing custom widgets. The example also shows
- how to do simple animations.
-
- The application's main window displays several widgets which are
- drawn using the various combinations of precision and
- anti-aliasing.
-
- \image concentriccircles-example.png
-
- Anti-aliasing is one of QPainter's render hints. The
- QPainter::RenderHints are used to specify flags to QPainter that
- may, or may not, be respected by any given
- engine. QPainter::Antialiasing indicates that the engine should
- anti-alias the edges of primitives if possible, i.e. put
- additional pixels around the original ones to smooth the edges.
-
- The difference between floating point precision and integer
- precision is a matter of accuracy, and is visible in the
- application's main window: Even though the logic that is
- calculating the circles' geometry is the same, floating points
- ensure that the white spaces between each circle are of the same
- size, while integers make two and two circles appear as if they
- belong together. The reason is that the integer based precision
- rely on rounding off non-integer calculations.
-
- The example consists of two classes:
-
- \list
- \li \c CircleWidget is a custom widget which renders several animated
- concentric circles.
- \li \c Window is the application's main window displaying four \c
- {CircleWidget}s drawn using different combinations of precision
- and aliasing.
- \endlist
-
- First we will review the CircleWidget class, then we will take a
- look at the Window class.
-
- \section1 CircleWidget Class Definition
-
- The CircleWidget class inherits QWidget, and is a custom widget
- which renders several animated concentric circles.
-
- \snippet painting/concentriccircles/circlewidget.h 0
-
- We declare the \c floatBased and \c antialiased variables to hold
- whether an instance of the class should be rendered with integer
- or float based precision, and whether the rendering should be
- anti-aliased or not. We also declare functions setting each of
- these variables.
-
- In addition we reimplement the QWidget::paintEvent() function to
- apply the various combinations of precision and anti-aliasing when
- rendering, and to support the animation. We reimplement the
- QWidget::minimumSizeHint() and QWidget::sizeHint() functions to
- give the widget a reasonable size within our application.
-
- We declare the private \c nextAnimationFrame() slot, and the
- associated \c frameNo variable holding the number of "animation
- frames" for the widget, to facilitate the animation.
-
- \section1 CircleWidget Class Implementation
-
- In the constructor we make the widget's rendering integer based
- and aliased by default:
-
- \snippet painting/concentriccircles/circlewidget.cpp 0
-
- We initialize the widget's \c frameNo variable, and set the
- widget's background color using the QWidget::setBackgroundColor()
- function which takes a \l {QPalette::ColorRole}{color role} as
- argument; the QPalette::Base color role is typically white.
-
- Then we set the widgets size policy using the
- QWidget::setSizePolicy() function. QSizePolicy::Expanding means
- that the widget's \l {QWidget::sizeHint()}{sizeHint()} is a
- sensible size, but that the widget can be shrunk and still be
- useful. The widget can also make use of extra space, so it should
- get as much space as possible.
-
- \snippet painting/concentriccircles/circlewidget.cpp 1
- \codeline
- \snippet painting/concentriccircles/circlewidget.cpp 2
-
- The public \c setFloatBased() and \c setAntialiased() functions
- update the widget's rendering preferences, i.e. whether the widget
- should be rendered with integer or float based precision, and
- whether the rendering should be anti-aliased or not.
-
- The functions also generate a paint event by calling the
- QWidget::update() function, forcing a repaint of the widget with
- the new rendering preferences.
-
- \snippet painting/concentriccircles/circlewidget.cpp 3
- \codeline
- \snippet painting/concentriccircles/circlewidget.cpp 4
-
- The default implementations of the QWidget::minimumSizeHint() and
- QWidget::sizeHint() functions return invalid sizes if there is no
- layout for the widget, otherwise they return the layout's minimum and
- preferred size, respectively.
-
- We reimplement the functions to give the widget minimum and
- preferred sizes which are reasonable within our application.
-
- \snippet painting/concentriccircles/circlewidget.cpp 5
-
- The nextAnimationFrame() slot simply increments the \c frameNo
- variable's value, and calls the QWidget::update() function which
- schedules a paint event for processing when Qt returns to the main
- event loop.
-
- \snippet painting/concentriccircles/circlewidget.cpp 6
-
- A paint event is a request to repaint all or part of the
- widget. The \c paintEvent() function is an event handler that can
- be reimplemented to receive the widget's paint events. We
- reimplement the event handler to apply the various combinations of
- precision and anti-aliasing when rendering the widget, and to
- support the animation.
-
- First, we create a QPainter for the widget, and set its
- antialiased flag to the widget's preferred aliasing. We also
- translate the painters coordinate system, preparing to draw the
- widget's cocentric circles. The translation ensures that the
- center of the circles will be equivalent to the widget's center.
-
- \snippet painting/concentriccircles/circlewidget.cpp 7
-
- When painting a circle, we use the number of "animation frames" to
- determine the alpha channel of the circle's color. The alpha
- channel specifies the color's transparency effect, 0 represents a
- fully transparent color, while 255 represents a fully opaque
- color.
-
- \snippet painting/concentriccircles/circlewidget.cpp 8
-
- If the calculated alpha channel is fully transparent, we don't
- draw anything since that would be equivalent to drawing a white
- circle on a white background. Instead we skip to the next circle
- still creating a white space. If the calculated alpha channel is
- fully opaque, we set the pen (the QColor passed to the QPen
- constructor is converted into the required QBrush by default) and
- draw the circle. If the widget's preferred precision is float
- based, we specify the circle's bounding rectangle using QRectF and
- double values, otherwise we use QRect and integers.
-
- The animation is controlled by the public \c nextAnimationFrame()
- slot: Whenever the \c nextAnimationFrame() slot is called the
- number of frames is incremented and a paint event is
- scheduled. Then, when the widget is repainted, the alpha-blending
- of the circles' colors change and the circles appear as animated.
-
- \section1 Window Class Definition
-
- The Window class inherits QWidget, and is the application's main
- window rendering four \c {CircleWidget}s using different
- combinations of precision and aliasing.
-
- \snippet painting/concentriccircles/window.h 0
-
- We declare the various components of the main window, i.e., the text
- labels and a double array that will hold reference to the four \c
- {CircleWidget}s. In addition we declare the private \c
- createLabel() function to simplify the constructor.
-
- \section1 Window Class Implementation
-
- \snippet painting/concentriccircles/window.cpp 0
-
- In the constructor, we first create the various labels and put
- them in a QGridLayout.
-
- \snippet painting/concentriccircles/window.cpp 1
-
- Then we create a QTimer. The QTimer class is a high-level
- programming interface for timers, and provides repetitive and
- single-shot timers.
-
- We create a timer to facilitate the animation of our concentric
- circles; when we create the four CircleWidget instances (and add
- them to the layout), we connect the QTimer::timeout() signal to
- each of the widgets' \c nextAnimationFrame() slots.
-
- \snippet painting/concentriccircles/window.cpp 2
-
- Before we set the layout and window title for our main window, we
- make the timer start with a timeout interval of 100 milliseconds,
- using the QTimer::start() function. That means that the
- QTimer::timeout() signal will be emitted, forcing a repaint of the
- four \c {CircleWidget}s, every 100 millisecond which is the reason
- the circles appear as animated.
-
- \snippet painting/concentriccircles/window.cpp 3
-
- The private \c createLabel() function is implemented to simlify
- the constructor.
-*/
diff --git a/examples/widgets/doc/src/cuberhiwidget.qdoc b/examples/widgets/doc/src/cuberhiwidget.qdoc
new file mode 100644
index 0000000000..d40459ecf1
--- /dev/null
+++ b/examples/widgets/doc/src/cuberhiwidget.qdoc
@@ -0,0 +1,170 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example rhi/cuberhiwidget
+ \title Cube RHI Widget Example
+ \examplecategory {Graphics}
+ \ingroup examples-widgets
+ \brief Shows how to render a textured cube and integrate with QPainter and widgets, using QRhi Qt's 3D API and shading language abstraction layer.
+
+ \image cuberhiwidget-example.jpg
+ \caption Screenshot of the Cube RHI Widget example
+
+ This example builds on the \l{Simple RHI Widget Example}. While the simple
+ example is intentionally minimal and as compact as possible, rendering only
+ a single triangle with no additional widgets in the window, this
+ application demonstrates:
+
+ \list
+
+ \li Having various widgets in the window, some of them controlling data
+ that is consumed by the QRhiWidget subclass.
+
+ \li Instead of continuously requesting updates, the QRhiWidget here only
+ updates the content in its backing texture when some related data changes.
+
+ \li The cube is textured using a \l QRhiTexture that sources its content
+ from a \l QImage that contains software-based rendering performed with
+ \l QPainter.
+
+ \li The contents of the QRhiWidget \l{QRhiWidget::grab()}{can be
+ read back} and saved to an image file (e.g. a PNG file).
+
+ \li 4x multisample antialiasing \l{QRhiWidget::sampleCount()}{can be toggled}
+ at run time. The QRhiWidget subclass is prepared to handle the changing
+ sample count correctly.
+
+ \li Forcing an \l{QRhiWidget::explicitSize}{explicitly specified backing
+ texture size} can be toggled dynamically and controlled with a slider
+ between 16x16 up to 512x512 pixels.
+
+ \li The QRhiWidget subclass deals with a changing \l QRhi correctly. This
+ can be seen in action when making the widget top-level (no parent; becomes
+ a separate window) and then reparenting it again into the main window's
+ child hierarchy.
+
+ \li Most importantly, some widgets, with semi-transparency even, can be
+ placed on top of the QRhiWidget, proving that correct stacking and blending
+ is feasible. This is a case where QRhiWidget is superior to embedding a
+ native window, i.e. a QRhi-based QWindow using
+ QWidget::createWindowContainer(), because it allows stacking and clipping
+ the same way as any ordinary, software-rendered QWidget, whereas native
+ window embedding may, depending on the platform, have various limitations,
+ e.g. often it can be difficult or inefficient to place additional controls
+ on top.
+
+ \endlist
+
+ In the reimplementation of \l{QRhiWidget::initialize()}{initialize()}, the
+ first thing to do is to check if the QRhi we last worked with is still
+ up-to-date, and if the sample count (for multisample antialiasing) has
+ changed. The former is important because all graphics resources must be
+ released when the QRhi changes, whereas with a dynamically changing sample
+ count a similar problem arises specifically for QRhiGraphicsPipeline
+ objects as those bake the sample count in. For simplicity, the application
+ handles all such changes the same way, by resetting its \c scene struct to
+ a default constructed one, which conveniently drops all graphics resources.
+ All resources are then recreated.
+
+ When the backing texture size (so the render target size) changes, no
+ special action is needed, but a signal is emitted for convenience, just so
+ that main() can reposition the overlay label. The 3D API name is also
+ exposed via a signal by querying \l QRhi::backendName() whenever the QRhi
+ changes.
+
+ The implementation has to be aware that multisample antialiasing implies
+ that \l{QRhiWidget::colorTexture()}{colorTexture()} is \nullptr, while
+ \l{QRhiWidget::msaaColorBuffer()}{msaaColorBuffer()} is valid. This is
+ the opposite of when MSAA is not in use. The reason for differentiating
+ and using different types (QRhiTexture, QRhiRenderBuffer) is to allow
+ using MSAA with 3D graphics APIs that do not have support for
+ multisample textures, but have support for multisample renderbuffers.
+ An example of this is OpenGL ES 3.0.
+
+ When checking the up-to-date pixel size and sample count, a convenient and
+ compact solution is to query via the QRhiRenderTarget, because this way one
+ does not need to check which of colorTexture() and msaaColorBuffer() are
+ valid.
+
+ \snippet rhi/cuberhiwidget/examplewidget.cpp init-1
+
+ The rest is quite self-explanatory. The buffers and pipelines are
+ (re)created, if necessary. The contents of the texture that is used to
+ texture the cube mesh is updated. The scene is rendered using a perspective
+ projection. The view is just a simple translation for now.
+
+ \snippet rhi/cuberhiwidget/examplewidget.cpp init-2
+
+ The function that performs the actual enqueuing of the uniform buffer write
+ is also taking the user-provided rotation into account, thus generating the
+ final modelview-projection matrix.
+
+ \snippet rhi/cuberhiwidget/examplewidget.cpp rotation-update
+
+ Updating the \l QRhiTexture that is sampled in the fragment shader when
+ rendering the cube, is quite simple, even though a lot is happening in
+ there: first a QPainter-based drawing is generated within a QImage. This
+ uses the user-provided text. Then the CPU-side pixel data is uploaded to a
+ texture (more precisely, the upload operation is recorded on a \l
+ QRhiResourceUpdateBatch, which is then submitted later in render()).
+
+ \snippet rhi/cuberhiwidget/examplewidget.cpp texture-update
+
+ The graphics resource initialization is simple. There is only a vertex
+ buffer, no index buffer, and a uniform buffer with only a 4x4 matrix in it
+ (16 floats).
+
+ The texture that contains the QPainter-generated drawing has a size of
+ 512x512. Note that all sizes (texture sizes, viewports, scissors, texture
+ upload regions, etc.) are always in pixels when working with QRhi. To
+ sample this texture in the shader, a \l{QRhiSampler}{sampler object} is
+ needed (irrespective of the fact that QRhi-based applications will
+ typically use combined image samplers in the GLSL shader code, which then
+ may be transpiled to separate texture and sampler objects with some shading
+ languages, or may stay a combined texture-sampler object with others,
+ meaning there may not actually be a native sampler object under the hood at
+ run time, depending on the 3D API, but this is all transparent to the
+ application)
+
+ The vertex shader reads from the uniform buffer at binding point 0,
+ therefore
+ \c{scene.ubuf} is exposed at that binding location. The fragment shader
+ samples a texture provided at binding point 1,
+ therefore a combined texture-sampler pair is specified for that binding location.
+
+ The QRhiGraphicsPipeline enables depth test/write, and culls backfaces. It
+ also relies on a number of defaults, e.g. the depth comparison function
+ defaults to \c Less, which is fine for us, and the front face mode is
+ counter-clockwise, which is also good as-is so does not need to be set
+ again.
+
+ \snippet rhi/cuberhiwidget/examplewidget.cpp setup-scene
+
+ In the reimplementation of \l{QRhiWidget::render()}{render()}, first the
+ user-provided data is checked. If the \l QSlider controlling the rotation
+ has provided a new value, or the \l QTextEdit with the cube text has
+ changed its text, the graphics resources the contents of which depend on
+ such data get updated.
+
+ Then, a single render pass with a single draw call is recorded. The cube
+ mesh data is provided in a non-interleaved format, hence the need for two
+ vertex input bindings, one is the positions (x, y, z) the other is the UVs
+ (u, v), with a start offset that corresponds to 36 x-y-z float pairs.
+
+ \snippet rhi/cuberhiwidget/examplewidget.cpp render
+
+ How is the user-provided data sent? Take the rotation for example. main()
+ connects to the QSlider's \l{QSlider::valueChanged}{valueChanged} signal.
+ When emitted, the connected lamda calls setCubeRotation() on the
+ ExampleRhiWidget. Here, if the value is different from before, it is
+ stored, and a dirty flag is set. Then, most importantly,
+ \l{QWidget::update()}{update()} is called on the ExampleRhiWidget. This is
+ what triggers rendering a new frame into the QRhiWidget's backing texture.
+ Without this the content of the ExampleRhiWidget would not update when
+ dragging the slider.
+
+ \snippet rhi/cuberhiwidget/examplewidget.h data-setters
+
+ \sa QRhi, {Simple RHI Widget Example}, {RHI Window Example}
+*/
diff --git a/examples/widgets/doc/src/customsortfiltermodel.qdoc b/examples/widgets/doc/src/customsortfiltermodel.qdoc
index 5ee98362ba..b6ff8e7b48 100644
--- a/examples/widgets/doc/src/customsortfiltermodel.qdoc
+++ b/examples/widgets/doc/src/customsortfiltermodel.qdoc
@@ -4,6 +4,7 @@
/*!
\example itemviews/customsortfiltermodel
\title Custom Sort/Filter Model Example
+ \examplecategory {User Interface Components}
\ingroup examples-itemviews
\brief The Custom Sort/Filter Model example illustrates how to subclass
QSortFilterProxyModel to perform advanced sorting and filtering.
diff --git a/examples/widgets/doc/src/deform.qdoc b/examples/widgets/doc/src/deform.qdoc
index 371f1a41c7..f33522fa3b 100644
--- a/examples/widgets/doc/src/deform.qdoc
+++ b/examples/widgets/doc/src/deform.qdoc
@@ -4,6 +4,7 @@
/*!
\example painting/deform
\title Vector Deformation
+ \examplecategory {Graphics}
\ingroup examples-painting
\brief Demonstrates how to manipulate the elements of a QPainterPath.
diff --git a/examples/widgets/doc/src/diagramscene.qdoc b/examples/widgets/doc/src/diagramscene.qdoc
index 115f22ce8a..6f307ef97c 100644
--- a/examples/widgets/doc/src/diagramscene.qdoc
+++ b/examples/widgets/doc/src/diagramscene.qdoc
@@ -4,6 +4,7 @@
/*!
\example graphicsview/diagramscene
\title Diagram Scene Example
+ \examplecategory {Graphics}
\ingroup examples-graphicsview
\brief Demonstrate how to use the Graphics View framework.
@@ -12,7 +13,7 @@
The Diagram Scene example is an application in which you can
create a flowchart diagram. It is possible to add flowchart shapes
and text and connect the shapes by arrows as shown in the image
- above. The shapes, arrows, and text can be given different
+ above. The shapes, arrows, and text can be given different
colors, and it is possible to change the font, style, and
underline of the text.
@@ -121,9 +122,7 @@
We show an example of the creation of an action. The
functionality the actions trigger is discussed in the slots we
- connect the actions to. You can see the \l{Qt Widgets - Application
- Example}{application example} if you need a high-level
- introduction to actions.
+ connect the actions to.
The is the \c createMenus() function:
@@ -289,7 +288,7 @@
added to the scene. We set the mode of the scene back to the mode
before the item was inserted, which is ItemMove or InsertText
depending on which button is checked in the \c pointerTypeGroup.
- We must also uncheck the button in the in the \c buttonGroup.
+ We must also uncheck the button in the \c buttonGroup.
Here is the implementation of \c textInserted():
diff --git a/examples/widgets/doc/src/digitalclock.qdoc b/examples/widgets/doc/src/digitalclock.qdoc
deleted file mode 100644
index d24277177f..0000000000
--- a/examples/widgets/doc/src/digitalclock.qdoc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/digitalclock
- \title Digital Clock Example
- \ingroup examples-widgets
- \brief The Digital Clock example shows how to use QLCDNumber to display a
- number with LCD-like digits.
-
- \borderedimage digitalclock-example.png
- \caption Screenshot of the Digital Clock example
-
- This example also demonstrates how QTimer can be used to update a widget
- at regular intervals.
-
- \section1 DigitalClock Class Definition
-
- The \c DigitalClock class provides a clock widget showing the time with
- hours and minutes separated by a blinking colon. We subclass QLCDNumber
- and implement a private slot called \c showTime() to update the clock
- display:
-
- \snippet widgets/digitalclock/digitalclock.h 0
-
- \section1 DigitalClock Class Implementation
-
- \snippet widgets/digitalclock/digitalclock.cpp 0
-
- In the constructor, we first change the look of the LCD numbers. The
- QLCDNumber::Filled style produces raised segments filled with the
- foreground color (typically black). We also set up a one-second timer
- to keep track of the current time, and we connect
- its \l{QTimer::timeout()}{timeout()} signal to the private \c showTime() slot
- so that the display is updated every second. Then, we
- call the \c showTime() slot; without this call, there would be a one-second
- delay at startup before the time is shown.
-
- \snippet widgets/digitalclock/digitalclock.cpp 1
- \snippet widgets/digitalclock/digitalclock.cpp 2
-
- The \c showTime() slot is called whenever the clock display needs
- to be updated.
-
- The current time is converted into a string with the format "hh:mm".
- When QTime::second() is a even number, the colon in the string is
- replaced with a space. This makes the colon appear and vanish every
- other second.
-
- Finally, we call QLCDNumber::display() to update the widget.
-*/
diff --git a/examples/widgets/doc/src/dirview.qdoc b/examples/widgets/doc/src/dirview.qdoc
deleted file mode 100644
index 5c63d99eaa..0000000000
--- a/examples/widgets/doc/src/dirview.qdoc
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example itemviews/dirview
- \title Dir View Example
- \ingroup examples-itemviews
- \brief This example demonstrates the usage of a tree view, and smooth flicking on a touchscreen.
-
- The Dir View example shows a tree view of the local file
- system. It uses the QFileSystemModel class to provide file
- and directory information.
-
- \borderedimage dirview-example.png
-
- \quotefromfile itemviews/dirview/main.cpp
- \skipto QCommandLineParser parser
- \printuntil parser.positionalArguments
-
- The example supports a number of command line options.
- These options include:
- \list
- \li Application description
- \li -help option
- \li -version option
- \li if the optionc {-c} is specified, the application will not
- use custom directory options
- \endlist
-
- \skipto QFileSystemModel
- \printuntil tree.setModel
-
- Declares \c model as data model for reading the local filesystem.
- \c model.setRootPath("") sets the current folder as the folder from
- which \c model will start reading.
- QTreeView object \c tree visualizes the filesystem in a tree structure.
-
- \skipto tree.setAnimated(false)
- \printuntil tree.setColumnWidth
-
- Sets layout options for animation, indentation, sorting, and sizing of the
- filesystem tree.
-
- \skipto QScroller::grabGesture
- \printuntil QScroller::grabGesture
-
- Creates a \l QScroller instance to recognize gestures on touchscreens,
- so that you can flick the tree view with your finger.
-*/
diff --git a/examples/widgets/doc/src/dockwidgets.qdoc b/examples/widgets/doc/src/dockwidgets.qdoc
deleted file mode 100644
index 9907cea2e2..0000000000
--- a/examples/widgets/doc/src/dockwidgets.qdoc
+++ /dev/null
@@ -1,140 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example mainwindows/dockwidgets
- \title Dock Widgets Example
- \ingroup examples-mainwindow
-
- \brief The Dock Widgets example shows how to add dock windows to an
- application. It also shows how to use Qt's rich text engine.
-
- \image dockwidgets-example.png Screenshot of the Dock Widgets example
-
- The application presents a simple business letter template, and has
- a list of customer names and addresses and a list of standard
- phrases in two dock windows. The user can click a customer to have
- their name and address inserted into the template, and click one or
- more of the standard phrases. Errors can be corrected by clicking
- the Undo button. Once the letter has been prepared it can be printed
- or saved as HTML.
-
- \section1 MainWindow Class Definition
-
- Here's the class definition:
-
- \snippet mainwindows/dockwidgets/mainwindow.h 0
-
- We will now review each function in turn.
-
- \section1 MainWindow Class Implementation
-
- \snippet mainwindows/dockwidgets/mainwindow.cpp 0
-
- We start by including \c <QtWidgets>, a header file that contains the
- definition of all classes in the Qt Core, Qt GUI and Qt Widgets
- modules. This saves us from having to include
- every class individually and is especially convenient if we add new
- widgets. We also include \c mainwindow.h.
-
- \snippet mainwindows/dockwidgets/mainwindow.cpp 1
-
- In the constructor, we start by creating a QTextEdit widget. Then we call
- QMainWindow::setCentralWidget(). This function passes ownership of
- the QTextEdit to the \c MainWindow and tells the \c MainWindow that
- the QTextEdit will occupy the \c MainWindow's central area.
-
- Then we call \c createActions(), \c createMenus(), \c
- createToolBars(), \c createStatusBar(), and \c createDockWindows()
- to set up the user interface. Finally we call \c setWindowTitle() to
- give the application a title, and \c newLetter() to create a new
- letter template.
-
- We won't quote the \c createActions(), \c createMenus(), \c
- createToolBars(), and \c createStatusBar() functions since they
- follow the same pattern as all the other Qt examples.
-
- \snippet mainwindows/dockwidgets/mainwindow.cpp 9
-
- We create the customers dock window first, and in addition to a
- window title, we also pass it a \c this pointer so that it becomes a
- child of \c MainWindow. Normally we don't have to pass a parent
- because widgets are parented automatically when they are laid out:
- but dock windows aren't laid out using layouts.
-
- We've chosen to restrict the customers dock window to the left and
- right dock areas. (So the user cannot drag the dock window to the
- top or bottom dock areas.) The user can drag the dock window out of
- the dock areas entirely so that it becomes a free floating window.
- We can change this (and whether the dock window is moveable or
- closable) using QDockWidget::setFeatures().
-
- Once we've created the dock window we create a list widget with the
- dock window as parent, then we populate the list and make it the
- dock window's widget. Finally we add the dock widget to the \c
- MainWindow using \c addDockWidget(), choosing to put it in the right
- dock area.
-
- We undertake a similar process for the paragraphs dock window,
- except that we don't restrict which dock areas it can be dragged to.
-
- Finally we set up the signal-slot connections. If the user clicks a
- customer or a paragraph their \c currentTextChanged() signal will be
- emitted and we connect these to \c insertCustomer() and
- addParagraph() passing the text that was clicked.
-
- We briefly discuss the rest of the implementation, but have now
- covered everything relating to dock windows.
-
- \snippet mainwindows/dockwidgets/mainwindow.cpp 2
-
- In this function we clear the QTextEdit so that it is empty. Next we
- create a QTextCursor on the QTextEdit. We move the cursor to the
- start of the document and create and format a frame. We then create
- some character formats and a table format. We insert a table into
- the document and insert the company's name and address into a table
- using the table and character formats we created earlier. Then we
- insert the skeleton of the letter including two markers \c NAME and
- \c ADDRESS. We will also use the \c{Yours sincerely,} text as a marker.
-
- \snippet mainwindows/dockwidgets/mainwindow.cpp 6
-
- If the user clicks a customer we split the customer details into
- pieces. We then look for the \c NAME marker using the \c find()
- function. This function selects the text it finds, so when we call
- \c insertText() with the customer's name the name replaces the marker.
- We then look for the \c ADDRESS marker and replace it with each line
- of the customer's address. Notice that we wrapped all the insertions
- between a \c beginEditBlock() and \c endEditBlock() pair. This means
- that the entire name and address insertion is treated as a single
- operation by the QTextEdit, so a single undo will revert all the
- insertions.
-
- \snippet mainwindows/dockwidgets/mainwindow.cpp 7
-
- This function works in a similar way to \c insertCustomer(). First
- we look for the marker, in this case, \c {Yours sincerely,}, and then
- replace it with the standard paragraph that the user clicked. Again
- we use a \c beginEditBlock() ... \c endEditBlock() pair so that the
- insertion can be undone as a single operation.
-
- \snippet mainwindows/dockwidgets/mainwindow.cpp 3
-
- Qt's QTextDocument class makes printing documents easy. We simply
- take the QTextEdit's QTextDocument, set up the printer and print the
- document.
-
- \snippet mainwindows/dockwidgets/mainwindow.cpp 4
-
- QTextEdit can output its contents in HTML format, so we prompt the
- user for the name of an HTML file and if they provide one we simply
- write the QTextEdit's contents in HTML format to the file.
-
- \snippet mainwindows/dockwidgets/mainwindow.cpp 5
-
- If the focus is in the QTextEdit, pressing \uicontrol Ctrl+Z undoes as
- expected. But for the user's convenience we provide an
- application-wide undo function that simply calls the QTextEdit's
- undo: this means that the user can undo regardless of where the
- focus is in the application.
-*/
diff --git a/examples/widgets/doc/src/draganddroppuzzle.qdoc b/examples/widgets/doc/src/draganddroppuzzle.qdoc
deleted file mode 100644
index c2504b245b..0000000000
--- a/examples/widgets/doc/src/draganddroppuzzle.qdoc
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example draganddrop/puzzle
- \title Drag and Drop Puzzle Example
-
- \brief The Drag and Drop Puzzle example demonstrates a way of using the drag and drop system with
- item view widgets.
-
- \image draganddroppuzzle-example.png
-
- This example is an implementation of a simple jigsaw puzzle game using Qt's
- drag and drop API.
- The \l{Item Views Puzzle Example}{Item View Puzzle} example shows
- many of the same features, but takes an alternative approach that uses Qt's
- model/view framework to manage drag and drop operations.
-*/
diff --git a/examples/widgets/doc/src/dragdroprobot.qdoc b/examples/widgets/doc/src/dragdroprobot.qdoc
index ca62bf73df..c9ff04574b 100644
--- a/examples/widgets/doc/src/dragdroprobot.qdoc
+++ b/examples/widgets/doc/src/dragdroprobot.qdoc
@@ -4,6 +4,7 @@
/*!
\example graphicsview/dragdroprobot
\title Drag and Drop Robot Example
+ \examplecategory {Graphics}
\ingroup examples-graphicsview
\brief Demonstrates how to drag and drop items in a graphics view.
diff --git a/examples/widgets/doc/src/draggableicons.qdoc b/examples/widgets/doc/src/draggableicons.qdoc
index 9a0290c82f..fd4f9e69e3 100644
--- a/examples/widgets/doc/src/draggableicons.qdoc
+++ b/examples/widgets/doc/src/draggableicons.qdoc
@@ -4,6 +4,7 @@
/*!
\example draganddrop/draggableicons
\title Draggable Icons Example
+ \examplecategory {User Interface Components}
\brief The Draggable Icons example shows how to drag and drop image data between widgets
in the same application, and between different applications.
diff --git a/examples/widgets/doc/src/draggabletext.qdoc b/examples/widgets/doc/src/draggabletext.qdoc
index 3cc3560bb9..6e15e7f946 100644
--- a/examples/widgets/doc/src/draggabletext.qdoc
+++ b/examples/widgets/doc/src/draggabletext.qdoc
@@ -4,6 +4,7 @@
/*!
\example draganddrop/draggabletext
\title Draggable Text Example
+ \examplecategory {User Interface Components}
\brief Illustrates how to drag and drop text between widgets.
\brief The Draggable Text example shows how to drag and drop textual data between widgets
diff --git a/examples/widgets/doc/src/dynamiclayouts.qdoc b/examples/widgets/doc/src/dynamiclayouts.qdoc
deleted file mode 100644
index 5dea8a7f6a..0000000000
--- a/examples/widgets/doc/src/dynamiclayouts.qdoc
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example layouts/dynamiclayouts
- \title Dynamic Layouts Example
- \brief Shows how to re-orient widgets in running applications.
-
- \e{Dynamic Layouts} implements dynamically placed widgets within running
- applications. The widget placement depends on whether \c Horizontal or \c
- Vertical is chosen.
-
- \borderedimage dynamiclayouts-example.png
- For more information, visit the \l{Layout Management} page.
-
- \section1 Dialog Constructor
-
- To begin with, the application creates the UI components by calling the
- following methods:
-
- \list
- \li createRotatableGroupBox()
- \li createOptionsGroupBox()
- \li createButtonBox()
- \endlist
-
- It then adds the UI components to a GridLayout (\c mainLayout).
-
- Finally, \c Dialog::rotateWidgets() is called.
-
- \quotefromfile layouts/dynamiclayouts/dialog.cpp
- \skipuntil createRotatableGroupBox
- \printuntil setWindowTitle
-
- \section1 Creating the Main Widgets
-
- The \c createRotatableGroupBox() method creates a rotatable group box,
- then adds a series of widgets:
-
- \list
- \li QSpinBox
- \li QSlider
- \li QDial
- \li QProgressBar
- \endlist
-
- It goes on to add signals and slots to each widget, and assigns
- a QGridLayout called \a rotatableLayout.
-
- \skipto Dialog::createRotatableGroupBox
- \printuntil /^\}/
-
- \section1 Adding Options
-
- \c createOptionsGroupBox() creates the following widgets:
- \list
- \li \c optionsGroupBox
- \li \c buttonsOrientationLabel
- \li \c buttonsOrientationComboBox. The orientation of the ComboBox is either
- \c horizontal (default value) or \c vertical. These two values
- are added during the startup of the application. It is not possible
- to leave the option empty.
- \endlist
-
- \skipto Dialog::createOptionsGroupBox()
- \printuntil /^\}/
-
- \section1 Adding Buttons
-
- createButtonBox() constructs a QDialogButtonBox called \c buttonBox
- to which are added a \c closeButton, a \c helpButton and a
- \c rotateWidgetsButton.
- It then assigns a signal and a slot to each button in \c buttonBox.
-
- \skipto Dialog::createButtonBox()
- \printuntil /^\}/
-
-
- \section1 Rotating the Widgets
-
- Removes the current widgets and activates the next widget.
-
- \quotefromfile layouts/dynamiclayouts/dialog.cpp
- \skipto Dialog::rotateWidgets()
- \printuntil rotatableLayout->addWidget(rotatableWidgets[i]
- \printuntil }
- \printuntil }
-
- \include examples-run.qdocinc
-*/
-
diff --git a/examples/widgets/doc/src/easing.qdoc b/examples/widgets/doc/src/easing.qdoc
index c9f8752b93..79c985392c 100644
--- a/examples/widgets/doc/src/easing.qdoc
+++ b/examples/widgets/doc/src/easing.qdoc
@@ -4,6 +4,7 @@
/*!
\example animation/easing
\title Easing Curves Example
+ \examplecategory {Multimedia}
\brief The Easing Curves example shows how to use easing curves to
control the speed of an animation.
diff --git a/examples/widgets/doc/src/echoplugin.qdoc b/examples/widgets/doc/src/echoplugin.qdoc
deleted file mode 100644
index 4cdd700534..0000000000
--- a/examples/widgets/doc/src/echoplugin.qdoc
+++ /dev/null
@@ -1,181 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example tools/echoplugin
- \title Echo Plugin Example
- \ingroup examples-widgets-tools
- \ingroup examples-layout
-
- \brief This example shows how to create a Qt plugin.
-
- \image echopluginexample.png
-
- There are two kinds of plugins in Qt: plugins that extend Qt
- itself and plugins that extend applications written in Qt. In this
- example, we show the procedure of implementing plugins that extend
- applications. When you create a plugin you declare an interface,
- which is a class with only pure virtual functions. This interface
- is inherited by the class that implements the plugin. The class is
- stored in a shared library and can therefore be loaded by
- applications at run-time. When loaded, the plugin is dynamically
- cast to the interface using Qt's \l{Meta-Object
- System}{meta-object system}. The plugin \l{How to Create Qt
- Plugins}{overview document} gives a high-level introduction to
- plugins.
-
- We have implemented a plugin, the \c EchoPlugin, which implements
- the \c EchoInterface. The interface consists of \c echo(), which
- takes a QString as argument. The \c EchoPlugin returns the string
- unaltered (i.e., it works as the familiar echo command found in
- both Unix and Windows).
-
- We test the plugin in \c EchoWindow: when you push the QPushButton
- (as seen in the image above), the application sends the text in
- the QLineEdit to the plugin, which echoes it back to the
- application. The answer from the plugin is displayed in the
- QLabel.
-
-
- \section1 EchoWindow Class Definition
-
- The \c EchoWindow class lets us test the \c EchoPlugin through a
- GUI.
-
- \snippet tools/echoplugin/echowindow/echowindow.h 0
-
- We load the plugin in \c loadPlugin() and cast it to \c
- EchoInterface. When the user clicks the \c button we take the
- text in \c lineEdit and call the interface's \c echo() with it.
-
-
- \section1 EchoWindow Class Implementation
-
- We start with a look at the constructor:
-
- \snippet tools/echoplugin/echowindow/echowindow.cpp 0
-
- We create the widgets and set a title for the window. We then load
- the plugin. \c loadPlugin() returns false if the plugin could not
- be loaded, in which case we disable the widgets. If you wish a
- more detailed error message, you can use
- \l{QPluginLoader::}{errorString()}; we will look more closely at
- QPluginLoader later.
-
- Here is the implementation of \c sendEcho():
-
- \snippet tools/echoplugin/echowindow/echowindow.cpp 1
-
- This slot is called when the user pushes \c button or presses
- enter in \c lineEdit. We call \c echo() of the echo interface. In
- our example this is the \c EchoPlugin, but it could be any plugin
- that inherit the \c EchoInterface. We take the QString returned
- from \c echo() and display it in the \c label.
-
- Here is the implementation of \c createGUI():
-
- \snippet tools/echoplugin/echowindow/echowindow.cpp 2
-
- We create the widgets and lay them out in a grid layout. We
- connect the label and line edit to our \c sendEcho() slot.
-
- Here is the \c loadPlugin() function:
-
- \snippet tools/echoplugin/echowindow/echowindow.cpp 3
-
- Access to plugins at run-time is provided by QPluginLoader. You
- supply it with the filename of the shared library the plugin is
- stored in and call \l{QPluginLoader::}{instance()}, which loads
- and returns the root component of the plugin (i.e., it resolves
- the type of the plugin and creates a QObject instance of it). If
- the plugin was not successfully loaded, it will be null, so we
- return false. If it was loaded correctly, we can cast the plugin
- to our \c EchoInterface and return true. In the case that the
- plugin loaded does not implement the \c EchoInterface, \c
- instance() will return null, but this cannot happen in our
- example. Notice that the location of the plugin is not the same
- for all platforms.
-
-
- \section1 EchoInterface Class Definition
-
- The \c EchoInterface defines the functions that the plugin will
- provide. An interface is a class that only consists of pure
- virtual functions. If non virtual functions were present in the
- class you would get misleading compile errors in the moc files.
-
- \snippet tools/echoplugin/echowindow/echointerface.h 0
-
- We declare \c echo(). In our \c EchoPlugin we use this method to
- return, or echo, \a message.
-
- We use the Q_DECLARE_INTERFACE macro to let \l{Meta-Object
- System}{Qt's meta object system} aware of the interface. We do
- this so that it will be possible to identify plugins that
- implements the interface at run-time. The second argument is a
- string that must identify the interface in a unique way.
-
-
- \section1 EchoPlugin Class Definition
-
- We inherit both QObject and \c EchoInterface to make this class a
- plugin. The Q_INTERFACES macro tells Qt which interfaces the class
- implements. In our case we only implement the \c EchoInterface.
- If a class implements more than one interface, they are given as
- a space separated list. The Q_PLUGIN_METADATA macro is included next
- to the Q_OBJECT macro. It contains the plugins IID and a filename
- pointing to a json file containing the metadata for the plugin.
- The json file is compiled into the plugin and does not need to be installed.
-
- \snippet tools/echoplugin/plugin/echoplugin.h 0
-
- \section1 EchoPlugin Class Implementation
-
- Here is the implementation of \c echo():
-
- \snippet tools/echoplugin/plugin/echoplugin.cpp 0
-
- We simply return the functions parameter.
-
- \section1 The \c main() function
-
- \snippet tools/echoplugin/echowindow/main.cpp 0
-
- We create an \c EchoWindow and display it as a top-level window.
-
- \section1 The Profiles
-
- When creating plugins the profiles need to be adjusted.
- We show here what changes need to be done.
-
- The profile in the echoplugin directory uses the \c subdirs
- template and simply includes includes to directories in which
- the echo window and echo plugin lives:
-
- \snippet tools/echoplugin/echoplugin.pro 0
-
- The profile for the echo window does not need any plugin specific
- settings. We move on to the plugin profile:
-
- \snippet tools/echoplugin/plugin/plugin.pro 0
-
- We need to set the TEMPLATE as we now want to make a library
- instead of an executable. We also need to tell qmake that we are
- creating a plugin. The \c EchoInterface that the plugin implements
- lives in the \c echowindow directory, so we need to add that
- directory to the include path. We set the TARGET of the project,
- which is the name of the library file in which the plugin will be
- stored; qmake appends the appropriate file extension depending on
- the platform. By convention the target should have the same name
- as the plugin (set with Q_EXPORT_PLUGIN2)
-
- \section1 Further Reading and Examples
-
- The \l {qtplugin-defining-plugins}{Defining Plugins} page presents an overview of the macros needed to
- create plugins.
-
- We give an example of a plugin that extends Qt in the \l{Style
- Plugin Example}{style plugin} example. The \l{Plug & Paint
- Example}{plug and paint} example shows how to create static
- plugins.
-*/
diff --git a/examples/widgets/doc/src/editabletreemodel.qdoc b/examples/widgets/doc/src/editabletreemodel.qdoc
index 9616610758..15df678c87 100644
--- a/examples/widgets/doc/src/editabletreemodel.qdoc
+++ b/examples/widgets/doc/src/editabletreemodel.qdoc
@@ -4,9 +4,10 @@
/*!
\example itemviews/editabletreemodel
\title Editable Tree Model Example
+ \examplecategory {User Interface Components}
\ingroup examples-itemviews
\brief This example shows how to implement a simple item-based tree model that can
- be used with other classes the model/view framework.
+ be used with other classes in the model/view framework.
\image itemviews-editabletreemodel.png
@@ -229,32 +230,30 @@
internal \c childItems member using the \c insertChildren() function
described later.
- The destructor ensures that each child added to the item is deleted
- when the item itself is deleted:
-
- \snippet itemviews/editabletreemodel/treeitem.cpp 1
+ The children are stored in std::unique_ptr to ensures that each child
+ added to the item is deleted when the item itself is deleted.
\target TreeItem::parent
Since each item stores a pointer to its parent, the \c parent() function
is trivial:
- \snippet itemviews/editabletreemodel/treeitem.cpp 9
+ \snippet itemviews/editabletreemodel/treeitem.cpp 8
\target TreeItem::child
Three functions provide information about the children of an item.
\c child() returns a specific child from the internal list of children:
- \snippet itemviews/editabletreemodel/treeitem.cpp 2
+ \snippet itemviews/editabletreemodel/treeitem.cpp 1
The \c childCount() function returns the total number of children:
- \snippet itemviews/editabletreemodel/treeitem.cpp 3
+ \snippet itemviews/editabletreemodel/treeitem.cpp 2
The \c childNumber() function is used to determine the index of the child
in its parent's list of children. It accesses the parent's \c childItems
member directly to obtain this information:
- \snippet itemviews/editabletreemodel/treeitem.cpp 4
+ \snippet itemviews/editabletreemodel/treeitem.cpp 3
The root item has no parent item; for this item, we return zero to be
consistent with the other items.
@@ -262,20 +261,20 @@
The \c columnCount() function simply returns the number of elements in
the internal \c itemData list of QVariant objects:
- \snippet itemviews/editabletreemodel/treeitem.cpp 5
+ \snippet itemviews/editabletreemodel/treeitem.cpp 4
\target TreeItem::data
Data is retrieved using the \c data() function, which accesses the
appropriate element in the \c itemData list:
- \snippet itemviews/editabletreemodel/treeitem.cpp 6
+ \snippet itemviews/editabletreemodel/treeitem.cpp 5
\target TreeItem::setData
Data is set using the \c setData() function, which only stores values
in the \c itemData list for valid list indexes, corresponding to column
values in the model:
- \snippet itemviews/editabletreemodel/treeitem.cpp 11
+ \snippet itemviews/editabletreemodel/treeitem.cpp 10
To make implementation of the model easier, we return true to indicate
that the data was set successfully.
@@ -285,20 +284,20 @@
in the model leads to the insertion of new child items in the corresponding
item, handled by the \c insertChildren() function:
- \snippet itemviews/editabletreemodel/treeitem.cpp 7
+ \snippet itemviews/editabletreemodel/treeitem.cpp 6
This ensures that new items are created with the required number of columns
and inserted at a valid position in the internal \c childItems list.
Items are removed with the \c removeChildren() function:
- \snippet itemviews/editabletreemodel/treeitem.cpp 10
+ \snippet itemviews/editabletreemodel/treeitem.cpp 9
As discussed above, the functions for inserting and removing columns are
used differently to those for inserting and removing child items because
they are expected to be called on every item in the tree. We do this by
recursively calling this function on each child of the item:
- \snippet itemviews/editabletreemodel/treeitem.cpp 8
+ \snippet itemviews/editabletreemodel/treeitem.cpp 7
\section1 TreeModel Class Definition
@@ -334,11 +333,12 @@
use with the model. Other models may be initialized with a ready-made
data structure, or use an API from a library that maintains its own data.
- The destructor only has to delete the root item, which will cause all child
- items to be recursively deleted.
-
\snippet itemviews/editabletreemodel/treemodel.cpp 1
+ The destructor only has to delete the root item, which will cause all child
+ items to be recursively deleted. This is done automatically by the default
+ destructor since the root item is stored inside an unique_ptr.
+
\target TreeModel::getItem
Since the model's interface to the other model/view components is based
on model indexes, and since the internal data structure is item-based,
@@ -419,4 +419,20 @@
\target TreeModel::data
\target TreeModel::setupModelData
+ \section1 Testing the model
+
+ Correctly implementing an item model can be challenging. The class
+ \l [QtTest] QAbstractItemModelTester from the \l [QtTest]{Qt Test} module
+ checks for model consistency, like the model index creation and
+ parent-child relationships.
+
+ You can test your model by just passing a model instance to the class
+ constructor, for instance as part of a Qt unit test:
+
+ \snippet itemviews/editabletreemodel/test.cpp 1
+
+ To create a test which can be run using the \c ctest executable,
+ \c add_test() is used:
+
+ \snippet itemviews/editabletreemodel/CMakeLists.txt 1
*/
diff --git a/examples/widgets/doc/src/elasticnodes.qdoc b/examples/widgets/doc/src/elasticnodes.qdoc
index fbe506468a..c25fd68009 100644
--- a/examples/widgets/doc/src/elasticnodes.qdoc
+++ b/examples/widgets/doc/src/elasticnodes.qdoc
@@ -4,6 +4,7 @@
/*!
\example graphicsview/elasticnodes
\title Elastic Nodes Example
+ \examplecategory {Graphics}
\ingroup examples-graphicsview
\brief Demonstrates how to interact with graphical items in a scene.
@@ -235,7 +236,7 @@
This ensures that the edge items are not considered for mouse input at all
(i.e., you cannot click the edges). Then, the source and destination
pointers are updated, this edge is registered with each node, and we call
- \c adjust() to update this edge's start end end position.
+ \c adjust() to update this edge's start and end position.
\snippet graphicsview/elasticnodes/edge.cpp 1
diff --git a/examples/widgets/doc/src/elidedlabel.qdoc b/examples/widgets/doc/src/elidedlabel.qdoc
deleted file mode 100644
index 5820ddf2b1..0000000000
--- a/examples/widgets/doc/src/elidedlabel.qdoc
+++ /dev/null
@@ -1,131 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/elidedlabel
- \title Elided Label Example
-
- \brief This example creates a widget similar to QLabel, that elides the last
- visible line, if the text is too long to fit the widget's geometry.
-
- \image elidedlabel-example.png Elided Label example on XPressMusic 5800
-
- When text of varying length has to be displayed in a uniformly sized
- area, for instance within a list or grid view where all list items have the
- same size, it can be useful to give the user a visual clue when not all
- text is visible. QLabel can elide text that doesn't fit within it, but only
- in one line. The \c ElidedLabel widget shown in this example word wraps its
- text by its width, and elides the last visible line if some text is left
- out. \c TestWidget gives control to the features of \c ElidedWidget and
- forms the example application.
-
-
- \section1 ElidedLabel Class Definition
-
- Like QLabel, \c ElidedLabel inherits from QFrame. Here's the definition of
- the \c ElidedLabel class:
-
-
- \snippet widgets/elidedlabel/elidedlabel.h 0
-
- The \c isElided property depends the font, text content and geometry of the
- widget. Whenever any of these change, the \c elisionChanged() signal might
- trigger. We cache the current elision value in \c elided, so that it
- doesn't have to be recomputed every time it's asked for.
-
-
- \section1 ElidedLabel Class Implementation
-
- Except for initializing the member variables, the constructor sets the size
- policy to be horizontally expanding, since it's meant to fill the width of
- its container and grow vertically.
-
- \snippet widgets/elidedlabel/elidedlabel.cpp 0
-
- Changing the \c content require a repaint of the widget.
-
- \snippet widgets/elidedlabel/elidedlabel.cpp 1
-
- QTextLayout is used in the \c paintEvent() to divide the \c content into
- lines, that wrap on word boundaries. Each line, except the last visible
- one, is drawn \c lineSpacing pixels below the previous one. The \c draw()
- method of QTextLine will draw the line using the coordinate point as the
- top left corner.
-
- \snippet widgets/elidedlabel/elidedlabel.cpp 2
-
- Unfortunately, QTextLayout does not elide text, so the last visible line
- has to be treated differently. This last line is elided if it is too wide.
- The \c drawText() method of QPainter draws the text starting from the base
- line, which is \c ascecnt() pixels below the last drawn line.
-
- Finally, one more line is created to see if everything fit on this line.
-
- \snippet widgets/elidedlabel/elidedlabel.cpp 3
-
- If the text was elided and wasn't before or vice versa, cache it in
- \c elided and emit the change.
-
- \snippet widgets/elidedlabel/elidedlabel.cpp 4
-
-
- \section1 TestWidget Class Definition
-
- \c TestWidget is a QWidget and is the main window of the example. It
- contains an \c ElidedLabel which can be resized with two QSlider widgets.
-
- \snippet widgets/elidedlabel/testwidget.h 0
-
- \section1 TestWidget Class Implementation
-
- The constructor initializes the whole widget. Strings of different length
- are stored in \c textSamples. The user is able to switch between these.
-
- \snippet widgets/elidedlabel/testwidget.cpp 0
-
- An \c ElidedLabel is created to contain the first of the sample strings.
- The frame is made visible to make it easier to see the actual size of the
- widget.
-
- \snippet widgets/elidedlabel/testwidget.cpp 1
-
- The buttons and the elision label are created. By connecting the
- \c elisionChanged() signal to the \c setVisible() slot of the \c label,
- it will act as an indicator to when the text is elided or not. This signal
- could, for instance, be used to make a "More" button visible, or similar.
-
- \snippet widgets/elidedlabel/testwidget.cpp 2
-
- The \c widthSlider and \c heightSlider specify the size of the
- \c elidedText. Since the y-axis is inverted, the \c heightSlider has to be
- inverted to act appropriately.
-
- \snippet widgets/elidedlabel/testwidget.cpp 3
-
- The components are all stored in a QGridLayout, which is made the layout of
- the \c TestWidget.
-
- \snippet widgets/elidedlabel/testwidget.cpp 4
-
- The \c widthSlider and \c heightSlider have the exact same length as the
- dimensions of the \c elidedText. The maximum value for both of them is
- thus their lengths, and each tick indicates one pixel.
-
- \snippet widgets/elidedlabel/testwidget.cpp 6
-
- The \c switchText() slot simply cycles through all the available sample
- texts.
-
- \snippet widgets/elidedlabel/testwidget.cpp 7
-
- These slots set the width and height of the \c elided text, in response to
- changes in the sliders.
-
- \section1 The \c main() Function
-
- The \c main() function creates an instance of \c TestWidget fullscreen and
- enters the message loop.
-
- \snippet widgets/elidedlabel/main.cpp 0
-*/
-
diff --git a/examples/widgets/doc/src/embeddeddialogs.qdoc b/examples/widgets/doc/src/embeddeddialogs.qdoc
deleted file mode 100644
index 09df334c77..0000000000
--- a/examples/widgets/doc/src/embeddeddialogs.qdoc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example graphicsview/embeddeddialogs
- \title Embedded Dialogs
- \ingroup examples-graphicsview-layout
- \brief Demonstrates how to embed dialogs into a graphics view.
-
- This example shows how to embed standard dialogs into
- Graphics View. It also shows how you can customize the
- proxy class and add window shadows.
-
- \image embeddeddialogs-demo.png
-*/
diff --git a/examples/widgets/doc/src/extension.qdoc b/examples/widgets/doc/src/extension.qdoc
deleted file mode 100644
index 8f35e0e196..0000000000
--- a/examples/widgets/doc/src/extension.qdoc
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example dialogs/extension
- \title Extension Example
- \ingroup examples-dialogs
-
- \brief The Extension example shows how to add an extension to a QDialog
- using the QAbstractButton::toggled() signal and the
- QWidget::setVisible() slot.
-
- \image extension-example.png Screenshot of the Extension example
-
- The Extension application lets the user add search parameters in
- a dialog and launch a simple or advanced search.
-
- The simple search has two options: \uicontrol {Match case} and \uicontrol
- {Search from start}. The advanced search offers search for \uicontrol {Whole words},
- \uicontrol {Search backward}, and \uicontrol {Search selection}. The
- application starts with simple search as the default. Click the \uicontrol More button
- to show the advanced search options:
-
- \image extension_more.png Screenshot of the Extension example
-
- \section1 FindDialog Class Definition
-
- The \c FindDialog class inherits QDialog. QDialog is the
- base class for dialog windows. A dialog window is a top-level
- window mostly used for short-term tasks and brief communications
- with the user.
-
- \snippet dialogs/extension/finddialog.h 0
-
- The \c FindDialog widget is the main application widget, and
- displays the application's search options and controlling
- buttons.
-
- In addition to the constructor, there are several child widgets:
-
- \list
- \li A QLineEdit with an associated QLabel to let the
- user type a word to search for.
- \li Several \l {QCheckBox}{QCheckBox}es to facilitate the search options.
- \li Three \l {QPushButton}{QPushButton}s:
- \list
- \li the \uicontrol Find button to start a search
- \li the \uicontrol More button to enable an advanced search
- \li a QWidget representing the application's extension part
- \endlist
- \endlist
-
- \section1 FindDialog Class Implementation
-
- Create the standard child widgets for the simple search in the constructor:
- the QLineEdit with the associated QLabel, two {QCheckBox}es and all the
- \l {QPushButton}{QPushButton}s.
-
- \snippet dialogs/extension/finddialog.cpp 0
-
- This snippet illustrates how you can define a shortcut key
- for a widget. A shortcut should be defined by putting the ampersand
- character (\c &) in front of the letter that should
- become the shortcut.
- For example, for \uicontrol {Find what}, pressing \uicontrol Alt
- and \uicontrol w transfers focus to the QLineEdit widget.
- Shortcuts can also be used for checking on or off a checkmark.
- For example, pressing \uicontrol Alt and \uicontrol c puts the check mark
- on \uicontrol {Match Case} if it was unchecked and vice versa.
- It is the QLabel::setBuddy() method that links a widget to the shortcut
- character if it has been defined.
-
- Set the \uicontrol Find button's default property to true, using the
- QPushButton::setDefault() function. Then the push button will be
- pressed if the user presses the Enter (or Return) key. Note that a
- QDialog can only have one default button.
-
- \snippet dialogs/extension/finddialog.cpp 2
-
- Create the extension widget, and the \l {QCheckBox}{QCheckBox}es associated
- with the advanced search options.
-
- \snippet dialogs/extension/finddialog.cpp 3
-
- Now that the extension widget is created, connect the \uicontrol
- More button's \l{QAbstractButton::toggled()}{toggled()} signal to
- the extension widget's \l{QWidget::setVisible()}{setVisible()} slot.
-
- The QAbstractButton::toggled() signal is emitted whenever a
- checkable button changes its state. The signal's argument is true
- if the button is checked, or false if the button is unchecked. The
- QWidget::setVisible() slot sets the widget's visible status. If
- the status is true the widget is shown, otherwise the widget is
- hidden.
-
- Since the \uicontrol More button is checkable, the connection makes
- sure that the extension widget is shown depending on the state of
- the \uicontrol More button.
-
- Create checkboxes associated with the advanced search options in
- a layout installed on the extension widget.
-
- \snippet dialogs/extension/finddialog.cpp 4
-
- Before creating the main layout, create several child layouts
- for the widgets. First align the QLabel and its buddy, the
- QLineEdit, using a QHBoxLayout. Then align the QLabel and the QLineEdit
- vertically with the checkboxes associated with the simple search,
- using a QVBoxLayout. Create also a QVBoxLayout for the buttons.
- Finally, lay out the two latter layouts and the extension widget
- using a QGridLayout.
-
- \snippet dialogs/extension/finddialog.cpp 5
-
- Hide the extension widget using the QWidget::hide()
- function, making the application only show the simple search
- options when it starts. When the user wants to access the advanced
- search options, the dialog only needs to change the visibility of
- the extension widget. Qt's layout management takes care of the
- dialog's appearance.
-*/
diff --git a/examples/widgets/doc/src/fademessage.qdoc b/examples/widgets/doc/src/fademessage.qdoc
deleted file mode 100644
index bd46593ad3..0000000000
--- a/examples/widgets/doc/src/fademessage.qdoc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example effects/fademessage
- \title Fade Message Effect Example
- \ingroup examples-graphicsview-graphicseffects
- \brief Demonstrates how to apply effects on items in the view.
-
- \div { style="text-align: left"}
- \inlineimage fademessageeffect-example.png
- \inlineimage fademessageeffect-example-faded.png
- \enddiv
-
-*/
diff --git a/examples/widgets/doc/src/fetchmore.qdoc b/examples/widgets/doc/src/fetchmore.qdoc
index 1e80e803d5..d8dae18f33 100644
--- a/examples/widgets/doc/src/fetchmore.qdoc
+++ b/examples/widgets/doc/src/fetchmore.qdoc
@@ -4,6 +4,7 @@
/*!
\example itemviews/fetchmore
\title Fetch More Example
+ \examplecategory {User Interface Components}
\ingroup examples-itemviews
\brief The Fetch More example shows how to add items to an item view
model on demand.
diff --git a/examples/widgets/doc/src/findfiles.qdoc b/examples/widgets/doc/src/findfiles.qdoc
deleted file mode 100644
index bed831d14d..0000000000
--- a/examples/widgets/doc/src/findfiles.qdoc
+++ /dev/null
@@ -1,269 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example dialogs/findfiles
- \title Find Files Example
- \ingroup examples-dialogs
-
- \brief A dialog for finding files in a specified folder.
-
- The Find Files application allows the user to search for files in a
- specified directory, matching a given file name or wildcard,
- and containing a specified string (if filled in). The search
- result is displayed in a table containing the names of the files
- and their sizes. The application also shows the number of files found.
-
- The Find Files example illustrates the use of several classes:
-
- \table
- \row
- \li QProgressDialog
- \li Provide feedback on the progress of a search operation
- \row
- \li QFileDialog
- \li Browse through a file list
- \row
- \li QTextStream
- \li Use stream operators to read a file
- \row
- \li QTableWidget
- \li Browse through the search results in a table
- \row
- \li QDesktopServices
- \li Open files in the result list in a suitable application
- \endtable
-
- \image findfiles-example.png Screenshot of the Find Files example
-
-
- \section1 Window Class Definition
-
- The \c Window class inherits QWidget, and is the main application
- widget. It shows the search options and displays the search
- results.
-
- \snippet dialogs/findfiles/window.h 0
-
- The application has two private slots:
- \table
- \row
- \li The \c browse() slot
- \li Called whenever the user wants to browse for a directory to search in
- \row
- \li The \c find() slot
- \li Called whenever the user launches a search with the \uicontrol Find button
- \endtable
-
- In addition we declare several private functions:
-
- \table
- \row
- \li findFiles()
- \li Search for files matching the search parameters
- \row
- \li showFiles()
- \li Display the search result
- \row
- \li ceateButton()
- \li Construct the widget
- \row
- \li createComboBox()
- \li Construct the widget
- \row
- \li createFilesTable()
- \li Construct the widget
- \endtable
-
- \section1 Window Class Implementation
-
- In the constructor we first create the application's widgets.
-
- \snippet dialogs/findfiles/window.cpp 0
-
- We create the widgets to build up the UI, and we add them to a main layout
- using QGridLayout. We have, however, put the \c Find and \c Quit buttons
- and a stretchable space in a separate \l QHBoxLayout first, to make the
- buttons appear in the \c Window widget's bottom right corner.
-
- Alternatively, we could have used Qt Designer to construct a UI file,
- and \l {uic} to generate this code.
-
- \snippet dialogs/findfiles/window.cpp 1
-
- We did not create a \l QMenuBar with a \uicontrol Quit menu item; but we
- would still like to have a keyboard shortcut for quitting. Since we
- construct a \l QShortcut with \l QKeySequence::Quit, and connect it to
- \l QApplication::quit(), on most platforms it will be possible to press
- Control-Q to quit (or whichever standard Quit key is configured on that platform).
- (On \macos, this is redundant, because every application gets a
- \uicontrol Quit menu item automatically; but it helps to make the application portable.)
-
- \snippet dialogs/findfiles/window.cpp 2
-
- The \c browse() slot presents a file dialog to the user, using the
- QFileDialog class. QFileDialog enables a user to traverse the file
- system in order to select one or many files or a directory. The
- easiest way to create a QFileDialog is to use the convenience
- static functions.
-
- Here we use the static QFileDialog::getExistingDirectory()
- function which returns an existing directory selected by the
- user. Then we display the directory in the directory combobox
- using the QComboBox::addItem() function and update the current
- index.
-
- QComboBox::addItem() adds an item to the combobox with the given
- text (if not already present in the list), and containing
- the specified userData. The item is appended to the list of
- existing items.
-
- \snippet dialogs/findfiles/window.cpp 3
-
- The \c find() slot is called whenever the user requests a new
- search by pressing the \uicontrol Find button.
-
- First we eliminate any previous search results by setting the
- table widgets row count to zero. Then we retrieve the
- specified file name, text, and directory path from the respective
- comboboxes.
-
- \snippet dialogs/findfiles/window.cpp 4
-
- We use the directory's path to create a QDir; the QDir class
- provides access to the directory structure and its contents.
-
- We use QDirIterator to iterate over the files that match the
- specified file name and build a QStringList of paths.
-
- Then we search through all the files in the list, using the private
- \c findFiles() function, eliminating the ones that don't contain the
- specified text. We sort them (because QDirIterator did not). And finally,
- we display the results using the private \c showFiles() function.
-
- If the user didn't specify any text, there is no reason to search
- through the files, so we sort and display the results immediately.
-
- \image findfiles_progress_dialog.png Screenshot of the Progress Dialog
-
- \snippet dialogs/findfiles/window.cpp 5
-
- In the private \c findFiles() function we search through a list of
- files, looking for the ones that contain a specified text. This
- can be a very slow operation depending on the number of files as
- well as their sizes. QProgressDialog displays a progress dialog
- if the application has to search through a large number of files,
- or if some of the files have a large size. QProgressDialog can
- also allow the user to abort the operation if it takes too much
- time.
-
- \snippet dialogs/findfiles/window.cpp 6
-
- We run through the files, one at a time, and for each file we
- update the QProgressDialog value. This property holds the current
- amount of progress made. We also update the progress dialog's
- label.
-
- Then we call the QCoreApplication::processEvents() function using
- the QApplication object. In this way we interleave the display of
- the progress made with the process of searching through the files
- so the application doesn't appear to be frozen.
-
- The QApplication class manages the GUI application's control flow
- and main settings. It contains the main event loop, where all
- events from the window system and other sources are processed and
- dispatched. QApplication inherits QCoreApplication. The
- QCoreApplication::processEvents() function processes all pending
- events according to the specified QEventLoop::ProcessEventFlags
- until there are no more events to process. The default flags are
- QEventLoop::AllEvents.
-
- \snippet dialogs/findfiles/window.cpp 7
-
- After updating the QProgressDialog, we open the file in read-only
- mode, and read one line at a time using QTextStream.
-
- The QTextStream class provides a convenient interface for reading
- and writing text. Using QTextStream's streaming operators, you can
- conveniently read and write words, lines and numbers.
-
- For each line we read we check if the QProgressDialog has been
- canceled. If it has, we abort the operation, otherwise we check if
- the line contains the specified text. When we find the text within
- one of the files, we add the file's name to a list of found files
- that contain the specified text, and start searching a new file.
-
- Finally, we return the list of the files found.
-
- \snippet dialogs/findfiles/window.cpp 8
-
- Both the \c findFiles() and \c showFiles() functions are called from
- the \c find() slot. In the \c showFiles() function we run through
- the provided list of file names, adding each relative file name to the
- first column in the table widget and retrieving the file's size using
- QFileInfo for the second column. We use \l QLocale::formattedDataSize()
- to format the file size in a human-readable form. For later use, we set
- the absolute path as a data on the QTableWidget using the
- the role absoluteFileNameRole defined to be Qt::UserRole + 1.
-
- \snippet dialogs/findfiles/window.cpp 17
-
- This allows for retrieving the name of an item using a
- convenience function:
-
- \snippet dialogs/findfiles/window.cpp 18
-
- We also update the total number of files found.
-
- \snippet dialogs/findfiles/window.cpp 10
-
- The private \c createComboBox() function is also called from the
- constructor. We create a QComboBox with the given text, and make it
- editable.
-
- When the user enters a new string in an editable combobox, the
- widget may or may not insert it, and it can insert it in several
- locations, depending on the QComboBox::InsertPolicy. The default
- policy is is QComboBox::InsertAtBottom.
-
- Then we add the provided text to the combobox, and specify the
- widget's size policies, before we return a pointer to the
- combobox.
-
- \snippet dialogs/findfiles/window.cpp 11
-
- The private \c createFilesTable() function is called from the
- constructor. In this function we create the QTableWidget that
- will display the search results. We set its horizontal headers and
- their resize mode.
-
- QTableWidget inherits QTableView which provides a default
- model/view implementation of a table view. The
- QTableView::horizontalHeader() function returns the table view's
- horizontal header as a QHeaderView. The QHeaderView class provides
- a header row or header column for item views, and the
- QHeaderView::setResizeMode() function sets the constraints on how
- the section in the header can be resized.
-
- Finally, we hide the QTableWidget's vertical headers using the
- QWidget::hide() function, and remove the default grid drawn for
- the table using the QTableView::setShowGrid() function.
-
- \snippet dialogs/findfiles/window.cpp 12
-
- \snippet dialogs/findfiles/window.cpp 14
-
- The \c openFileOfItem() slot is invoked when the user double
- clicks on a cell in the table. The QDesktopServices::openUrl()
- knows how to open a file given the file name.
-
- \snippet dialogs/findfiles/window.cpp 15
- \snippet dialogs/findfiles/window.cpp 16
-
- We set the context menu policy to of the table view to Qt::CustomContextMenu
- and connect a slot contextMenu() to its signal
- customContextMenuRequested(). We retrieve the absolute file name
- from the data of the QTableWidgetItem and populate the context menu
- with actions offering to copy the file name and to open the file.
-*/
-
diff --git a/examples/widgets/doc/src/flowlayout.qdoc b/examples/widgets/doc/src/flowlayout.qdoc
index 5a3316b6e4..03dfc164d7 100644
--- a/examples/widgets/doc/src/flowlayout.qdoc
+++ b/examples/widgets/doc/src/flowlayout.qdoc
@@ -4,6 +4,7 @@
/*!
\example layouts/flowlayout
\title Flow Layout Example
+ \examplecategory {User Interface Components}
\ingroup examples-layout
\brief Shows how to arrange widgets for different window sizes.
diff --git a/examples/widgets/doc/src/fontsampler.qdoc b/examples/widgets/doc/src/fontsampler.qdoc
deleted file mode 100644
index 3b014b5713..0000000000
--- a/examples/widgets/doc/src/fontsampler.qdoc
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example painting/fontsampler
- \title Font Sampler Example
- \ingroup examples-painting
- \brief The Font Sampler example shows how to preview and print multi-page documents.
-
- The Font Sampler example shows how to preview and print multi-page documents.
-
- \image fontsampler-example.png
-*/
diff --git a/examples/widgets/doc/src/fridgemagnets.qdoc b/examples/widgets/doc/src/fridgemagnets.qdoc
deleted file mode 100644
index fccadd3b71..0000000000
--- a/examples/widgets/doc/src/fridgemagnets.qdoc
+++ /dev/null
@@ -1,338 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example draganddrop/fridgemagnets
- \title Fridge Magnets Example
- \brief The Fridge Magnets example illustrates how to move around several types of
- MIME-encoded data with drag and drop.
-
- The Fridge Magnets example shows how to supply more than one type
- of MIME-encoded data with a drag and drop operation.
-
- \image fridgemagnets-example.png
-
- With this application the user can play around with a collection
- of fridge magnets, using drag and drop to form new sentences from
- the words on the magnets. The example consists of two classes:
-
- \list
- \li \c DragLabel is a custom widget representing one
- single fridge magnet.
- \li \c DragWidget provides the main application window.
- \endlist
-
- We will first take a look at the \c DragLabel class, then we will
- examine the \c DragWidget class.
-
- \section1 DragLabel Class Definition
-
- Each fridge magnet is represented by an instance of the \c
- DragLabel class:
-
- \snippet draganddrop/fridgemagnets/draglabel.h 0
-
- Each instance of this QLabel subclass will be used to display an
- pixmap generated from a text string. Since we cannot store both
- text and a pixmap in a standard label, we declare a private variable
- to hold the original text, and we define an additional member
- function to allow it to be accessed.
-
- \section1 DragLabel Class Implementation
-
- In the \c DragLabel constructor, we first create a QImage object
- on which we will draw the fridge magnet's text and frame:
-
- \snippet draganddrop/fridgemagnets/draglabel.cpp 0
-
- Its size depends on the current font size, and its format is
- QImage::Format_ARGB32_Premultiplied; i.e., the image is stored
- using a premultiplied 32-bit ARGB format (0xAARRGGBB).
-
- We then construct a font object that uses the application's
- default font, and set its style strategy. The style strategy tells
- the font matching algorithm what type of fonts should be used to
- find an appropriate default family. The QFont::ForceOutline forces
- the use of outline fonts.
-
- To draw the text and frame onto the image, we use the QPainter
- class. QPainter provides highly optimized methods to do most of
- the drawing GUI programs require. It can draw everything from
- simple lines to complex shapes like pies and chords. It can also
- draw aligned text and pixmaps.
-
- \snippet draganddrop/fridgemagnets/draglabel.cpp 1
-
- A painter can be activated by passing a paint device to the
- constructor, or by using the \l{QPainter::}{begin()} method as we
- do in this example. The \l{QPainter::}{end()} method deactivates
- it. Note that the latter function is called automatically upon
- destruction when the painter is activated by its constructor. The
- QPainter::Antialiasing render hint ensures that the paint engine
- will antialias the edges of primitives if possible.
-
- When the painting is done, we convert our image to a pixmap using
- QPixmap's \l {QPixmap::}{fromImage()} method. This method also
- takes an optional flags argument, and converts the given image to
- a pixmap using the specified flags to control the conversion (the
- flags argument is a bitwise-OR of the Qt::ImageConversionFlags;
- passing 0 for flags sets all the default options).
-
- \snippet draganddrop/fridgemagnets/draglabel.cpp 2
-
- Finally, we set the label's \l{QLabel::pixmap}{pixmap property}
- and store the label's text for later use.
-
- \e{Note that setting the pixmap clears any previous content, including
- any text previously set using QLabel::setText(), and disables
- the label widget's buddy shortcut, if any.}
-
- \section1 DragWidget Class Definition
-
- The \c DragWidget class inherits QWidget, providing support for
- drag and drop operations:
-
- \snippet draganddrop/fridgemagnets/dragwidget.h 0
-
- To make the widget responsive to drag and drop operations, we simply
- reimplement the \l{QWidget::}{dragEnterEvent()},
- \l{QWidget::}{dragMoveEvent()} and \l{QWidget::}{dropEvent()} event
- handlers inherited from QWidget.
-
- We also reimplement \l{QWidget::}{mousePressEvent()} to make the
- widget responsive to mouse clicks. This is where we will write code
- to start drag and drop operations.
-
- \section1 DragWidget Class Implementation
-
- In the constructor, we first open the file containing the words on
- our fridge magnets:
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 0
-
- QFile is an I/O device for reading and writing text and binary
- files and resources, and may be used by itself or in combination
- with QTextStream or QDataStream. We have chosen to read the
- contents of the file using the QTextStream class that provides a
- convenient interface for reading and writing text.
-
- We then create the fridge magnets. As long as there is data (the
- QTextStream::atEnd() method returns true if there is no more data
- to be read from the stream), we read one line at a time using
- QTextStream's \l {QTextStream::}{readLine()} method.
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 1
-
- For each line, we create a \c DragLabel object using the read line
- as text, we calculate its position and ensure that it is visible by
- calling the QWidget::show() method. We set the Qt::WA_DeleteOnClose
- attribute on each label to ensure that any unused labels will be
- deleted; we will need to create new labels and delete old ones when
- they are dragged around, and this ensures that the example does not
- leak memory.
-
- We also set the \c FridgeMagnets widget's palette, minimum size
- and window title.
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 2
-
- Finally, to enable our user to move the fridge magnets around, we
- must also set the \c FridgeMagnets widget's
- \l{QWidget::acceptDrops}{acceptDrops} property.
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 3
-
- Setting this property to true announces to the system that this
- widget \e may be able to accept drop events (events that are sent
- when drag and drop actions are completed). Later, we will
- implement the functions that ensure that the widget accepts the
- drop events it is interested in.
-
- \section2 Dragging
-
- Let's take a look at the \l{QWidget::}{mousePressEvent()} event
- handler, where drag and drop operations begin:
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 13
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 14
-
- Mouse events occur when a mouse button is pressed or released
- inside a widget, or when the mouse cursor is moved. By
- reimplementing the \l{QWidget::}{mousePressEvent()} method we
- ensure that we will receive mouse press events for the widget
- containing the fridge magnets.
-
- Whenever we receive such an event, we first check to see if the
- position of the click coincides with one of the labels. If not,
- we simply return.
-
- If the user clicked a label, we determine the position of the
- \e{hot spot} (the position of the click relative to the top-left
- corner of the label). We create a byte array to store the label's
- text and the hot spot, and we use a QDataStream object to stream
- the data into the byte array.
-
- With all the information in place, we create a new QMimeData object.
- As mentioned above, QMimeData objects associate the data that they
- hold with the corresponding MIME types to ensure that information
- can be safely transferred between applications. The
- \l{QMimeData::}{setData()} method sets the data associated with a
- given MIME type. In our case, we associate our item data with the
- custom \c application/x-fridgemagnet type.
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 15
-
- Note that we also associate the magnet's text with the
- \c text/plain MIME type using QMimeData's \l{QMimeData::}{setText()}
- method. Below, we will see how our widget detects both these MIME
- types with its event handlers.
-
- Finally, we create a QDrag object. It is the QDrag class that
- handles most of the details of a drag and drop operation,
- providing support for MIME-based drag and drop data transfer. The
- data to be transferred by the drag and drop operation is contained
- in a QMimeData object. When we call QDrag's
- \l{QDrag::}{setMimeData()} method the ownership of our item data is
- transferred to the QDrag object.
-
- We call the \l{QDrag::}{setPixmap()} function to set the pixmap used
- to represent the data during the drag and drop operation.
- Typically, this pixmap shows an icon that represents the MIME type
- of the data being transferred, but any pixmap can be used. In this
- example, we simply use the pixmap used by the label itself to make
- it look like the fridge magnet itself is being moved.
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 16
-
- We also specify the cursor's hot spot, its position relative to the
- top-level corner of the drag pixmap, to be the point we calculated
- above. This makes the process of dragging the label feel more natural
- because the cursor always points to the same place on the label
- during the drag operation.
-
- We start the drag operation using QDrag's \l{QDrag::}{exec()} function,
- requesting that the magnet is copied when the drag is completed.
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 17
-
- The function returns the drop action actually performed by the user
- (this can be either a copy or a move action in this case); if this
- action is equal to Qt::MoveAction we will close the activated
- fridge magnet widget because we will create a new one to replace it
- (see the \l{drop}{dropEvent()} implementation). Otherwise, if
- the drop is outside our main widget, we simply show the widget in
- its original position.
-
- \section2 Dropping
-
- When a a drag and drop action enters our widget, we will receive a
- drag enter \e event. QDragEnterEvent inherits most of its
- functionality from QDragMoveEvent, which in turn inherits most of
- its functionality from QDropEvent. Note that we must accept this
- event in order to receive the drag move events that are sent while
- the drag and drop action is in progress. The drag enter event is
- always immediately followed by a drag move event.
-
- In our \c dragEnterEvent() implementation, we first determine
- whether we support the event's MIME type or not:
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 4
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 5
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 6
-
- If the type is \c application/x-fridgemagnet and the event
- origins from any of this application's fridge magnet widgets, we
- first set the event's drop action using the
- QDropEvent::setDropAction() method. An event's drop action is the
- action to be performed on the data by the target. Qt::MoveAction
- indicates that the data is moved from the source to the target.
-
- Then we call the event's \l {QDragMoveEvent::}{accept()} method to
- indicate that we have handled the event. In general, unaccepted
- events might be propagated to the parent widget. If the event
- origins from any other widget, we simply accept the proposed
- action.
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 7
-
- We also accept the proposed action if the event's MIME type is \c
- text/plain, i.e., if QMimeData::hasText() returns true. If the
- event has any other type, on the other hand, we call the event's
- \l {QDragMoveEvent::}{ignore()} method allowing the event to be
- propagated further.
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 8
-
- Drag move events occur when the cursor enters a widget, when it
- moves within the widget, and when a modifier key is pressed on the
- keyboard while the widget has focus. Our widget will receive drag
- move events repeatedly while a drag is within its boundaries. We
- reimplement the \l {QWidget::}{dragMoveEvent()} method, and
- examine the event in the exact same way as we did with drag enter
- events.
-
- Note that the \l{QWidget::}{dropEvent()} event handler behaves
- slightly differently: We first get hold of the event's MIME
- data.
-
- \target drop
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 9
-
- The QMimeData class provides a container for data that
- records information about its MIME type. QMimeData objects
- associate the data that they hold with the corresponding MIME
- types to ensure that information can be safely transferred between
- applications, and copied around within the same application.
-
- We retrieve the data associated with the \c application/x-fridgemagnet
- MIME type using a data stream in order to create a new \c DragLabel
- object.
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 10
-
- The QDataStream class provides serialization of binary data to a
- QIODevice (a data stream is a binary stream of encoded information
- which is completely independent of the host computer's operating
- system, CPU or byte order).
-
- Finally, we create a label and move it to the event's position:
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 11
-
- If the source of the event is also the widget receiving the
- drop event, we set the event's drop action to Qt::MoveAction and
- call the event's \l{QDragMoveEvent::}{accept()}
- method. Otherwise, we simply accept the proposed action. This
- means that labels are moved rather than copied in the same
- window. However, if we drag a label to a second instance of the
- Fridge Magnets example, the default action is to copy it, leaving
- the original in the first instance.
-
- If the event's MIME type is \c text/plain (i.e., if
- QMimeData::hasText() returns true) we retrieve its text and split
- it into words. For each word we create a new \c DragLabel action,
- and show it at the event's position plus an offset depending on
- the number of words in the text. In the end we accept the proposed
- action. This lets the user drop selected text from a text editor or
- Web browser onto the widget to add more fridge magnets.
-
- \snippet draganddrop/fridgemagnets/dragwidget.cpp 12
-
- If the event has any other type, we call the event's
- \l{QDragMoveEvent::}{ignore()} method allowing the event to be
- propagated further.
-
- \section1 Summary
-
- We set our main widget's \l{QWidget::}{acceptDrops} property
- and reimplemented QWidget's \l{QWidget::}{dragEnterEvent()},
- \l{QWidget::}{dragMoveEvent()} and \l{QWidget::}{dropEvent()} event
- handlers to support content dropped on our widget.
-
- In addition, we reimplemented the \l{QWidget::}{mousePressEvent()}
- function to let the user pick up fridge magnets in the first place.
-
- Because data is communicated using drag and drop operations and
- encoded using MIME types, you can run more than one instance of this
- example, and transfer magnets between them.
-*/
diff --git a/examples/widgets/doc/src/frozencolumn.qdoc b/examples/widgets/doc/src/frozencolumn.qdoc
index 54040bc9e1..c213ba1779 100644
--- a/examples/widgets/doc/src/frozencolumn.qdoc
+++ b/examples/widgets/doc/src/frozencolumn.qdoc
@@ -4,6 +4,7 @@
/*!
\example itemviews/frozencolumn
\title Frozen Column Example
+ \examplecategory {User Interface Components}
\ingroup examples-itemviews
\brief This example demonstrates how to freeze a column within a QTableView.
diff --git a/examples/widgets/doc/src/gallery.qdoc b/examples/widgets/doc/src/gallery.qdoc
index 5287fb5b53..36b76d8f63 100644
--- a/examples/widgets/doc/src/gallery.qdoc
+++ b/examples/widgets/doc/src/gallery.qdoc
@@ -5,6 +5,7 @@
\example gallery
\meta {tag} {gallery}
\title Widgets Gallery Example
+ \examplecategory {User Interface Components}
\ingroup examples-widgets
\brief The Widgets Gallery example shows widgets relevant for designing UIs.
diff --git a/examples/widgets/doc/src/gradients.qdoc b/examples/widgets/doc/src/gradients.qdoc
index 5a951ffb95..e2ad68db1a 100644
--- a/examples/widgets/doc/src/gradients.qdoc
+++ b/examples/widgets/doc/src/gradients.qdoc
@@ -4,6 +4,7 @@
/*!
\example painting/gradients
\title Gradients
+ \examplecategory {Graphics}
\ingroup examples-painting
\brief Shows how gradients can be used with QPainter.
diff --git a/examples/widgets/doc/src/graphicsview-anchorlayout.qdoc b/examples/widgets/doc/src/graphicsview-anchorlayout.qdoc
deleted file mode 100644
index ec74367f9b..0000000000
--- a/examples/widgets/doc/src/graphicsview-anchorlayout.qdoc
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example graphicsview/anchorlayout
- \title Anchor Layout Example
- \ingroup examples-graphicsview-layout
- \brief Demonstrates anchor layout in a graphics view scene.
-
- The Anchor Layout example demonstrates the use of the QGraphicsAnchorLayout
- class.
-
- \image graphicsanchorlayout-example.png
-
- The basic steps of this example are:
- \list
- \li Create a QGraphicsScene
- \li Create widgets
- \li Create a QGraphicsAnchorLayout
- \li Create a QGraphicsWidget
- \li Add vertical and horizontal anchors between the widgets
- \li View the scene with a QGraphicsView object
- \endlist
-
- \section1 Creating a QGraphicsScene
-
- \quotefromfile graphicsview/anchorlayout/main.cpp
- \skipto QGraphicsScene
- \printuntil setSceneRect
-
- \section1 Creating Widgets
-
- \skipto QGraphicsProxyWidget
- \printuntil *g
-
- \section1 Creating a Layout
-
- \skipto QGraphicsAnchorLayout
- \printuntil l->setSpacing
-
- \section1 Creating a QGraphicsWidget
-
- \skipto QGraphicsWidget
- \printuntil setLayout(l)
-
- \section1 Adding Anchors
-
- \skipto vertical
- \printuntil l->addAnchor(f, Qt::AnchorRight
-
- \section1 Viewing the Scene with QGraphicsView
-
- \skipto scene.addItem
- \printuntil view.show
-
- \sa {Simple Anchor Layout Example}
-*/
diff --git a/examples/widgets/doc/src/graphicsview-flowlayout.qdoc b/examples/widgets/doc/src/graphicsview-flowlayout.qdoc
deleted file mode 100644
index 179f3501df..0000000000
--- a/examples/widgets/doc/src/graphicsview-flowlayout.qdoc
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example graphicsview/flowlayout
- \title Graphics View Flow Layout Example
- \ingroup examples-graphicsview-layout
- \brief Demonstrates flow layout on a graphics view scene.
-
- The Graphics View Flow Layout example shows the use of a flow layout
- in a Graphics View widget.
-
- \image graphicsflowlayout-example.png
-
- This example uses a Graphics View to display the widget, which is a more
- customizable approach than displaying the flow layout in the application
- window (See \l {Flow Layout Example}).
-
- Graphics View Flow Layout snippet:
-
- \snippet graphicsview/flowlayout/main.cpp 1
-
- Flow Layout Example snippet:
-
- \snippet layouts/flowlayout/main.cpp 1
-
-
-*/
diff --git a/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc b/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc
index 3ecafa873e..ce5fe8934a 100644
--- a/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc
+++ b/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc
@@ -4,6 +4,7 @@
/*!
\example graphicsview/simpleanchorlayout
\title Simple Anchor Layout Example
+ \examplecategory {Graphics}
\ingroup examples-graphicsview-layout
\brief Demonstrates anchor layout on a graphics view scene.
@@ -55,6 +56,4 @@
\skipto QGraphicsWidget
\printuntil app.exec()
-
- \sa {Anchor Layout Example}
*/
diff --git a/examples/widgets/doc/src/graphicsview-weatheranchorlayout.qdoc b/examples/widgets/doc/src/graphicsview-weatheranchorlayout.qdoc
deleted file mode 100644
index 8dbf2356a0..0000000000
--- a/examples/widgets/doc/src/graphicsview-weatheranchorlayout.qdoc
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example graphicsview/weatheranchorlayout
- \title Weather Anchor Layout Example
- \ingroup examples-graphicsview-layout
- \brief Demonstrates anchor layout on a graphics view scene.
-
- The Weather Anchor Layout example shows more complex use of the
- QGraphicsAnchorLayout class to create a real-world window layout.
-
- \image weatheranchorlayout-example.png
-*/
diff --git a/examples/widgets/doc/src/groupbox.qdoc b/examples/widgets/doc/src/groupbox.qdoc
index 5c565f1cb5..aa339098ab 100644
--- a/examples/widgets/doc/src/groupbox.qdoc
+++ b/examples/widgets/doc/src/groupbox.qdoc
@@ -4,6 +4,7 @@
/*!
\example widgets/groupbox
\title Group Box Example
+ \examplecategory {User Interface Components}
\ingroup examples-widgets
\brief The Group Box example shows how to use the different kinds of group
boxes in Qt.
diff --git a/examples/widgets/doc/src/i18n.qdoc b/examples/widgets/doc/src/i18n.qdoc
deleted file mode 100644
index 6077691b92..0000000000
--- a/examples/widgets/doc/src/i18n.qdoc
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example tools/i18n
- \title I18N Example
- \ingroup examples-widgets-tools
-
- \brief The Internationalization (I18N) example demonstrates Qt's support for translated
- text. Developers can write the initial application text in one language, and
- translations can be provided later without any modifications to the code. It also
- demonstrates how to detect the system language settings and show the UI in the appropriate
- language.
-
- \image i18n-example.png
-*/
diff --git a/examples/widgets/doc/src/icons.qdoc b/examples/widgets/doc/src/icons.qdoc
deleted file mode 100644
index 8ec062ea43..0000000000
--- a/examples/widgets/doc/src/icons.qdoc
+++ /dev/null
@@ -1,805 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/icons
- \title Icons Example
- \ingroup examples-widgets
- \brief The Icons example shows how QIcon can generate pixmaps reflecting
- an icon's state, mode and size.
-
- These pixmaps are generated from the set of pixmaps made available to the
- icon, and are used by Qt widgets to show an icon representing a particular
- action.
-
- \image icons-example.png Screenshot of the Icons example
-
- Contents:
-
- \tableofcontents
-
- \section1 QIcon Overview
-
- The QIcon class provides scalable icons in different modes and
- states. An icon's state and mode are depending on the intended use
- of the icon. Qt currently defines four modes:
-
- \table
- \header \li Mode \li Description
- \row
- \li QIcon::Normal
- \li Display the pixmap when the user is not interacting with the
- icon, but the functionality represented by the icon is
- available.
- \row
- \li QIcon::Active
- \li Display the pixmap when the functionality represented by the
- icon is available and the user is interacting with the icon,
- for example, moving the mouse over it or clicking it.
- \row
- \li QIcon::Disabled
- \li Display the pixmap when the functionality represented by
- the icon is not available.
- \row
- \li QIcon::Selected
- \li Display the pixmap when the icon is selected.
- \endtable
-
- QIcon's states are QIcon::On and QIcon::Off, which will display
- the pixmap when the widget is in the respective state. The most
- common usage of QIcon's states are when displaying checkable tool
- buttons or menu entries (see QAbstractButton::setCheckable() and
- QAction::setCheckable()). When a tool button or menu entry is
- checked, the QIcon's state is \l{QIcon::}{On}, otherwise it's
- \l{QIcon::}{Off}. You can, for example, use the QIcon's states to
- display differing pixmaps depending on whether the tool button or
- menu entry is checked or not.
-
- A QIcon can generate smaller, larger, active, disabled, and
- selected pixmaps from the set of pixmaps it is given. Such
- pixmaps are used by Qt widgets to show an icon representing a
- particular action.
-
- \section1 Overview of the Icons Application
-
- With the Icons application you get a preview of an icon's
- generated pixmaps reflecting its different states, modes and size.
-
- When an image is loaded into the application, it is converted into
- a pixmap and becomes a part of the set of pixmaps available to the
- icon. An image can be excluded from this set by checking off the
- related checkbox. The application provides a sub directory
- containing sets of images explicitly designed to illustrate how Qt
- renders an icon in different modes and states.
-
- The application allows you to manipulate the icon size with some
- predefined sizes and a spin box. The predefined sizes are style
- dependent, but most of the styles have the same values. Only the
- \macos style differs by using 32 pixels instead of 16 pixels
- for toolbar buttons. You can navigate between the available styles
- using the \uicontrol View menu.
-
- \image icons-view-menu.png Screenshot of the View menu
-
- The \uicontrol View menu also provide the option to make the application
- guess the icon state and mode from an image's file name. The \uicontrol
- File menu provide the options of adding an image and removing all
- images. These last options are also available through a context
- menu that appears if you press the right mouse button within the
- table of image files. In addition, the \uicontrol File menu provide an
- \uicontrol Exit option, and the \uicontrol Help menu provide information about
- the example and about Qt.
-
- \image icons_find_normal.png Screenshot of the Find Files
-
- The screenshot above shows the application with one image file
- loaded. The \uicontrol {Guess Image Mode/State} is enabled and the
- style is Plastique.
-
- When QIcon is provided with only one available pixmap, that
- pixmap is used for all the states and modes. In this case the
- pixmap's icon mode is set to normal, and the generated pixmaps
- for the normal and active modes will look the same. But in
- disabled and selected mode, Qt will generate a slightly different
- pixmap.
-
- The next screenshot shows the application with an additional file
- loaded, providing QIcon with two available pixmaps. Note that the
- new image file's mode is set to disabled. When rendering the \uicontrol
- Disabled mode pixmaps, Qt will now use the new image. We can see
- the difference: The generated disabled pixmap in the first
- screenshot is slightly darker than the pixmap with the originally
- set disabled mode in the second screenshot.
-
- \image icons_find_normal_disabled.png Screenshot of the Find Files
-
- When Qt renders the icon's pixmaps it searches through the set of
- available pixmaps following a particular algorithm. The algorithm
- is documented in QIcon, but we will describe some particular cases
- below.
-
- \image icons_monkey_active.png Screenshot of the Find Files
-
- In the screenshot above, we have set \c monkey_on_32x32 to be an
- Active/On pixmap and \c monkey_off_64x64 to be Normal/Off. To
- render the other six mode/state combinations, QIcon uses the
- search algorithm described in the table below:
-
- \table 100%
- \header \li{2,1} Requested Pixmap \li {8,1} Preferred Alternatives (mode/state)
- \header \li Mode \li State \li 1 \li 2 \li 3 \li 4 \li 5 \li 6 \li 7 \li 8
- \row \li{1,2} Normal \li Off \li \b N0 \li A0 \li N1 \li A1 \li D0 \li S0 \li D1 \li S1
- \row \li On \li N1 \li \b A1 \li N0 \li A0 \li D1 \li S1 \li D0 \li S0
- \row \li{1,2} Active \li Off \li A0 \li \b N0 \li A1 \li N1 \li D0 \li S0 \li D1 \li S1
- \row \li On \li \b A1 \li N1 \li A0 \li N0 \li D1 \li S1 \li D0 \li S0
- \row \li{1,2} Disabled \li Off \li D0 \li \b {N0'} \li A0' \li D1 \li N1' \li A1' \li S0' \li S1'
- \row \li On \li D1 \li N1' \li \b {A1'} \li D0 \li N0' \li A0' \li S1' \li S0'
- \row \li{1,2} Selected \li Off \li S0 \li \b {N0''} \li A0'' \li S1 \li N1'' \li A1'' \li D0'' \li D1''
- \row \li On \li S1 \li N1'' \li \b {A1''} \li S0 \li N0'' \li A0'' \li D1'' \li D0''
- \endtable
-
- In the table, "0" and "1" stand for "Off" and "On", respectively.
- Single quotes indicates that QIcon generates a disabled ("grayed
- out") version of the pixmap; similarly, double quuote indicate
- that QIcon generates a selected ("blued out") version of the
- pixmap.
-
- The alternatives used in the screenshot above are shown in bold.
- For example, the Disabled/Off pixmap is derived by graying out
- the Normal/Off pixmap (\c monkey_off_64x64).
-
- In the next screenshots, we loaded the whole set of monkey
- images. By checking or unchecking file names from the image list,
- we get different results:
-
- \table
- \row
- \li \inlineimage icons_monkey.png Screenshot of the Monkey Files
- \li \inlineimage icons_monkey_mess.png Screenshot of the Monkey Files
- \endtable
-
- For any given mode/state combination, it is possible to specify
- several images at different resolutions. When rendering an
- icon, QIcon will automatically pick the most suitable image
- and scale it down if necessary. (QIcon never scales up images,
- because this rarely looks good.)
-
- The screenshots below shows what happens when we provide QIcon
- with three images (\c qt_extended_16x16.png, \c qt_extended_32x32.png, \c
- qt_extended_48x48.png) and try to render the QIcon at various
- resolutions:
-
- \table
- \row
- \li
- \li \inlineimage icons_qt_extended_8x8.png Qt Extended icon at 8 x 8
- \li \inlineimage icons_qt_extended_16x16.png Qt Extended icon at 16 x 16
- \li \inlineimage icons_qt_extended_17x17.png Qt Extended icon at 17 x 17
- \row
- \li
- \li 8 x 8
- \li \b {16 x 16}
- \li 17 x 17
- \row
- \li \inlineimage icons_qt_extended_32x32.png Qt Extended icon at 32 x 32
- \li \inlineimage icons_qt_extended_33x33.png Qt Extended icon at 33 x 33
- \li \inlineimage icons_qt_extended_48x48.png Qt Extended icon at 48 x 48
- \li \inlineimage icons_qt_extended_64x64.png Qt Extended icon at 64 x 64
- \row
- \li \b {32 x 32}
- \li 33 x 33
- \li \b {48 x 48}
- \li 64 x 64
- \endtable
-
- For sizes up to 16 x 16, QIcon uses \c qt_extended_16x16.png and
- scales it down if necessary. For sizes between 17 x 17 and 32 x
- 32, it uses \c qt_extended_32x32.png. For sizes above 32 x 32, it uses
- \c qt_extended_48x48.png.
-
- \section1 Line-by-Line Walkthrough
-
- The Icons example consists of four classes:
-
- \list
- \li \c MainWindow inherits QMainWindow and is the main application
- window.
- \li \c IconPreviewArea is a custom widget that displays all
- combinations of states and modes for a given icon.
- \li \c IconSizeSpinBox is a subclass of QSpinBox that lets the
- user enter icon sizes (e.g., "48 x 48").
- \li \c ImageDelegate is a subclass of QStyledItemDelegate that
- provides comboboxes for letting the user set the mode and state
- associated with an image.
- \endlist
-
- We will start by reviewing the \c IconPreviewArea class before we
- take a look at the \c MainWindow class. Finally, we will review the
- \c IconSizeSpinBox and \c ImageDelegate classes.
-
- \section2 IconPreviewArea Class Definition
-
- An \c IconPreviewArea widget consists of a group box containing a grid of
- QLabel widgets displaying headers and pixmaps.
-
- \image icons_preview_area.png Screenshot of IconPreviewArea.
-
- \snippet widgets/icons/iconpreviewarea.h 0
-
- The \c IconPreviewArea class inherits QWidget. It displays the
- generated pixmaps corresponding to an icon's possible states and
- modes at a given size.
-
- \snippet widgets/icons/iconpreviewarea.cpp 42
-
- We would like the table columns to be in the order QIcon::Normal,
- QIcon::Active, QIcon::Disabled, QIcon::Selected and the rows in the order
- QIcon::Off, QIcon::On, which does not match the enumeration. The above code
- provides arrays allowing to map from enumeration value to row/column
- (by using QList::indexOf()) and back by using the array index and lists
- of the matching strings. Qt's containers can be easily populated by
- using C++ 11 initializer lists.
-
- We need two public functions to set the current icon and the
- icon's size. In addition the class has three private functions: We
- use the \c createHeaderLabel() and \c createPixmapLabel()
- functions when constructing the preview area, and we need the \c
- updatePixmapLabels() function to update the preview area when
- the icon or the icon's size has changed.
-
- The \c NumModes and \c NumStates constants reflect \l{QIcon}'s
- number of currently defined modes and states.
-
- \section2 IconPreviewArea Class Implementation
-
- \snippet widgets/icons/iconpreviewarea.cpp 0
-
- In the constructor we create the labels displaying the headers and
- the icon's generated pixmaps, and add them to a grid layout.
-
- When creating the header labels, we make sure the enums \c
- NumModes and \c NumStates defined in the \c .h file, correspond
- with the number of labels that we create. Then if the enums at
- some point are changed, the \c Q_ASSERT() macro will alert that this
- part of the \c .cpp file needs to be updated as well.
-
- If the application is built in debug mode, the \c Q_ASSERT()
- macro will expand to
-
- \code
- if (!condition)
- qFatal("ASSERT: "condition" in file ...");
- \endcode
-
- In release mode, the macro simply disappear. The mode can be set
- in the application's \c .pro file. One way to do so is to add an
- option to \c qmake when building the application:
-
- \code
- qmake "CONFIG += debug" icons.pro
- \endcode
-
- or
-
- \code
- qmake "CONFIG += release" icons.pro
- \endcode
-
- Another approach is to add this line directly to the \c .pro
- file.
-
- \snippet widgets/icons/iconpreviewarea.cpp 1
- \codeline
- \snippet widgets/icons/iconpreviewarea.cpp 2
-
- The public \c setIcon() and \c setSize() functions change the icon
- or the icon size, and make sure that the generated pixmaps are
- updated.
-
- \snippet widgets/icons/iconpreviewarea.cpp 3
- \codeline
- \snippet widgets/icons/iconpreviewarea.cpp 4
-
- We use the \c createHeaderLabel() and \c createPixmapLabel()
- functions to create the preview area's labels displaying the
- headers and the icon's generated pixmaps. Both functions return
- the QLabel that is created.
-
- \snippet widgets/icons/iconpreviewarea.cpp 5
-
- We use the private \c updatePixmapLabel() function to update the
- generated pixmaps displayed in the preview area.
-
- For each mode, and for each state, we retrieve a pixmap using the
- QIcon::pixmap() function, which generates a pixmap corresponding
- to the given state, mode and size. We pass the QWindows instance
- obtained by calling QWidget::windowHandle() on the top level
- widget (QWidget::nativeParentWidget()) in order to retrieve
- the pixmap that matches best.
- We format a tooltip displaying size, actual size and device pixel
- ratio.
-
- \section2 MainWindow Class Definition
-
- The \c MainWindow widget consists of three main elements: an
- images group box, an icon size group box and a preview area.
-
- \image icons-example.png Screenshot of the Icons example
-
- \snippet widgets/icons/mainwindow.h 0
-
- The MainWindow class inherits from QMainWindow. We reimplement the
- constructor, and declare several private slots:
-
- \list
- \li The \c about() slot simply provides information about the example.
- \li The \c changeStyle() slot changes the application's GUI style and
- adjust the style dependent size options.
- \li The \c changeSize() slot changes the size of the preview area's icon.
- \li The \c changeIcon() slot updates the set of pixmaps available to the
- icon displayed in the preview area.
- \li The \c addSampleImages() slot allows the user to load a new image
- from the samples provided into the application.
- \li The \c addOtherImages() slot allows the user to load a new image from
- the directory obtained by calling
- QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).
- \li The \c screenChanged() updates the display in the \uicontrol{High DPI}
- group box to correctly display the parameters of the current screen
- the window is located on.
- \endlist
-
- In addition we declare several private functions to simplify the
- constructor.
-
- \section2 MainWindow Class Implementation
-
- \snippet widgets/icons/mainwindow.cpp 0
-
- In the constructor we first create the main window's central
- widget and its child widgets, and put them in a grid layout. Then
- we create the menus with their associated entries and actions.
-
- We set the window title and determine the current style for the
- application. We also enable the icon size spin box by clicking the
- associated radio button, making the current value of the spin box
- the icon's initial size.
-
- \snippet widgets/icons/mainwindow.cpp 1
-
- The \c about() slot displays a message box using the static
- QMessageBox::about() function. In this example it displays a
- simple box with information about the example.
-
- The \c about() function looks for a suitable icon in four
- locations: It prefers its parent's icon if that exists. If it
- doesn't, the function tries the top-level widget containing
- parent, and if that fails, it tries the active window. As a last
- resort it uses the QMessageBox's Information icon.
-
- \snippet widgets/icons/mainwindow.cpp 2
-
- In the \c changeStyle() slot we first check the slot's
- parameter. If it is false we immediately return, otherwise we find
- out which style to change to, i.e. which action that triggered the
- slot, using the QObject::sender() function.
-
- This function returns the sender as a QObject pointer. Since we
- know that the sender is a QAction object, we can safely cast the
- QObject. We could have used a C-style cast or a C++ \c
- static_cast(), but as a defensive programming technique we use a
- \l qobject_cast(). The advantage is that if the object has the
- wrong type, a null pointer is returned. Crashes due to null
- pointers are much easier to diagnose than crashes due to unsafe
- casts.
-
- \snippet widgets/icons/mainwindow.cpp 3
- \snippet widgets/icons/mainwindow.cpp 4
-
- Once we have the action, we extract the style name using
- QAction::data(). Then we create a QStyle object using the static
- QStyleFactory::create() function.
-
- Although we can assume that the style is supported by the
- QStyleFactory: To be on the safe side, we use the \c Q_ASSERT()
- macro to check if the created style is valid before we use the
- QApplication::setStyle() function to set the application's GUI
- style to the new style. QApplication will automatically delete
- the style object when a new style is set or when the application
- exits.
-
- The predefined icon size options provided in the application are
- style dependent, so we need to update the labels in the icon size
- group box and in the end call the \c changeSize() slot to update
- the icon's size.
-
- \snippet widgets/icons/mainwindow.cpp 5
-
- The \c changeSize() slot sets the size for the preview area's
- icon.
-
- It is invoked by the QButtonGroup whose members are radio buttons for
- controlling the icon size. In \c createIconSizeGroupBox(), each button is
- assigned a QStyle::PixelMetric value as an id, which is passed as a
- parameter to the slot.
-
- The special value \c OtherSize indicates that the spin box is
- enabled. If it is, we extract the extent of the new size from the
- box. If it's not, we query the style for the metric. Then we create
- a QSize object based on the extent, and use that object to set the
- size of the preview area's icon.
-
- \snippet widgets/icons/mainwindow.cpp 12
-
- The function \c addImages() is called by the slot addSampleImages()
- passing the samples directory, or by the slot addOtherImages()
- passing the directory obtained by querying
- QStandardPaths::standardLocations().
-
- The first thing we do is to show a file dialog to the user.
- We initialize it to show the filters returned by
- QImageReader::supportedMimeTypes().
-
- For each of the files the file dialog returns, we add a row to the
- table widget. The table widget is listing the images the user has
- loaded into the application.
-
- \snippet widgets/icons/mainwindow.cpp 13
-
- We retrieve the image name using the QFileInfo::baseName()
- function that returns the base name of the file without the path,
- and create the first table widget item in the row.
- We check if a high resolution version of the image exists (identified by
- the suffix \c @2x on the base name) and display that along with the size
- in the tooltip.
-
- We add the file's complete name to the item's data. Since an item can
- hold several information pieces, we need to assign the file name a role
- that will distinguish it from other data. This role can be Qt::UserRole
- or any value above it.
-
- We also make sure that the item is not editable by removing the
- Qt::ItemIsEditable flag. Table items are editable by default.
-
- \snippet widgets/icons/mainwindow.cpp 15
-
- Then we create the second and third items in the row making the
- default mode Normal and the default state Off. But if the \uicontrol
- {Guess Image Mode/State} option is checked, and the file name
- contains "_act", "_dis", or "_sel", the modes are changed to
- Active, Disabled, or Selected. And if the file name contains
- "_on", the state is changed to On. The sample files in the
- example's \c images subdirectory respect this naming convention.
-
- \snippet widgets/icons/mainwindow.cpp 18
-
- In the end we add the items to the associated row, and use the
- QTableWidget::openPersistentEditor() function to create
- comboboxes for the mode and state columns of the items.
-
- Due to the connection between the table widget's \l
- {QTableWidget::itemChanged()}{itemChanged()} signal and the \c
- changeIcon() slot, the new image is automatically converted into a
- pixmap and made part of the set of pixmaps available to the icon
- in the preview area. So, corresponding to this fact, we need to
- make sure that the new image's check box is enabled.
-
- \snippet widgets/icons/mainwindow.cpp 6
-
- The \c changeIcon() slot is called when the user alters the set
- of images listed in the QTableWidget, to update the QIcon object
- rendered by the \c IconPreviewArea.
-
- We first create a QIcon object, and then we run through the
- QTableWidget, which lists the images the user has loaded into the
- application.
-
- \snippet widgets/icons/mainwindow.cpp 8
-
- We also extract the image file's name using the
- QTableWidgetItem::data() function. This function takes a
- Qt::DataItemRole as an argument to retrieve the right data
- (remember that an item can hold several pieces of information)
- and returns it as a QVariant. Then we use the
- QVariant::toString() function to get the file name as a QString.
-
- To create a pixmap from the file, we need to first create an
- image and then convert this image into a pixmap using
- QPixmap::fromImage(). Once we have the final pixmap, we add it,
- with its associated mode and state, to the QIcon's set of
- available pixmaps.
-
- \snippet widgets/icons/mainwindow.cpp 11
-
- After running through the entire list of images, we change the
- icon of the preview area to the one we just created.
-
- \snippet widgets/icons/mainwindow.cpp 20
-
- In the \c removeAllImages() slot, we simply set the table widget's
- row count to zero, automatically removing all the images the user
- has loaded into the application. Then we update the set of pixmaps
- available to the preview area's icon using the \c changeIcon()
- slot.
-
- \image icons_images_groupbox.png Screenshot of the images group box
-
- The \c createImagesGroupBox() function is implemented to simplify
- the constructor. The main purpose of the function is to create a
- QTableWidget that will keep track of the images the user has
- loaded into the application.
-
- \snippet widgets/icons/mainwindow.cpp 21
-
- First we create a group box that will contain the table widget.
- Then we create a QTableWidget and customize it to suit our
- purposes.
-
- We call QAbstractItemView::setSelectionMode() to prevent the user
- from selecting items.
-
- The QAbstractItemView::setItemDelegate() call sets the item
- delegate for the table widget. We create a \c ImageDelegate that
- we make the item delegate for our view.
-
- The QStyledItemDelegate class can be used to provide an editor for an item view
- class that is subclassed from QAbstractItemView. Using a delegate
- for this purpose allows the editing mechanism to be customized and
- developed independently from the model and view.
-
- In this example we derive \c ImageDelegate from QStyledItemDelegate.
- QStyledItemDelegate usually provides line editors, while our subclass
- \c ImageDelegate, provides comboboxes for the mode and state
- fields.
-
- \snippet widgets/icons/mainwindow.cpp 22
-
- Then we customize the QTableWidget's horizontal header, and hide
- the vertical header.
-
- \snippet widgets/icons/mainwindow.cpp 24
-
- At the end, we connect the QTableWidget::itemChanged() signal to
- the \c changeIcon() slot to ensure that the preview area is in
- sync with the image table.
-
- \image icons_size_groupbox.png Screenshot of the icon size group box
-
- The \c createIconSizeGroupBox() function is called from the
- constructor. It creates the widgets controlling the size of the
- preview area's icon.
-
- \snippet widgets/icons/mainwindow.cpp 26
-
- First we create a group box that will contain all the widgets;
- then we create the radio buttons and the spin box. We add the
- radio buttons to an instance of QButtonGroup, using the value
- of the QStyle::PixelMetric they represent as an integer id.
-
- \snippet widgets/icons/mainwindow.cpp 40
-
- We introduce an enumeration constant \c OtherSize to represent
- a custom size.
-
- The spin box is not a regular QSpinBox but an \c IconSizeSpinBox.
- The \c IconSizeSpinBox class inherits QSpinBox and reimplements
- two functions: QSpinBox::textFromValue() and
- QSpinBox::valueFromText(). The \c IconSizeSpinBox is designed to
- handle icon sizes, e.g., "32 x 32", instead of plain integer
- values.
-
- \snippet widgets/icons/mainwindow.cpp 27
-
- Then we connect all of the radio buttons
- \l{QRadioButton::toggled()}{toggled()} signals and the spin box's
- \l {QSpinBox::valueChanged()}{valueChanged()} signal to the \c
- changeSize() slot to make sure that the size of the preview
- area's icon is updated whenever the user changes the icon size.
- In the end we put the widgets in a layout that we install on the
- group box.
-
- \snippet widgets/icons/mainwindow.cpp 28
-
- In the \c createActions() function we create and customize all the
- actions needed to implement the functionality associated with the
- menu entries in the application.
-
- In particular we create the \c styleActionGroup based on the
- currently available GUI styles using
- QStyleFactory. QStyleFactory::keys() returns a list of valid keys,
- typically including "windows" and "fusion". Depending on the platform,
- "windowsvista" and "macos" may be available.
-
- We create one action for each key, and adds the action to the
- action group. Also, for each action, we call QAction::setData()
- with the style name. We will retrieve it later using
- QAction::data().
-
- As we go along, we create the \uicontrol File, \uicontrol View and
- \uicontrol Help menus and add the actions to them.
-
- The QMenu class provides a menu widget for use in menu bars,
- context menus, and other popup menus. We put each menu in the
- application's menu bar, which we retrieve using
- QMainWindow::menuBar().
-
- \snippet widgets/icons/mainwindow.cpp 30
-
- QWidgets have a \l{QWidget::contextMenuPolicy}{contextMenuPolicy}
- property that controls how the widget should behave when the user
- requests a context menu (e.g., by right-clicking). We set the
- QTableWidget's context menu policy to Qt::ActionsContextMenu,
- meaning that the \l{QAction}s associated with the widget should
- appear in its context menu.
-
- Then we add the \uicontrol{Add Image} and \uicontrol{Remove All Images}
- actions to the table widget. They will then appear in the table
- widget's context menu.
-
- \snippet widgets/icons/mainwindow.cpp 31
-
- In the \c checkCurrentStyle() function we go through the group of
- style actions, looking for the current GUI style.
-
- For each action, we first extract the style name using
- QAction::data(). Since this is only a QStyleFactory key (e.g.,
- "macos"), we cannot compare it directly to the current
- style's class name. We need to create a QStyle object using the
- static QStyleFactory::create() function and compare the class
- name of the created QStyle object with that of the current style.
- As soon as we are done with a QStyle candidate, we delete it.
-
- For all QObject subclasses that use the \c Q_OBJECT macro, the
- class name of an object is available through its
- \l{QObject::metaObject()}{meta-object}.
-
- We can assume that the style is supported by
- QStyleFactory, but to be on the safe side we use the \c
- Q_ASSERT() macro to make sure that QStyleFactory::create()
- returned a valid pointer.
-
- \snippet widgets/icons/mainwindow.cpp 44
-
- We overload the show() function to set up the updating of the
- current screen in \c screenChanged(). After calling QWidget::show(),
- the QWindow associated with the QWidget is created and we can
- connect to its QWindow::screenChanged() signal.
-
- \section2 IconSizeSpinBox Class Definition
-
- \snippet widgets/icons/iconsizespinbox.h 0
-
- The \c IconSizeSpinBox class is a subclass of QSpinBox. A plain
- QSpinBox can only handle integers. But since we want to display
- the spin box's values in a more sophisticated way, we need to
- subclass QSpinBox and reimplement the QSpinBox::textFromValue()
- and QSpinBox::valueFromText() functions.
-
- \image icons_size_spinbox.png Screenshot of the icon size spinbox
-
- \section2 IconSizeSpinBox Class Implementation
-
- \snippet widgets/icons/iconsizespinbox.cpp 0
-
- The constructor is trivial.
-
- \snippet widgets/icons/iconsizespinbox.cpp 2
-
- QSpinBox::textFromValue() is used by the spin box whenever it
- needs to display a value. The default implementation returns a
- base 10 representation of the \c value parameter.
-
- Our reimplementation returns a QString of the form "32 x 32".
-
- \snippet widgets/icons/iconsizespinbox.cpp 1
-
- The QSpinBox::valueFromText() function is used by the spin box
- whenever it needs to interpret text typed in by the user. Since
- we reimplement the \c textFromValue() function we also need to
- reimplement the \c valueFromText() function to interpret the
- parameter text and return the associated int value.
-
- We parse the text using a regular expression (a QRegularExpression). We
- define an expression that matches one or several digits,
- optionally followed by whitespace, an "x" or the times symbol,
- whitespace and one or several digits again.
-
- The first digits of the regular expression are captured using
- parentheses. This enables us to use the QRegularExpressionMatch::captured()
- or QRegularExpressionMatch::capturedTexts() functions to extract the matched
- characters. If the first and second numbers of the spin box value
- differ (e.g., "16 x 24"), we use the first number.
-
- When the user presses \uicontrol Enter, QSpinBox first calls
- QSpinBox::valueFromText() to interpret the text typed by the
- user, then QSpinBox::textFromValue() to present it in a canonical
- format (e.g., "16 x 16").
-
- \section2 ImageDelegate Class Definition
-
- \snippet widgets/icons/imagedelegate.h 0
-
- The \c ImageDelegate class is a subclass of QStyledItemDelegate. The
- QStyledItemDelegate class provides display and editing facilities for
- data items from a model. A single QStyledItemDelegate object is
- responsible for all items displayed in a item view (in our case,
- a QTableWidget).
-
- A QStyledItemDelegate can be used to provide an editor for an item view
- class that is subclassed from QAbstractItemView. Using a delegate
- for this purpose allows the editing mechanism to be customized and
- developed independently from the model and view.
-
- \snippet widgets/icons/imagedelegate.h 1
-
- The default implementation of QStyledItemDelegate creates a QLineEdit.
- Since we want the editor to be a QComboBox, we need to subclass
- QStyledItemDelegate and reimplement the QStyledItemDelegate::createEditor(),
- QStyledItemDelegate::setEditorData() and QStyledItemDelegate::setModelData()
- functions.
-
- \snippet widgets/icons/imagedelegate.h 2
-
- The \c emitCommitData() slot is used to emit the
- QImageDelegate::commitData() signal with the appropriate
- argument.
-
- \section2 ImageDelegate Class Implementation
-
- \snippet widgets/icons/imagedelegate.cpp 0
-
- The constructor is trivial.
-
- \snippet widgets/icons/imagedelegate.cpp 1
-
- The default QStyledItemDelegate::createEditor() implementation returns
- the widget used to edit the item specified by the model and item
- index for editing. The parent widget and style option are used to
- control the appearance of the editor widget.
-
- Our reimplementation creates and populates a combobox instead of
- the default line edit. The contents of the combobox depends on
- the column in the table for which the editor is requested. Column
- 1 contains the QIcon modes, whereas column 2 contains the QIcon
- states.
-
- In addition, we connect the combobox's \l
- {QComboBox::activated()}{activated()} signal to the \c
- emitCommitData() slot to emit the
- QAbstractItemDelegate::commitData() signal whenever the user
- chooses an item using the combobox. This ensures that the rest of
- the application notices the change and updates itself.
-
- \snippet widgets/icons/imagedelegate.cpp 2
-
- The QStyledItemDelegate::setEditorData() function is used by
- QTableWidget to transfer data from a QTableWidgetItem to the
- editor. The data is stored as a string; we use
- QComboBox::findText() to locate it in the combobox.
-
- Delegates work in terms of models, not items. This makes it
- possible to use them with any item view class (e.g., QListView,
- QListWidget, QTreeView, etc.). The transition between model and
- items is done implicitly by QTableWidget; we don't need to worry
- about it.
-
- \snippet widgets/icons/imagedelegate.cpp 3
-
- The QStyledItemDelegate::setEditorData() function is used by QTableWidget
- to transfer data back from the editor to the \l{QTableWidgetItem}.
-
- \snippet widgets/icons/imagedelegate.cpp 4
-
- The \c emitCommitData() slot simply emit the
- QAbstractItemDelegate::commitData() signal for the editor that
- triggered the slot. This signal must be emitted when the editor
- widget has completed editing the data, and wants to write it back
- into the model.
-
- \section2 The Implementation of the Function main()
-
- \snippet widgets/icons/main.cpp 45
-
- We use QCommandLineParser to handle any command line options or parameters
- passed to the application. Then, we resize the main window according
- to the available screen geometry and show it.
-*/
diff --git a/examples/widgets/doc/src/imagecomposition.qdoc b/examples/widgets/doc/src/imagecomposition.qdoc
index 3b192f378e..9eec57ca88 100644
--- a/examples/widgets/doc/src/imagecomposition.qdoc
+++ b/examples/widgets/doc/src/imagecomposition.qdoc
@@ -4,6 +4,7 @@
/*!
\example painting/imagecomposition
\title Image Composition Example
+ \examplecategory {Graphics}
\ingroup examples-painting
\ingroup examples-layout
\brief Shows how composition modes work in QPainter.
diff --git a/examples/widgets/doc/src/imageviewer.qdoc b/examples/widgets/doc/src/imageviewer.qdoc
deleted file mode 100644
index 17b969d4c8..0000000000
--- a/examples/widgets/doc/src/imageviewer.qdoc
+++ /dev/null
@@ -1,320 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/imageviewer
- \title Image Viewer Example
- \ingroup examples-widgets
- \brief The example shows how to combine QLabel and QScrollArea to
- display an image.
-
- QLabel is typically used for displaying text,
- but it can also display an image. QScrollArea provides a
- scrolling view around another widget. If the child widget exceeds
- the size of the frame, QScrollArea automatically provides scroll
- bars.
-
- The example demonstrates how QLabel's ability to scale its
- contents (QLabel::scaledContents), and QScrollArea's ability to
- automatically resize its contents (QScrollArea::widgetResizable),
- can be used to implement zooming and scaling features. In
- addition the example shows how to use QPainter to print an image.
-
- \borderedimage imageviewer-example.png
- \caption Screenshot of the Image Viewer example
-
- With the Image Viewer application, the users can view an image of
- their choice. The \uicontrol File menu gives the user the possibility
- to:
-
- \list
- \li \uicontrol{Open...} - Open an image file
- \li \uicontrol{Print...} - Print an image
- \li \uicontrol{Exit} - Exit the application
- \endlist
-
- Once an image is loaded, the \uicontrol View menu allows the users to:
-
- \list
- \li \uicontrol{Zoom In} - Scale the image up by 25%
- \li \uicontrol{Zoom Out} - Scale the image down by 25%
- \li \uicontrol{Normal Size} - Show the image at its original size
- \li \uicontrol{Fit to Window} - Stretch the image to occupy the entire window
- \endlist
-
- In addition the \uicontrol Help menu provides the users with information
- about the Image Viewer example in particular, and about Qt in
- general.
-
- \section1 ImageViewer Class Definition
-
- \snippet widgets/imageviewer/imageviewer.h 0
-
- The \c ImageViewer class inherits from QMainWindow. We reimplement
- the constructor, and create several private slots to facilitate
- the menu entries. In addition we create four private functions.
-
- We use \c createActions() and \c createMenus() when constructing
- the \c ImageViewer widget. We use the \c updateActions() function
- to update the menu entries when a new image is loaded, or when
- the \uicontrol {Fit to Window} option is toggled. The zoom slots use \c
- scaleImage() to perform the zooming. In turn, \c
- scaleImage() uses \c adjustScrollBar() to preserve the focal point after
- scaling an image.
-
- \section1 ImageViewer Class Implementation
-
- \snippet widgets/imageviewer/imageviewer.cpp 0
-
- In the constructor we first create the label and the scroll area.
-
- We set \c {imageLabel}'s size policy to \l
- {QSizePolicy::Ignored}{ignored}, making the users able to scale
- the image to whatever size they want when the \uicontrol {Fit to Window}
- option is turned on. Otherwise, the default size polizy (\l
- {QSizePolicy::Preferred}{preferred}) will make scroll bars appear
- when the scroll area becomes smaller than the label's minimum size
- hint.
-
- We ensure that the label will scale its contents to fill all
- available space, to enable the image to scale properly when
- zooming. If we omitted to set the \c {imageLabel}'s \l
- {QLabel::scaledContents}{scaledContents} property, zooming in
- would enlarge the QLabel, but leave the pixmap at
- its original size, exposing the QLabel's background.
-
- We make \c imageLabel the scroll area's child widget, and we make
- \c scrollArea the central widget of the QMainWindow. At the end
- we create the associated actions and menus, and customize the \c
- {ImageViewer}'s appearance.
-
- \snippet widgets/imageviewer/imageviewer.cpp 1
-
- In the \c open() slot, we show a file dialog to the user. We compile
- a list of mime types for use as a filter by querying QImageReader
- for the available mime type names.
-
- We show the file dialog until a valid file name is entered or
- the user cancels.
-
- The function \c loadFile() is used to load the image.
-
- \snippet widgets/imageviewer/imageviewer.cpp 2
-
- In the \c loadFile() function, we instantiate a QImageReader
- and enable automatic transformations by calling
- QImageReader::setAutoTransform(). For files in JPEG format,
- this ensures that portrait mode images of digital cameras are shown
- correctly by applying the appropriate orientation read from the
- EXIF meta data stored in the image file.
-
- We then load the image using QImageReader::read(). If this returns
- a null image, indicating that the file is not an image file,
- we use a QMessageBox to alert the user.
-
- The QMessageBox class provides a modal dialog with a short
- message, an icon, and some buttons. As with QFileDialog the
- easiest way to create a QMessageBox is to use its static
- convenience functions. QMessageBox provides a range of different
- messages arranged along two axes: severity (question,
- information, warning and critical) and complexity (the number of
- necessary response buttons). In this particular example an
- information message with an \uicontrol OK button (the default) is
- sufficient, since the message is part of a normal operation.
-
- \snippet widgets/imageviewer/imageviewer.cpp 4
-
- If the format is supported, we display the image in \c imageLabel
- by setting the label's \l {QLabel::pixmap}{pixmap}. Then we enable
- the \uicontrol Print and \uicontrol {Fit to Window} menu entries and update
- the rest of the view menu entries. The \uicontrol Open and \uicontrol Exit
- entries are enabled by default.
-
- If the \uicontrol {Fit to Window} option is turned off, the
- QScrollArea::widgetResizable property is \c false and it is
- our responsibility (not QScrollArea's) to give the QLabel a
- reasonable size based on its contents. We call
- \{QWidget::adjustSize()}{adjustSize()} to achieve this, which is
- essentially the same as
-
- \code
- imageLabel->resize(imageLabel->pixmap()->size());
- \endcode
-
- In the \c print() slot, we first make sure that an image has been
- loaded into the application:
-
- \snippet widgets/imageviewer/imageviewer.cpp 5
- \snippet widgets/imageviewer/imageviewer.cpp 6
-
- If the application is built in debug mode, the \c Q_ASSERT() macro
- will expand to
-
- \code
- if (imageLabel->pixmap(Qt::ReturnByValue).isNull())
- qFatal("ASSERT: "imageLabel->pixmap(Qt::ReturnByValue).isNull()" in file ...");
- \endcode
-
- In release mode, the macro simply disappear. The mode can be set
- in the application's \c .pro file. One way to do so is to add an
- option to \uicontrol qmake when building the application:
-
- \code
- qmake "CONFIG += debug" foo.pro
- \endcode
-
- or
-
- \code
- qmake "CONFIG += release" foo.pro
- \endcode
-
- Another approach is to add this line directly to the \c .pro
- file.
-
- \snippet widgets/imageviewer/imageviewer.cpp 7
- \snippet widgets/imageviewer/imageviewer.cpp 8
-
- Then we present a print dialog allowing the user to choose a
- printer and to set a few options. We construct a painter with a
- QPrinter as the paint device. We set the painter's window
- and viewport in such a way that the image is as large as possible
- on the paper, but without altering its
- \l{Qt::KeepAspectRatio}{aspect ratio}.
-
- In the end we draw the pixmap at position (0, 0).
-
- \snippet widgets/imageviewer/imageviewer.cpp 9
- \snippet widgets/imageviewer/imageviewer.cpp 10
-
- We implement the zooming slots using the private \c scaleImage()
- function. We set the scaling factors to 1.25 and 0.8,
- respectively. These factor values ensure that a \uicontrol {Zoom In}
- action and a \uicontrol {Zoom Out} action will cancel each other (since
- 1.25 * 0.8 == 1), and in that way the normal image size can be
- restored using the zooming features.
-
- The screenshots below show an image in its normal size, and the
- same image after zooming in:
-
- \table
- \row
- \li \inlineimage imageviewer-original_size.png
- \li \inlineimage imageviewer-zoom_in_1.png
- \li \inlineimage imageviewer-zoom_in_2.png
- \endtable
-
- \snippet widgets/imageviewer/imageviewer.cpp 11
- \snippet widgets/imageviewer/imageviewer.cpp 12
-
- When zooming, we use the QLabel's ability to scale its contents.
- Such scaling doesn't change the actual size hint of the contents.
- And since the \l {QLabel::adjustSize()}{adjustSize()} function
- use those size hint, the only thing we need to do to restore the
- normal size of the currently displayed image is to call \c
- adjustSize() and reset the scale factor to 1.0.
-
- \snippet widgets/imageviewer/imageviewer.cpp 13
- \snippet widgets/imageviewer/imageviewer.cpp 14
-
- The \c fitToWindow() slot is called each time the user toggled
- the \uicontrol {Fit to Window} option. If the slot is called to turn on
- the option, we tell the scroll area to resize its child widget
- with the QScrollArea::setWidgetResizable() function. Then we
- disable the \uicontrol {Zoom In}, \uicontrol {Zoom Out} and \uicontrol {Normal
- Size} menu entries using the private \c updateActions() function.
-
- If the \l {QScrollArea::widgetResizable} property is set to \c
- false (the default), the scroll area honors the size of its child
- widget. If this property is set to \c true, the scroll area will
- automatically resize the widget in order to avoid scroll bars
- where they can be avoided, or to take advantage of extra space.
- But the scroll area will honor the minimum size hint of its child
- widget independent of the widget resizable property. So in this
- example we set \c {imageLabel}'s size policy to \l
- {QSizePolicy::Ignored}{ignored} in the constructor, to avoid that
- scroll bars appear when the scroll area becomes smaller than the
- label's minimum size hint.
-
- The screenshots below shows an image in its normal size, and the
- same image with the \uicontrol {Fit to window} option turned on.
- Enlarging the window will stretch the image further, as shown in
- the third screenshot.
-
- \table
- \row
- \li \inlineimage imageviewer-original_size.png
- \li \inlineimage imageviewer-fit_to_window_1.png
- \li \inlineimage imageviewer-fit_to_window_2.png
- \endtable
-
- If the slot is called to turn off the option, the
- {QScrollArea::setWidgetResizable} property is set to \c false. We
- also restore the image pixmap to its normal size by adjusting the
- label's size to its content. And in the end we update the view
- menu entries.
-
- \snippet widgets/imageviewer/imageviewer.cpp 15
- \snippet widgets/imageviewer/imageviewer.cpp 16
-
- We implement the \c about() slot to create a message box
- describing what the example is designed to show.
-
- \snippet widgets/imageviewer/imageviewer.cpp 17
- \snippet widgets/imageviewer/imageviewer.cpp 18
-
- In the private \c createAction() function, we create the
- actions providing the application features and populate
- a menu with them.
-
- We assign a short-cut key to each action and connect them to the
- appropriate slots. We only enable the \c openAct and \c exitAct at
- the time of creation, the others are updated once an image has
- been loaded into the application. In addition we make the \c
- fitToWindowAct \l {QAction::checkable}{checkable}.
-
- The QMenu class provides a menu widget for use in menu bars,
- context menus, and other popup menus. The QMenuBar class provides
- a horizontal menu bar that consists of a list of pull-down menu
- items. So we put the menus in the \c {ImageViewer}'s
- menu bar which we retrieve with the QMainWindow::menuBar()
- function.
-
- \snippet widgets/imageviewer/imageviewer.cpp 21
- \snippet widgets/imageviewer/imageviewer.cpp 22
-
- The private \c updateActions() function enables or disables the
- \uicontrol {Zoom In}, \uicontrol {Zoom Out} and \uicontrol {Normal Size} menu
- entries depending on whether the \uicontrol {Fit to Window} option is
- turned on or off.
-
- \snippet widgets/imageviewer/imageviewer.cpp 23
- \snippet widgets/imageviewer/imageviewer.cpp 24
-
- In \c scaleImage(), we use the \c factor parameter to calculate
- the new scaling factor for the displayed image, and resize \c
- imageLabel. Since we set the
- \l{QLabel::scaledContents}{scaledContents} property to \c true in
- the constructor, the call to QWidget::resize() will scale the
- image displayed in the label. We also adjust the scroll bars to
- preserve the focal point of the image.
-
- At the end, if the scale factor is less than 33.3% or greater
- than 300%, we disable the respective menu entry to prevent the
- image pixmap from becoming too large, consuming too much
- resources in the window system.
-
- \snippet widgets/imageviewer/imageviewer.cpp 25
- \snippet widgets/imageviewer/imageviewer.cpp 26
-
- Whenever we zoom in or out, we need to adjust the scroll bars in
- consequence. It would have been tempting to simply call
-
- \code
- scrollBar->setValue(int(factor * scrollBar->value()));
- \endcode
-
- but this would make the top-left corner the focal point, not the
- center. Therefore we need to take into account the scroll bar
- handle's size (the \l{QScrollBar::pageStep}{page step}).
-*/
diff --git a/examples/widgets/doc/src/interview.qdoc b/examples/widgets/doc/src/interview.qdoc
deleted file mode 100644
index 328e4fc92b..0000000000
--- a/examples/widgets/doc/src/interview.qdoc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example itemviews/interview
- \title Interview
- \ingroup examples-itemviews
- \brief This example demonstrates the usage of the model/view framework.
-
- \brief The Interview example explores the flexibility and scalability of the
- model/view framework by presenting an infinitely deep data structure using a model
- and three different types of view.
-
- \image interview-demo.png
-*/
diff --git a/examples/widgets/doc/src/itemviewspuzzle.qdoc b/examples/widgets/doc/src/itemviewspuzzle.qdoc
deleted file mode 100644
index c1e0c361d6..0000000000
--- a/examples/widgets/doc/src/itemviewspuzzle.qdoc
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example itemviews/puzzle
- \title Item Views Puzzle Example
- \ingroup examples-itemviews
- \brief The Puzzle example shows how to enable drag and drop with a custom model
- to allow items to be transferred between a view and another widget.
-
- \image itemviewspuzzle-example.png
-
- This example is an implementation of a simple jigsaw puzzle game using the
- built-in support for drag and drop provided by Qt's model/view framework.
- The \l{Drag and Drop Puzzle Example}{Drag and Drop Puzzle} example shows
- many of the same features, but takes an alternative approach that uses Qt's
- drag and drop API at the application level to handle drag and drop
- operations.
-*/
diff --git a/examples/widgets/doc/src/licensewizard.qdoc b/examples/widgets/doc/src/licensewizard.qdoc
index 2770a38ae2..66c822e421 100644
--- a/examples/widgets/doc/src/licensewizard.qdoc
+++ b/examples/widgets/doc/src/licensewizard.qdoc
@@ -4,6 +4,7 @@
/*!
\example dialogs/licensewizard
\title License Wizard Example
+ \examplecategory {User Interface Components}
\ingroup examples-dialogs
\brief The License Wizard example shows how to implement complex wizards in
@@ -13,7 +14,7 @@
Most wizards have a linear structure, with page 1 followed by
page 2 and so on until the last page. The
- \l{dialogs/classwizard}{Class Wizard} example shows how to create
+ \l{dialogs/trivialwizard}{Trivial Wizard} example shows how to create
such wizards.
Some wizards are more complex in that they allow different
@@ -191,5 +192,5 @@
option and disconnect the \c printButtonClicked() slot.
\endlist
- \sa QWizard, {Class Wizard Example}, {Trivial Wizard Example}
+ \sa QWizard, {Trivial Wizard Example}
*/
diff --git a/examples/widgets/doc/src/lineedits.qdoc b/examples/widgets/doc/src/lineedits.qdoc
index c268f473e3..7065a5f425 100644
--- a/examples/widgets/doc/src/lineedits.qdoc
+++ b/examples/widgets/doc/src/lineedits.qdoc
@@ -4,6 +4,7 @@
/*!
\example widgets/lineedits
\title Line Edits Example
+ \examplecategory {User Interface Components}
\ingroup examples-widgets
\brief The Line Edits example demonstrates the many ways that QLineEdit
can be used, and shows the effects of various properties and validators
diff --git a/examples/widgets/doc/src/mainwindow.qdoc b/examples/widgets/doc/src/mainwindow.qdoc
deleted file mode 100644
index ca2840123d..0000000000
--- a/examples/widgets/doc/src/mainwindow.qdoc
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example mainwindows/mainwindow
- \title Main Window
- \ingroup examples-mainwindow
-
- \brief The Main Window example shows Qt's extensive support for tool bars,
- dock windows, menus, and other standard application features.
-
- \image mainwindow-demo.png
-*/
diff --git a/examples/widgets/doc/src/mdi.qdoc b/examples/widgets/doc/src/mdi.qdoc
deleted file mode 100644
index 23daeeb9bd..0000000000
--- a/examples/widgets/doc/src/mdi.qdoc
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example mainwindows/mdi
- \title MDI Example
- \ingroup examples-mainwindow
-
- \brief The MDI example shows how to implement a Multiple Document Interface using Qt's
- QMdiArea class.
-
- \image mdi-example.png
-
-*/
diff --git a/examples/widgets/doc/src/menus.qdoc b/examples/widgets/doc/src/menus.qdoc
index 2bffd17b6b..b78d394691 100644
--- a/examples/widgets/doc/src/menus.qdoc
+++ b/examples/widgets/doc/src/menus.qdoc
@@ -4,6 +4,7 @@
/*!
\example mainwindows/menus
\title Menus Example
+ \examplecategory {User Interface Components}
\ingroup examples-mainwindow
\ingroup examples-layout
@@ -119,7 +120,8 @@
using the provided convenience functions.
In the \c createActions() function, we first create a \c newAct
- action. We make \uicontrol Ctrl+N its shortcut using the
+ action, passing the text and and an icon using one of the theme
+ icon constants. We make \uicontrol Ctrl+N its shortcut using the
QAction::setShortcut() function, and we set its status tip using the
QAction::setStatusTip() function (the status tip is displayed on all
status bars provided by the action's top-level parent widget). We
diff --git a/examples/widgets/doc/src/movie.qdoc b/examples/widgets/doc/src/movie.qdoc
deleted file mode 100644
index d5aebc4156..0000000000
--- a/examples/widgets/doc/src/movie.qdoc
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/movie
- \title Movie Example
- \ingroup examples-widgets
- \brief The Movie example demonstrates how to use QMovie and QLabel to
- display animations.
-
- QMovie is mostly useful if one wants to play
- a simple animation without the added complexity of a multimedia
- framework to install and deploy.
-
- \borderedimage movie-example.png
-*/
diff --git a/examples/widgets/doc/src/orderform.qdoc b/examples/widgets/doc/src/orderform.qdoc
index 529ed6d24b..7ae89dfda8 100644
--- a/examples/widgets/doc/src/orderform.qdoc
+++ b/examples/widgets/doc/src/orderform.qdoc
@@ -4,6 +4,7 @@
/*!
\example richtext/orderform
\title Order Form Example
+ \examplecategory {User Interface Components}
\ingroup examples-richtext
\brief The Order Form example shows how to generate rich text
documents by combining a simple template with data input by the
diff --git a/examples/widgets/doc/src/painterpaths.qdoc b/examples/widgets/doc/src/painterpaths.qdoc
index 55e78c849d..305a7608e5 100644
--- a/examples/widgets/doc/src/painterpaths.qdoc
+++ b/examples/widgets/doc/src/painterpaths.qdoc
@@ -4,12 +4,10 @@
/*!
\example painting/painterpaths
\title Painter Paths Example
+ \examplecategory {Graphics}
\ingroup examples-painting
- \brief The Painter Paths example shows how painter paths can be
- used to beuild complex shapes for rendering.
-
- \brief The Painter Paths example shows how painter paths can be used to
- build complex shapes for rendering.
+ \brief The Painter Paths example shows how to use painter paths
+ to build complex shapes for rendering.
\image painterpaths-example.png
@@ -103,7 +101,7 @@
explicitly start a new subpath using the QPainterPath::moveTo()
function.
- QPainterPath also provide the QPainterPath::addRect() convenience
+ QPainterPath also provides the QPainterPath::addRect() convenience
function, which adds a given rectangle to the path as a closed
subpath. The rectangle is added as a clockwise set of lines. The
painter path's current position after the rect has been added is
@@ -151,7 +149,7 @@
Constructing a polygon is equivalent to constructing a rectangle.
- QPainterPath also provide the QPainterPath::addPolygon()
+ QPainterPath also provides the QPainterPath::addPolygon()
convenience function which adds the given polygon to the path as a
new subpath. Current position after the polygon has been added is
the last point in polygon.
diff --git a/examples/widgets/doc/src/pathstroke.qdoc b/examples/widgets/doc/src/pathstroke.qdoc
index 01c3771d24..bc4001ebb5 100644
--- a/examples/widgets/doc/src/pathstroke.qdoc
+++ b/examples/widgets/doc/src/pathstroke.qdoc
@@ -4,6 +4,7 @@
/*!
\example painting/pathstroke
\title Path Stroking
+ \examplecategory {Graphics}
\ingroup examples-painting
\brief The Path Stroking example shows various types of pens that
can be used with QPainter.
diff --git a/examples/widgets/doc/src/pixelator.qdoc b/examples/widgets/doc/src/pixelator.qdoc
deleted file mode 100644
index ab6f639d87..0000000000
--- a/examples/widgets/doc/src/pixelator.qdoc
+++ /dev/null
@@ -1,231 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example itemviews/pixelator
- \title Pixelator Example
- \ingroup examples-itemviews
- \brief The Pixelator example shows how delegates can be used to customize the way that
- items are rendered in standard item views.
-
- \image pixelator-example.png
-
- By default, QTreeView, QTableView, and QListView use a standard item delegate
- to display and edit a set of common data types that are sufficient for many
- applications. However, an application may need to represent items of data in a
- particular way, or provide support for rendering more specialized data types,
- and this often requires the use of a custom delegate.
-
- In this example, we show how to use custom delegates to modify the appearance
- of standard views. To do this, we implement the following components:
-
- \list
- \li A model which represents each pixel in an image as an item of data, where each
- item contains a value for the brightness of the corresponding pixel.
- \li A custom delegate that uses the information supplied by the model to represent
- each pixel as a black circle on a white background, where the radius of the
- circle corresponds to the darkness of the pixel.
- \endlist
-
- This example may be useful for developers who want to implement their own table
- models or custom delegates. The process of creating custom delegates for editing
- item data is covered in the \l{Spin Box Delegate Example}{Spin Box Delegate}
- example.
-
- \section1 ImageModel Class Definition
-
- The \c ImageModel class is defined as follows:
-
- \snippet itemviews/pixelator/imagemodel.h 0
-
- Since we only require a simple, read-only table model, we only need to implement
- functions to indicate the dimensions of the image and supply data to other
- components.
-
- \section1 ImageModel Class Implementation
-
- The constructor is trivial:
-
- \snippet itemviews/pixelator/imagemodel.cpp 0
-
- The \c setImage() function sets the image that will be used by the model:
-
- \snippet itemviews/pixelator/imagemodel.cpp 1
-
- The QAbstractItemModel::reset() call tells the view(s) that the model
- has changed.
-
- The \c rowCount() and \c columnCount() functions return the height and width of
- the image respectively:
-
- \snippet itemviews/pixelator/imagemodel.cpp 2
- \snippet itemviews/pixelator/imagemodel.cpp 3
-
- Since the image is a simple two-dimensional structure, the \c parent arguments
- to these functions are unused. They both simply return the relevant size from
- the underlying image object.
-
- The \c data() function returns data for the item that corresponds to a given
- model index in a format that is suitable for a particular role:
-
- \snippet itemviews/pixelator/imagemodel.cpp 4
-
- In this implementation, we only check that the model index is valid, and that
- the role requested is the \l{Qt::ItemDataRole}{DisplayRole}. If so, the function
- returns the grayscale value of the relevant pixel in the image; otherwise, a null
- model index is returned.
-
- This model can be used with QTableView to display the integer brightness values
- for the pixels in the image. However, we will implement a custom delegate to
- display this information in a more artistic way.
-
- The \c headerData() function is also reimplemented:
-
- \snippet itemviews/pixelator/imagemodel.cpp 5
-
- We return (1, 1) as the size hint for a header item. If we
- didn't, the headers would default to a larger size, preventing
- us from displaying really small items (which can be specified
- using the \uicontrol{Pixel size} combobox).
-
- \section1 PixelDelegate Class Definition
-
- The \c PixelDelegate class is defined as follows:
-
- \snippet itemviews/pixelator/pixeldelegate.h 0
-
- This class provides only basic features for a delegate so, unlike the
- \l{Spin Box Delegate Example}{Spin Box Delegate} example, we subclass
- QAbstractItemDelegate instead of QItemDelegate.
-
- We only need to reimplement \l{QAbstractItemDelegate::paint()}{paint()} and
- \l{QAbstractItemDelegate::sizeHint()}{sizeHint()} in this class.
- However, we also provide a delegate-specific \c setPixelSize() function so
- that we can change the delegate's behavior via the signals and slots mechanism.
-
- \section1 PixelDelegate Class Implementation
-
- The \c PixelDelegate constructor is used to set up a default value for
- the size of each "pixel" that it renders. The base class constructor is
- also called to ensure that the delegate is set up with a parent object,
- if one is supplied:
-
- \snippet itemviews/pixelator/pixeldelegate.cpp 0
-
- Each item is rendered by the delegate's
- \l{QAbstractItemDelegate::paint()}{paint()} function. The view calls this
- function with a ready-to-use QPainter object, style information that the
- delegate should use to correctly draw the item, and an index to the item in
- the model:
-
- \snippet itemviews/pixelator/pixeldelegate.cpp 1
-
- The first task the delegate has to perform is to draw the item's background
- correctly. Usually, selected items appear differently to non-selected items,
- so we begin by testing the state passed in the style option and filling the
- background if necessary.
-
- The radius of each circle is calculated in the following lines of code:
-
- \snippet itemviews/pixelator/pixeldelegate.cpp 3
- \snippet itemviews/pixelator/pixeldelegate.cpp 4
-
- First, the largest possible radius of the circle is determined by taking the
- smallest dimension of the style option's \c rect attribute.
- Using the model index supplied, we obtain a value for the brightness of the
- relevant pixel in the image. The radius of the circle is calculated by
- scaling the brightness to fit within the item and subtracting it from the
- largest possible radius.
-
- \snippet itemviews/pixelator/pixeldelegate.cpp 5
- \snippet itemviews/pixelator/pixeldelegate.cpp 6
- \snippet itemviews/pixelator/pixeldelegate.cpp 7
-
- We save the painter's state, turn on antialiasing (to obtain smoother
- curves), and turn off the pen.
-
- \snippet itemviews/pixelator/pixeldelegate.cpp 8
- \snippet itemviews/pixelator/pixeldelegate.cpp 9
-
- The foreground of the item (the circle representing a pixel) must be
- rendered using an appropriate brush. For unselected items, we will use a
- solid black brush; selected items are drawn using a predefined brush from
- the style option's palette.
-
- \snippet itemviews/pixelator/pixeldelegate.cpp 10
-
- Finally, we paint the circle within the rectangle specified by the style
- option and we call \l{QPainter::}{restore()} on the painter.
-
- The \c paint() function does not have to be particularly complicated; it is
- only necessary to ensure that the state of the painter when the function
- returns is the same as it was when it was called. This usually
- means that any transformations applied to the painter must be preceded by
- a call to QPainter::save() and followed by a call to QPainter::restore().
-
- The delegate's \l{QAbstractItemDelegate::}{sizeHint()} function
- returns a size for the item based on the predefined pixel size, initially set
- up in the constructor:
-
- \snippet itemviews/pixelator/pixeldelegate.cpp 11
-
- The delegate's size is updated whenever the pixel size is changed.
- We provide a custom slot to do this:
-
- \snippet itemviews/pixelator/pixeldelegate.cpp 12
-
- \section1 Using The Custom Delegate
-
- In this example, we use a main window to display a table of data, using the
- custom delegate to render each cell in a particular way. Much of the
- \c MainWindow class performs tasks that are not related to item views. Here,
- we only quote the parts that are relevant. You can look at the rest of the
- implementation by following the links to the code at the top of this
- document.
-
- In the constructor, we set up a table view, turn off its grid, and hide its
- headers:
-
- \snippet itemviews/pixelator/mainwindow.cpp 0
- \dots
- \snippet itemviews/pixelator/mainwindow.cpp 1
-
- This enables the items to be drawn without any gaps between them. Removing
- the headers also prevents the user from adjusting the sizes of individual
- rows and columns.
-
- We also set the minimum section size to 1 on the headers. If we
- didn't, the headers would default to a larger size, preventing
- us from displaying really small items (which can be specified
- using the \uicontrol{Pixel size} combobox).
-
- The custom delegate is constructed with the main window as its parent, so
- that it will be deleted correctly later, and we set it on the table view.
-
- \snippet itemviews/pixelator/mainwindow.cpp 2
-
- Each item in the table view will be rendered by the \c PixelDelegate
- instance.
-
- We construct a spin box to allow the user to change the size of each "pixel"
- drawn by the delegate:
-
- \snippet itemviews/pixelator/mainwindow.cpp 3
-
- This spin box is connected to the custom slot we implemented in the
- \c PixelDelegate class. This ensures that the delegate always draws each
- pixel at the currently specified size:
-
- \snippet itemviews/pixelator/mainwindow.cpp 4
- \dots
- \snippet itemviews/pixelator/mainwindow.cpp 5
-
- We also connect the spin box to a slot in the \c MainWindow class. This
- forces the view to take into account the new size hints for each item;
- these are provided by the delegate in its \c sizeHint() function.
-
- \snippet itemviews/pixelator/mainwindow.cpp 6
-
- We explicitly resize the columns and rows to match the
- \uicontrol{Pixel size} combobox.
-*/
diff --git a/examples/widgets/doc/src/plugandpaint.qdoc b/examples/widgets/doc/src/plugandpaint.qdoc
deleted file mode 100644
index 2ee08311f2..0000000000
--- a/examples/widgets/doc/src/plugandpaint.qdoc
+++ /dev/null
@@ -1,527 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example tools/plugandpaint/app
- \title Plug & Paint Example
- \ingroup examples-widgets-tools
-
- \brief Demonstrates how to extend Qt applications using plugins.
-
- \image plugandpaint.png Screenshot of the Plug & Paint example
-
- A plugin is a dynamic library that can be loaded at run-time to
- extend an application. Qt makes it possible to create custom
- plugins and to load them using QPluginLoader. To ensure that
- plugins don't get lost, it is also possible to link them
- statically to the executable. The Plug & Paint example uses
- plugins to support custom brushes, shapes, and image filters. A
- single plugin can provide multiple brushes, shapes, and/or
- filters.
-
- If you want to learn how to make your own application extensible
- through plugins, we recommend that you start by reading this
- overview, which explains how to make an application use plugins.
- Afterwards, you can read the
- \l{tools/plugandpaint/plugins/basictools}{Basic Tools} and
- \l{tools/plugandpaint/plugins/extrafilters}{Extra Filters}
- overviews, which show how to implement static and dynamic
- plugins, respectively.
-
- Plug & Paint consists of the following classes:
-
- \list
- \li \c MainWindow is a QMainWindow subclass that provides the menu
- system and that contains a \c PaintArea as the central widget.
- \li \c PaintArea is a QWidget that allows the user to draw using a
- brush and to insert shapes.
- \li \c PluginDialog is a dialog that shows information about the
- plugins detected by the application.
- \li \c BrushInterface, \c ShapeInterface, and \c FilterInterface are
- abstract base classes that can be implemented by plugins to
- provide custom brushes, shapes, and image filters.
- \endlist
-
- \section1 The Plugin Interfaces
-
- We will start by reviewing the interfaces defined in \c
- interfaces.h. These interfaces are used by the Plug & Paint
- application to access extra functionality. They are implemented
- in the plugins.
-
-
- \snippet tools/plugandpaint/app/interfaces.h 0
-
- The \c BrushInterface class declares four pure virtual functions.
- The first pure virtual function, \c brushes(), returns a list of
- strings that identify the brushes provided by the plugin. By
- returning a QStringList instead of a QString, we make it possible
- for a single plugin to provide multiple brushes. The other
- functions have a \c brush parameter to identify which brush
- (among those returned by \c brushes()) is used.
-
- \c mousePress(), \c mouseMove(), and \c mouseRelease() take a
- QPainter and one or two \l{QPoint}s, and return a QRect
- identifying which portion of the image was altered by the brush.
-
- The class also has a virtual destructor. Interface classes
- usually don't need such a destructor (because it would make
- little sense to \c delete the object that implements the
- interface through a pointer to the interface), but some compilers
- emit a warning for classes that declare virtual functions but no
- virtual destructor. We provide the destructor to keep these
- compilers happy.
-
- \snippet tools/plugandpaint/app/interfaces.h 1
-
- The \c ShapeInterface class declares a \c shapes() function that
- works the same as \c{BrushInterface}'s \c brushes() function, and
- a \c generateShape() function that has a \c shape parameter.
- Shapes are represented by a QPainterPath, a data type that can
- represent arbitrary 2D shapes or combinations of shapes. The \c
- parent parameter can be used by the plugin to pop up a dialog
- asking the user to specify more information.
-
- \snippet tools/plugandpaint/app/interfaces.h 2
-
- The \c FilterInterface class declares a \c filters() function
- that returns a list of filter names, and a \c filterImage()
- function that applies a filter to an image.
-
- \snippet tools/plugandpaint/app/interfaces.h 4
-
- To make it possible to query at run-time whether a plugin
- implements a given interface, we must use the \c
- Q_DECLARE_INTERFACE() macro. The first argument is the name of
- the interface. The second argument is a string identifying the
- interface in a unique way. By convention, we use a "Java package
- name" syntax to identify interfaces. If we later change the
- interfaces, we must use a different string to identify the new
- interface; otherwise, the application might crash. It is therefore
- a good idea to include a version number in the string, as we did
- above.
-
- The \l{tools/plugandpaint/plugins/basictools}{Basic Tools} plugin
- and the \l{tools/plugandpaint/plugins/extrafilters}{Extra Filters}
- plugin shows how to derive from \c BrushInterface, \c
- ShapeInterface, and \c FilterInterface.
-
- A note on naming: It might have been tempting to give the \c
- brushes(), \c shapes(), and \c filters() functions a more generic
- name, such as \c keys() or \c features(). However, that would
- have made multiple inheritance impractical. When creating
- interfaces, we should always try to give unique names to the pure
- virtual functions.
-
- \section1 The MainWindow Class
-
- The \c MainWindow class is a standard QMainWindow subclass, as
- found in many of the other examples (e.g.,
- \l{mainwindows/application}{Application}). Here, we'll
- concentrate on the parts of the code that are related to plugins.
-
- \snippet tools/plugandpaint/app/mainwindow.cpp 4
-
- The \c loadPlugins() function is called from the \c MainWindow
- constructor to detect plugins and update the \uicontrol{Brush},
- \uicontrol{Shapes}, and \uicontrol{Filters} menus. We start by handling static
- plugins (available through QPluginLoader::staticInstances())
-
- To the application that uses the plugin, a Qt plugin is simply a
- QObject. That QObject implements plugin interfaces using multiple
- inheritance.
-
- \snippet tools/plugandpaint/app/mainwindow.cpp 5
-
- The next step is to load dynamic plugins. We initialize the \c
- pluginsDir member variable to refer to the \c plugins
- subdirectory of the Plug & Paint example. On Unix, this is just a
- matter of initializing the QDir variable with
- QApplication::applicationDirPath(), the path of the executable
- file, and to do a \l{QDir::cd()}{cd()}. On Windows and \macos,
- this file is usually located in a subdirectory, so we need to
- take this into account.
-
- \snippet tools/plugandpaint/app/mainwindow.cpp 6
- \snippet tools/plugandpaint/app/mainwindow.cpp 7
- \snippet tools/plugandpaint/app/mainwindow.cpp 8
-
- We use QDir::entryList() to get a list of all files in that
- directory. Then we iterate over the result using a range-based for loop
- and try to load the plugin using QPluginLoader.
-
- The QObject provided by the plugin is accessible through
- QPluginLoader::instance(). If the dynamic library isn't a Qt
- plugin, or if it was compiled against an incompatible version of
- the Qt library, QPluginLoader::instance() returns a null pointer.
-
- If QPluginLoader::instance() is non-null, we add it to the menus.
-
- \snippet tools/plugandpaint/app/mainwindow.cpp 9
-
- At the end, we enable or disable the \uicontrol{Brush}, \uicontrol{Shapes},
- and \uicontrol{Filters} menus based on whether they contain any items.
-
- \snippet tools/plugandpaint/app/mainwindow.cpp 10
-
- For each plugin (static or dynamic), we check which interfaces it
- implements using \l qobject_cast(). First, we try to cast the
- plugin instance to a \c BrushInterface; if it works, we call the
- private function \c addToMenu() with the list of brushes returned
- by \c brushes(). Then we do the same with the \c ShapeInterface
- and the \c FilterInterface.
-
- \snippet tools/plugandpaint/app/mainwindow.cpp 3
-
- The \c aboutPlugins() slot is called on startup and can be
- invoked at any time through the \uicontrol{About Plugins} action. It
- pops up a \c PluginDialog, providing information about the loaded
- plugins.
-
- \image plugandpaint-plugindialog.png Screenshot of the Plugin dialog
-
-
- The \c addToMenu() function is called from \c loadPlugin() to
- create \l{QAction}s for custom brushes, shapes, or filters and
- add them to the relevant menu. The QAction is created with the
- plugin from which it comes from as the parent; this makes it
- convenient to get access to the plugin later.
-
- \snippet tools/plugandpaint/app/mainwindow.cpp 0
-
- The \c changeBrush() slot is invoked when the user chooses one of
- the brushes from the \uicontrol{Brush} menu. We start by finding out
- which action invoked the slot using QObject::sender(). Then we
- get the \c BrushInterface out of the plugin (which we
- conveniently passed as the QAction's parent) and we call \c
- PaintArea::setBrush() with the \c BrushInterface and the string
- identifying the brush. Next time the user draws on the paint
- area, \c PaintArea will use this brush.
-
- \snippet tools/plugandpaint/app/mainwindow.cpp 1
-
- The \c insertShape() is invoked when the use chooses one of the
- shapes from the \uicontrol{Shapes} menu. We retrieve the QAction that
- invoked the slot, then the \c ShapeInterface associated with that
- QAction, and finally we call \c ShapeInterface::generateShape()
- to obtain a QPainterPath.
-
- \snippet tools/plugandpaint/app/mainwindow.cpp 2
-
- The \c applyFilter() slot is similar: We retrieve the QAction
- that invoked the slot, then the \c FilterInterface associated to
- that QAction, and finally we call \c
- FilterInterface::filterImage() to apply the filter onto the
- current image.
-
- \section1 The PaintArea Class
-
- The \c PaintArea class contains some code that deals with \c
- BrushInterface, so we'll review it briefly.
-
- \snippet tools/plugandpaint/app/paintarea.cpp 0
-
- In \c setBrush(), we simply store the \c BrushInterface and the
- brush that are given to us by \c MainWindow.
-
- \snippet tools/plugandpaint/app/paintarea.cpp 1
-
- In the \l{QWidget::mouseMoveEvent()}{mouse move event handler},
- we call the \c BrushInterface::mouseMove() function on the
- current \c BrushInterface, with the current brush. The mouse
- press and mouse release handlers are very similar.
-
- \section1 The PluginDialog Class
-
- The \c PluginDialog class provides information about the loaded
- plugins to the user. Its constructor takes a path to the plugins
- and a list of plugin file names. It calls \c findPlugins()
- to fill the QTreeWdiget with information about the plugins:
-
- \snippet tools/plugandpaint/app/plugindialog.cpp 0
-
- The \c findPlugins() is very similar to \c
- MainWindow::loadPlugins(). It uses QPluginLoader to access the
- static and dynamic plugins. Its helper function \c
- populateTreeWidget() uses \l qobject_cast() to find out which
- interfaces are implemented by the plugins:
-
- \snippet tools/plugandpaint/app/plugindialog.cpp 1
-
- \section1 Importing Static Plugins
-
- The \l{tools/plugandpaint/plugins/basictools}{Basic Tools} plugin
- is built as a static plugin, to ensure that it is always
- available to the application. This requires using the
- Q_IMPORT_PLUGIN() macro somewhere in the application (in a \c
- .cpp file) and specifying the plugin in the \c .pro file.
-
- For Plug & Paint, we have chosen to put Q_IMPORT_PLUGIN() in \c
- main.cpp:
-
- \snippet tools/plugandpaint/app/main.cpp 0
-
- The argument to Q_IMPORT_PLUGIN() is the plugin name, which corresponds
- with the name of the class that declares metadata for the plugin with
- Q_PLUGIN_METADATA().
-
- In the \c .pro file, we need to specify the static library.
- Here's the project file for building Plug & Paint:
-
- \snippet tools/plugandpaint/app/app.pro 0
-
- The \c LIBS line variable specifies the library \c pnp_basictools
- located in the \c ../plugandpaint/plugins/basictools directory.
- (Although the \c LIBS syntax has a distinct Unix flavor, \c qmake
- supports it on all platforms.)
-
- The \c CONFIG() code at the end is necessary for this example
- because the example is part of the Qt distribution and Qt can be
- configured to be built simultaneously in debug and in release
- modes. You don't need to for your own plugin applications.
-
- This completes our review of the Plug & Paint application. At
- this point, you might want to take a look at the
- \l{tools/plugandpaint/plugins/basictools}{Basic Tools} example
- plugin.
-*/
-
-/*!
- \example tools/plugandpaint/plugins/basictools
- \title Plug & Paint Basic Tools Example
- \brief A plugin providing the basic tools for painting functionality.
-
- \image plugandpaint.png Screenshot of the Plug & Paint example
-
- The Basic Tools example is a static plugin for the
- \l{tools/plugandpaint/app}{Plug & Paint} example. It provides a set
- of basic brushes, shapes, and filters. Through the Basic Tools
- example, we will review the four steps involved in writing a Qt
- plugin:
-
- \list 1
- \li Declare a plugin class.
- \li Implement the interfaces provided by the plugin.
- \li Export the plugin using the Q_PLUGIN_METADATA() macro.
- \li Build the plugin using an adequate \c .pro file.
- \endlist
-
- \section1 Declaration of the Plugin Class
-
- \snippet tools/plugandpaint/plugins/basictools/basictoolsplugin.h 0
-
- We start by including \c interfaces.h, which defines the plugin
- interfaces for the \l{tools/plugandpaint/app}{Plug & Paint}
- application. For the \c #include to work, we need to add an \c
- INCLUDEPATH entry to the \c .pro file with the path to the
- header file.
-
- The \c BasicToolsPlugin class is a QObject subclass that
- implements the \c BrushInterface, the \c ShapeInterface, and the
- \c FilterInterface. This is done through multiple inheritance.
- The \c Q_INTERFACES() macro is necessary to tell \l{moc}, Qt's
- meta-object compiler, that the base classes are plugin
- interfaces. Without the \c Q_INTERFACES() macro, we couldn't use
- \l qobject_cast() in the \l{tools/plugandpaint/app}{Plug & Paint}
- application to detect interfaces.
- For an explanation for the \c Q_PLUGIN_METADATA() macro see
- \l {Exporting the Plugin}.
-
- \snippet tools/plugandpaint/plugins/basictools/basictoolsplugin.h 2
-
- In the \c public section of the class, we declare all the
- functions from the three interfaces.
-
- \section1 Implementation of the Brush Interface
-
- Let's now review the implementation of the \c BasicToolsPlugin
- member functions inherited from \c BrushInterface.
-
- \snippet tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp 0
-
- The \c brushes() function returns a list of brushes provided by
- this plugin. We provide three brushes: \uicontrol{Pencil}, \uicontrol{Air
- Brush}, and \uicontrol{Random Letters}.
-
- \snippet tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp 1
-
- On a mouse press event, we just call \c mouseMove() to draw the
- spot where the event occurred.
-
- \snippet tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp 2
-
- In \c mouseMove(), we start by saving the state of the QPainter
- and we compute a few variables that we'll need later.
-
- \snippet tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp 3
-
- Then comes the brush-dependent part of the code:
-
- \list
- \li If the brush is \uicontrol{Pencil}, we just call
- QPainter::drawLine() with the current QPen.
-
- \li If the brush is \uicontrol{Air Brush}, we start by setting the
- painter's QBrush to Qt::Dense6Pattern to obtain a dotted
- pattern. Then we draw a circle filled with that QBrush several
- times, resulting in a thick line.
-
- \li If the brush is \uicontrol{Random Letters}, we draw a random letter
- at the new cursor position. Most of the code is for setting
- the font to be bold and larger than the default font and for
- computing an appropriate bounding rect.
- \endlist
-
- At the end, we restore the painter state to what it was upon
- entering the function and we return the bounding rectangle.
-
- \snippet tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp 4
-
- When the user releases the mouse, we do nothing and return an
- empty QRect.
-
- \section1 Implementation of the Shape Interface
-
- \snippet tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp 5
-
- The plugin provides three shapes: \uicontrol{Circle}, \uicontrol{Star}, and
- \uicontrol{Text...}. The three dots after \uicontrol{Text} are there because
- the shape pops up a dialog asking for more information. We know
- that the shape names will end up in a menu, so we include the
- three dots in the shape name.
-
- A cleaner but more complicated design would have been to
- distinguish between the internal shape name and the name used in
- the user interface.
-
- \snippet tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp 6
-
- The \c generateShape() creates a QPainterPath for the specified
- shape. If the shape is \uicontrol{Text}, we pop up a QInputDialog to
- let the user enter some text.
-
- \section1 Implementation of the Filter Interface
-
- \snippet tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp 7
-
- The plugin provides three filters: \uicontrol{Invert Pixels}, \uicontrol{Swap
- RGB}, and \uicontrol{Grayscale}.
-
- \snippet tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp 8
-
- The \c filterImage() function takes a filter name and a QImage as
- parameters and returns an altered QImage. The first thing we do
- is to convert the image to a 32-bit RGB format, to ensure that
- the algorithms will work as expected. For example,
- QImage::invertPixels(), which is used to implement the
- \uicontrol{Invert Pixels} filter, gives counterintuitive results for
- 8-bit images, because they invert the indices into the color
- table instead of inverting the color table's entries.
-
- \section1 Exporting the Plugin
-
- To finally export your plugin you just have to add the
- \c Q_PLUGIN_METADATA() macro right next to the \c Q_OBJECT() macro
- into the header file of the plugin.
- It must contain the plugins IID and optionally a filename pointing
- to a json file containing the metadata for the plugin.
-
- \snippet tools/plugandpaint/plugins/basictools/basictoolsplugin.h 4
-
- Within this example the json file does not need to export any metadata,
- so it just contains an empty json object.
-
- \code
- {}
- \endcode
-
- \section1 The .pro File
-
- Here's the project file for building the Basic Tools plugin:
-
- \snippet tools/plugandpaint/plugins/basictools/basictools.pro 0
-
- The \c .pro file differs from typical \c .pro files in many
- respects. First, it starts with a \c TEMPLATE entry specifying \c
- lib. (The default template is \c app.) It also adds \c plugin to
- the \c CONFIG variable. This is necessary on some platforms to
- avoid generating symbolic links with version numbers in the file
- name, which is appropriate for most dynamic libraries but not for
- plugins.
-
- To make the plugin a static plugin, all that is required is to
- specify \c static in addition to \c plugin. The
- \l{tools/plugandpaint/plugins/extrafilters}{Extra Filters} plugin,
- which is compiled as a dynamic plugin, doesn't specify \c static
- in its \c .pro file.
-
- The \c INCLUDEPATH variable sets the search paths for global
- headers (i.e., header files included using \c{#include <...>}).
- We add \c ../../app to the list, so that we can include
- \c <interfaces.h>.
-
- The \c TARGET variable specifies which name we want to give the
- target library. We use \c pnp_ as the prefix to show that the
- plugin is designed to work with Plug & Paint. On Unix, \c lib is
- also prepended to that name. On all platforms, a
- platform-specific suffix is appended (e.g., \c .dll on Windows,
- \c .a on Linux).
-
- The \c CONFIG() code at the end is necessary for this example
- because the example is part of the Qt distribution and Qt can be
- configured to be built simultaneously in debug and in release
- modes. You don't need to for your own plugins.
-*/
-
-/*!
- \example tools/plugandpaint/plugins/extrafilters
- \title Plug & Paint Extra Filters Example
- \brief A plugin providing the extra filters.
-
- \image plugandpaint.png Screenshot of the Plug & Paint example
-
- The Extra Filters example is a plugin for the
- \l{tools/plugandpaint/app}{Plug & Paint} example. It provides a set
- of filters in addition to those provided by the
- \l{tools/plugandpaint/plugins/basictools}{Basic Tools} plugin.
-
- Since the approach is identical to
- \l{tools/plugandpaint/plugins/basictools}{Basic Tools}, we won't
- review the code here. The only part of interest is the
- \c .pro file, since Extra Filters is a dynamic plugin
- (\l{tools/plugandpaint/plugins/basictools}{Basic Tools} is
- linked statically into the Plug & Paint executable).
-
- Here's the project file for building the Extra Filters plugin:
-
- \snippet tools/plugandpaint/plugins/extrafilters/extrafilters.pro 0
-
- The \c .pro file differs from typical \c .pro files in many
- respects. First, it starts with a \c TEMPLATE entry specifying \c
- lib. (The default template is \c app.) It also adds \c plugin to
- the \c CONFIG variable. This is necessary on some platforms to
- avoid generating symbolic links with version numbers in the file
- name, which is appropriate for most dynamic libraries but not for
- plugins.
-
- The \c INCLUDEPATH variable sets the search paths for global
- headers (i.e., header files included using \c{#include <...>}).
- We add \c ../../app to the list, so that we can include
- \c <interfaces.h>.
-
- The \c TARGET variable specifies which name we want to give the
- target library. We use \c pnp_ as the prefix to show that the
- plugin is designed to work with Plug & Paint. On Unix, \c lib is
- also prepended to that name. On all platforms, a
- platform-specific suffix is appended (e.g., \c .dll on Windows,
- \c .so on Linux).
-
- The \c DESTDIR variable specifies where we want to install the
- plugin. We put it in Plug & Paint's \c plugins subdirectory,
- since that's where the application looks for dynamic plugins.
-
- The \c CONFIG() code at the end is necessary for this example
- because the example is part of the Qt distribution and Qt can be
- configured to be built simultaneously in debug and in release
- modes. You don't need to for your own plugins.
-*/
diff --git a/examples/widgets/doc/src/regularexpression.qdoc b/examples/widgets/doc/src/regularexpression.qdoc
index 8d7aa61629..f6f1e87689 100644
--- a/examples/widgets/doc/src/regularexpression.qdoc
+++ b/examples/widgets/doc/src/regularexpression.qdoc
@@ -4,6 +4,7 @@
/*!
\example tools/regularexpression
\title QRegularExpression Example
+ \examplecategory {User Interface Components}
\ingroup examples-widgets-tools
\brief The QRegularExpression example shows how regular expressions in Qt are
diff --git a/examples/widgets/doc/src/screenshot.qdoc b/examples/widgets/doc/src/screenshot.qdoc
index 54826dc1dd..2e2b3123ef 100644
--- a/examples/widgets/doc/src/screenshot.qdoc
+++ b/examples/widgets/doc/src/screenshot.qdoc
@@ -3,7 +3,8 @@
/*!
\example desktop/screenshot
- \title Screenshot Example
+ \title Taking a Screenshot
+ \examplecategory {Desktop}
\ingroup examples-desktop
\brief The Screenshot example shows how to take a screenshot of the
desktop.
diff --git a/examples/widgets/doc/src/scribble.qdoc b/examples/widgets/doc/src/scribble.qdoc
index 1a87576e39..3cd7205397 100644
--- a/examples/widgets/doc/src/scribble.qdoc
+++ b/examples/widgets/doc/src/scribble.qdoc
@@ -4,6 +4,7 @@
/*!
\example widgets/scribble
\title Scribble Example
+ \examplecategory {User Interface Components}
\ingroup examples-widgets
\brief The Scribble example shows how to reimplement some of QWidget's
event handlers to receive the events generated for the
diff --git a/examples/widgets/doc/src/sdi.qdoc b/examples/widgets/doc/src/sdi.qdoc
deleted file mode 100644
index eebb50cbfe..0000000000
--- a/examples/widgets/doc/src/sdi.qdoc
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example mainwindows/sdi
- \title SDI Example
- \ingroup examples-mainwindow
-
- \brief The SDI example shows how to create a Single Document Interface. It uses a number of
- top-level windows to display the contents of different text files.
-
- \image sdi-example.png
-*/
diff --git a/examples/widgets/doc/src/settingseditor.qdoc b/examples/widgets/doc/src/settingseditor.qdoc
deleted file mode 100644
index 55226a9846..0000000000
--- a/examples/widgets/doc/src/settingseditor.qdoc
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example tools/settingseditor
- \title Settings Editor Example
- \ingroup examples-widgets-tools
-
- \brief The Settings Editor example shows how Qt's standard settings support is used in an
- application by providing an editor that enables the user to view the settings for
- installed applications, and modify those that can be edited.
-
- \image settingseditor-example.png
-*/
diff --git a/examples/widgets/doc/src/shapedclock.qdoc b/examples/widgets/doc/src/shapedclock.qdoc
index a571086370..4bcd04683c 100644
--- a/examples/widgets/doc/src/shapedclock.qdoc
+++ b/examples/widgets/doc/src/shapedclock.qdoc
@@ -3,17 +3,19 @@
/*!
\example widgets/shapedclock
- \title Shaped Clock Example
+ \title Translucent Background
+ \examplecategory {User Interface Components}
\ingroup examples-widgets
- \brief The Shaped Clock example shows how to apply a translucent background
- and a widget mask to a top-level widget to produce a shaped window.
+ \brief The example shows how to make a round window with a translucent
+ background.
\borderedimage shapedclock-example.png
- Widget masks are used to customize the shapes of top-level widgets by
- restricting the area available for painting and mouse input. Using a
- translucent background facilitates partially transparent windows and smooth
- edges. On most window systems, setting certain window flags will cause the
+ Widgets that set their background to be translucent will be transparent for all
+ unpainted pixels, and the background will shine through pixels painted with an
+ opacity of less than 100%. Pixels that are not painted at all will also not
+ receive any mouse input. This can be used to customize the shapes of top-level
+ widgets. On most window systems, setting certain window flags will cause the
window decoration (title bar, window frame, buttons) to be disabled,
allowing specially-shaped windows to be created. In this example, we use
this feature to create a circular window containing an analog clock.
@@ -25,17 +27,15 @@
\section1 ShapedClock Class Definition
The \c ShapedClock class is based on the \c AnalogClock class defined in the
- \l{Analog Clock Example}{Analog Clock} example. The whole class definition is
+ \l{Analog Clock} example. The whole class definition is
presented below:
\snippet widgets/shapedclock/shapedclock.h 0
- The \l{QWidget::paintEvent()}{paintEvent()} implementation is the same as
- that found in the \c AnalogClock class, with one important exception: we
- now must also draw background (the clock face) ourselves, since the widget
- background is just transparent. We implement \l{QWidget::sizeHint()}{sizeHint()}
- so that we don't have to resize the widget explicitly. We also provide an event
- handler for resize events. This allows us to update the mask if the clock is resized.
+ The \l{QWidget::paintEvent()}{paintEvent()} implementation draws an analog clock
+ on a semi-transparent background (the clock face). In addition, we implement
+ \l{QWidget::sizeHint()}{sizeHint()} so that we don't have to resize the widget
+ explicitly.
Since the window containing the clock widget will have no title bar, we provide
implementations for \l{QWidget::mouseMoveEvent()}{mouseMoveEvent()} and
@@ -45,8 +45,9 @@
\section1 ShapedClock Class Implementation
- The \c ShapedClock constructor performs many of the same tasks as the \c AnalogClock
- constructor. We set up a timer and connect it to the widget's update() slot:
+ The \c ShapedClock constructor sets up a timer and connect it to the widget's
+ update() slot. In addition, we add an action to the widget, which will automatically
+ become available through a context menu when right-clicking on the widget.
\snippet widgets/shapedclock/shapedclock.cpp 0
@@ -77,49 +78,14 @@
cursor position in global coordinates. If we drag the widget, we also accept the event.
The \c paintEvent() function is mainly the same as described in the
- \l{Analog Clock Example}{Analog Clock} example. The one addition is that we
- use QPainter::drawEllipse() to draw a round clock face with the current
- palette's default background color. We make the clock face a bit smaller
- than the widget mask, so that the anti-aliased, semi-transparent pixels on
- the edge are not clipped away by the widget mask. This gives the shaped
- window smooth edges on the screen.
+ \l{Analog Clock} example. The one addition is that we use QPainter::drawEllipse() to
+ draw a round clock face. We reduce the painter's opacity to 90%, and use the palette's
+ default background color.
\snippet widgets/shapedclock/shapedclock.cpp 3
- In the \c resizeEvent() handler, we re-use some of the code from the \c
- paintEvent() to determine the region of the widget that is visible to the
- user. This tells the system the area where mouse clicks should go to us,
- and not to whatever window is behind us:
-
- \snippet widgets/shapedclock/shapedclock.cpp 4
-
- Since the clock face is a circle drawn in the center of the widget, this is the region
- we use as the mask.
-
- Although the lack of a window frame may make it difficult for the user to resize the
- widget on some platforms, it will not necessarily be impossible. The \c resizeEvent()
- function ensures that the widget mask will always be updated if the widget's dimensions
- change, and additionally ensures that it will be set up correctly when the widget is
- first displayed.
-
Finally, we implement the \c sizeHint() for the widget so that it is given a reasonable
default size when it is first shown:
- \snippet widgets/shapedclock/shapedclock.cpp 5
-
- \section1 Notes on Widget Masks
-
- Widget masks are used to hint to the window system that the application
- does not want mouse events for areas outside the mask. On most systems,
- they also result in coarse visual clipping. To get smooth window edges, one
- should use translucent background and anti-aliased painting, as shown in
- this example.
-
- Since QRegion allows arbitrarily complex regions to be created, widget masks can be
- made to suit the most unconventionally-shaped windows, and even allow widgets to be
- displayed with holes in them.
-
- Widget masks can also be constructed by using the contents of pixmap to define the
- opaque part of the widget. For a pixmap with an alpha channel, a suitable mask can be
- obtained with QPixmap::mask().
+ \snippet widgets/shapedclock/shapedclock.cpp 4
*/
diff --git a/examples/widgets/doc/src/shortcuteditor.qdoc b/examples/widgets/doc/src/shortcuteditor.qdoc
new file mode 100644
index 0000000000..9999a18421
--- /dev/null
+++ b/examples/widgets/doc/src/shortcuteditor.qdoc
@@ -0,0 +1,231 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example widgets/shortcuteditor
+ \title Shortcut Editor Example
+ \examplecategory {User Interface Components}
+ \ingroup examples-widgets
+ \brief The Shortcut Editor example shows how to create a basic, read-write
+ hierarchical model to use with Qt's standard view and QKeySequenceEdit
+ classes. For a description of Model/View Programming, see the \l{Model/View
+ Programming} overview.
+
+ \image shortcuteditor-example.png
+
+ Qt's model/view architecture provides a standard way for views to
+ manipulate information in a data source, using an abstract model
+ of the data to simplify and standardize the way it is accessed.
+ The shortcut editor model represents the actions as a tree of items, and
+ allow views to access this data via an
+ \l{Model/View Programming#Models}{index-based} system. More generally,
+ models can be used to represent data in the form of a tree structure
+ by allowing each item to act as a parent to a table of child items.
+
+ \section1 Design and Concepts
+
+ The data structure that we use to represent the structure of the data takes
+ the form of a tree built from ShortcutEditorModelItem objects. Each
+ ShortcutEditorModelItem represents an item in a tree view, and contains
+ two columns of data.
+
+ \table
+ \row \li \inlineimage treemodel-structure.png
+ \li \b{Shortcut Editor Structure}
+
+ The data is stored internally in the model using ShortcutEditorModelItem
+ objects that are linked together in a pointer-based tree structure.
+ Generally, each ShortcutEditorModelItem has a parent item, and can have a
+ number of child items. However, the root item in the tree structure has no
+ parent item and it is never referenced outside the model.
+
+ Each ShortcutEditorModelItem contains information about its place in the
+ tree structure; it can return its parent item and its row number. Having
+ this information readily available makes implementing the model easier.
+
+ Since each item in a tree view usually contains several columns of data
+ (a name and a shortcut in this example), it is natural to store this
+ information in each item. For simplicity, we will use a list of QVariant
+ objects to store the data for each column in the item.
+ \endtable
+
+ The use of a pointer-based tree structure means that, when passing a
+ model index to a view, we can record the address of the corresponding
+ item in the index (see QAbstractItemModel::createIndex()) and retrieve
+ it later with QModelIndex::internalPointer(). This makes writing the
+ model easier and ensures that all model indexes that refer to the same
+ item have the same internal data pointer.
+
+ With the appropriate data structure in place, we can create a tree model
+ with a minimal amount of extra code to supply model indexes and data to
+ other components.
+
+ \section1 ShortcutEditorModelItem Class Definition
+
+ The ShortcutEditorModelItem class is defined as follows:
+
+ The class is a basic C++ class. It does not inherit from QObject or
+ provide signals and slots. It is used to hold a list of QVariants,
+ containing column data, and information about its position in the tree
+ structure. The functions provide the following features:
+
+ \list
+ \li The \c appendChildItem() is used to add data when the model is first
+ constructed and is not used during normal use.
+ \li The \c child() and \c childCount() functions allow the model to obtain
+ information about any child items.
+ \li Information about the number of columns associated with the item is
+ provided by \c columnCount(), and the data in each column can be
+ obtained with the data() function.
+ \li The \c row() and \c parent() functions are used to obtain the item's
+ row number and parent item.
+ \endlist
+
+ The parent item and column data are stored in the \c parentItem and
+ \c itemData private member variables. The \c childItems variable contains
+ a list of pointers to the item's own child items.
+
+ \section1 ShortcutEditorModel Class Definition
+
+ The \c ShortcutEditorModel class is defined as follows:
+
+ \snippet widgets/shortcuteditor/shortcuteditormodel.h 0
+
+ This class is similar to most other subclasses of QAbstractItemModel that
+ provide read-write models. Only the form of the constructor and the
+ \c setupModelData() function are specific to this model. In addition, we
+ provide a destructor to clean up when the model is destroyed.
+
+ \section1 ShortcutEditorModel Class Implementation
+
+ The constructor takes an argument containing the data that the model will
+ share with views and delegates:
+
+ \snippet widgets/shortcuteditor/shortcuteditormodel.cpp 0
+
+ It is up to the constructor to create a root item for the model. This
+ item only contains vertical header data for convenience. We also use it
+ to reference the internal data structure that contains the model data,
+ and it is used to represent an imaginary parent of top-level items in
+ the model.
+
+ The model's internal data structure is populated with items by the
+ \c setupModelData() function. We will examine this function separately
+ at the end of this document.
+
+ The destructor ensures that the root item and all of its descendants
+ are deleted when the model is destroyed:
+
+ \snippet widgets/shortcuteditor/shortcuteditormodel.cpp 1
+
+ Since we cannot add data to the model after it is constructed and set
+ up, this simplifies the way that the internal tree of items is managed.
+
+ Models must implement an \c index() function to provide indexes for
+ views and delegates to use when accessing data. Indexes are created
+ for other components when they are referenced by their row and column
+ numbers, and their parent model index. If an invalid model
+ index is specified as the parent, it is up to the model to return an
+ index that corresponds to a top-level item in the model.
+
+ When supplied with a model index, we first check whether it is valid.
+ If it is not, we assume that a top-level item is being referred to;
+ otherwise, we obtain the data pointer from the model index with its
+ \l{QModelIndex::internalPointer()}{internalPointer()} function and use
+ it to reference a \c TreeItem object. Note that all the model indexes
+ that we construct will contain a pointer to an existing \c TreeItem,
+ so we can guarantee that any valid model indexes that we receive will
+ contain a valid data pointer.
+
+ \snippet widgets/shortcuteditor/shortcuteditormodel.cpp 2
+
+ Since the row and column arguments to this function refer to a
+ child item of the corresponding parent item, we obtain the item using
+ the \c TreeItem::child() function. The
+ \l{QAbstractItemModel::createIndex()}{createIndex()} function is used
+ to create a model index to be returned. We specify the row and column
+ numbers, and a pointer to the item itself. The model index can be used
+ later to obtain the item's data.
+
+ The way that the \c TreeItem objects are defined makes writing the
+ \c parent() function easy:
+
+ \snippet widgets/shortcuteditor/shortcuteditormodel.cpp 3
+
+ We only need to ensure that we never return a model index corresponding
+ to the root item. To be consistent with the way that the \c index()
+ function is implemented, we return an invalid model index for the
+ parent of any top-level items in the model.
+
+ When creating a model index to return, we must specify the row and
+ column numbers of the parent item within its own parent. We can
+ easily discover the row number with the \c TreeItem::row() function,
+ but we follow a convention of specifying 0 as the column number of
+ the parent. The model index is created with
+ \l{QAbstractItemModel::createIndex()}{createIndex()} in the same way
+ as in the \c index() function.
+
+ The \c rowCount() function simply returns the number of child items
+ for the \c TreeItem that corresponds to a given model index, or the
+ number of top-level items if an invalid index is specified:
+
+ \snippet widgets/shortcuteditor/shortcuteditormodel.cpp 4
+
+ Since each item manages its own column data, the \c columnCount()
+ function has to call the item's own \c columnCount() function to
+ determine how many columns are present for a given model index.
+ As with the \c rowCount() function, if an invalid model index is
+ specified, the number of columns returned is determined from the
+ root item:
+
+ \snippet widgets/shortcuteditor/shortcuteditormodel.cpp 5
+
+ Data is obtained from the model via \c data(). Since the item manages
+ its own columns, we need to use the column number to retrieve the data
+ with the \c TreeItem::data() function:
+
+ \snippet widgets/shortcuteditor/shortcuteditormodel.cpp 6
+
+ Note that we only support the \l{Qt::ItemDataRole}{DisplayRole}
+ in this implementation, and we also return invalid QVariant objects for
+ invalid model indexes.
+
+ We use the \c flags() function to ensure that views know that the
+ model is read-only:
+
+ \snippet widgets/shortcuteditor/shortcuteditormodel.cpp 7
+
+ The \c headerData() function returns data that we conveniently stored
+ in the root item:
+
+ \snippet widgets/shortcuteditor/shortcuteditormodel.cpp 8
+
+ This information could have been supplied in a different way: either
+ specified in the constructor, or hard coded into the \c headerData()
+ function.
+
+ \snippet widgets/shortcuteditor/shortcuteditormodel.cpp 9
+
+ TODO
+
+ \snippet widgets/shortcuteditor/shortcuteditormodel.cpp 10
+
+ TODO
+
+ \snippet widgets/shortcuteditor/shortcuteditormodel.cpp 11
+
+ TODO
+
+ \section1 Setting Up the Data in the Model
+
+ We use the \c setupModelData() function to set up the initial data in
+ the model. This function retrieves the registered actions text and creates
+ item objects that record both the data and the overall model structure.
+ Naturally, this function works in a way that is very specific to
+ this model. We provide the following description of its behavior,
+ and refer the reader to the example code itself for more information.
+
+ To ensure that the model works correctly, it is only necessary to
+ create instances of ShortcutEditorModelItem with the correct data and
+ parent item.
+*/
diff --git a/examples/widgets/doc/src/simpledommodel.qdoc b/examples/widgets/doc/src/simpledommodel.qdoc
deleted file mode 100644
index 82bd5c5d54..0000000000
--- a/examples/widgets/doc/src/simpledommodel.qdoc
+++ /dev/null
@@ -1,256 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example itemviews/simpledommodel
- \title Simple DOM Model Example
- \ingroup examples-itemviews
- \brief The Simple DOM Model example shows how an existing class can be adapted for use with
- the model/view framework.
-
- \image simpledommodel-example.png
-
- Qt provides two complementary sets of classes for reading XML files: The classes based
- around QXmlReader provide a SAX-style API for incremental reading of large files, and
- the classes based around QDomDocument enable developers to access the contents of XML
- files using a Document Object Model (DOM) API.
-
- In this example, we create a model that uses the DOM API to expose the structure and
- contents of XML documents to views via the standard QAbstractModel interface.
-
- \section1 Design and Concepts
-
- Reading an XML document with Qt's DOM classes is a straightforward process. Typically,
- the contents of a file are supplied to QDomDocument, and nodes are accessed using the
- functions provided by QDomNode and its subclasses.
-
- \omit
- For example, the following code
- snippet reads the contents of a file into a QDomDocument object and traverses the
- document, reading all the plain text that can be found:
-
- \snippet doc/src/snippets/code/doc_src_examples_simpledommodel.cpp 0
-
- In principle, the functions provided by QDomNode can be used to navigate from any
- given starting point in a document to the piece of data requested by another component.
- Since QDomDocument maintains information about the structure of a document, we can
- use this to implement the required virtual functions in a QAbstractItemModel subclass.
- \endomit
-
- The aim is to use the structure provided by QDomDocument by wrapping QDomNode objects
- in item objects similar to the \c TreeItem objects used in the
- \l{Simple Tree Model Example}{Simple Tree Model} example.
-
- \section1 DomModel Class Definition
-
- Let us begin by examining the \c DomModel class:
-
- \snippet itemviews/simpledommodel/dommodel.h 0
-
- The class definition contains all the basic functions that are needed for a
- read-only model. Only the constructor and \c document() function are specific to
- this model. The private \c domDocument variable is used to hold the document
- that is exposed by the model; the \c rootItem variable contains a pointer to
- the root item in the model.
-
- \section1 DomItem Class Definition
-
- The \c DomItem class is used to hold information about a specific QDomNode in
- the document:
-
- \snippet itemviews/simpledommodel/domitem.h 0
-
- Each \c DomItem provides a wrapper for a QDomNode obtained from the underlying
- document which contains a reference to the node, it's location in the parent node's
- list of child nodes, and a pointer to a parent wrapper item.
-
- The \c parent(), \c child(), and \c row() functions are convenience functions for
- the \c DomModel to use that provide basic information about the item to be discovered
- quickly. The node() function provides access to the underlying QDomNode object.
-
- As well as the information supplied in the constructor, the class maintains a cache
- of information about any child items. This is used to provide a collection of
- persistent item objects that the model can identify consistently and improve the
- performance of the model when accessing child items.
-
- \section1 DomItem Class Implementation
-
- Since the \c DomItem class is only a thin wrapper around QDomNode objects, with a
- few additional features to help improve performance and memory usage, we can provide
- a brief outline of the class before discussing the model itself.
-
- The constructor simply records details of the QDomNode that needs to be wrapped:
-
- \snippet itemviews/simpledommodel/domitem.cpp 0
- \snippet itemviews/simpledommodel/domitem.cpp 1
-
- As a result, functions to provide the parent wrapper, the row number occupied by
- the item in its parent's list of children, and the underlying QDomNode for each item
- are straightforward to write:
-
- \snippet itemviews/simpledommodel/domitem.cpp 4
- \codeline
- \snippet itemviews/simpledommodel/domitem.cpp 6
- \codeline
- \snippet itemviews/simpledommodel/domitem.cpp 3
-
- It is necessary to maintain a collection of items which can be consistently identified
- by the model. For that reason, we maintain a hash of child wrapper items that, to
- minimize memory usage, is initially empty. The model uses the item's \c child()
- function to help create model indexes, and this constructs wrappers for the children
- of the item's QDomNode, relating the row number of each child to the newly-constructed
- wrapper:
-
- \snippet itemviews/simpledommodel/domitem.cpp 5
-
- If a QDomNode was previously wrapped, the cached wrapper is returned; otherwise, a
- new wrapper is constructed and stored for valid children, and zero is returned for
- invalid ones.
-
- The class's destructor deletes all the child items of the wrapper:
-
- \snippet itemviews/simpledommodel/domitem.cpp 2
-
- These, in turn, will delete their children and free any QDomNode objects in use.
-
- \section1 DomModel Class Implementation
-
- The structure provided by the \c DomItem class makes the implementation of \c DomModel
- similar to the \c TreeModel shown in the
- \l{Simple Tree Model Example}{Simple Tree Model} example.
-
- The constructor accepts an existing document and a parent object for the model:
-
- \snippet itemviews/simpledommodel/dommodel.cpp 0
-
- A shallow copy of the document is stored for future reference, and a root item is
- created to provide a wrapper around the document. We assign the root item a row
- number of zero only to be consistent since the root item will have no siblings.
-
- Since the model only contains information about the root item, the destructor only
- needs to delete this one item:
-
- \snippet itemviews/simpledommodel/dommodel.cpp 1
-
- All of the child items in the tree will be deleted by the \c DomItem destructor as
- their parent items are deleted.
-
- \section2 Basic Properties of The Model
-
- Some aspects of the model do not depend on the structure of the underlying document,
- and these are simple to implement.
-
- The number of columns exposed by the model is returned by the \c columnCount()
- function:
-
- \snippet itemviews/simpledommodel/dommodel.cpp 2
-
- This value is fixed, and does not depend on the location or type of the underlying
- node in the document. We will use these three columns to display different kinds of
- data from the underlying document.
-
- Since we only implement a read-only model, the \c flags() function is straightforward
- to write:
-
- \snippet itemviews/simpledommodel/dommodel.cpp 5
-
- Since the model is intended for use in a tree view, the \c headerData() function only
- provides a horizontal header:
-
- \snippet itemviews/simpledommodel/dommodel.cpp 6
-
- The model presents the names of nodes in the first column, element attributes in the
- second, and any node values in the third.
-
- \section2 Navigating The Document
-
- The index() function creates a model index for the item with the given row, column,
- and parent in the model:
-
- \snippet itemviews/simpledommodel/dommodel.cpp 7
-
- The function first has to relate the parent index to an item that contains a node
- from the underlying document. If the parent index is invalid, it refers to the root
- node in the document, so we retrieve the root item that wraps it; otherwise, we
- obtain a pointer to the relevant item using the QModelIndex::internalPointer()
- function. We are able to extract a pointer in this way because any valid model index
- will have been created by this function, and we store pointers to item objects in
- any new indexes that we create with QAbstractItemModel::createIndex():
-
- \snippet itemviews/simpledommodel/dommodel.cpp 8
-
- A child item for the given row is provided by the parent item's \c child() function.
- If a suitable child item was found then we call
- \l{QAbstractItemModel::createIndex()}{createIndex()} to produce a model index for the
- requested row and column, passing a pointer to the child item for it to store
- internally. If no suitable child item is found, an invalid model index is returned.
-
- Note that the items themselves maintain ownership of their child items. This means
- that the model does not need to keep track of the child items that have been created,
- and can let the items themselves tidy up when they are deleted.
-
- The number of rows beneath a given item in the model is returned by the \c rowCount()
- function, and is the number of child nodes contained by the node that corresponds to
- the specified model index:
-
- \snippet itemviews/simpledommodel/dommodel.cpp 10
-
- To obtain the relevant node in the underlying document, we access the item via the
- internal pointer stored in the model index. If an invalid index is supplied, the
- root item is used instead. We use the item's \c node() function to access the node
- itself, and simply count the number of child nodes it contains.
-
- Since the model is used to represent a hierarchical data structure, it needs to
- provide an implementation for the \c parent() function. This returns a model index
- that corresponds to the parent of a child model index supplied as its argument:
-
- \snippet itemviews/simpledommodel/dommodel.cpp 9
-
- For valid indexes other than the index corresponding to the root item, we obtain
- a pointer to the relevant item using the method described in the \c index() function,
- and use the item's \c parent() function to obtain a pointer to the parent item.
-
- If no valid parent item exists, or if the parent item is the root item, we can simply
- follow convention and return an invalid model index. For all other parent items, we
- create a model index containing the appropriate row and column numbers, and a pointer
- to the parent item we just obtained.
-
- Data is provided by the \c data() function. For simplicity, we only provide data for
- the \l{Qt::DisplayRole}{display role}, returning an invalid variant for all other
- requests:
-
- \snippet itemviews/simpledommodel/dommodel.cpp 3
-
- As before, we obtain an item pointer for the index supplied, and use it to obtain
- the underlying document node. Depending on the column specified, the data we return
- is obtained in different ways:
-
- \snippet itemviews/simpledommodel/dommodel.cpp 4
-
- For the first column, we return the node's name. For the second column, we read any
- attributes that the node may have, and return a string that contains a space-separated
- list of attribute-value assignments. For the third column, we return any value that
- the node may have; this allows the contents of text nodes to be displayed in a view.
-
- If data from any other column is requested, an invalid variant is returned.
-
- \section1 Implementation Notes
-
- Ideally, we would rely on the structure provided by QDomDocument to help us write
- the \l{QAbstractItemModel::parent()}{parent()} and
- \l{QAbstractItemModel::index()}{index()} functions that are required when subclassing
- QAbstractItemModel. However, since Qt's DOM classes use their own system for
- dynamically allocating memory for DOM nodes, we cannot guarantee that the QDomNode
- objects returned for a given piece of information will be the same for subsequent
- accesses to the document.
-
- We use item wrappers for each QDomNode to provide consistent pointers that the model
- can use to navigate the document structure.
- \omit
- Since these items contain value references to the QDomNode objects themselves, this
- has the side effect that the DOM nodes themselves can be used to reliably navigate
- the document [not sure about this - QDom* may return different QDomNode objects for
- the same piece of information]. However, this advantage is redundant since we need to
- use wrapper items to obtain it. [Possible use of QDomNode cache in the model itself.]
- \endomit
-*/
diff --git a/examples/widgets/doc/src/simplerhiwidget.qdoc b/examples/widgets/doc/src/simplerhiwidget.qdoc
new file mode 100644
index 0000000000..e53302218e
--- /dev/null
+++ b/examples/widgets/doc/src/simplerhiwidget.qdoc
@@ -0,0 +1,204 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example rhi/simplerhiwidget
+ \title Simple RHI Widget Example
+ \examplecategory {Graphics}
+ \ingroup examples-widgets
+ \brief Shows how to render a triangle using QRhi, Qt's 3D API and shading language abstraction layer.
+
+ \image simplerhiwidget-example.jpg
+ \caption Screenshot of the Simple RHI Widget example
+
+ This example is, in many ways, the counterpart of the \l{RHI Window
+ Example} in the \l QWidget world. The \l QRhiWidget subclass in this
+ applications renders a single triangle, using a simple graphics pipeline
+ with basic vertex and fragment shaders. Unlike the plain QWindow-based
+ application, this example does not need to worry about lower level details,
+ such as setting up the window and the QRhi, or dealing with swapchain and
+ window events, as that is taken care of by the QWidget framework here. The
+ instance of the \l QRhiWidget subclass is added to a QVBoxLayout. To keep
+ the example minimal and compact, there are no further widgets or 3D content
+ introduced.
+
+ Once an instance of \c ExampleRhiWidget, a \l QRhiWidget subclass, is added
+ to a top-level widget's child hierarchy, the corresponding window
+ automatically becomes a Direct 3D, Vulkan, Metal, or OpenGL-rendered
+ window. The QPainter-rendered widget content, i.e. everything that is not a
+ QRhiWidget, QOpenGLWidget, or QQuickWidget, is then uploaded to a texture,
+ whereas the mentioned special widgets each render to a texture. The
+ resulting set of \l{QRhiTexture}{textures} is composited together by the
+ top-level widget's backingstore.
+
+ \section1 Structure and main()
+
+ The \c{main()} function is quite simple. The top-level widget defaults to a
+ size of 720p (this size is in logical units, the actual pixel size may be
+ different, depending on the \l{QWidget::devicePixelRatio()}{scale factor}.
+ The window is resizable. QRhiWidget makes it simple to implement subclasses
+ that correctly deal with the resizing of the widget due to window size or
+ layout changes.
+
+ \snippet rhi/simplerhiwidget/main.cpp 0
+
+ The QRhiWidget subclass reimplements the two virtuals:
+ \l{QRhiWidget::initialize()}{initialize()} and
+ \l{QRhiWidget::render()}{render()}.
+ initialize() is called at least once before render(),
+ but is also invoked upon a number of important changes, such as when the
+ widget's backing texture is recreated due to a changing widget size, when
+ render target parameters change, or when the widget changes to a new QRhi
+ due to moving to a new top-level window.
+
+ \note Unlike QOpenGLWidget's legacy \c initializeGL - \c resizeGL - \c
+ paintGL model, there are only two virtuals in QRhiWidget. This is because
+ there are more special events that possible need taking care of than just
+ resizing, e.g. when reparenting to a different top-level window. (robust
+ QOpenGLWidget implementations had to deal with this by performing
+ additional bookkeeping, e.g. by tracking the associated QOpenGLContext
+ lifetime, meaning the three virtuals were not actually sufficient) A
+ simpler pair of \c initialize - \c render, where \c initialize is
+ re-invoked upon important changes is better suited for this.
+
+ The \l QRhi instance is not owned by the widget. It is going to be queried
+ in \c initialize() \l{QRhiWidget::rhi()}{from the base class}. Storing it
+ as a member allows recognizing changes when \c initialize() is invoked
+ again. Graphics resources, such as the vertex and uniform buffers, or the
+ graphics pipeline are however under the control of \c ExampleRhiWidget.
+
+ \snippet rhi/simplerhiwidget/examplewidget.h 0
+
+ For the \c{#include <rhi/qrhi.h>} statement to work, the application must
+ link to \c GuiPrivate (or \c{gui-private} with qmake). See \l QRhi for more
+ details about the compatibility promise of the QRhi family of APIs.
+
+ \c CMakeLists.txt
+
+ \badcode
+ target_link_libraries(simplerhiwidget PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::GuiPrivate
+ Qt6::Widgets
+ )
+ \endcode
+
+ \section1 Rendering Setup
+
+ In \c examplewidget.cpp the widget implementation uses a helper function to
+ load up a \l QShader object from a \c{.qsb} file. This application ships
+ pre-conditioned \c{.qsb} files embedded in to the executable via the Qt
+ Resource System. Due to module dependencies (and due to still supporting
+ qmake), this example does not use the convenient CMake function
+ \c{qt_add_shaders()}, but rather comes with the \c{.qsb} files as part of
+ the source tree. Real world applications are encouraged to avoid this and
+ rather use the Qt Shader Tools module's CMake integration features (\c
+ qt_add_shaders). Regardless of the approach, in the C++ code the loading
+ of the bundled/generated \c{.qsb} files is the same.
+
+ \snippet rhi/simplerhiwidget/examplewidget.cpp get-shader
+
+ Let's look at the initialize() implementation. First, the \l QRhi object is
+ queried and stored for later use, and also to allow comparison in future
+ invocations of the function. When there is a mismatch (e.g. when the widget
+ is moved between windows), recreation of graphics resources need to be
+ recreated is triggered by destroying and nulling out a suitable object, in
+ this case the \c m_pipeline. The example does not actively demonstrate
+ reparenting between windows, but it is prepared to handle it. It is also
+ prepared to handle a changing widget size that can happen when resizing the
+ window. That needs no special handling since \c{initialize()} is invoked
+ every time that happens, and so querying
+ \c{renderTarget()->pixelSize()} or \c{colorTexture()->pixelSize()}
+ always gives the latest, up-to-date size in pixels. What this example is
+ not prepared for is changing
+ \l{QRhiWidget::textureFormat}{texture formats} and
+ \l{QRhiWidget::sampleCount}{multisample settings}
+ since it only ever uses the defaults (RGBA8 and no multisample antialiasing).
+
+ \snippet rhi/simplerhiwidget/examplewidget.cpp init-1
+
+ When the graphics resources need to be (re)created, \c{initialize()} does
+ this using quite typical QRhi-based code. A single vertex buffer with the
+ interleaved position - color vertex data is sufficient, whereas the
+ modelview-projection matrix is exposed via a uniform buffer of 64 bytes (16
+ floats). The uniform buffer is the only shader visible resource, and it is
+ only used in the vertex shader. The graphics pipeline relies on a lot of
+ defaults (for example, depth test off, blending disabled, color write
+ enabled, face culling disabled, the default topology of triangles, etc.)
+ The vertex data layout is \c x, \c y, \c r, \c g, \c b, hence the stride is
+ 5 floats, whereas the second vertex input attribute (the color) has an
+ offset of 2 floats (skipping \c x and \c y). Each graphics pipeline has to
+ be associated with a \l QRhiRenderPassDescriptor. This can be retrieved
+ from the \l QRhiRenderTarget managed by the base class.
+
+ \note This example relies on the QRhiWidget's default of
+ \l{QRhiWidget::autoRenderTarget}{autoRenderTarget} set to \c true.
+ That is why it does not need to manage the render target, but can just
+ query the existing one by calling
+ \l{QRhiWidget::renderTarget()}{renderTarget()}.
+
+ \snippet rhi/simplerhiwidget/examplewidget.cpp init-pipeline
+
+ Finally, the projection matrix is calculated. This depends on the widget
+ size and is thus done unconditionally in every invocation of the functions.
+
+ \note Any size and viewport calculations should only ever rely on the pixel
+ size queried from the resource serving as the color buffer since that is
+ the actual render target. Avoid manually calculating sizes, viewports,
+ scissors, etc. based on the QWidget-reported size or device pixel ratio.
+
+ \note The projection matrix includes the
+ \l{QRhi::clipSpaceCorrMatrix()}{correction matrix} from QRhi in order to
+ cater for 3D API differences in normalized device coordinates.
+ (for example, Y down vs. Y up)
+
+ A translation of \c{-4} is applied just to make sure the triangle with \c z
+ values of 0 will be visible.
+
+ \snippet rhi/simplerhiwidget/examplewidget.cpp init-matrix
+
+ \section1 Rendering
+
+ The widget records a single render pass, which contains a single draw call.
+
+ The view-projection matrix calculated in the initialize step gets combined
+ with the model matrix, which in this case happens to be a simple rotation.
+ The resulting matrix is then written to the uniform buffer. Note how
+ \c resourceUpdates is passed to
+ \l{QRhiCommandBuffer::beginPass()}{beginPass()}, which is a shortcut to not
+ having to invoke \l{QRhiCommandBuffer::resourceUpdate()}{resourceUpdate()}
+ manually.
+
+ \snippet rhi/simplerhiwidget/examplewidget.cpp render-1
+
+ In the render pass, a single draw call with 3 vertices is recorded. The
+ graphics pipeline created in the initialize step is bound on the command
+ buffer, and the viewport is set to cover the entire widget. To make the
+ uniform buffer visible to the (vertex) shader,
+ \l{QRhiCommandBuffer::setShaderResources()}{setShaderResources()} is called
+ with no argument, which means using the \c m_srb since that was associated
+ with the pipeline at pipeline creation time. In more complex renderers it
+ is not unusual to pass in a different \l QRhiShaderResourceBindings object,
+ as long as that is
+ \l{QRhiShaderResourceBindings::isLayoutCompatible()}{layout-compatible}
+ with the one given at pipeline creation time.
+ There is no index buffer, and there is a single vertex buffer binding (the
+ single element in \c vbufBinding refers to the single entry in the binding
+ list of the \l QRhiVertexInputLayout that was specified when creating
+ pipeline).
+
+ \snippet rhi/simplerhiwidget/examplewidget.cpp render-pass
+
+ Once the render pass is recorded, \l{QWidget::update()}{update()} is
+ called. This requests a new frame, and is used to ensure the widget
+ continuously updates, and the triangle appears rotating. The rendering
+ thread (the main thread in this case) is throttled by the presentation rate
+ by default. There is no proper animation system in this example, and so the
+ rotation will increase in every frame, meaning the triangle will rotate at
+ different speeds on displays with different refresh rates.
+
+ \snippet rhi/simplerhiwidget/examplewidget.cpp render-2
+
+ \sa QRhi, {Cube RHI Widget Example}, {RHI Window Example}
+*/
diff --git a/examples/widgets/doc/src/simpletreemodel.qdoc b/examples/widgets/doc/src/simpletreemodel.qdoc
index 5892d05244..aa12a9585f 100644
--- a/examples/widgets/doc/src/simpletreemodel.qdoc
+++ b/examples/widgets/doc/src/simpletreemodel.qdoc
@@ -4,6 +4,7 @@
/*!
\example itemviews/simpletreemodel
\title Simple Tree Model Example
+ \examplecategory {User Interface Components}
\ingroup examples-itemviews
\ingroup examples-layout
\brief The Simple Tree Model example shows how to use a hierarchical model
@@ -104,16 +105,14 @@
\snippet itemviews/simpletreemodel/treeitem.cpp 0
A pointer to each of the child items belonging to this item will be
- stored in the \c childItems private member variable. When the class's
- destructor is called, it must delete each of these to ensure that
- their memory is reused:
-
- \snippet itemviews/simpletreemodel/treeitem.cpp 1
+ stored in the \c childItems private member variable as an std::unique_ptr.
+ When the class's destructor is called, the child items will be automatically
+ deleted to ensure that their memory is reused:
Since each of the child items are constructed when the model is initially
populated with data, the function to add child items is straightforward:
- \snippet itemviews/simpletreemodel/treeitem.cpp 2
+ \snippet itemviews/simpletreemodel/treeitem.cpp 1
Each item is able to return any of its child items when given a suitable
row number. For example, in the \l{#SimpleTreeModelStructure}{above diagram},
@@ -124,11 +123,11 @@
The \c child() function returns the child that corresponds to
the specified row number in the item's list of child items:
- \snippet itemviews/simpletreemodel/treeitem.cpp 3
+ \snippet itemviews/simpletreemodel/treeitem.cpp 2
The number of child items held can be found with \c childCount():
- \snippet itemviews/simpletreemodel/treeitem.cpp 4
+ \snippet itemviews/simpletreemodel/treeitem.cpp 3
The \c TreeModel uses this function to determine the number of rows that
exist for a given parent item.
@@ -136,7 +135,7 @@
The \c row() function reports the item's location within its parent's
list of items:
- \snippet itemviews/simpletreemodel/treeitem.cpp 8
+ \snippet itemviews/simpletreemodel/treeitem.cpp 7
Note that, although the root item (with no parent item) is automatically
assigned a row number of 0, this information is never used by the model.
@@ -144,16 +143,17 @@
The number of columns of data in the item is trivially returned by the
\c columnCount() function.
- \snippet itemviews/simpletreemodel/treeitem.cpp 5
+ \snippet itemviews/simpletreemodel/treeitem.cpp 4
- Column data is returned by the \c data() function. The bounds are checked
- before accessing the container with the data:
+ Column data is returned by the \c data() function. We use
+ the QList::value() convenience function which checks the bounds
+ and returns a default-constructed QVariant in case they are violated:
- \snippet itemviews/simpletreemodel/treeitem.cpp 6
+ \snippet itemviews/simpletreemodel/treeitem.cpp 5
The item's parent is found with \c parent():
- \snippet itemviews/simpletreemodel/treeitem.cpp 7
+ \snippet itemviews/simpletreemodel/treeitem.cpp 6
Note that, since the root item in the model will not have a parent, this
function will return zero in that case. We need to ensure that the model
@@ -183,14 +183,16 @@
item only contains vertical header data for convenience. We also use it
to reference the internal data structure that contains the model data,
and it is used to represent an imaginary parent of top-level items in
- the model.
+ the model. The root item is managed with a std::unique_ptr to ensure the
+ entire tree of item is deleted when the model is deleted.
The model's internal data structure is populated with items by the
\c setupModelData() function. We will examine this function separately
at the end of this document.
The destructor ensures that the root item and all of its descendants
- are deleted when the model is destroyed:
+ are deleted when the model is destroyed. This is done automatically
+ since the root item is stored in a unique_ptr.
\snippet itemviews/simpletreemodel/treemodel.cpp 1
@@ -317,4 +319,21 @@
To ensure that the model works correctly, it is only necessary to
create instances of \c TreeItem with the correct data and parent item.
+
+ \section1 Testing the model
+
+ Correctly implementing an item model can be challenging. The class
+ \l [QtTest] QAbstractItemModelTester from the \l [QtTest] {Qt Test} module
+ checks for model consistency, like the model index creation and
+ parent-child relationships.
+
+ You can test your model by just passing a model instance to the class
+ constructor, for instance as part of a Qt unit test:
+
+ \snippet itemviews/simpletreemodel/test.cpp 1
+
+ To create a test which can be run using the \c ctest executable,
+ \c add_test() is used:
+
+ \snippet itemviews/simpletreemodel/CMakeLists.txt 1
*/
diff --git a/examples/widgets/doc/src/simplewidgetmapper.qdoc b/examples/widgets/doc/src/simplewidgetmapper.qdoc
deleted file mode 100644
index 508f9d201f..0000000000
--- a/examples/widgets/doc/src/simplewidgetmapper.qdoc
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example itemviews/simplewidgetmapper
- \title Simple Widget Mapper Example
- \ingroup examples-itemviews
- \brief The Simple Widget Mapper example shows how to use a widget mapper to display
- data from a model in a collection of widgets.
-
- \image simplewidgetmapper-example.png
-
- The QDataWidgetMapper class allows information obtained from a
- \l{Model Classes}{model} to be viewed and edited in a collection of
- widgets instead of in an \l{View Classes}{item view}.
- Any model derived from QAbstractItemModel can be used as the source of
- data and almost any input widget can be used to display it.
-
- The example itself is very simple: we create \c Window, a QWidget subclass
- that we use to hold the widgets used to present the data, and show it. The
- \c Window class will provide buttons that the user can click to show
- different records from the model.
-
- \section1 Window Class Definition
-
- The class provides a constructor, a slot to keep the buttons up to date,
- and a private function to set up the model:
-
- \snippet itemviews/simplewidgetmapper/window.h Window definition
-
- In addition to the QDataWidgetMapper object and the controls used to make
- up the user interface, we use a QStandardItemModel to hold our data.
- We could use a custom model, but this standard implementation is sufficient
- for our purposes.
-
- \section1 Window Class Implementation
-
- The constructor of the \c Window class can be explained in three parts.
- In the first part, we set up the widgets used for the user interface:
-
- \snippet itemviews/simplewidgetmapper/window.cpp Set up widgets
-
- We also set up the buddy relationships between various labels and the
- corresponding input widgets.
-
- Next, we set up the widget mapper, relating each input widget to a column
- in the model specified by the call to \l{QDataWidgetMapper::}{setModel()}:
-
- \snippet itemviews/simplewidgetmapper/window.cpp Set up the mapper
-
- We also connect the mapper to the \uicontrol{Next} and \uicontrol{Previous} buttons
- via its \l{QDataWidgetMapper::}{toNext()} and
- \l{QDataWidgetMapper::}{toPrevious()} slots. The mapper's
- \l{QDataWidgetMapper::}{currentIndexChanged()} signal is connected to the
- \c{updateButtons()} slot in the window which we'll show later.
-
- In the final part of the constructor, we set up the layout, placing each
- of the widgets in a grid (we could also use a QFormLayout for this):
-
- \snippet itemviews/simplewidgetmapper/window.cpp Set up the layout
-
- Lastly, we set the window title and initialize the mapper by setting it to
- refer to the first row in the model.
-
- The model is initialized in the window's \c{setupModel()} function. Here,
- we create a standard model with 5 rows and 3 columns, and we insert some
- sample names, addresses and ages into each row:
-
- \snippet itemviews/simplewidgetmapper/window.cpp Set up the model
-
- As a result, each row can be treated like a record in a database, and the
- widget mapper will read the data from each row, using the column numbers
- specified earlier to access the correct data for each widget. This is
- shown in the following diagram:
-
- \image widgetmapper-simple-mapping.png
-
- Since the user can navigate using the buttons in the user interface, the
- example is fully-functional at this point, but to make it a bit more
- user-friendly, we implement the \c{updateButtons()} slot to show when the
- user is viewing the first or last records:
-
- \snippet itemviews/simplewidgetmapper/window.cpp Slot for updating the buttons
-
- If the mapper is referring to the first row in the model, the \uicontrol{Previous}
- button is disabled. Similarly, the \uicontrol{Next} button is disabled if the
- mapper reaches the last row in the model.
-
- \section1 More Complex Mappings
-
- The QDataWidgetMapper class makes it easy to relate information from a
- model to widgets in a user interface. However, it is sometimes necessary
- to use input widgets which offer choices to the user, such as QComboBox,
- in conjunction with a widget mapper.
-
- In these situations, although the mapping to input widgets remains simple,
- more work needs to be done to expose additional data to the widget mapper.
- This is covered by the \l{Combo Widget Mapper Example}{Combo Widget Mapper}
- and \l{SQL Widget Mapper Example}{SQL Widget Mapper}
- examples.
-*/
diff --git a/examples/widgets/doc/src/sliders.qdoc b/examples/widgets/doc/src/sliders.qdoc
index 26bfd44131..9bfb4abdc4 100644
--- a/examples/widgets/doc/src/sliders.qdoc
+++ b/examples/widgets/doc/src/sliders.qdoc
@@ -4,6 +4,7 @@
/*!
\example widgets/sliders
\title Sliders Example
+ \examplecategory {User Interface Components}
\ingroup examples-widgets
\brief The Sliders example shows how to use the different types of sliders
available in Qt: QSlider, QScrollBar and QDial.
@@ -17,7 +18,8 @@
manipulated through their properties.
The example also demonstrates how signals and slots can be used to
- synchronize the behavior of two or more widgets.
+ synchronize the behavior of two or more widgets, and how to override
+ \l{QWidget::}{resizeEvent()} to implement a responsive layout.
\borderedimage sliders-example.png
\caption Screenshot of the Sliders example
@@ -30,10 +32,8 @@
QScrollBar and a QDial.
\li \c Window is the main widget combining a QGroupBox and a
- QStackedWidget. In this example, the QStackedWidget provides a
- stack of two \c SlidersGroup widgets. The QGroupBox contain
- several widgets that control the behavior of the slider-like
- widgets.
+ SlidersGroup. The QGroupBox contains several widgets that control
+ the behavior of the slider-like widgets.
\endlist
@@ -55,28 +55,14 @@
\snippet widgets/sliders/window.cpp 0
- In the constructor we first create the two \c SlidersGroup
- widgets that display the slider widgets horizontally and
- vertically, and add them to the QStackedWidget. QStackedWidget
- provides a stack of widgets where only the top widget is visible.
- With \c createControls() we create a connection from a
- controlling widget to the QStackedWidget, making the user able to
- choose between horizontal and vertical orientation of the slider
- widgets. The rest of the controlling mechanisms is implemented by
- the same function call.
+ In the constructor we first create the \c SlidersGroup widget
+ that displays the slider widgets. With \c createControls() we
+ create the controlling widgets, and connect those to to the
+ sliders.
\snippet widgets/sliders/window.cpp 1
- \snippet widgets/sliders/window.cpp 2
-
- Then we connect the \c horizontalSliders, \c verticalSliders and
- \c valueSpinBox to each other, so that the slider widgets and the
- control widget will behave synchronized when the current value of
- one of them changes. The \c valueChanged() signal is emitted with
- the new value as argument. The \c setValue() slot sets the
- current value of the widget to the new value, and emits \c
- valueChanged() if the new value is different from the old one.
- We put the group of control widgets and the stacked widget in a
+ We put the groups of control widgets and the sliders in a
horizontal layout before we initialize the minimum, maximum and
current values. The initialization of the current value will
propagate to the slider widgets through the connection we made
@@ -84,15 +70,14 @@
minimum and maximum values propagate through the connections we
created with \c createControls().
+ \snippet widgets/sliders/window.cpp 2
\snippet widgets/sliders/window.cpp 3
- \snippet widgets/sliders/window.cpp 4
In the private \c createControls() function, we let a QGroupBox
(\c controlsGroup) display the control widgets. A group box can
provide a frame, a title and a keyboard shortcut, and displays
various other widgets inside itself. The group of control widgets
- is composed by two checkboxes, three spin boxes (with labels) and
- one combobox.
+ is composed by two checkboxes, and three spin boxes with labels.
After creating the labels, we create the two checkboxes.
Checkboxes are typically used to represent features in an
@@ -130,8 +115,8 @@
bindings are inverted by default: \uicontrol PageDown increases the
current value, and \uicontrol PageUp decreases it.
+ \snippet widgets/sliders/window.cpp 4
\snippet widgets/sliders/window.cpp 5
- \snippet widgets/sliders/window.cpp 6
Then we create the spin boxes. QSpinBox allows the user to choose
a value by clicking the up and down buttons or pressing the \uicontrol
@@ -140,14 +125,15 @@
manually. The spin boxes control the minimum, maximum and current
values for the QSlider, QScrollBar, and QDial widgets.
- We create a QComboBox that allows the user to choose the
- orientation of the slider widgets. The QComboBox widget is a
- combined button and popup list. It provides a means of presenting
- a list of options to the user in a way that takes up the minimum
- amount of screen space.
+ \snippet widgets/sliders/window.cpp 6
- \snippet widgets/sliders/window.cpp 7
- \snippet widgets/sliders/window.cpp 8
+ Then we connect the \c slidersGroup and the \c valueSpinBox to each
+ other, so that the slider widgets and the control widget will behave
+ synchronized when the current value of one of them changes.
+ The \c valueChanged() signal is emitted with the new value as
+ argument. The \c setValue() slot sets the current value of the
+ widget to the new value, and emits \c valueChanged() if the new
+ value is different from the old one.
We synchronize the behavior of the control widgets and the slider
widgets through their signals and slots. We connect each control
@@ -157,6 +143,17 @@
lay out the control widgets in a QGridLayout within the \c
controlsGroup group box.
+ \snippet widgets/sliders/window.cpp 7
+
+ Lastly, we override resizeEvent() from QWidget. We guard against
+ dividing by zero, and otherwise compute the aspect ratio of the
+ widget. If the window has a portrait format, then we set the
+ layout to organize the groups of control widgets and sliders
+ vertically, and we give the sliders a horizontal orientation.
+ If the window has a landscape format, then we change the layout
+ to show the sliders and controlling widgets side by side, and
+ give the sliders a vertical orientation.
+
\section1 SlidersGroup Class Definition
\snippet widgets/sliders/slidersgroup.h 0
@@ -169,7 +166,8 @@
slot with equivalent functionality to the ones in QAbstractSlider
and QSpinBox. In addition, we implement several other public
slots to set the minimum and maximum value, and invert the slider
- widgets' appearance as well as key bindings.
+ widgets' appearance as well as key bindings, and set the
+ orientation.
\section1 SlidersGroup Class Implementation
@@ -182,24 +180,21 @@
focus. The Qt::StrongFocus policy means that the widget accepts
focus by both tabbing and clicking.
+ \snippet widgets/sliders/slidersgroup.cpp 1
+
Then we connect the widgets with each other, so that they will
stay synchronized when the current value of one of them changes.
- \snippet widgets/sliders/slidersgroup.cpp 1
- \snippet widgets/sliders/slidersgroup.cpp 2
-
We connect \c {dial}'s \c valueChanged() signal to the
\c{SlidersGroup}'s \c valueChanged() signal, to notify the other
widgets in the application (i.e., the control widgets) of the
changed value.
- \snippet widgets/sliders/slidersgroup.cpp 3
\codeline
\snippet widgets/sliders/slidersgroup.cpp 4
- Finally, depending on the \l {Qt::Orientation}{orientation} given
- at the time of construction, we choose and create the layout for
- the slider widgets within the group box.
+ Finally, we create the layout for the slider widgets within the
+ group box. We start with a horizontal arrangement of the sliders.
\snippet widgets/sliders/slidersgroup.cpp 5
\snippet widgets/sliders/slidersgroup.cpp 6
@@ -232,4 +227,12 @@
\l{QAbstractSlider::invertedAppearance}{invertedAppearance} and
\l{QAbstractSlider::invertedControls}{invertedControls}
properties.
+
+ \snippet widgets/sliders/slidersgroup.cpp 15
+
+ The setOrientation() slot controls the direction of the layout
+ and the orientation of the sliders. In a horizontal group, the
+ sliders have a horizontal orientation, and are laid out on top
+ of each other. In a vertical group, the sliders have a vertical
+ orientation, and are laid out next to each other.
*/
diff --git a/examples/widgets/doc/src/spinboxdelegate.qdoc b/examples/widgets/doc/src/spinboxdelegate.qdoc
deleted file mode 100644
index 025c502113..0000000000
--- a/examples/widgets/doc/src/spinboxdelegate.qdoc
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example itemviews/spinboxdelegate
- \title Spin Box Delegate Example
- \ingroup examples-itemviews
- \brief The Spin Box Delegate example shows how to create an editor for a custom delegate in
- the model/view framework by reusing a standard Qt editor widget.
-
- The model/view framework provides a standard delegate that is used by default
- with the standard view classes. For most purposes, the selection of editor
- widgets available through this delegate is sufficient for editing text, boolean
- values, and other simple data types. However, for specific data types, it is
- sometimes necessary to use a custom delegate to either display the data in a
- specific way, or allow the user to edit it with a custom control.
-
- \image spinboxdelegate-example.png
-
- This concepts behind this example are covered in the
- \l{Model/View Programming#Delegate Classes}{Delegate Classes} chapter
- of the \l{Model/View Programming} overview.
-
- \section1 SpinBoxDelegate Class Definition
-
- The definition of the delegate is as follows:
-
- \snippet itemviews/spinboxdelegate/delegate.h 0
-
- The delegate class declares only those functions that are needed to
- create an editor widget, display it at the correct location in a view,
- and communicate with a model. Custom delegates can also provide their
- own painting code by reimplementing the \c paintEvent() function.
- Furthermore it is also possible to reuse (and avoid deleting) the editor
- widget by reimplementing the \a destroyEditor() function. A reused widget
- could be a mutable member created in the constructor and deleted in
- the destructor.
-
- \section1 SpinBoxDelegate Class Implementation
-
- Delegates are often stateless. The constructor only needs to
- call the base class's constructor with the parent QObject as its
- argument:
-
- \snippet itemviews/spinboxdelegate/delegate.cpp 0
-
- Since the delegate is a subclass of QStyledItemDelegate, the data it retrieves
- from the model is displayed in a default style, and we do not need to
- provide a custom \c paintEvent().
-
- The \c createEditor() function returns an editor widget, in this case a
- spin box that restricts values from the model to integers from 0 to 100
- inclusive.
-
- \snippet itemviews/spinboxdelegate/delegate.cpp 1
-
- We install an event filter on the spin box to ensure that it behaves in
- a way that is consistent with other delegates. The implementation for
- the event filter is provided by the base class.
-
- The \c setEditorData() function reads data from the model, converts it
- to an integer value, and writes it to the editor widget.
-
- \snippet itemviews/spinboxdelegate/delegate.cpp 2
-
- Since the view treats delegates as ordinary QWidget instances, we have
- to use a static cast before we can set the value in the spin box.
-
- The \c setModelData() function reads the contents of the spin box, and
- writes it to the model.
-
- \snippet itemviews/spinboxdelegate/delegate.cpp 3
-
- We call \l{QSpinBox::interpretText()}{interpretText()} to make sure that
- we obtain the most up-to-date value in the spin box.
-
- The \c updateEditorGeometry() function updates the editor widget's
- geometry using the information supplied in the style option. This is the
- minimum that the delegate must do in this case.
-
- \snippet itemviews/spinboxdelegate/delegate.cpp 4
-
- More complex editor widgets may divide the rectangle available in
- \c{option.rect} between different child widgets if required.
-
- \section1 The Main Function
-
- This example is written in a slightly different way to many of the
- other examples supplied with Qt. To demonstrate the use of a custom
- editor widget in a standard view, it is necessary to set up a model
- containing some arbitrary data and a view to display it.
-
- We set up the application in the normal way, construct a standard item
- model to hold some data, set up a table view to use the data in the
- model, and construct a custom delegate to use for editing:
-
- \snippet itemviews/spinboxdelegate/main.cpp 0
-
- The table view is informed about the delegate, and will use it to
- display each of the items. Since the delegate is a subclass of
- QStyledItemDelegate, each cell in the table will be rendered using standard
- painting operations.
-
- We insert some arbitrary data into the model for demonstration purposes:
-
- \snippet itemviews/spinboxdelegate/main.cpp 1
- \snippet itemviews/spinboxdelegate/main.cpp 2
-
- Finally, the table view is displayed with a window title, and we start
- the application's event loop:
-
- \snippet itemviews/spinboxdelegate/main.cpp 3
-
- Each of the cells in the table can now be edited in the usual way, but
- the spin box ensures that the data returned to the model is always
- constrained by the values allowed by the spin box delegate.
-*/
diff --git a/examples/widgets/doc/src/spinboxes.qdoc b/examples/widgets/doc/src/spinboxes.qdoc
index 263fee91a4..eb42696c48 100644
--- a/examples/widgets/doc/src/spinboxes.qdoc
+++ b/examples/widgets/doc/src/spinboxes.qdoc
@@ -4,6 +4,7 @@
/*!
\example widgets/spinboxes
\title Spin Boxes Example
+ \examplecategory {User Interface Components}
\ingroup examples-widgets
\brief The Spin Boxes example shows how to use the many different types of
spin boxes available in Qt, from a simple QSpinBox widget to more complex
diff --git a/examples/widgets/doc/src/spreadsheet.qdoc b/examples/widgets/doc/src/spreadsheet.qdoc
index 9d7c89d6ec..02d5e0a957 100644
--- a/examples/widgets/doc/src/spreadsheet.qdoc
+++ b/examples/widgets/doc/src/spreadsheet.qdoc
@@ -4,6 +4,7 @@
/*!
\example itemviews/spreadsheet
\title Spreadsheet
+ \examplecategory {User Interface Components}
\ingroup examples-itemviews
\brief The Spreadsheet example shows how to create a simple spreadsheet application.
diff --git a/examples/widgets/doc/src/standarddialogs.qdoc b/examples/widgets/doc/src/standarddialogs.qdoc
index 6770c918c8..396f1d1044 100644
--- a/examples/widgets/doc/src/standarddialogs.qdoc
+++ b/examples/widgets/doc/src/standarddialogs.qdoc
@@ -4,6 +4,7 @@
/*!
\example dialogs/standarddialogs
\title Standard Dialogs Example
+ \examplecategory {User Interface Components}
\ingroup examples-dialogs
\brief The Standard Dialogs example shows the standard dialogs that are provided by Qt.
diff --git a/examples/widgets/doc/src/stardelegate.qdoc b/examples/widgets/doc/src/stardelegate.qdoc
index 5d45577cb2..44d75e64f4 100644
--- a/examples/widgets/doc/src/stardelegate.qdoc
+++ b/examples/widgets/doc/src/stardelegate.qdoc
@@ -4,6 +4,7 @@
/*!
\example itemviews/stardelegate
\title Star Delegate Example
+ \examplecategory {User Interface Components}
\ingroup examples-itemviews
\brief The Star Delegate example shows how to create a delegate that
can paint itself and that supports editing.
diff --git a/examples/widgets/doc/src/styleplugin.qdoc b/examples/widgets/doc/src/styleplugin.qdoc
deleted file mode 100644
index c3c4c8d223..0000000000
--- a/examples/widgets/doc/src/styleplugin.qdoc
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example tools/styleplugin
- \title Style Plugin Example
- \ingroup examples-widgets-tools
-
- \brief This example shows how to create a plugin that extends Qt with a new
- GUI look and feel.
-
- \image stylepluginexample.png
-
- A plugin in Qt is a class stored in a shared library that can be
- loaded by a QPluginLoader at run-time. When you create plugins in
- Qt, they either extend a Qt application or Qt itself. Writing a
- plugin that extends Qt itself is achieved by inheriting one of the
- plugin \l{Plugin Classes}{base classes}, reimplementing functions
- from that class, and adding a macro. In this example we extend Qt
- by adding a new GUI look and feel (i.e., making a new QStyle
- available). A high-level introduction to plugins is given in the
- plugin \l{How to Create Qt Plugins}{overview document}.
-
- Plugins that provide new styles inherit the QStylePlugin base
- class. Style plugins are loaded by Qt and made available through
- QStyleFactory; we will look at this later. We have implemented \c
- SimpleStylePlugin, which provides \c SimpleStyle. The new style
- contributes to widget styling by drawing button backgrounds in
- red - not a major contribution, but it still makes a new style.
-
- The new style is platform agnostic in the sense that it is not
- based on any specific style implementation, but uses QProxyStyle
- to merely tweak the looks in the current application style that
- defaults to the native system style.
-
- \note On some platforms, the native style will prevent the button
- from having a red background. In this case, try to run the example
- in another style (e.g., fusion).
-
- We test the plugin with \c StyleWindow, in which we display a
- QPushButton. The \c SimpleStyle and \c StyleWindow classes do not
- contain any plugin specific functionality and their implementations
- are trivial; we will therefore leap past them and head on to the \c
- SimpleStylePlugin and the \c main() function. After we have looked
- at that, we examine the plugin's profile.
-
-
- \section1 SimpleStylePlugin Class Definition
-
- \c SimpleStylePlugin inherits QStylePlugin and is the plugin
- class.
-
- \snippet tools/styleplugin/plugin/simplestyleplugin.h 0
-
- \c keys() returns a list of style names that this plugin can
- create, while \c create() takes such a string and returns the
- QStyle corresponding to the key. Both functions are pure virtual
- functions reimplemented from QStylePlugin. When an application
- requests an instance of the \c SimpleStyle style, which this
- plugin creates, Qt will create it with this plugin.
-
-
- \section1 SimpleStylePlugin Class Implementation
-
- Here is the implementation of \c keys():
-
- \snippet tools/styleplugin/plugin/simplestyleplugin.cpp 0
-
- Since this plugin only supports one style, we return a QStringList
- with the class name of that style.
-
- Here is the \c create() function:
-
- \snippet tools/styleplugin/plugin/simplestyleplugin.cpp 1
-
- Note that the key for style plugins are case insensitive.
- The case sensitivity varies from plugin to plugin, so you need to
- check this when implementing new plugins.
-
- \section1 The \c main() function
-
- \snippet tools/styleplugin/stylewindow/main.cpp 0
-
- Qt loads the available style plugins when the QApplication object
- is initialized. The QStyleFactory class knows about all styles and
- produces them with \l{QStyleFactory::}{create()} (it is a
- wrapper around all the style plugins).
-
- \section1 The Simple Style Plugin Profile
-
- The \c SimpleStylePlugin lives in its own directory and have
- its own profile:
-
- \snippet tools/styleplugin/plugin/plugin.pro 0
-
- In the plugin profile we need to set the lib template as we are
- building a shared library instead of an executable. We must also
- set the config to plugin. We set the library to be stored in the
- styles folder under stylewindow because this is a path in which Qt
- will search for style plugins.
-
- \section1 Related Articles and Examples
-
- In addition to the plugin \l{How to Create Qt Plugins}{overview
- document}, we have other examples and articles that concern
- plugins.
-
- In the \l{Echo Plugin Example}{echo plugin example} we show how to
- implement plugins that extends Qt applications rather than Qt
- itself, which is the case with the style plugin of this example.
- The \l{Plug & Paint Example}{plug & paint} example shows how to
- implement a static plugin as well as being a more involved example
- on plugins that extend applications.
-*/
diff --git a/examples/widgets/doc/src/styles.qdoc b/examples/widgets/doc/src/styles.qdoc
deleted file mode 100644
index 53934c4011..0000000000
--- a/examples/widgets/doc/src/styles.qdoc
+++ /dev/null
@@ -1,448 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/styles
- \title Styles Example
- \ingroup examples-widgets
- \brief The Styles example illustrates how to create custom widget
- drawing styles using Qt, and demonstrates Qt's predefined styles.
-
- \borderedimage styles-enabledwood.png
- \caption Screenshot of the Styles example
-
- A style in Qt is a subclass of QStyle or of one of its
- subclasses. Styles perform drawing on behalf of widgets. Qt
- provides a whole range of predefined styles, either built into
- the Qt Widgets module or found in plugins. Styles are usually
- customized by subclassing QProxyStyle and reimplementing a few
- virtual functions. While QProxyStyle provides a transparent way
- to customize either a specific style or the appropriate platform's
- default style, Qt also provides QCommonStyle as a convenient base
- for full custom style implementations.
-
- In this example, the custom style is called \c NorwegianWoodStyle
- and derives from QProxyStyle. Its main features are the wooden
- textures used for filling most of the widgets and its round
- buttons and comboboxes.
-
- To implement the style, we use some advanced features provided by
- QPainter, such as \l{QPainter::Antialiasing}{antialiasing} (to
- obtain smoother button edges), \l{QColor::alpha()}{alpha blending}
- (to make the buttons appeared raised or sunken), and
- \l{QPainterPath}{painter paths} (to fill the buttons and draw the
- outline). We also use many features of QBrush and QPalette.
-
- The example consists of the following classes:
-
- \list
- \li \c NorwegianWoodStyle inherits from QProxyStyle and implements
- the Norwegian Wood style.
- \li \c WidgetGallery is a \c QDialog subclass that shows the most
- common widgets and allows the user to switch style
- dynamically.
- \endlist
-
- \section1 NorwegianWoodStyle Class Definition
-
- Here's the definition of the \c NorwegianWoodStyle class:
-
- \snippet widgets/styles/norwegianwoodstyle.h 0
-
- The public functions are all declared in QStyle (QProxyStyle's
- grandparent class) and reimplemented here to override the Windows
- look and feel. The private functions are helper functions.
-
- \section1 NorwegianWoodStyle Class Implementation
-
- We will now review the implementation of the \c
- NorwegianWoodStyle class.
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 0
-
- The \c standardPalette() function is reimplemented from QStyle.
- It returns a QPalette with the style's preferred colors and textures.
- Most styles don't need to reimplement that function. The
- Norwegian Wood style reimplements it to set a "wooden" palette.
-
- We start by defining a few \l{QColor}s that we'll need. Then we
- load two PNG images. The \c : prefix in the file path indicates
- that the PNG files are \l{The Qt Resource System}{embedded
- resources}.
-
- \table
- \row \li \inlineimage widgets/styles/images/woodbackground.png
-
- \li \b{woodbackground.png}
-
- This texture is used as the background of most widgets.
- The wood pattern is horizontal.
-
- \row \li \inlineimage widgets/styles/images/woodbutton.png
-
- \li \b{woodbutton.png}
-
- This texture is used for filling push buttons and
- comboboxes. The wood pattern is vertical and more reddish
- than the texture used for the background.
- \endtable
-
- The \c midImage variable is initialized to be the same as \c
- buttonImage, but then we use a QPainter and fill it with a 25%
- opaque black color (a black with an \l{QColor::alpha()}{alpha
- channel} of 63). The result is a somewhat darker image than \c
- buttonImage. This image will be used for filling buttons that the
- user is holding down.
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 1
-
- We initialize the palette. Palettes have various
- \l{QPalette::ColorRole}{color roles}, such as QPalette::Base
- (used for filling text editors, item views, etc.), QPalette::Text
- (used for foreground text), and QPalette::Window (used for
- the background of most widgets). Each role has its own QBrush,
- which usually is a plain color but can also be a brush pattern or
- even a texture (a QPixmap).
-
- In addition to the roles, palettes have several
- \l{QPalette::ColorGroup}{color groups}: active, disabled, and
- inactive. The active color group is used for painting widgets in
- the active window. The disabled group is used for disabled
- widgets. The inactive group is used for all other widgets. Most
- palettes have identical active and inactive groups, while the
- disabled group uses darker shades.
-
- We initialize the QPalette object with a brown color. Qt
- automatically derivates all color roles for all color groups from
- that single color. We then override some of the default values. For
- example, we use Qt::darkGreen instead of the default
- (Qt::darkBlue) for the QPalette::Highlight role. The
- QPalette::setBrush() overload that we use here sets the same
- color or brush for all three color groups.
-
- The \c setTexture() function is a private function that sets the
- texture for a certain color role, while preserving the existing
- color in the QBrush. A QBrush can hold both a solid color and a
- texture at the same time. The solid color is used for drawing
- text and other graphical elements where textures don't look good.
-
- At the end, we set the brush for the disabled color group of the
- palette. We use \c woodbackground.png as the texture for all
- disabled widgets, including buttons, and use a darker color to
- accompany the texture.
-
- \image styles-disabledwood.png The Norwegian Wood style with disabled widgets
-
- Let's move on to the other functions reimplemented from
- QProxyStyle:
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 3
- \snippet widgets/styles/norwegianwoodstyle.cpp 4
-
- This QStyle::polish() overload is called once on every widget
- drawn using the style. We reimplement it to set the Qt::WA_Hover
- attribute on \l{QPushButton}s and \l{QComboBox}es. When this
- attribute is set, Qt generates paint events when the mouse
- pointer enters or leaves the widget. This makes it possible to
- render push buttons and comboboxes differently when the mouse
- pointer is over them.
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 5
- \snippet widgets/styles/norwegianwoodstyle.cpp 6
-
- This QStyle::unpolish() overload is called to undo any
- modification done to the widget in \c polish(). For simplicity,
- we assume that the flag wasn't set before \c polish() was called.
- In an ideal world, we would remember the original state for each
- widgets (e.g., using a QMap<QWidget *, bool>) and restore it in
- \c unpolish().
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 7
- \snippet widgets/styles/norwegianwoodstyle.cpp 8
-
- The \l{QStyle::pixelMetric()}{pixelMetric()} function returns the
- size in pixels for a certain user interface element. By
- reimplementing this function, we can affect the way certain
- widgets are drawn and their size hint. Here, we return 8 as the
- width around a shown in a QComboBox, ensuring that there is
- enough place around the text and the arrow for the Norwegian Wood
- round corners. The default value for this setting in the Windows
- style is 2.
-
- We also change the extent of \l{QScrollBar}s, i.e., the height
- for a horizontal scroll bar and the width for a vertical scroll
- bar, to be 4 pixels more than in the Windows style. This makes the
- style a bit more distinctive.
-
- For all other QStyle::PixelMetric elements, we use the Windows
- settings.
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 9
- \snippet widgets/styles/norwegianwoodstyle.cpp 10
-
- The \l{QStyle::styleHint()}{styleHint()} function returns some
- hints to widgets or to the base style (in our case QProxyStyle)
- about how to draw the widgets. The Windows style returns \c true
- for the QStyle::SH_DitherDisabledText hint, resulting in a most
- unpleasing visual effect. We override this behavior and return \c
- false instead. We also return \c true for the
- QStyle::SH_EtchDisabledText hint, meaning that disabled text is
- rendered with an embossed look.
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 11
- \snippet widgets/styles/norwegianwoodstyle.cpp 12
-
- The \l{QStyle::drawPrimitive()}{drawPrimitive()} function is
- called by Qt widgets to draw various fundamental graphical
- elements. Here we reimplement it to draw QPushButton and
- QComboBox with round corners. The button part of these widgets is
- drawn using the QStyle::PE_PanelButtonCommand primitive element.
-
- The \c option parameter, of type QStyleOption, contains
- everything we need to know about the widget we want to draw on.
- In particular, \c option->rect gives the rectangle within which
- to draw the primitive element. The \c painter parameter is a
- QPainter object that we can use to draw on the widget.
-
- The \c widget parameter is the widget itself. Normally, all the
- information we need is available in \c option and \c painter, so
- we don't need \c widget. We can use it to perform special
- effects; for example, QMacStyle uses it to animate default
- buttons. If you use it, be aware that the caller is allowed to
- pass a null pointer.
-
- We start by defining three \l{QColor}s that we'll need later on.
- We also put the x, y, width, and height components of the
- widget's rectangle in local variables. The value used for the \c
- semiTransparentWhite and for the \c semiTransparentBlack color's
- alpha channel depends on whether the mouse cursor is over the
- widget or not. Since we set the Qt::WA_Hover attribute on
- \l{QPushButton}s and \l{QComboBox}es, we can rely on the
- QStyle::State_MouseOver flag to be set when the mouse is over the
- widget.
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 13
- \snippet widgets/styles/norwegianwoodstyle.cpp 14
-
- The \c roundRect variable is a QPainterPath. A QPainterPath is is
- a vectorial specification of a shape. Any shape (rectangle,
- ellipse, spline, etc.) or combination of shapes can be expressed
- as a path. We will use \c roundRect both for filling the button
- background with a wooden texture and for drawing the outline. The
- \c roundRectPath() function is a private function; we will come
- back to it later.
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 15
- \snippet widgets/styles/norwegianwoodstyle.cpp 16
- \snippet widgets/styles/norwegianwoodstyle.cpp 17
- \snippet widgets/styles/norwegianwoodstyle.cpp 18
-
- We define two variables, \c brush and \c darker, and initialize
- them based on the state of the button:
-
- \list
- \li If the button is a \l{QPushButton::flat}{flat button}, we use
- the \l{QPalette::Window}{Window} brush. We set \c
- darker to \c true if the button is
- \l{QAbstractButton::down}{down} or
- \l{QAbstractButton::checked}{checked}.
- \li If the button is currently held down by the user or in the
- \l{QAbstractButton::checked}{checked} state, we use the
- \l{QPalette::Mid}{Mid} component of the palette. We set
- \c darker to \c true if the button is
- \l{QAbstractButton::checked}{checked}.
- \li Otherwise, we use the \l{QPalette::Button}{Button} component
- of the palette.
- \endlist
-
- The screenshot below illustrates how \l{QPushButton}s are
- rendered based on their state:
-
- \image styles-woodbuttons.png Norwegian Wood buttons in different states
-
- To discover whether the button is flat or not, we need to cast
- the \c option parameter to QStyleOptionButton and check if the
- \l{QStyleOptionButton::features}{features} member specifies the
- QStyleOptionButton::Flat flag. The qstyleoption_cast() function
- performs a dynamic cast; if \c option is not a
- QStyleOptionButton, qstyleoption_cast() returns a null pointer.
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 19
- \snippet widgets/styles/norwegianwoodstyle.cpp 20
- \snippet widgets/styles/norwegianwoodstyle.cpp 21
- \snippet widgets/styles/norwegianwoodstyle.cpp 22
- \snippet widgets/styles/norwegianwoodstyle.cpp 23
-
- We turn on antialiasing on QPainter. Antialiasing is a technique
- that reduces the visual distortion that occurs when the edges of
- a shape are converted into pixels. For the Norwegian Wood style,
- we use it to obtain smoother edges for the round buttons.
-
- \image styles-aliasing.png Norwegian wood buttons with and without antialiasing
-
- The first call to QPainter::fillPath() draws the background of
- the button with a wooden texture. The second call to
- \l{QPainter::fillPath()}{fillPath()} paints the same area with a
- semi-transparent black color (a black color with an alpha channel
- of 63) to make the area darker if \c darker is true.
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 24
- \snippet widgets/styles/norwegianwoodstyle.cpp 25
-
- Next, we draw the outline. The top-left half of the outline and
- the bottom-right half of the outline are drawn using different
- \l{QPen}s to produce a 3D effect. Normally, the top-left half of
- the outline is drawn lighter whereas the bottom-right half is
- drawn darker, but if the button is
- \l{QAbstractButton::down}{down} or
- \l{QAbstractButton::checked}{checked}, we invert the two
- \l{QPen}s to give a sunken look to the button.
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 26
-
- We draw the top-left part of the outline by calling
- QPainter::drawPath() with an appropriate
- \l{QPainter::setClipRegion()}{clip region}. If the
- \l{QStyleOption::direction}{layout direction} is right-to-left
- instead of left-to-right, we swap the \c x1, \c x2, \c x3, and \c
- x4 variables to obtain correct results. On right-to-left desktop,
- the "light" comes from the top-right corner of the screen instead
- of the top-left corner; raised and sunken widgets must be drawn
- accordingly.
-
- The diagram below illustrates how 3D effects are drawn according
- to the layout direction. The area in red on the diagram
- corresponds to the \c topHalf polygon:
-
- \image styles-3d.png
-
- An easy way to test how a style looks in right-to-left mode is to
- pass the \c -reverse command-line option to the application. This
- option is recognized by the QApplication constructor.
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 32
- \snippet widgets/styles/norwegianwoodstyle.cpp 33
- \snippet widgets/styles/norwegianwoodstyle.cpp 34
-
- The bottom-right part of the outline is drawn in a similar
- fashion. Then we draw a one-pixel wide outline around the entire
- button, using the \l{QPalette::WindowText}{WindowText} component
- of the QPalette.
-
- This completes the QStyle::PE_PanelButtonCommand case of the \c
- switch statement. Other primitive elements are handled by the
- base style. Let's now turn to the other \c NorwegianWoodStyle
- member functions:
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 35
- \snippet widgets/styles/norwegianwoodstyle.cpp 36
-
- We reimplement QStyle::drawControl() to draw the text on a
- QPushButton in a bright color when the button is
- \l{QAbstractButton::down}{down} or
- \l{QAbstractButton::checked}{checked}.
-
- If the \c option parameter points to a QStyleOptionButton object
- (it normally should), we take a copy of the object and modify its
- \l{QStyleOption::palette}{palette} member to make the
- QPalette::ButtonText be the same as the QPalette::BrightText
- component (unless the widget is disabled).
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 37
- \snippet widgets/styles/norwegianwoodstyle.cpp 38
-
- The \c setTexture() function is a private function that sets the
- \l{QBrush::texture()}{texture} component of the \l{QBrush}es for
- a certain \l{QPalette::ColorRole}{color role}, for all three
- \l{QPalette::ColorGroup}{color groups} (active, disabled,
- inactive). We used it to initialize the Norwegian Wood palette in
- \c standardPalette.
-
- \snippet widgets/styles/norwegianwoodstyle.cpp 39
- \snippet widgets/styles/norwegianwoodstyle.cpp 40
-
- The \c roundRectPath() function is a private function that
- constructs a QPainterPath object for round buttons. The path
- consists of eight segments: four arc segments for the corners and
- four lines for the sides.
-
- With around 250 lines of code, we have a fully functional custom
- style based on one of the predefined styles. Custom styles can be
- used to provide a distinct look to an application or family of
- applications.
-
- \section1 WidgetGallery Class
-
- For completeness, we will quickly review the \c WidgetGallery
- class, which contains the most common Qt widgets and allows the
- user to change style dynamically. Here's the class definition:
-
- \snippet widgets/styles/widgetgallery.h 0
- \dots
- \snippet widgets/styles/widgetgallery.h 1
-
- Here's the \c WidgetGallery constructor:
-
- \snippet widgets/styles/widgetgallery.cpp 0
-
- We start by creating child widgets. The \uicontrol Style combobox is
- initialized with all the styles known to QStyleFactory, in
- addition to \c NorwegianWood. The \c create...() functions are
- private functions that set up the various parts of the \c
- WidgetGallery.
-
- \snippet widgets/styles/widgetgallery.cpp 1
- \snippet widgets/styles/widgetgallery.cpp 2
-
- We connect the \uicontrol Style combobox to the \c changeStyle()
- private slot, the \uicontrol{Use style's standard palette} check box to
- the \c changePalette() slot, and the \uicontrol{Disable widgets} check
- box to the child widgets'
- \l{QWidget::setDisabled()}{setDisabled()} slot.
-
- \snippet widgets/styles/widgetgallery.cpp 3
- \snippet widgets/styles/widgetgallery.cpp 4
-
- Finally, we put the child widgets in layouts.
-
- \snippet widgets/styles/widgetgallery.cpp 5
- \snippet widgets/styles/widgetgallery.cpp 6
-
- When the user changes the style in the combobox, we call
- QApplication::setStyle() to dynamically change the style of the
- application.
-
- \snippet widgets/styles/widgetgallery.cpp 7
- \snippet widgets/styles/widgetgallery.cpp 8
-
- If the user turns the \uicontrol{Use style's standard palette} on, the
- current style's \l{QStyle::standardPalette()}{standard palette}
- is used; otherwise, the system's default palette is honored.
-
- \snippet widgets/styles/widgetgallery.cpp 9
- \snippet widgets/styles/widgetgallery.cpp 10
-
- The \c advanceProgressBar() slot is called at regular intervals
- to advance the progress bar. Since we don't know how long the
- user will keep the Styles application running, we use a
- logarithmic formula: The closer the progress bar gets to 100%,
- the slower it advances.
-
- We will review \c createProgressBar() in a moment.
-
- \snippet widgets/styles/widgetgallery.cpp 11
- \snippet widgets/styles/widgetgallery.cpp 12
-
- The \c createTopLeftGroupBox() function creates the QGroupBox
- that occupies the top-left corner of the \c WidgetGallery. We
- skip the \c createTopRightGroupBox(), \c
- createBottomLeftTabWidget(), and \c createBottomRightGroupBox()
- functions, which are very similar.
-
- \snippet widgets/styles/widgetgallery.cpp 13
-
- In \c createProgressBar(), we create a QProgressBar at the bottom
- of the \c WidgetGallery and connect its
- \l{QTimer::timeout()}{timeout()} signal to the \c
- advanceProgressBar() slot.
-*/
diff --git a/examples/widgets/doc/src/stylesheet.qdoc b/examples/widgets/doc/src/stylesheet.qdoc
deleted file mode 100644
index b85ccdb015..0000000000
--- a/examples/widgets/doc/src/stylesheet.qdoc
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/stylesheet
- \title Style Sheet Example
- \ingroup examples-widgets
- \brief The Style Sheet Example shows how to use style sheets.
-
- \borderedimage stylesheet-pagefold.png
- \caption Screen Shot of the Pagefold style sheet
-
- The Style Sheet example shows how widgets can be styled using Qt Style Sheets.
- You can open the style editor by selecting \uicontrol File > \uicontrol Edit Style Sheet,
- to select an existing style sheet or design your own style and load it.
-
- The Style Sheet example consists of 2 classes:
- \list
- \li \c MainWindow
- \li \c StyleSheetEditor
- \endlist
-
-
- \section1 MainWindow Class
-
- \c MainWindow inherits QWidget, and is the application's main window defined in
- \c mainwindow.ui. The style of \c MainWindow can be modified with \c StyleSheetEditor.
-
-
- \section1 StyleSheetEditor Class
-
- \c StyleSheetEditor enables you to open an editor where you can load an existing style sheet.
- It is also possible to define a new stylesheet and load it. Its layout is defined in
- \c stylesheeteditor.ui.
-
- \quotefromfile widgets/stylesheet/stylesheeteditor.cpp
- \skipto setStyleName
- \printline setStyleName
-
- Sets the specified \a styleName and grays the \c applyButton.
-
- \skipto setStyleSheetName
- \printline setStyleSheetName
-
- Loads the stylesheet from \c styleSheetName.
-
- \skipto setModified()
- \printline setModified()
-
- Enables the \c applyButton when the text in the buffer has changed.
-
- \skipto apply()
- \printline apply()
-
- Sets the stylesheet properties in \l qApp and disables the \c applyButton.
-
- \skipto loadStyleSheet(const QString &sheetName)
- \printline loadStyleSheet(const QString &sheetName)
-
- Loads the specified \a sheetName, and sets its properties in
- \l qApp.
-
-*/
-
diff --git a/examples/widgets/doc/src/syntaxhighlighter.qdoc b/examples/widgets/doc/src/syntaxhighlighter.qdoc
index 1b4ef2561b..17bcc1fa06 100644
--- a/examples/widgets/doc/src/syntaxhighlighter.qdoc
+++ b/examples/widgets/doc/src/syntaxhighlighter.qdoc
@@ -4,6 +4,7 @@
/*!
\example richtext/syntaxhighlighter
\title Syntax Highlighter Example
+ \examplecategory {User Interface Components}
\ingroup examples-richtext
\brief The Syntax Highlighter example shows how to perform
simple syntax highlighting.
@@ -219,10 +220,4 @@
function. The QSyntaxHighlighter class also provides the \l
{QSyntaxHighlighter::document()}{document()} function which
returns the currently set document.
-
- \section1 Other Code Editor Features
-
- The \l{Code Editor Example} shows how to implement line
- numbers and how to highlight the current line.
-
*/
diff --git a/examples/widgets/doc/src/tabdialog.qdoc b/examples/widgets/doc/src/tabdialog.qdoc
index f3887c94c8..fb45bbae04 100644
--- a/examples/widgets/doc/src/tabdialog.qdoc
+++ b/examples/widgets/doc/src/tabdialog.qdoc
@@ -4,6 +4,7 @@
/*!
\example dialogs/tabdialog
\title Tab Dialog Example
+ \examplecategory {User Interface Components}
\ingroup examples-dialogs
\brief The Tab Dialog example shows how to construct a tab dialog using the
diff --git a/examples/widgets/doc/src/tablet.qdoc b/examples/widgets/doc/src/tablet.qdoc
index efbb769e64..9d49d8dec8 100644
--- a/examples/widgets/doc/src/tablet.qdoc
+++ b/examples/widgets/doc/src/tablet.qdoc
@@ -4,6 +4,7 @@
/*!
\example widgets/tablet
\title Tablet Example
+ \examplecategory {User Interface Components}
\ingroup examples-widgets
\brief This example shows how to use a Wacom tablet in Qt applications.
@@ -13,7 +14,7 @@
generated. You need to reimplement the \l{QWidget::}{tabletEvent()} event
handler if you want to handle tablet events. Events are generated when the
tool (stylus) used for drawing enters and leaves the proximity of the
- tablet (i.e., when it is close but not pressed down on it), when the tool
+ tablet (i.e., when it is closed but not pressed down on it), when the tool
is pressed down and released from it, when the tool is moved across the
tablet, and when one of the buttons on the tool is pressed or released.
@@ -31,7 +32,7 @@
draw on the tablet as you use a pencil on paper. When you draw with the
airbrush you get a spray of virtual paint; the finger wheel is used to
change the density of the spray. When you draw with the art pen, you get a
- a line whose width and endpoint angle depend on the rotation of the pen.
+ line whose width and endpoint angle depend on the rotation of the pen.
The pressure and tilt can also be assigned to change the alpha and
saturation values of the color and the width of the stroke.
@@ -88,8 +89,6 @@
in a submenu of the \b Tablet menu, for selecting which property of each
QTabletEvent will be used to vary the translucency (alpha channel) of the
line being drawn or color being airbrushed.
- (See the \l{Qt Widgets - Application Example}{application example} if you want
- a high-level introduction to QActions.)
\snippet widgets/tablet/mainwindow.cpp 9
diff --git a/examples/widgets/doc/src/tetrix.qdoc b/examples/widgets/doc/src/tetrix.qdoc
deleted file mode 100644
index 1f6ed76047..0000000000
--- a/examples/widgets/doc/src/tetrix.qdoc
+++ /dev/null
@@ -1,407 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/tetrix
- \title Tetrix Example
- \ingroup examples-widgets
- \brief The Tetrix example is a Qt version of the classic Tetrix game.
-
- \borderedimage tetrix-example.png
-
- The object of the game is to stack pieces dropped from the top of the
- playing area so that they fill entire rows at the bottom of the playing area.
-
- When a row is filled, all the blocks on that row are removed, the player earns
- a number of points, and the pieces above are moved down to occupy that row.
- If more than one row is filled, the blocks on each row are removed, and the
- player earns extra points.
-
- The \uicontrol{Left} cursor key moves the current piece one space to the left, the
- \uicontrol{Right} cursor key moves it one space to the right, the \uicontrol{Up} cursor
- key rotates the piece counter-clockwise by 90 degrees, and the \uicontrol{Down}
- cursor key rotates the piece clockwise by 90 degrees.
-
- To avoid waiting for a piece to fall to the bottom of the board, press \uicontrol{D}
- to immediately move the piece down by one row, or press the \uicontrol{Space} key to
- drop it as close to the bottom of the board as possible.
-
- This example shows how a simple game can be created using only three classes:
-
- \list
- \li The \c TetrixWindow class is used to display the player's score, number of
- lives, and information about the next piece to appear.
- \li The \c TetrixBoard class contains the game logic, handles keyboard input, and
- displays the pieces on the playing area.
- \li The \c TetrixPiece class contains information about each piece.
- \endlist
-
- In this approach, the \c TetrixBoard class is the most complex class, since it
- handles the game logic and rendering. One benefit of this is that the
- \c TetrixWindow and \c TetrixPiece classes are very simple and contain only a
- minimum of code.
-
- \section1 TetrixWindow Class Definition
-
- The \c TetrixWindow class is used to display the game information and contains
- the playing area:
-
- \snippet widgets/tetrix/tetrixwindow.h 0
-
- We use private member variables for the board, various display widgets, and
- buttons to allow the user to start a new game, pause the current game, and quit.
-
- Although the window inherits QWidget, the constructor does not provide an
- argument to allow a parent widget to be specified. This is because the window
- will always be used as a top-level widget.
-
- \section1 TetrixWindow Class Implementation
-
- The constructor sets up the user interface elements for the game:
-
- \snippet widgets/tetrix/tetrixwindow.cpp 0
-
- We begin by constructing a \c TetrixBoard instance for the playing area and a
- label that shows the next piece to be dropped into the playing area; the label
- is initially empty.
-
- Three QLCDNumber objects are used to display the score, number of lives, and
- lines removed. These initially show default values, and will be filled in
- when a game begins:
-
- \snippet widgets/tetrix/tetrixwindow.cpp 1
-
- Three buttons with shortcuts are constructed so that the user can start a
- new game, pause the current game, and quit the application:
-
- \snippet widgets/tetrix/tetrixwindow.cpp 2
- \snippet widgets/tetrix/tetrixwindow.cpp 3
-
- These buttons are configured so that they never receive the keyboard focus;
- we want the keyboard focus to remain with the \c TetrixBoard instance so that
- it receives all the keyboard events. Nonetheless, the buttons will still respond
- to \uicontrol{Alt} key shortcuts.
-
- We connect \l{QAbstractButton::}{clicked()} signals from the \uicontrol{Start}
- and \uicontrol{Pause} buttons to the board, and from the \uicontrol{Quit} button to the
- application's \l{QCoreApplication::quit()} slot.
-
- \snippet widgets/tetrix/tetrixwindow.cpp 4
- \snippet widgets/tetrix/tetrixwindow.cpp 5
-
- Signals from the board are also connected to the LCD widgets for the purpose of
- updating the score, number of lives, and lines removed from the playing area.
-
- We place the label, LCD widgets, and the board into a QGridLayout
- along with some labels that we create with the \c createLabel() convenience
- function:
-
- \snippet widgets/tetrix/tetrixwindow.cpp 6
-
- Finally, we set the grid layout on the widget, give the window a title, and
- resize it to an appropriate size.
-
- The \c createLabel() convenience function simply creates a new label on the
- heap, gives it an appropriate alignment, and returns it to the caller:
-
- \snippet widgets/tetrix/tetrixwindow.cpp 7
-
- Since each label will be used in the widget's layout, it will become a child
- of the \c TetrixWindow widget and, as a result, it will be deleted when the
- window is deleted.
-
- \section1 TetrixPiece Class Definition
-
- The \c TetrixPiece class holds information about a piece in the game's
- playing area, including its shape, position, and the range of positions it can
- occupy on the board:
-
- \snippet widgets/tetrix/tetrixpiece.h 0
-
- Each shape contains four blocks, and these are defined by the \c coords private
- member variable. Additionally, each piece has a high-level description that is
- stored internally in the \c pieceShape variable.
-
- The constructor is written inline in the definition, and simply ensures that
- each piece is initially created with no shape. The \c shape() function simply
- returns the contents of the \c pieceShape variable, and the \c x() and \c y()
- functions return the x and y-coordinates of any given block in the shape.
-
- \section1 TetrixPiece Class Implementation
-
- The \c setRandomShape() function is used to select a random shape for a piece:
-
- \snippet widgets/tetrix/tetrixpiece.cpp 0
-
- For convenience, it simply chooses a random shape from the \c TetrixShape enum
- and calls the \c setShape() function to perform the task of positioning the
- blocks.
-
- The \c setShape() function uses a look-up table of pieces to associate each
- shape with an array of block positions:
-
- \snippet widgets/tetrix/tetrixpiece.cpp 1
- \snippet widgets/tetrix/tetrixpiece.cpp 2
-
- These positions are read from the table into the piece's own array of positions,
- and the piece's internal shape information is updated to use the new shape.
-
- The \c x() and \c y() functions are implemented inline in the class definition,
- returning positions defined on a grid that extends horizontally and vertically
- with coordinates from -2 to 2. Although the predefined coordinates for each
- piece only vary horizontally from -1 to 1 and vertically from -1 to 2, each
- piece can be rotated by 90, 180, and 270 degrees.
-
- The \c minX() and \c maxX() functions return the minimum and maximum horizontal
- coordinates occupied by the blocks that make up the piece:
-
- \snippet widgets/tetrix/tetrixpiece.cpp 3
- \snippet widgets/tetrix/tetrixpiece.cpp 4
-
- Similarly, the \c minY() and \c maxY() functions return the minimum and maximum
- vertical coordinates occupied by the blocks:
-
- \snippet widgets/tetrix/tetrixpiece.cpp 5
- \snippet widgets/tetrix/tetrixpiece.cpp 6
-
- The \c rotatedLeft() function returns a new piece with the same shape as an
- existing piece, but rotated counter-clockwise by 90 degrees:
-
- \snippet widgets/tetrix/tetrixpiece.cpp 7
-
- Similarly, the \c rotatedRight() function returns a new piece with the same
- shape as an existing piece, but rotated clockwise by 90 degrees:
-
- \snippet widgets/tetrix/tetrixpiece.cpp 9
-
- These last two functions enable each piece to create rotated copies of itself.
-
- \section1 TetrixBoard Class Definition
-
- The \c TetrixBoard class inherits from QFrame and contains the game logic and display features:
-
- \snippet widgets/tetrix/tetrixboard.h 0
-
- Apart from the \c setNextPieceLabel() function and the \c start() and \c pause()
- public slots, we only provide public functions to reimplement QWidget::sizeHint()
- and QWidget::minimumSizeHint(). The signals are used to communicate changes to
- the player's information to the \c TetrixWindow instance.
-
- The rest of the functionality is provided by reimplementations of protected event
- handlers and private functions:
-
- \snippet widgets/tetrix/tetrixboard.h 1
-
- The board is composed of a fixed-size array whose elements correspond to
- spaces for individual blocks. Each element in the array contains a \c TetrixShape
- value corresponding to the type of shape that occupies that element.
-
- Each shape on the board will occupy four elements in the array, and these will
- all contain the enum value that corresponds to the type of the shape.
-
- We use a QBasicTimer to control the rate at which pieces fall toward the bottom
- of the playing area. This allows us to provide an implementation of
- \l{QObject::}{timerEvent()} that we can use to update the widget.
-
- \section1 TetrixBoard Class Implementation
-
- In the constructor, we customize the frame style of the widget, ensure that
- keyboard input will be received by the widget by using Qt::StrongFocus for the
- focus policy, and initialize the game state:
-
- \snippet widgets/tetrix/tetrixboard.cpp 0
-
- The first (next) piece is also set up with a random shape.
-
- The \c setNextPieceLabel() function is used to pass in an externally-constructed
- label to the board, so that it can be shown alongside the playing area:
-
- \snippet widgets/tetrix/tetrixboard.cpp 1
-
- We provide a reasonable size hint and minimum size hint for the board, based on
- the size of the space for each block in the playing area:
-
- \snippet widgets/tetrix/tetrixboard.cpp 2
- \snippet widgets/tetrix/tetrixboard.cpp 3
-
- By using a minimum size hint, we indicate to the layout in the parent widget
- that the board should not shrink below a minimum size.
-
- A new game is started when the \c start() slot is called. This resets the
- game's state, the player's score and level, and the contents of the board:
-
- \snippet widgets/tetrix/tetrixboard.cpp 4
-
- We also emit signals to inform other components of these changes before creating
- a new piece that is ready to be dropped into the playing area. We start the
- timer that determines how often the piece drops down one row on the board.
-
- The \c pause() slot is used to temporarily stop the current game by stopping the
- internal timer:
-
- \snippet widgets/tetrix/tetrixboard.cpp 5
- \snippet widgets/tetrix/tetrixboard.cpp 6
-
- We perform checks to ensure that the game can only be paused if it is already
- running and not already paused.
-
- The \c paintEvent() function is straightforward to implement. We begin by
- calling the base class's implementation of \l{QWidget::}{paintEvent()} before
- constructing a QPainter for use on the board:
-
- \snippet widgets/tetrix/tetrixboard.cpp 7
-
- Since the board is a subclass of QFrame, we obtain a QRect that covers the area
- \e inside the frame decoration before drawing our own content.
-
- If the game is paused, we want to hide the existing state of the board and
- show some text. We achieve this by painting text onto the widget and returning
- early from the function. The rest of the painting is performed after this point.
-
- The position of the top of the board is found by subtracting the total height
- of each space on the board from the bottom of the frame's internal rectangle.
- For each space on the board that is occupied by a piece, we call the
- \c drawSquare() function to draw a block at that position.
-
- \snippet widgets/tetrix/tetrixboard.cpp 8
- \snippet widgets/tetrix/tetrixboard.cpp 9
-
- Spaces that are not occupied by blocks are left blank.
-
- Unlike the existing pieces on the board, the current piece is drawn
- block-by-block at its current position:
-
- \snippet widgets/tetrix/tetrixboard.cpp 10
- \snippet widgets/tetrix/tetrixboard.cpp 11
- \snippet widgets/tetrix/tetrixboard.cpp 12
-
- The \c keyPressEvent() handler is called whenever the player presses a key while
- the \c TetrixBoard widget has the keyboard focus.
-
- \snippet widgets/tetrix/tetrixboard.cpp 13
-
- If there is no current game, the game is running but paused, or if there is no
- current shape to control, we simply pass on the event to the base class.
-
- We check whether the event is about any of the keys that the player uses to
- control the current piece and, if so, we call the relevant function to handle
- the input:
-
- \snippet widgets/tetrix/tetrixboard.cpp 14
-
- In the case where the player presses a key that we are not interested in, we
- again pass on the event to the base class's implementation of
- \l{QWidget::}{keyPressEvent()}.
-
- The \c timerEvent() handler is called every time the class's QBasicTimer
- instance times out. We need to check that the event we receive corresponds to
- our timer. If it does, we can update the board:
-
- \snippet widgets/tetrix/tetrixboard.cpp 15
- \snippet widgets/tetrix/tetrixboard.cpp 16
- \snippet widgets/tetrix/tetrixboard.cpp 17
-
- If a row (or line) has just been filled, we create a new piece and reset the
- timer; otherwise we move the current piece down by one row. We let the base
- class handle other timer events that we receive.
-
- The \c clearBoard() function simply fills the board with the
- \c TetrixShape::NoShape value:
-
- \snippet widgets/tetrix/tetrixboard.cpp 18
-
- The \c dropDown() function moves the current piece down as far as possible on
- the board, either until it is touching the bottom of the playing area or it is
- stacked on top of another piece:
-
- \snippet widgets/tetrix/tetrixboard.cpp 19
- \snippet widgets/tetrix/tetrixboard.cpp 20
-
- The number of rows the piece has dropped is recorded and passed to the
- \c pieceDropped() function so that the player's score can be updated.
-
- The \c oneLineDown() function is used to move the current piece down by one row
- (line), either when the user presses the \uicontrol{D} key or when the piece is
- scheduled to move:
-
- \snippet widgets/tetrix/tetrixboard.cpp 21
-
- If the piece cannot drop down by one line, we call the \c pieceDropped() function
- with zero as the argument to indicate that it cannot fall any further, and that
- the player should receive no extra points for the fall.
-
- The \c pieceDropped() function itself is responsible for awarding points to the
- player for positioning the current piece, checking for full rows on the board
- and, if no lines have been removed, creating a new piece to replace the current
- one:
-
- \snippet widgets/tetrix/tetrixboard.cpp 22
- \snippet widgets/tetrix/tetrixboard.cpp 23
-
- We call \c removeFullLines() each time a piece has been dropped. This scans
- the board from bottom to top, looking for blank spaces on each row.
-
- \snippet widgets/tetrix/tetrixboard.cpp 24
- \snippet widgets/tetrix/tetrixboard.cpp 25
- \snippet widgets/tetrix/tetrixboard.cpp 26
- \snippet widgets/tetrix/tetrixboard.cpp 27
-
- If a row contains no blank spaces, the rows above it are copied down by one row
- to compress the stack of pieces, the top row on the board is cleared, and the
- number of full lines found is incremented.
-
- \snippet widgets/tetrix/tetrixboard.cpp 28
- \snippet widgets/tetrix/tetrixboard.cpp 29
-
- If some lines have been removed, the player's score and the total number of lines
- removed are updated. The \c linesRemoved() and \c scoreChanged() signals are
- emitted to send these new values to other widgets in the window.
-
- Additionally, we set the timer to elapse after half a second, set the
- \c isWaitingAfterLine flag to indicate that lines have been removed, unset
- the piece's shape to ensure that it is not drawn, and update the widget.
- The next time that the \c timerEvent() handler is called, a new piece will be
- created and the game will continue.
-
- The \c newPiece() function places the next available piece at the top of the
- board, and creates a new piece with a random shape:
-
- \snippet widgets/tetrix/tetrixboard.cpp 30
- \snippet widgets/tetrix/tetrixboard.cpp 31
-
- We place a new piece in the middle of the board at the top. The game is over if
- the piece can't move, so we unset its shape to prevent it from being drawn, stop
- the timer, and unset the \c isStarted flag.
-
- The \c showNextPiece() function updates the label that shows the next piece to
- be dropped:
-
- \snippet widgets/tetrix/tetrixboard.cpp 32
- \snippet widgets/tetrix/tetrixboard.cpp 33
-
- We draw the piece's component blocks onto a pixmap that is then set on the label.
-
- The \c tryMove() function is used to determine whether a piece can be positioned
- at the specified coordinates:
-
- \snippet widgets/tetrix/tetrixboard.cpp 34
-
- We examine the spaces on the board that the piece needs to occupy and, if they
- are already occupied by other pieces, we return \c false to indicate that the
- move has failed.
-
- \snippet widgets/tetrix/tetrixboard.cpp 35
-
- If the piece could be placed on the board at the desired location, we update the
- current piece and its position, update the widget, and return \c true to indicate
- success.
-
- The \c drawSquare() function draws the blocks (normally squares) that make up
- each piece using different colors for pieces with different shapes:
-
- \snippet widgets/tetrix/tetrixboard.cpp 36
-
- We obtain the color to use from a look-up table that relates each shape to an
- RGB value, and use the painter provided to draw the block at the specified
- coordinates.
-*/
diff --git a/examples/widgets/doc/src/textedit.qdoc b/examples/widgets/doc/src/textedit.qdoc
deleted file mode 100644
index f41a58fe90..0000000000
--- a/examples/widgets/doc/src/textedit.qdoc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example richtext/textedit
- \title Text Edit
- \ingroup examples-richtext
- \brief The Text Edit example shows Qt's rich text editing facilities
- in action.
-
- \brief The Text Edit example shows Qt's rich text editing facilities in action,
- providing an example document for you to experiment with.
-
- \image textedit-demo.png
-*/
diff --git a/examples/widgets/doc/src/tooltips.qdoc b/examples/widgets/doc/src/tooltips.qdoc
deleted file mode 100644
index 4712c80851..0000000000
--- a/examples/widgets/doc/src/tooltips.qdoc
+++ /dev/null
@@ -1,370 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/tooltips
- \title Tool Tips Example
- \ingroup examples-widgets
- \brief The Tool Tips example shows how to provide static and dynamic tool
- tips for an application's widgets.
-
- The simplest and most common way to set a widget's tool tip is by
- calling its QWidget::setToolTip() function (static tool
- tips). Then the tool tip is shown whenever the cursor points at
- the widget. We show how to do this with our application's tool
- buttons. But it is also possible to show different tool tips
- depending on the cursor's position (dynamic tooltips). This
- approach uses mouse tracking and event handling to determine what
- widgets are located under the cursor at any point in time, and
- displays their tool tips. The tool tips for the shape items in our
- application are implemented using the latter approach.
-
- \image tooltips-example.png
-
- With the \c Tooltips application the user can create new shape
- items with the provided tool buttons, and move the items around
- using the mouse. Tooltips are provided whenever the cursor is
- pointing to a shape item or one of the buttons.
-
- The Tooltips example consists of two classes:
-
- \list
- \li \c ShapeItem is a custom widget representing one single shape item.
- \li \c SortingBox inherits from QWidget and is the application's main
- widget.
- \endlist
-
- First we will review the \c SortingBox class, then we will take a
- look at the \c ShapeItem class.
-
- \section1 SortingBox Class Definition
-
- \snippet widgets/tooltips/sortingbox.h 0
-
- The \c SortingBox class inherits QWidget, and it is the Tooltips
- application's main widget. We reimplement several of the event
- handlers.
-
- The \c event() function provides tooltips, the \c resize()
- function makes sure the application appears consistently when the
- user resizes the main widget, and the \c paintEvent() function
- displays the shape items within the \c SortingBox widget. The
- mouse event handlers are reimplemented to make the user able to
- move the items around.
-
- In addition we need three private slots to make the user able to
- create new shape items.
-
- \snippet widgets/tooltips/sortingbox.h 1
-
- We also create several private functions: We use the \c
- initialItemPosition(), \c initialItemColor() and \c
- createToolButton() functions when we are constructing the widget,
- and we use the \c updateButtonGeometry() function whenever the
- user is resizing the application's main widget.
-
- The \c itemAt() function determines if there is a shape item at a
- particular position, and the \c moveItemTo() function moves an
- item to a new position. We use the \c createShapeItem(), \c
- randomItemPosition() and \c randomItemColor() functions to create
- new shape items.
-
- \snippet widgets/tooltips/sortingbox.h 2
-
- We keep all the shape items in a QList, and we keep three
- QPainterPath objects holding the shapes of a circle, a square and
- a triangle. We also need to have a pointer to an item when it is
- moving, and we need to know its previous position.
-
- \section1 SortingBox Class Implementation
-
- \snippet widgets/tooltips/sortingbox.cpp 0
-
- In the constructor, we first set the Qt::WA_StaticContents
- attribute on the widget. This attribute indicates that the widget
- contents are north-west aligned and static. On resize, such a
- widget will receive paint events only for the newly visible part
- of itself.
-
- \snippet widgets/tooltips/sortingbox.cpp 1
-
- To be able to show the appropriate tooltips while the user is
- moving the cursor around, we need to enable mouse tracking for the
- widget.
-
- If mouse tracking is disabled (the default), the widget only
- receives mouse move events when at least one mouse button is
- pressed while the mouse is being moved. If mouse tracking is
- enabled, the widget receives mouse move events even if no buttons
- are pressed.
-
- \snippet widgets/tooltips/sortingbox.cpp 2
-
- A widget's background role defines the brush from the widget's
- palette that is used to render the background, and QPalette::Base
- is typically white.
-
- \snippet widgets/tooltips/sortingbox.cpp 3
-
- After creating the application's tool buttons using the private \c
- createToolButton() function, we construct the shapes of a circle,
- a square and a triangle using QPainterPath.
-
- The QPainterPath class provides a container for painting
- operations, enabling graphical shapes to be constructed and
- reused. The main advantage of painter paths over normal drawing
- operations is that complex shapes only need to be created once,
- but they can be drawn many times using only calls to
- QPainter::drawPath().
-
- \snippet widgets/tooltips/sortingbox.cpp 4
-
- Then we set the window title, resize the widget to a suitable
- size, and finally create three initial shape items using the
- private \c createShapeItem(), \c initialItemPosition() and \c
- initialItemColor() functions.
-
- \snippet widgets/tooltips/sortingbox.cpp 5
-
- QWidget::event() is the main event handler and receives all the
- widget's events. Normally, we recommend reimplementing one of the
- specialized event handlers instead of this function. But here we
- want to catch the QEvent::ToolTip events, and since these are
- rather rare, there exists no specific event handler. For that
- reason we reimplement the main event handler, and the first thing
- we need to do is to determine the event's type:
-
- \snippet widgets/tooltips/sortingbox.cpp 6
-
- If the type is QEvent::ToolTip, we cast the event to a QHelpEvent,
- otherwise we propagate the event using the QWidget::event()
- function.
-
- The QHelpEvent class provides an event that is used to request
- helpful information about a particular point in a widget.
-
- For example, the QHelpEvent::pos() function returns the event's
- position relative to the widget to which the event is dispatched.
- Here we use this information to determine if the position of the
- event is contained within the area of any of the shape items. If
- it is, we display the shape item's tooltip at the position of the
- event. If not, we hide the tooltip and explicitly ignore the event.
- This makes sure that the calling code does not start any tooltip
- specific modes as a result of the event. Note that the
- QToolTip::showText() function needs the event's position in global
- coordinates provided by QHelpEvent::globalPos().
-
- \snippet widgets/tooltips/sortingbox.cpp 7
-
- The \c resizeEvent() function is reimplemented to receive the
- resize events dispatched to the widget. It makes sure that the
- tool buttons keep their position relative to the main widget when
- the widget is resized. We want the buttons to always be vertically
- aligned in the application's bottom right corner, so each time the
- main widget is resized we update the buttons geometry.
-
- \snippet widgets/tooltips/sortingbox.cpp 8
-
- The \c paintEvent() function is reimplemented to receive paint
- events for the widget. We create a QPainter for the \c SortingBox
- widget, and run through the list of created shape items, drawing
- each item at its defined position.
-
- \snippet widgets/tooltips/sortingbox.cpp 9
-
- The painter will by default draw all the shape items at position
- (0,0) in the \c SortingBox widget. The QPainter::translate()
- function translates the coordinate system by the given offset,
- making each shape item appear at its defined position. But
- remember to translate the coordinate system back when the item is
- drawn, otherwise the next shape item will appear at a position
- relative to the item drawn last.
-
- \snippet widgets/tooltips/sortingbox.cpp 10
-
- The QPainter::setBrush() function sets the current brush used by
- the painter. When the provided argument is a QColor, the function
- calls the appropriate QBrush constructor which creates a brush with
- the specified color and Qt::SolidPattern style. The
- QPainter::drawPath() function draws the given path using the
- current pen for outline and the current brush for filling.
-
- \snippet widgets/tooltips/sortingbox.cpp 11
-
- The \c mousePressEvent() function is reimplemented to receive the
- mouse press events dispatched to the widget. It determines if an
- event's position is contained within the area of any of the shape
- items, using the private \c itemAt() function.
-
- If an item covers the position, we store a pointer to that item
- and the event's position. If several of the shape items cover the
- position, we store the pointer to the uppermost item. Finally, we
- move the shape item to the end of the list, and make a call to the
- QWidget::update() function to make the item appear on top.
-
- The QWidget::update() function does not cause an immediate
- repaint; instead it schedules a paint event for processing when Qt
- returns to the main event loop.
-
- \snippet widgets/tooltips/sortingbox.cpp 12
-
- The \c mouseMoveEvent() function is reimplemented to receive mouse
- move events for the widget. If the left mouse button is pressed
- and there exists a shape item in motion, we use the private \c
- moveItemTo() function to move the item with an offset
- corresponding to the offset between the positions of the current
- mouse event and the previous one.
-
- \snippet widgets/tooltips/sortingbox.cpp 13
-
- The \c mouseReleaseEvent() function is reimplemented to receive
- the mouse release events dispatched to the widget. If the left
- mouse button is pressed and there exists a shape item in motion,
- we use the private \c moveItemTo() function to move the item like
- we did in \c mouseMoveEvent(). But then we remove the pointer to
- the item in motion, making the shape item's position final for
- now. To move the item further, the user will need to press the
- left mouse button again.
-
- \snippet widgets/tooltips/sortingbox.cpp 14
- \codeline
- \snippet widgets/tooltips/sortingbox.cpp 15
- \codeline
- \snippet widgets/tooltips/sortingbox.cpp 16
-
- The \c createNewCircle(), \c createNewSquare() and \c
- createNewTriangle() slots simply create new shape items, using the
- private \c createShapeItem(), \c randomItemPosition() and \c
- randomItemColor() functions.
-
- \snippet widgets/tooltips/sortingbox.cpp 17
-
- In the \c itemAt() function, we run through the list of created
- shape items to check if the given position is contained within the
- area of any of the shape items.
-
- For each shape item we use the QPainterPath::contains() function
- to find out if the item's painter path contains the position. If
- it does we return the index of the item, otherwise we return
- -1. We run through the list backwards to get the index of the
- uppermost shape item in case several items cover the position.
-
- \snippet widgets/tooltips/sortingbox.cpp 18
-
- The \c moveItemTo() function moves the shape item in motion, and
- the parameter \c pos is the position of a mouse event. First we
- calculate the offset between the parameter \c pos and the previous
- mouse event position. Then we add the offset to the current
- position of the item in motion.
-
- It is tempting to simply set the position of the item to be the
- parameter \c pos. But an item's position defines the top left
- corner of the item's bounding rectangle, and the parameter \c pos
- can be any point; The suggested shortcut would cause the item to
- jump to a position where the cursor is pointing to the bounding
- rectangle's top left corner, regardless of the item's previous
- position.
-
- \snippet widgets/tooltips/sortingbox.cpp 19
-
- Finally, we update the previous mouse event position, and make a
- call to the QWidget::update() function to make the item appear at
- its new position.
-
- \snippet widgets/tooltips/sortingbox.cpp 20
-
- In the \c updateButtonGeometry() function we set the geometry for
- the given button. The parameter coordinates define the bottom
- right corner of the button. We use these coordinates and the
- button's size hint to determine the position of the upper left
- corner. This position, and the button's width and height, are the
- arguments required by the QWidget::setGeometry() function.
-
- In the end, we calculate and return the y-coordinate of the bottom
- right corner of the next button. We use the QWidget::style()
- function to retrieve the widget's GUI style, and then
- QStyle::pixelMetric() to determine the widget's preferred default
- spacing between its child widgets.
-
- \snippet widgets/tooltips/sortingbox.cpp 21
-
- The \c createShapeItem() function creates a single shape item. It
- sets the path, tooltip, position and color, using the item's own
- functions. In the end, the function appends the new item to the
- list of shape items, and calls the QWidget::update() function to
- make it appear with the other items within the \c SortingBox
- widget.
-
- \snippet widgets/tooltips/sortingbox.cpp 22
-
- The \c createToolButton() function is called from the \c
- SortingBox constructor. We create a tool button with the given
- tooltip and icon. The button's parent is the \c SortingBox widget,
- and its size is 32 x 32 pixels. Before we return the button, we
- connect it to the given slot.
-
- \snippet widgets/tooltips/sortingbox.cpp 23
-
- The \c initialItemPosition() function is also called from the
- constructor. We want the three first items to initially be
- centered in the middle of the \c SortingBox widget, and we use
- this function to calculate their positions.
-
- \snippet widgets/tooltips/sortingbox.cpp 24
-
- Whenever the user creates a new shape item, we want the new item
- to appear at a random position, and we use the \c
- randomItemPosition() function to calculate such a position. We
- make sure that the item appears within the visible area of the
- \c SortingBox widget, using the widget's current width and height
- when calculating the random coordinates.
-
- \snippet widgets/tooltips/sortingbox.cpp 25
-
- As with \c initialItemPosition(), the \c initialItemColor()
- function is called from the constructor. The purposes of both
- functions are purely cosmetic: We want to control the initial
- position and color of the three first items.
-
- \snippet widgets/tooltips/sortingbox.cpp 26
-
- Finally the \c randomItemColor() function is implemented to give
- the shape items the user creates, a random color.
-
- \section1 ShapeItem Class Definition
-
- \snippet widgets/tooltips/shapeitem.h 0
-
- The \c ShapeItem class is a custom widget representing one single
- shape item. The widget has a path, a position, a color and a
- tooltip. We need functions to set or modify these objects, as well
- as functions that return them. We make the latter functions \c
- const to prohibit any modifications of the objects,
- i.e. prohibiting unauthorized manipulation of the shape items
- appearance.
-
- \section1 ShapeItem Class Implementation
-
- \snippet widgets/tooltips/shapeitem.cpp 0
- \codeline
- \snippet widgets/tooltips/shapeitem.cpp 1
- \codeline
- \snippet widgets/tooltips/shapeitem.cpp 2
- \codeline
- \snippet widgets/tooltips/shapeitem.cpp 3
-
- This first group of functions simply return the objects that are
- requested. The objects are returned as constants, i.e. they cannot
- be modified.
-
- \snippet widgets/tooltips/shapeitem.cpp 4
- \codeline
- \snippet widgets/tooltips/shapeitem.cpp 5
- \codeline
- \snippet widgets/tooltips/shapeitem.cpp 6
- \codeline
- \snippet widgets/tooltips/shapeitem.cpp 7
-
- The last group of functions set or modify the shape item's path,
- position, color and tooltip, respectively.
-*/
diff --git a/examples/widgets/doc/src/transformations.qdoc b/examples/widgets/doc/src/transformations.qdoc
index aabb672b86..d90708340c 100644
--- a/examples/widgets/doc/src/transformations.qdoc
+++ b/examples/widgets/doc/src/transformations.qdoc
@@ -4,6 +4,7 @@
/*!
\example painting/transformations
\title Transformations Example
+ \examplecategory {Graphics}
\ingroup examples-painting
\brief The Transformations example shows how transformations
influence the way that QPainter renders graphics primitives.
diff --git a/examples/widgets/doc/src/treemodelcompleter.qdoc b/examples/widgets/doc/src/treemodelcompleter.qdoc
index 9734c3bc7c..ae7c18f442 100644
--- a/examples/widgets/doc/src/treemodelcompleter.qdoc
+++ b/examples/widgets/doc/src/treemodelcompleter.qdoc
@@ -4,6 +4,7 @@
/*!
\example tools/treemodelcompleter
\title Tree Model Completer Example
+ \examplecategory {User Interface Components}
\ingroup examples-widgets-tools
\brief The Tree Model Completer example shows how to provide completion
diff --git a/examples/widgets/doc/src/trivialwizard.qdoc b/examples/widgets/doc/src/trivialwizard.qdoc
index f62e917401..75d007f388 100644
--- a/examples/widgets/doc/src/trivialwizard.qdoc
+++ b/examples/widgets/doc/src/trivialwizard.qdoc
@@ -4,6 +4,7 @@
/*!
\example dialogs/trivialwizard
\title Trivial Wizard Example
+ \examplecategory {User Interface Components}
\ingroup examples-dialogs
\brief The Trivial Wizard example illustrates how to create a linear three-page
@@ -55,5 +56,5 @@
\snippet dialogs/trivialwizard/trivialwizard.cpp 10
- \sa QWizard, {Class Wizard Example}, {License Wizard Example}
+ \sa QWizard, {License Wizard Example}
*/
diff --git a/examples/widgets/doc/src/undo.qdoc b/examples/widgets/doc/src/undo.qdoc
deleted file mode 100644
index 3ffe10ddf3..0000000000
--- a/examples/widgets/doc/src/undo.qdoc
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example tools/undo
- \title Undo Framework
- \ingroup examples-widgets-tools
-
- \brief This example shows Qt's undo framework in action.
-
- \image undodemo.png
-
- Qt's undo framework is an implementation of the Command
- pattern, which provides advanced undo/redo functionality.
-
- To show the abilities of the framework, we have implemented a
- small diagram application in which the diagram items are geometric
- primitives. You can edit the diagram in the following ways: add,
- move, change the color of, and delete the items.
-*/
diff --git a/examples/widgets/doc/src/undoframework.qdoc b/examples/widgets/doc/src/undoframework.qdoc
index 3d275788f6..e8d895b7f0 100644
--- a/examples/widgets/doc/src/undoframework.qdoc
+++ b/examples/widgets/doc/src/undoframework.qdoc
@@ -4,6 +4,7 @@
/*!
\example tools/undoframework
\title Undo Framework Example
+ \examplecategory {Data Processing & I/O}
\ingroup examples-widgets-tools
\brief This example shows how to implement undo/redo functionality
@@ -69,6 +70,9 @@
\snippet tools/undoframework/mainwindow.cpp 0
In the constructor, we set up the DiagramScene and QGraphicsView.
+ We only want \c deleteAction to be enabled when we have selected an
+ item, so we connect to the \c selectionChanged() signal of the scene
+ to \c updateActions() slot.
Here is the \c createUndoView() function:
@@ -76,13 +80,11 @@
The QUndoView is a widget that display the text, which is set with
the \l{QUndoCommand::}{setText()} function, for each QUndoCommand
- in the undo stack in a list.
+ in the undo stack in a list. We put it into a docking widget.
Here is the \c createActions() function:
\snippet tools/undoframework/mainwindow.cpp 2
- \codeline
- \snippet tools/undoframework/mainwindow.cpp 3
\dots
\snippet tools/undoframework/mainwindow.cpp 5
@@ -95,46 +97,38 @@
\l{QUndoCommand::}{text()} of the undo commands. For the other
actions we have implemented slots in the \c MainWindow class.
- Here is the \c createMenus() function:
-
+ \dots
\snippet tools/undoframework/mainwindow.cpp 6
- \dots
+ Once all actions are created we update their state by calling the
+ same function that is connected to the \c selectionChanged signal of
+ the scene.
+
+ The \c createMenus() and \c createToolBars() functions add the
+ actions to menus and toolbars:
+
\snippet tools/undoframework/mainwindow.cpp 7
\dots
\snippet tools/undoframework/mainwindow.cpp 8
-
- We have to use the QMenu \c aboutToShow() and \c aboutToHide()
- signals since we only want \c deleteAction to be enabled when we
- have selected an item.
+ \dots
+ \snippet tools/undoframework/mainwindow.cpp 9
Here is the \c itemMoved() slot:
- \snippet tools/undoframework/mainwindow.cpp 9
+ \snippet tools/undoframework/mainwindow.cpp 11
We simply push a MoveCommand on the stack, which calls \c redo()
on it.
Here is the \c deleteItem() slot:
- \snippet tools/undoframework/mainwindow.cpp 10
+ \snippet tools/undoframework/mainwindow.cpp 12
- An item must be selected to be deleted. We need to check if it is
+ An item must be selected to be deleted. We need to check if it is
selected as the \c deleteAction may be enabled even if an item is
not selected. This can happen as we do not catch a signal or event
when an item is selected.
- Here is the \c itemMenuAboutToShow() and itemMenuAboutToHide() slots:
-
- \snippet tools/undoframework/mainwindow.cpp 11
- \codeline
- \snippet tools/undoframework/mainwindow.cpp 12
-
- We implement \c itemMenuAboutToShow() and \c itemMenuAboutToHide()
- to get a dynamic item menu. These slots are connected to the
- \l{QMenu::}{aboutToShow()} and \l{QMenu::}{aboutToHide()} signals.
- We need this to disable or enable the \c deleteAction.
-
Here is the \c addBox() slot:
\snippet tools/undoframework/mainwindow.cpp 13
diff --git a/examples/widgets/doc/src/validators.qdoc b/examples/widgets/doc/src/validators.qdoc
deleted file mode 100644
index a0b88617b5..0000000000
--- a/examples/widgets/doc/src/validators.qdoc
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/validators
- \title Validators Example
- \brief The Validators example shows the signal emission behavior of input
- validators.
-
- \borderedimage validators.png
-*/
diff --git a/examples/widgets/doc/src/wiggly.qdoc b/examples/widgets/doc/src/wiggly.qdoc
deleted file mode 100644
index 2c7ea5db9e..0000000000
--- a/examples/widgets/doc/src/wiggly.qdoc
+++ /dev/null
@@ -1,144 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example widgets/wiggly
- \title Wiggly Example
- \ingroup examples-widgets
- \brief The Wiggly example shows how to animate a widget using
- QBasicTimer and \l{QObject::timerEvent()}{timerEvent()}. In
- addition, the example demonstrates how to use QFontMetrics to
- determine the size of text on screen.
-
- \borderedimage wiggly-example.png
- \caption Screenshot of the Wiggly example
-
- QBasicTimer is a low-level class for timers. Unlike QTimer,
- QBasicTimer doesn't inherit from QObject; instead of emitting a
- \l{QTimer::timeout()}{timeout()} signal when a certain amount of
- time has passed, it sends a QTimerEvent to a QObject of our
- choice. This makes QBasicTimer a more lightweight alternative to
- QTimer. Qt's built-in widgets use it internally, and it is
- provided in Qt's API for highly-optimized applications (such as
- embedded applications).
-
- The example consists of two classes:
-
- \list
- \li \c WigglyWidget is the custom widget displaying the text
- in a wiggly line.
-
- \li \c Dialog is the dialog widget allowing the user to enter a
- text. It combines a \c WigglyWidget and a \c QLineEdit.
- \endlist
-
- We will first take a quick look at the \c Dialog class, then we
- will review the \c WigglyWidget class.
-
- \section1 Dialog Class Definition
-
- \snippet widgets/wiggly/dialog.h 0
-
- The \c Dialog class provides a dialog widget that allows the user
- to enter a text. The text is then rendered by \c WigglyWidget.
-
- \section1 Dialog Class Implementation
-
- \snippet widgets/wiggly/dialog.cpp 0
-
- In the constructor we create a wiggly widget along with a
- \l{QLineEdit}{line edit}, and we put the two widgets in a
- vertical layout. We connect the line edit's \l
- {QLineEdit::textChanged()}{textChanged()} signal to the wiggly
- widget's \c setText() slot to obtain the real time interaction
- with the wiggly widget. The widget's default text is "Hello
- world!".
-
- \section1 WigglyWidget Class Definition
-
- \snippet widgets/wiggly/wigglywidget.h 0
-
- The \c WigglyWidget class provides the wiggly line displaying the
- text. We subclass QWidget and reimplement the standard \l
- {QWidget::paintEvent()}{paintEvent()} and \l
- {QObject::timerEvent()}{timerEvent()} functions to draw and update
- the widget. In addition we implement a public \c setText() slot
- that sets the widget's text.
-
- The \c timer variable, of type QBasicTimer, is used to update the
- widget at regular intervals, making the widget move. The \c text
- variable is used to store the currently displayed text, and \c
- step to calculate position and color for each character on the
- wiggly line.
-
- \section1 WigglyWidget Class Implementation
-
- \snippet widgets/wiggly/wigglywidget.cpp 0
-
- In the constructor, we make the widget's background slightly
- lighter than the usual background using the QPalette::Midlight
- color role. The background role defines the brush from the
- widget's palette that Qt uses to paint the background. Then we
- enlarge the widget's font with 20 points.
-
- Finally we start the timer; the call to QBasicTimer::start()
- makes sure that \e this particular wiggly widget will receive the
- timer events generated when the timer times out (every 60
- milliseconds).
-
- \snippet widgets/wiggly/wigglywidget.cpp 1
- \snippet widgets/wiggly/wigglywidget.cpp 2
-
- The \c paintEvent() function is called whenever a QPaintEvent is
- sent to the widget. Paint events are sent to widgets that need to
- update themselves, for instance when part of a widget is exposed
- because a covering widget was moved. For the wiggly widget, a
- paint event will also be generated every 60 milliseconds from
- the \c timerEvent() slot.
-
- The \c sineTable represents y-values of the sine curve,
- multiplied by 100. It is used to make the wiggly widget move
- along the sine curve.
-
- The QFontMetrics object provides information about the widget's
- font. The \c x variable is the horizontal position where we start
- drawing the text. The \c y variable is the vertical position of
- the text's base line. Both variables are computed so that the
- text is horizontally and vertically centered. To compute the base
- line, we take into account the font's ascent (the height of the
- font above the base line) and font's descent (the height of the
- font below the base line). If the descent equals the ascent, they
- cancel out each other and the base line is at \c height() / 2.
-
- \snippet widgets/wiggly/wigglywidget.cpp 3
- \snippet widgets/wiggly/wigglywidget.cpp 4
-
- Each time the \c paintEvent() function is called, we create a
- QPainter object \c painter to draw the contents of the widget.
- For each character in \c text, we determine the color and the
- position on the wiggly line based on \c step. In addition, \c x
- is incremented by the character's width.
-
- For simplicity, we assume that QFontMetrics::horizontalAdvance(\c text)
- returns the sum of the individual character advances
- (QFontMetrics::horizontalAdvance(\c text[i])). In practice, this is not
- always the case because QFontMetrics::horizontalAdvance(\c text) also takes
- into account the kerning between certain letters (e.g., 'A' and
- 'V'). The result is that the text isn't perfectly centered. You
- can verify this by typing "AVAVAVAVAVAV" in the line edit.
-
- \snippet widgets/wiggly/wigglywidget.cpp 5
- \snippet widgets/wiggly/wigglywidget.cpp 6
-
- The \c timerEvent() function receives all the timer events that
- are generated for this widget. If a timer event is sent from the
- widget's QBasicTimer, we increment \c step to make the text move,
- and call QWidget::update() to refresh the display. Any other
- timer event is passed on to the base class's implementation of
- the \l{QWidget::timerEvent()}{timerEvent()} function.
-
- The QWidget::update() slot does not cause an immediate repaint;
- instead the slot schedules a paint event for processing when Qt
- returns to the main event loop. The paint events are then handled
- by \c{WigglyWidget}'s \c paintEvent() function.
-*/
diff --git a/examples/widgets/doc/src/windowflags.qdoc b/examples/widgets/doc/src/windowflags.qdoc
index d521894a17..10b0496728 100644
--- a/examples/widgets/doc/src/windowflags.qdoc
+++ b/examples/widgets/doc/src/windowflags.qdoc
@@ -4,6 +4,7 @@
/*!
\example widgets/windowflags
\title Window Flags Example
+ \examplecategory {User Interface Components}
\ingroup examples-widgets
\brief The Window Flags example shows how to use the window flags
available in Qt.
diff --git a/examples/widgets/draganddrop/CMakeLists.txt b/examples/widgets/draganddrop/CMakeLists.txt
index c75600f660..bdc6480790 100644
--- a/examples/widgets/draganddrop/CMakeLists.txt
+++ b/examples/widgets/draganddrop/CMakeLists.txt
@@ -1,8 +1,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
qt_internal_add_example(draggableicons)
qt_internal_add_example(draggabletext)
qt_internal_add_example(dropsite)
-qt_internal_add_example(fridgemagnets)
-qt_internal_add_example(puzzle)
diff --git a/examples/widgets/draganddrop/draganddrop.pro b/examples/widgets/draganddrop/draganddrop.pro
index 1ecafd33a1..ad56f3f677 100644
--- a/examples/widgets/draganddrop/draganddrop.pro
+++ b/examples/widgets/draganddrop/draganddrop.pro
@@ -1,6 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = draggableicons \
draggabletext \
- dropsite \
- fridgemagnets \
- puzzle
+ dropsite
diff --git a/examples/widgets/draganddrop/draggableicons/CMakeLists.txt b/examples/widgets/draganddrop/draggableicons/CMakeLists.txt
index 5bb08a593e..c1fac8da6b 100644
--- a/examples/widgets/draganddrop/draggableicons/CMakeLists.txt
+++ b/examples/widgets/draganddrop/draggableicons/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(draggableicons LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/draganddrop/draggableicons")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(draggableicons
dragwidget.cpp dragwidget.h
main.cpp
@@ -24,12 +18,17 @@ set_target_properties(draggableicons PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(draggableicons PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(draggableicons PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
+if(EMSCRIPTEN)
+ target_link_options(draggableicons PUBLIC -sASYNCIFY -Os)
+endif()
+
+
# Resources:
set(draggableicons_resource_files
"images/boat.png"
@@ -45,7 +44,14 @@ qt_add_resources(draggableicons "draggableicons"
)
install(TARGETS draggableicons
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET draggableicons
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/draganddrop/draggableicons/draggableicons.pro b/examples/widgets/draganddrop/draggableicons/draggableicons.pro
index f87ec4ad60..e43df790b4 100644
--- a/examples/widgets/draganddrop/draggableicons/draggableicons.pro
+++ b/examples/widgets/draganddrop/draggableicons/draggableicons.pro
@@ -4,7 +4,9 @@ HEADERS = dragwidget.h
RESOURCES = draggableicons.qrc
SOURCES = dragwidget.cpp \
main.cpp
-
+wasm {
+ QMAKE_LFLAGS += -sASYNCIFY -Os
+}
# install
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/draganddrop/draggableicons
INSTALLS += target
diff --git a/examples/widgets/draganddrop/draggableicons/dragwidget.cpp b/examples/widgets/draganddrop/draggableicons/dragwidget.cpp
index 135574d058..ba06c836d4 100644
--- a/examples/widgets/draganddrop/draggableicons/dragwidget.cpp
+++ b/examples/widgets/draganddrop/draggableicons/dragwidget.cpp
@@ -95,7 +95,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event)
if (!child)
return;
- QPixmap pixmap = child->pixmap(Qt::ReturnByValue);
+ QPixmap pixmap = child->pixmap();
QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
diff --git a/examples/widgets/draganddrop/draggableicons/main.cpp b/examples/widgets/draganddrop/draggableicons/main.cpp
index cd22e4e394..fe92708594 100644
--- a/examples/widgets/draganddrop/draggableicons/main.cpp
+++ b/examples/widgets/draganddrop/draggableicons/main.cpp
@@ -8,8 +8,6 @@
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(draggableicons);
-
QApplication app(argc, argv);
QWidget mainWidget;
diff --git a/examples/widgets/draganddrop/draggabletext/CMakeLists.txt b/examples/widgets/draganddrop/draggabletext/CMakeLists.txt
index aae64b7e23..bc1e72db80 100644
--- a/examples/widgets/draganddrop/draggabletext/CMakeLists.txt
+++ b/examples/widgets/draganddrop/draggabletext/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(draggabletext LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/draganddrop/draggabletext")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(draggabletext
dragwidget.cpp dragwidget.h
main.cpp
@@ -24,12 +18,16 @@ set_target_properties(draggabletext PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(draggabletext PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(draggabletext PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
+if(EMSCRIPTEN)
+ target_link_options(draggabletext PUBLIC -sASYNCIFY -Os)
+endif()
+
# Resources:
set(draggabletext_resource_files
"words.txt"
@@ -43,7 +41,14 @@ qt_add_resources(draggabletext "draggabletext"
)
install(TARGETS draggabletext
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET draggabletext
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/draganddrop/draggabletext/draggabletext.pro b/examples/widgets/draganddrop/draggabletext/draggabletext.pro
index 1add2a270e..007b9d834e 100644
--- a/examples/widgets/draganddrop/draggabletext/draggabletext.pro
+++ b/examples/widgets/draganddrop/draggabletext/draggabletext.pro
@@ -4,6 +4,9 @@ HEADERS = dragwidget.h
RESOURCES = draggabletext.qrc
SOURCES = dragwidget.cpp \
main.cpp
+wasm {
+ QMAKE_LFLAGS += -sASYNCIFY -Os
+}
# install
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/draganddrop/draggabletext
diff --git a/examples/widgets/draganddrop/draggabletext/main.cpp b/examples/widgets/draganddrop/draggabletext/main.cpp
index f6ab39aee1..ebfd481e62 100644
--- a/examples/widgets/draganddrop/draggabletext/main.cpp
+++ b/examples/widgets/draganddrop/draggabletext/main.cpp
@@ -7,8 +7,6 @@
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(draggabletext);
-
QApplication app(argc, argv);
DragWidget window;
window.show();
diff --git a/examples/widgets/draganddrop/draggabletext/words.txt b/examples/widgets/draganddrop/draggabletext/words.txt
index 19b8b0325b..78bf304fa9 100644
--- a/examples/widgets/draganddrop/draggabletext/words.txt
+++ b/examples/widgets/draganddrop/draggabletext/words.txt
@@ -1,41 +1,35 @@
Qt
-Quarterly
+Academy
is
-a
-paper
-based
-newsletter
-exclusively
-available
-to
+where
+you
+begin
+your
+journey
+into
Qt
-customers
-Every
-quarter
-we
-mail
-out
-an
-issue
+It
+is
+a
+learning
+platform
that
-we
-hope
-will
-bring
-added
-insight
+can
+teach
+you
+everything
+from
+the
+basics
+to
+the
+details
and
-pleasure
+is
+open
to
-your
-Qt
-programming
-with
-high
-quality
-technical
-articles
-written
-by
-Qt
-experts
+students
+and
+experienced
+programmers
+alike
diff --git a/examples/widgets/draganddrop/dropsite/CMakeLists.txt b/examples/widgets/draganddrop/dropsite/CMakeLists.txt
index 3fa7f2bb52..ae8d00eb91 100644
--- a/examples/widgets/draganddrop/dropsite/CMakeLists.txt
+++ b/examples/widgets/draganddrop/dropsite/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(dropsite LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/draganddrop/dropsite")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(dropsite
droparea.cpp droparea.h
dropsitewindow.cpp dropsitewindow.h
@@ -25,14 +19,21 @@ set_target_properties(dropsite PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(dropsite PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(dropsite PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS dropsite
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET dropsite
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/draganddrop/fridgemagnets/CMakeLists.txt b/examples/widgets/draganddrop/fridgemagnets/CMakeLists.txt
deleted file mode 100644
index 67dc549c4a..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/CMakeLists.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(fridgemagnets LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/draganddrop/fridgemagnets")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(fridgemagnets
- draglabel.cpp draglabel.h
- dragwidget.cpp dragwidget.h
- main.cpp
-)
-
-set_target_properties(fridgemagnets PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(fridgemagnets PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(fridgemagnets_resource_files
- "words.txt"
-)
-
-qt_add_resources(fridgemagnets "fridgemagnets"
- PREFIX
- "/dictionary"
- FILES
- ${fridgemagnets_resource_files}
-)
-
-install(TARGETS fridgemagnets
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/draganddrop/fridgemagnets/draglabel.cpp b/examples/widgets/draganddrop/fridgemagnets/draglabel.cpp
deleted file mode 100644
index 952faae8fe..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/draglabel.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "draglabel.h"
-
-#include <QtWidgets>
-
-//! [0]
-DragLabel::DragLabel(const QString &text, QWidget *parent)
- : QLabel(parent)
-{
- QFontMetrics metric(font());
- QSize size = metric.size(Qt::TextSingleLine, text);
-
- QImage image(size.width() + 12, size.height() + 12, QImage::Format_ARGB32_Premultiplied);
- image.fill(qRgba(0, 0, 0, 0));
-
- QFont font;
- font.setStyleStrategy(QFont::ForceOutline);
-//! [0]
-
-//! [1]
- QLinearGradient gradient(0, 0, 0, image.height()-1);
- gradient.setColorAt(0.0, Qt::white);
- gradient.setColorAt(0.2, QColor(200, 200, 255));
- gradient.setColorAt(0.8, QColor(200, 200, 255));
- gradient.setColorAt(1.0, QColor(127, 127, 200));
-
- QPainter painter;
- painter.begin(&image);
- painter.setRenderHint(QPainter::Antialiasing);
- painter.setBrush(gradient);
- painter.drawRoundedRect(QRectF(0.5, 0.5, image.width()-1, image.height()-1),
- 25, 25, Qt::RelativeSize);
-
- painter.setFont(font);
- painter.setBrush(Qt::black);
- painter.drawText(QRect(QPoint(6, 6), size), Qt::AlignCenter, text);
- painter.end();
-//! [1]
-
-//! [2]
- setPixmap(QPixmap::fromImage(image));
- m_labelText = text;
-}
-//! [2]
-
-QString DragLabel::labelText() const
-{
- return m_labelText;
-}
diff --git a/examples/widgets/draganddrop/fridgemagnets/draglabel.h b/examples/widgets/draganddrop/fridgemagnets/draglabel.h
deleted file mode 100644
index e734a9ff78..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/draglabel.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef DRAGLABEL_H
-#define DRAGLABEL_H
-
-#include <QLabel>
-
-QT_BEGIN_NAMESPACE
-class QDragEnterEvent;
-class QDragMoveEvent;
-class QFrame;
-QT_END_NAMESPACE
-
-//! [0]
-class DragLabel : public QLabel
-{
-public:
- DragLabel(const QString &text, QWidget *parent);
- QString labelText() const;
-
-private:
- QString m_labelText;
-};
-//! [0]
-
-#endif // DRAGLABEL_H
diff --git a/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp b/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp
deleted file mode 100644
index 619e0c1200..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "draglabel.h"
-#include "dragwidget.h"
-
-#include <QtWidgets>
-
-static inline QString fridgetMagnetsMimeType() { return QStringLiteral("application/x-fridgemagnet"); }
-
-//! [0]
-DragWidget::DragWidget(QWidget *parent)
- : QWidget(parent)
-{
- QFile dictionaryFile(QStringLiteral(":/dictionary/words.txt"));
- dictionaryFile.open(QFile::ReadOnly);
- QTextStream inputStream(&dictionaryFile);
-//! [0]
-
-//! [1]
- int x = 5;
- int y = 5;
-
- while (!inputStream.atEnd()) {
- QString word;
- inputStream >> word;
- if (!word.isEmpty()) {
- DragLabel *wordLabel = new DragLabel(word, this);
- wordLabel->move(x, y);
- wordLabel->show();
- wordLabel->setAttribute(Qt::WA_DeleteOnClose);
- x += wordLabel->width() + 2;
- if (x >= 245) {
- x = 5;
- y += wordLabel->height() + 2;
- }
- }
- }
-//! [1]
-
-//! [2]
- QPalette newPalette = palette();
- newPalette.setColor(QPalette::Window, Qt::white);
- setPalette(newPalette);
-
- setMinimumSize(400, qMax(200, y));
- setWindowTitle(tr("Fridge Magnets"));
-//! [2] //! [3]
- setAcceptDrops(true);
-}
-//! [3]
-
-//! [4]
-void DragWidget::dragEnterEvent(QDragEnterEvent *event)
-{
-//! [4] //! [5]
- if (event->mimeData()->hasFormat(fridgetMagnetsMimeType())) {
- if (children().contains(event->source())) {
- event->setDropAction(Qt::MoveAction);
- event->accept();
- } else {
- event->acceptProposedAction();
-//! [5] //! [6]
- }
-//! [6] //! [7]
- } else if (event->mimeData()->hasText()) {
- event->acceptProposedAction();
- } else {
- event->ignore();
- }
-}
-//! [7]
-
-//! [8]
-void DragWidget::dragMoveEvent(QDragMoveEvent *event)
-{
- if (event->mimeData()->hasFormat(fridgetMagnetsMimeType())) {
- if (children().contains(event->source())) {
- event->setDropAction(Qt::MoveAction);
- event->accept();
- } else {
- event->acceptProposedAction();
- }
- } else if (event->mimeData()->hasText()) {
- event->acceptProposedAction();
- } else {
- event->ignore();
- }
-}
-//! [8]
-
-//! [9]
-void DragWidget::dropEvent(QDropEvent *event)
-{
- if (event->mimeData()->hasFormat(fridgetMagnetsMimeType())) {
- const QMimeData *mime = event->mimeData();
-//! [9] //! [10]
- QByteArray itemData = mime->data(fridgetMagnetsMimeType());
- QDataStream dataStream(&itemData, QIODevice::ReadOnly);
-
- QString text;
- QPoint offset;
- dataStream >> text >> offset;
-//! [10]
-//! [11]
- DragLabel *newLabel = new DragLabel(text, this);
- newLabel->move(event->position().toPoint() - offset);
- newLabel->show();
- newLabel->setAttribute(Qt::WA_DeleteOnClose);
-
- if (event->source() == this) {
- event->setDropAction(Qt::MoveAction);
- event->accept();
- } else {
- event->acceptProposedAction();
- }
-//! [11] //! [12]
- } else if (event->mimeData()->hasText()) {
- QStringList pieces = event->mimeData()->text().split(
- QRegularExpression(QStringLiteral("\\s+")), Qt::SkipEmptyParts);
- QPoint position = event->position().toPoint();
-
- for (const QString &piece : pieces) {
- DragLabel *newLabel = new DragLabel(piece, this);
- newLabel->move(position);
- newLabel->show();
- newLabel->setAttribute(Qt::WA_DeleteOnClose);
-
- position += QPoint(newLabel->width(), 0);
- }
-
- event->acceptProposedAction();
- } else {
- event->ignore();
- }
-}
-//! [12]
-
-//! [13]
-void DragWidget::mousePressEvent(QMouseEvent *event)
-{
-//! [13]
-//! [14]
- DragLabel *child = static_cast<DragLabel*>(childAt(event->position().toPoint()));
- if (!child)
- return;
-
- QPoint hotSpot = event->position().toPoint() - child->pos();
-
- QByteArray itemData;
- QDataStream dataStream(&itemData, QIODevice::WriteOnly);
- dataStream << child->labelText() << QPoint(hotSpot);
-//! [14]
-
-//! [15]
- QMimeData *mimeData = new QMimeData;
- mimeData->setData(fridgetMagnetsMimeType(), itemData);
- mimeData->setText(child->labelText());
-//! [15]
-
-//! [16]
- QDrag *drag = new QDrag(this);
- drag->setMimeData(mimeData);
- drag->setPixmap(child->pixmap(Qt::ReturnByValue));
- drag->setHotSpot(hotSpot);
-
- child->hide();
-//! [16]
-
-//! [17]
- if (drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction) == Qt::MoveAction)
- child->close();
- else
- child->show();
-}
-//! [17]
diff --git a/examples/widgets/draganddrop/fridgemagnets/dragwidget.h b/examples/widgets/draganddrop/fridgemagnets/dragwidget.h
deleted file mode 100644
index 9614a3b76a..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/dragwidget.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef DRAGWIDGET_H
-#define DRAGWIDGET_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QDragEnterEvent;
-class QDropEvent;
-QT_END_NAMESPACE
-
-//! [0]
-class DragWidget : public QWidget
-{
-public:
- explicit DragWidget(QWidget *parent = nullptr);
-
-protected:
- void dragEnterEvent(QDragEnterEvent *event) override;
- void dragMoveEvent(QDragMoveEvent *event) override;
- void dropEvent(QDropEvent *event) override;
- void mousePressEvent(QMouseEvent *event) override;
-};
-//! [0]
-
-#endif // DRAGWIDGET_H
diff --git a/examples/widgets/draganddrop/fridgemagnets/fridgemagnets.pro b/examples/widgets/draganddrop/fridgemagnets/fridgemagnets.pro
deleted file mode 100644
index 2c3165d1c5..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/fridgemagnets.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-QT += widgets
-
-HEADERS = draglabel.h \
- dragwidget.h
-RESOURCES = fridgemagnets.qrc
-SOURCES = draglabel.cpp \
- dragwidget.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/draganddrop/fridgemagnets
-INSTALLS += target
diff --git a/examples/widgets/draganddrop/fridgemagnets/fridgemagnets.qrc b/examples/widgets/draganddrop/fridgemagnets/fridgemagnets.qrc
deleted file mode 100644
index b72217d701..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/fridgemagnets.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/dictionary">
- <file>words.txt</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/draganddrop/fridgemagnets/main.cpp b/examples/widgets/draganddrop/fridgemagnets/main.cpp
deleted file mode 100644
index d2b2e5dbed..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/main.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "dragwidget.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(fridgemagnets);
-
- QApplication app(argc, argv);
-#ifdef QT_KEYPAD_NAVIGATION
- QApplication::setNavigationMode(Qt::NavigationModeCursorAuto);
-#endif
- DragWidget window;
-
- bool smallScreen = QApplication::arguments().contains(QStringLiteral("-small-screen"));
- if (smallScreen)
- window.showFullScreen();
- else
- window.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/draganddrop/fridgemagnets/words.txt b/examples/widgets/draganddrop/fridgemagnets/words.txt
deleted file mode 100644
index a7e1632b09..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/words.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-Colorless
-green
-ideas
-sleep
-furiously
-A
-colorless
-green
-idea
-is
-a
-new
-untried
-idea
-that
-is
-without
-vividness
-dull
-and
-unexciting
-To
-sleep
-furiously
-may
-seem
-a
-puzzling
-turn
-of
-phrase
-but
-the
-mind
-in
-sleep
-often
-indeed
-moves
-furiously
-with
-ideas
-and
-images
-flickering
-in
-and
-out
diff --git a/examples/widgets/draganddrop/puzzle/CMakeLists.txt b/examples/widgets/draganddrop/puzzle/CMakeLists.txt
deleted file mode 100644
index a9231f3f9e..0000000000
--- a/examples/widgets/draganddrop/puzzle/CMakeLists.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(puzzle LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/draganddrop_puzzle")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(draganddrop_puzzle
- main.cpp
- mainwindow.cpp mainwindow.h
- pieceslist.cpp pieceslist.h
- puzzlewidget.cpp puzzlewidget.h
-)
-
-set_target_properties(draganddrop_puzzle PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(draganddrop_puzzle PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(puzzle_resource_files
- "example.jpg"
-)
-
-qt_add_resources(draganddrop_puzzle "puzzle"
- PREFIX
- "/images"
- FILES
- ${puzzle_resource_files}
-)
-
-install(TARGETS draganddrop_puzzle
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/draganddrop/puzzle/example.jpg b/examples/widgets/draganddrop/puzzle/example.jpg
deleted file mode 100644
index 023203c57a..0000000000
--- a/examples/widgets/draganddrop/puzzle/example.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/draganddrop/puzzle/main.cpp b/examples/widgets/draganddrop/puzzle/main.cpp
deleted file mode 100644
index 73fdd6513b..0000000000
--- a/examples/widgets/draganddrop/puzzle/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(puzzle);
-
- QApplication app(argc, argv);
- MainWindow window;
- window.loadImage(QStringLiteral(":/images/example.jpg"));
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/draganddrop/puzzle/mainwindow.cpp b/examples/widgets/draganddrop/puzzle/mainwindow.cpp
deleted file mode 100644
index b34bc24201..0000000000
--- a/examples/widgets/draganddrop/puzzle/mainwindow.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-#include "pieceslist.h"
-#include "puzzlewidget.h"
-
-#include <QtWidgets>
-#include <stdlib.h>
-
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
-{
- setupMenus();
- setupWidgets();
-
- setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
- setWindowTitle(tr("Puzzle"));
-}
-
-void MainWindow::openImage()
-{
- const QString directory =
- QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).value(0, QDir::homePath());
- QFileDialog dialog(this, tr("Open Image"), directory);
- dialog.setAcceptMode(QFileDialog::AcceptOpen);
- dialog.setFileMode(QFileDialog::ExistingFile);
- QStringList mimeTypeFilters;
- for (const QByteArray &mimeTypeName : QImageReader::supportedMimeTypes())
- mimeTypeFilters.append(mimeTypeName);
- mimeTypeFilters.sort();
- dialog.setMimeTypeFilters(mimeTypeFilters);
- dialog.selectMimeTypeFilter("image/jpeg");
- if (dialog.exec() == QDialog::Accepted)
- loadImage(dialog.selectedFiles().constFirst());
-}
-
-void MainWindow::loadImage(const QString &fileName)
-{
- QPixmap newImage;
- if (!newImage.load(fileName)) {
- QMessageBox::warning(this, tr("Open Image"),
- tr("The image file could not be loaded."),
- QMessageBox::Close);
- return;
- }
- puzzleImage = newImage;
- setupPuzzle();
-}
-
-void MainWindow::setCompleted()
-{
- QMessageBox::information(this, tr("Puzzle Completed"),
- tr("Congratulations! You have completed the puzzle!\n"
- "Click OK to start again."),
- QMessageBox::Ok);
-
- setupPuzzle();
-}
-
-void MainWindow::setupPuzzle()
-{
- int size = qMin(puzzleImage.width(), puzzleImage.height());
- puzzleImage = puzzleImage.copy((puzzleImage.width() - size) / 2,
- (puzzleImage.height() - size) / 2, size, size).scaled(puzzleWidget->width(),
- puzzleWidget->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
-
- piecesList->clear();
-
- for (int y = 0; y < 5; ++y) {
- for (int x = 0; x < 5; ++x) {
- int pieceSize = puzzleWidget->pieceSize();
- QPixmap pieceImage = puzzleImage.copy(x * pieceSize, y * pieceSize, pieceSize, pieceSize);
- piecesList->addPiece(pieceImage, QPoint(x, y));
- }
- }
-
- for (int i = 0; i < piecesList->count(); ++i) {
- if (QRandomGenerator::global()->bounded(2) == 1) {
- QListWidgetItem *item = piecesList->takeItem(i);
- piecesList->insertItem(0, item);
- }
- }
-
- puzzleWidget->clear();
-}
-
-void MainWindow::setupMenus()
-{
- QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
-
- QAction *openAction = fileMenu->addAction(tr("&Open..."), this, &MainWindow::openImage);
- openAction->setShortcuts(QKeySequence::Open);
-
- QAction *exitAction = fileMenu->addAction(tr("E&xit"), qApp, &QCoreApplication::quit);
- exitAction->setShortcuts(QKeySequence::Quit);
-
- QMenu *gameMenu = menuBar()->addMenu(tr("&Game"));
-
- gameMenu->addAction(tr("&Restart"), this, &MainWindow::setupPuzzle);
-}
-
-void MainWindow::setupWidgets()
-{
- QFrame *frame = new QFrame;
- QHBoxLayout *frameLayout = new QHBoxLayout(frame);
- puzzleWidget = new PuzzleWidget(400);
-
- piecesList = new PiecesList(puzzleWidget->pieceSize(), this);
-
-
- connect(puzzleWidget, &PuzzleWidget::puzzleCompleted,
- this, &MainWindow::setCompleted, Qt::QueuedConnection);
-
- frameLayout->addWidget(piecesList);
- frameLayout->addWidget(puzzleWidget);
- setCentralWidget(frame);
-}
diff --git a/examples/widgets/draganddrop/puzzle/mainwindow.h b/examples/widgets/draganddrop/puzzle/mainwindow.h
deleted file mode 100644
index 83a441c722..0000000000
--- a/examples/widgets/draganddrop/puzzle/mainwindow.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include <QPixmap>
-
-class PiecesList;
-class PuzzleWidget;
-QT_BEGIN_NAMESPACE
-class QListWidgetItem;
-QT_END_NAMESPACE
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- explicit MainWindow(QWidget *parent = nullptr);
- void loadImage(const QString &path);
-
-public slots:
- void openImage();
- void setupPuzzle();
-
-private slots:
- void setCompleted();
-
-private:
- void setupMenus();
- void setupWidgets();
-
- QPixmap puzzleImage;
- PiecesList *piecesList;
- PuzzleWidget *puzzleWidget;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/widgets/draganddrop/puzzle/pieceslist.cpp b/examples/widgets/draganddrop/puzzle/pieceslist.cpp
deleted file mode 100644
index 0c7e771e42..0000000000
--- a/examples/widgets/draganddrop/puzzle/pieceslist.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "pieceslist.h"
-
-#include <QDrag>
-#include <QDragEnterEvent>
-#include <QMimeData>
-
-PiecesList::PiecesList(int pieceSize, QWidget *parent)
- : QListWidget(parent), m_PieceSize(pieceSize)
-{
- setDragEnabled(true);
- setViewMode(QListView::IconMode);
- setIconSize(QSize(m_PieceSize, m_PieceSize));
- setSpacing(10);
- setAcceptDrops(true);
- setDropIndicatorShown(true);
-}
-
-void PiecesList::dragEnterEvent(QDragEnterEvent *event)
-{
- if (event->mimeData()->hasFormat(PiecesList::puzzleMimeType()))
- event->accept();
- else
- event->ignore();
-}
-
-void PiecesList::dragMoveEvent(QDragMoveEvent *event)
-{
- if (event->mimeData()->hasFormat(PiecesList::puzzleMimeType())) {
- event->setDropAction(Qt::MoveAction);
- event->accept();
- } else {
- event->ignore();
- }
-}
-
-void PiecesList::dropEvent(QDropEvent *event)
-{
- if (event->mimeData()->hasFormat(PiecesList::puzzleMimeType())) {
- QByteArray pieceData = event->mimeData()->data(PiecesList::puzzleMimeType());
- QDataStream dataStream(&pieceData, QIODevice::ReadOnly);
- QPixmap pixmap;
- QPoint location;
- dataStream >> pixmap >> location;
-
- addPiece(pixmap, location);
-
- event->setDropAction(Qt::MoveAction);
- event->accept();
- } else {
- event->ignore();
- }
-}
-
-void PiecesList::addPiece(const QPixmap &pixmap, const QPoint &location)
-{
- QListWidgetItem *pieceItem = new QListWidgetItem(this);
- pieceItem->setIcon(QIcon(pixmap));
- pieceItem->setData(Qt::UserRole, QVariant(pixmap));
- pieceItem->setData(Qt::UserRole+1, location);
- pieceItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled);
-}
-
-void PiecesList::startDrag(Qt::DropActions /*supportedActions*/)
-{
- QListWidgetItem *item = currentItem();
-
- QByteArray itemData;
- QDataStream dataStream(&itemData, QIODevice::WriteOnly);
- QPixmap pixmap = qvariant_cast<QPixmap>(item->data(Qt::UserRole));
- QPoint location = item->data(Qt::UserRole+1).toPoint();
-
- dataStream << pixmap << location;
-
- QMimeData *mimeData = new QMimeData;
- mimeData->setData(PiecesList::puzzleMimeType(), itemData);
-
- QDrag *drag = new QDrag(this);
- drag->setMimeData(mimeData);
- drag->setHotSpot(QPoint(pixmap.width()/2, pixmap.height()/2));
- drag->setPixmap(pixmap);
-
- if (drag->exec(Qt::MoveAction) == Qt::MoveAction)
- delete takeItem(row(item));
-}
diff --git a/examples/widgets/draganddrop/puzzle/pieceslist.h b/examples/widgets/draganddrop/puzzle/pieceslist.h
deleted file mode 100644
index 4c617e7006..0000000000
--- a/examples/widgets/draganddrop/puzzle/pieceslist.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef PIECESLIST_H
-#define PIECESLIST_H
-
-#include <QListWidget>
-
-class PiecesList : public QListWidget
-{
- Q_OBJECT
-
-public:
- explicit PiecesList(int pieceSize, QWidget *parent = nullptr);
- void addPiece(const QPixmap &pixmap, const QPoint &location);
-
- static QString puzzleMimeType() { return QStringLiteral("image/x-puzzle-piece"); }
-
-protected:
- void dragEnterEvent(QDragEnterEvent *event) override;
- void dragMoveEvent(QDragMoveEvent *event) override;
- void dropEvent(QDropEvent *event) override;
- void startDrag(Qt::DropActions supportedActions) override;
-
- int m_PieceSize;
-};
-
-#endif // PIECESLIST_H
diff --git a/examples/widgets/draganddrop/puzzle/puzzle.pro b/examples/widgets/draganddrop/puzzle/puzzle.pro
deleted file mode 100644
index c462ba1bb8..0000000000
--- a/examples/widgets/draganddrop/puzzle/puzzle.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-QT += widgets
-requires(qtConfig(filedialog))
-
-HEADERS = mainwindow.h \
- pieceslist.h \
- puzzlewidget.h
-RESOURCES = puzzle.qrc
-SOURCES = main.cpp \
- mainwindow.cpp \
- pieceslist.cpp \
- puzzlewidget.cpp
-
-QMAKE_PROJECT_NAME = dndpuzzle
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/draganddrop/puzzle
-INSTALLS += target
diff --git a/examples/widgets/draganddrop/puzzle/puzzle.qrc b/examples/widgets/draganddrop/puzzle/puzzle.qrc
deleted file mode 100644
index 4076cec026..0000000000
--- a/examples/widgets/draganddrop/puzzle/puzzle.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/images">
- <file>example.jpg</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/draganddrop/puzzle/puzzlewidget.cpp b/examples/widgets/draganddrop/puzzle/puzzlewidget.cpp
deleted file mode 100644
index 7c3f12f7d8..0000000000
--- a/examples/widgets/draganddrop/puzzle/puzzlewidget.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "puzzlewidget.h"
-#include "pieceslist.h"
-
-#include <QDrag>
-#include <QDragEnterEvent>
-#include <QMimeData>
-#include <QPainter>
-
-PuzzleWidget::PuzzleWidget(int imageSize, QWidget *parent)
- : QWidget(parent), m_ImageSize(imageSize)
-{
- setAcceptDrops(true);
- setMinimumSize(m_ImageSize, m_ImageSize);
- setMaximumSize(m_ImageSize, m_ImageSize);
-}
-
-void PuzzleWidget::clear()
-{
- pieces.clear();
- highlightedRect = QRect();
- inPlace = 0;
- update();
-}
-
-void PuzzleWidget::dragEnterEvent(QDragEnterEvent *event)
-{
- if (event->mimeData()->hasFormat(PiecesList::puzzleMimeType()))
- event->accept();
- else
- event->ignore();
-}
-
-void PuzzleWidget::dragLeaveEvent(QDragLeaveEvent *event)
-{
- QRect updateRect = highlightedRect;
- highlightedRect = QRect();
- update(updateRect);
- event->accept();
-}
-
-void PuzzleWidget::dragMoveEvent(QDragMoveEvent *event)
-{
- QRect updateRect = highlightedRect.united(targetSquare(event->position().toPoint()));
-
- if (event->mimeData()->hasFormat(PiecesList::puzzleMimeType())
- && findPiece(targetSquare(event->position().toPoint())) == -1) {
-
- highlightedRect = targetSquare(event->position().toPoint());
- event->setDropAction(Qt::MoveAction);
- event->accept();
- } else {
- highlightedRect = QRect();
- event->ignore();
- }
-
- update(updateRect);
-}
-
-void PuzzleWidget::dropEvent(QDropEvent *event)
-{
- if (event->mimeData()->hasFormat(PiecesList::puzzleMimeType())
- && findPiece(targetSquare(event->position().toPoint())) == -1) {
-
- QByteArray pieceData = event->mimeData()->data(PiecesList::puzzleMimeType());
- QDataStream dataStream(&pieceData, QIODevice::ReadOnly);
- Piece piece;
- piece.rect = targetSquare(event->position().toPoint());
- dataStream >> piece.pixmap >> piece.location;
-
- pieces.append(piece);
-
- highlightedRect = QRect();
- update(piece.rect);
-
- event->setDropAction(Qt::MoveAction);
- event->accept();
-
- if (piece.location == piece.rect.topLeft() / pieceSize()) {
- inPlace++;
- if (inPlace == 25)
- emit puzzleCompleted();
- }
- } else {
- highlightedRect = QRect();
- event->ignore();
- }
-}
-
-int PuzzleWidget::findPiece(const QRect &pieceRect) const
-{
- for (int i = 0, size = pieces.size(); i < size; ++i) {
- if (pieces.at(i).rect == pieceRect)
- return i;
- }
- return -1;
-}
-
-void PuzzleWidget::mousePressEvent(QMouseEvent *event)
-{
- QRect square = targetSquare(event->position().toPoint());
- const int found = findPiece(square);
-
- if (found == -1)
- return;
-
- Piece piece = pieces.takeAt(found);
-
- if (piece.location == square.topLeft() / pieceSize())
- inPlace--;
-
- update(square);
-
- QByteArray itemData;
- QDataStream dataStream(&itemData, QIODevice::WriteOnly);
-
- dataStream << piece.pixmap << piece.location;
-
- QMimeData *mimeData = new QMimeData;
- mimeData->setData(PiecesList::puzzleMimeType(), itemData);
-
- QDrag *drag = new QDrag(this);
- drag->setMimeData(mimeData);
- drag->setHotSpot(event->position().toPoint() - square.topLeft());
- drag->setPixmap(piece.pixmap);
-
- if (drag->exec(Qt::MoveAction) != Qt::MoveAction) {
- pieces.insert(found, piece);
- update(targetSquare(event->position().toPoint()));
-
- if (piece.location == square.topLeft() / pieceSize())
- inPlace++;
- }
-}
-
-void PuzzleWidget::paintEvent(QPaintEvent *event)
-{
- QPainter painter(this);
- painter.fillRect(event->rect(), Qt::white);
-
- if (highlightedRect.isValid()) {
- painter.setBrush(QColor("#ffcccc"));
- painter.setPen(Qt::NoPen);
- painter.drawRect(highlightedRect.adjusted(0, 0, -1, -1));
- }
-
- for (const Piece &piece : pieces)
- painter.drawPixmap(piece.rect, piece.pixmap);
-}
-
-const QRect PuzzleWidget::targetSquare(const QPoint &position) const
-{
- QPoint topLeft = QPoint(position.x() / pieceSize(), position.y() / pieceSize()) * pieceSize();
- return QRect(topLeft, QSize(pieceSize(), pieceSize()));
-}
-
-int PuzzleWidget::pieceSize() const
-{
- return m_ImageSize / 5;
-}
-
-int PuzzleWidget::imageSize() const
-{
- return m_ImageSize;
-}
diff --git a/examples/widgets/draganddrop/puzzle/puzzlewidget.h b/examples/widgets/draganddrop/puzzle/puzzlewidget.h
deleted file mode 100644
index d1c00872ec..0000000000
--- a/examples/widgets/draganddrop/puzzle/puzzlewidget.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef PUZZLEWIDGET_H
-#define PUZZLEWIDGET_H
-
-#include <QPoint>
-#include <QPixmap>
-#include <QList>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QDragEnterEvent;
-class QDropEvent;
-class QMouseEvent;
-QT_END_NAMESPACE
-
-class PuzzleWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit PuzzleWidget(int imageSize, QWidget *parent = nullptr);
- void clear();
-
- int pieceSize() const;
- int imageSize() const;
-
-signals:
- void puzzleCompleted();
-
-protected:
- void dragEnterEvent(QDragEnterEvent *event) override;
- void dragLeaveEvent(QDragLeaveEvent *event) override;
- void dragMoveEvent(QDragMoveEvent *event) override;
- void dropEvent(QDropEvent *event) override;
- void mousePressEvent(QMouseEvent *event) override;
- void paintEvent(QPaintEvent *event) override;
-
-private:
- struct Piece {
- QPixmap pixmap;
- QRect rect;
- QPoint location;
- };
-
- int findPiece(const QRect &pieceRect) const;
- const QRect targetSquare(const QPoint &position) const;
-
- QList<Piece> pieces;
- QRect highlightedRect;
- int inPlace;
- int m_ImageSize;
-};
-
-#endif // PUZZLEWIDGET_H
diff --git a/examples/widgets/effects/CMakeLists.txt b/examples/widgets/effects/CMakeLists.txt
deleted file mode 100644
index 8b1471d1c2..0000000000
--- a/examples/widgets/effects/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-qt_internal_add_example(blurpicker)
-qt_internal_add_example(fademessage)
diff --git a/examples/widgets/effects/blurpicker/CMakeLists.txt b/examples/widgets/effects/blurpicker/CMakeLists.txt
deleted file mode 100644
index 4e4d404d2d..0000000000
--- a/examples/widgets/effects/blurpicker/CMakeLists.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(blurpicker LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/effects/blurpicker")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(blurpicker
- blureffect.cpp blureffect.h
- blurpicker.cpp blurpicker.h
- main.cpp
-)
-
-set_target_properties(blurpicker PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(blurpicker PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(blurpicker_resource_files
- "images/accessories-calculator.png"
- "images/accessories-text-editor.png"
- "images/background.jpg"
- "images/help-browser.png"
- "images/internet-group-chat.png"
- "images/internet-mail.png"
- "images/internet-web-browser.png"
- "images/office-calendar.png"
- "images/system-users.png"
-)
-
-qt_add_resources(blurpicker "blurpicker"
- PREFIX
- "/"
- FILES
- ${blurpicker_resource_files}
-)
-
-install(TARGETS blurpicker
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/effects/blurpicker/blureffect.cpp b/examples/widgets/effects/blurpicker/blureffect.cpp
deleted file mode 100644
index 2e2b8c8d6b..0000000000
--- a/examples/widgets/effects/blurpicker/blureffect.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "blureffect.h"
-
-#include <QDebug>
-
-BlurEffect::BlurEffect(QGraphicsItem *item)
- : QGraphicsBlurEffect()
- , m_baseLine(200), item(item)
-{
-}
-
-void BlurEffect::adjustForItem()
-{
- qreal y = m_baseLine - item->pos().y();
- qreal radius = qBound(qreal(0.0), y / 32, qreal(16.0));
- setBlurRadius(radius);
-}
-
-QRectF BlurEffect::boundingRect() const
-{
- const_cast<BlurEffect *>(this)->adjustForItem();
- return QGraphicsBlurEffect::boundingRect();
-}
-
-void BlurEffect::draw(QPainter *painter)
-{
- adjustForItem();
- QGraphicsBlurEffect::draw(painter);
-}
diff --git a/examples/widgets/effects/blurpicker/blureffect.h b/examples/widgets/effects/blurpicker/blureffect.h
deleted file mode 100644
index a39261fc5a..0000000000
--- a/examples/widgets/effects/blurpicker/blureffect.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef BLUREFFECT_H
-#define BLUREFFECT_H
-
-#include <QGraphicsEffect>
-#include <QGraphicsItem>
-
-class BlurEffect: public QGraphicsBlurEffect
-{
-public:
- BlurEffect(QGraphicsItem *item);
-
- void setBaseLine(qreal y) { m_baseLine = y; }
-
- QRectF boundingRect() const;
-
- void draw(QPainter *painter) override;
-
-private:
- void adjustForItem();
-
-private:
- qreal m_baseLine;
- QGraphicsItem *item;
-};
-
-#endif // BLUREFFECT_H
diff --git a/examples/widgets/effects/blurpicker/blurpicker.cpp b/examples/widgets/effects/blurpicker/blurpicker.cpp
deleted file mode 100644
index 00269c8fe3..0000000000
--- a/examples/widgets/effects/blurpicker/blurpicker.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "blurpicker.h"
-
-#include <QtWidgets>
-#include <QtCore/qmath.h>
-#include <qmath.h>
-#include "blureffect.h"
-
-BlurPicker::BlurPicker(QWidget *parent): QGraphicsView(parent), m_index(0.0), m_animation(this, "index")
-{
- setBackgroundBrush(QPixmap(":/images/background.jpg"));
- setScene(new QGraphicsScene(this));
-
- setupScene();
- setIndex(0);
-
- m_animation.setDuration(400);
- m_animation.setEasingCurve(QEasingCurve::InOutSine);
-
- setRenderHint(QPainter::Antialiasing, true);
- setFrameStyle(QFrame::NoFrame);
-}
-
-qreal BlurPicker::index() const
-{
- return m_index;
-}
-
-void BlurPicker::setIndex(qreal index)
-{
- m_index = index;
-
- qreal baseline = 0;
- const qreal iconAngle = 2 * M_PI / m_icons.count();
- for (int i = 0; i < m_icons.count(); ++i) {
- QGraphicsItem *icon = m_icons[i];
- qreal a = (i + m_index) * iconAngle;
- qreal xs = 170 * qSin(a);
- qreal ys = 100 * qCos(a);
- QPointF pos(xs, ys);
- pos = QTransform().rotate(-20).map(pos);
- pos -= QPointF(40, 40);
- icon->setPos(pos);
- baseline = qMax(baseline, ys);
- static_cast<BlurEffect *>(icon->graphicsEffect())->setBaseLine(baseline);
- }
-
- scene()->update();
-}
-
-void BlurPicker::setupScene()
-{
- scene()->setSceneRect(-200, -120, 400, 240);
-
- QStringList names;
- names << ":/images/accessories-calculator.png";
- names << ":/images/accessories-text-editor.png";
- names << ":/images/help-browser.png";
- names << ":/images/internet-group-chat.png";
- names << ":/images/internet-mail.png";
- names << ":/images/internet-web-browser.png";
- names << ":/images/office-calendar.png";
- names << ":/images/system-users.png";
-
- for (int i = 0; i < names.count(); i++) {
- QPixmap pixmap(names[i]);
- QGraphicsPixmapItem *icon = scene()->addPixmap(pixmap);
- icon->setZValue(1);
- icon->setGraphicsEffect(new BlurEffect(icon));
- m_icons << icon;
- }
-
- QGraphicsPixmapItem *bg = scene()->addPixmap(QPixmap(":/images/background.jpg"));
- bg->setZValue(0);
- bg->setPos(-200, -150);
-}
-
-void BlurPicker::keyPressEvent(QKeyEvent *event)
-{
- int delta = 0;
- switch (event->key())
- {
- case Qt::Key_Left:
- delta = -1;
- break;
- case Qt::Key_Right:
- delta = 1;
- break;
- default:
- break;
- }
- if (m_animation.state() == QAbstractAnimation::Stopped && delta) {
- m_animation.setEndValue(m_index + delta);
- m_animation.start();
- event->accept();
- }
-}
-
-void BlurPicker::resizeEvent(QResizeEvent * /* event */)
-{
-}
-
-void BlurPicker::mousePressEvent(QMouseEvent *event)
-{
- int delta = 0;
- if (event->position().x() > (width() / 2))
- {
- delta = 1;
- }
- else
- {
- delta = -1;
- }
-
- if (m_animation.state() == QAbstractAnimation::Stopped && delta) {
- m_animation.setEndValue(m_index + delta);
- m_animation.start();
- event->accept();
- }
-}
diff --git a/examples/widgets/effects/blurpicker/blurpicker.h b/examples/widgets/effects/blurpicker/blurpicker.h
deleted file mode 100644
index 6e4ac84e56..0000000000
--- a/examples/widgets/effects/blurpicker/blurpicker.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef BLURPICKER_H
-#define BLURPICKER_H
-
-#include <QGraphicsEffect>
-#include <QGraphicsView>
-#include <QPropertyAnimation>
-
-#include "blureffect.h"
-
-class BlurPicker: public QGraphicsView
-{
- Q_OBJECT
- Q_PROPERTY(qreal index READ index WRITE setIndex)
-
-public:
- BlurPicker(QWidget *parent = nullptr);
-
- qreal index() const;
- void setIndex(qreal);
-
-protected:
- void keyPressEvent(QKeyEvent *event) override;
- void resizeEvent(QResizeEvent *event) override;
- void mousePressEvent(QMouseEvent *event) override;
-
-private:
- void setupScene();
-
-private:
- qreal m_index;
- QList<QGraphicsItem*> m_icons;
- QPropertyAnimation m_animation;
-};
-
-#endif // BLURPICKER_H
diff --git a/examples/widgets/effects/blurpicker/blurpicker.pro b/examples/widgets/effects/blurpicker/blurpicker.pro
deleted file mode 100644
index c570ac3b98..0000000000
--- a/examples/widgets/effects/blurpicker/blurpicker.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QT += widgets
-
-SOURCES += main.cpp blurpicker.cpp blureffect.cpp
-HEADERS += blurpicker.h blureffect.h
-RESOURCES += blurpicker.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/effects/blurpicker
-INSTALLS += target
diff --git a/examples/widgets/effects/blurpicker/blurpicker.qrc b/examples/widgets/effects/blurpicker/blurpicker.qrc
deleted file mode 100644
index e88eaca966..0000000000
--- a/examples/widgets/effects/blurpicker/blurpicker.qrc
+++ /dev/null
@@ -1,14 +0,0 @@
-<RCC>
- <qresource prefix="/" >
- <file>images/background.jpg</file>
- <file>images/accessories-calculator.png</file>
- <file>images/accessories-text-editor.png</file>
- <file>images/help-browser.png</file>
- <file>images/internet-group-chat.png</file>
- <file>images/internet-mail.png</file>
- <file>images/internet-web-browser.png</file>
- <file>images/office-calendar.png</file>
- <file>images/system-users.png</file>
- </qresource>
-</RCC>
-
diff --git a/examples/widgets/effects/blurpicker/images/README.txt b/examples/widgets/effects/blurpicker/images/README.txt
deleted file mode 100644
index 0927e177d2..0000000000
--- a/examples/widgets/effects/blurpicker/images/README.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-The background is taken from a public domain photo at:
-http://www.photos8.com/view/computer_board2-800x600.html
-
-All other icons are from the Tango Desktop project:
-http://tango.freedesktop.org/Tango_Desktop_Project
diff --git a/examples/widgets/effects/blurpicker/images/accessories-calculator.png b/examples/widgets/effects/blurpicker/images/accessories-calculator.png
deleted file mode 100644
index 4e7661f65c..0000000000
--- a/examples/widgets/effects/blurpicker/images/accessories-calculator.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/effects/blurpicker/images/accessories-text-editor.png b/examples/widgets/effects/blurpicker/images/accessories-text-editor.png
deleted file mode 100644
index 33bef0bc17..0000000000
--- a/examples/widgets/effects/blurpicker/images/accessories-text-editor.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/effects/blurpicker/images/background.jpg b/examples/widgets/effects/blurpicker/images/background.jpg
deleted file mode 100644
index e75b38899d..0000000000
--- a/examples/widgets/effects/blurpicker/images/background.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/effects/blurpicker/images/help-browser.png b/examples/widgets/effects/blurpicker/images/help-browser.png
deleted file mode 100644
index 8ef4fae91b..0000000000
--- a/examples/widgets/effects/blurpicker/images/help-browser.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/effects/blurpicker/images/internet-group-chat.png b/examples/widgets/effects/blurpicker/images/internet-group-chat.png
deleted file mode 100644
index dd92d93947..0000000000
--- a/examples/widgets/effects/blurpicker/images/internet-group-chat.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/effects/blurpicker/images/internet-mail.png b/examples/widgets/effects/blurpicker/images/internet-mail.png
deleted file mode 100644
index 7e6b93be83..0000000000
--- a/examples/widgets/effects/blurpicker/images/internet-mail.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/effects/blurpicker/images/internet-web-browser.png b/examples/widgets/effects/blurpicker/images/internet-web-browser.png
deleted file mode 100644
index a979a92b4f..0000000000
--- a/examples/widgets/effects/blurpicker/images/internet-web-browser.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/effects/blurpicker/images/office-calendar.png b/examples/widgets/effects/blurpicker/images/office-calendar.png
deleted file mode 100644
index e09590682b..0000000000
--- a/examples/widgets/effects/blurpicker/images/office-calendar.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/effects/blurpicker/images/system-users.png b/examples/widgets/effects/blurpicker/images/system-users.png
deleted file mode 100644
index a7f630a5bd..0000000000
--- a/examples/widgets/effects/blurpicker/images/system-users.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/effects/blurpicker/main.cpp b/examples/widgets/effects/blurpicker/main.cpp
deleted file mode 100644
index 4d5bf158c9..0000000000
--- a/examples/widgets/effects/blurpicker/main.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "blurpicker.h"
-#include <QApplication>
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- BlurPicker blurPicker;
- blurPicker.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Application Picker"));
-
- blurPicker.setFixedSize(400, 300);
- blurPicker.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/effects/effects.pro b/examples/widgets/effects/effects.pro
deleted file mode 100644
index 05911979b9..0000000000
--- a/examples/widgets/effects/effects.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-TEMPLATE = \
- subdirs
-SUBDIRS = \
- blurpicker \
- fademessage
diff --git a/examples/widgets/effects/fademessage/CMakeLists.txt b/examples/widgets/effects/fademessage/CMakeLists.txt
deleted file mode 100644
index a5360dd197..0000000000
--- a/examples/widgets/effects/fademessage/CMakeLists.txt
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(fademessage LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/effects/fademessage")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(fademessage
- fademessage.cpp fademessage.h
- main.cpp
-)
-
-set_target_properties(fademessage PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(fademessage PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(fademessage_resource_files
- "background.jpg"
-)
-
-qt_add_resources(fademessage "fademessage"
- PREFIX
- "/"
- FILES
- ${fademessage_resource_files}
-)
-
-install(TARGETS fademessage
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/effects/fademessage/README b/examples/widgets/effects/fademessage/README
deleted file mode 100644
index f639e76508..0000000000
--- a/examples/widgets/effects/fademessage/README
+++ /dev/null
@@ -1,2 +0,0 @@
-The background is taken from a public domain photo at:
-http://www.photos8.com/view/windows_problem_blue-800x600.html
diff --git a/examples/widgets/effects/fademessage/background.jpg b/examples/widgets/effects/fademessage/background.jpg
deleted file mode 100644
index 9884233a29..0000000000
--- a/examples/widgets/effects/fademessage/background.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/effects/fademessage/fademessage.cpp b/examples/widgets/effects/fademessage/fademessage.cpp
deleted file mode 100644
index 3d8385020b..0000000000
--- a/examples/widgets/effects/fademessage/fademessage.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "fademessage.h"
-
-#include <QtWidgets>
-
-FadeMessage::FadeMessage(QWidget *parent): QGraphicsView(parent)
-{
- setScene(&m_scene);
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
- setupScene();
-
- m_animation = new QPropertyAnimation(m_effect, "strength", this);
- m_animation->setDuration(500);
- m_animation->setEasingCurve(QEasingCurve::InOutSine);
- m_animation->setStartValue(0);
- m_animation->setEndValue(1);
-
- setRenderHint(QPainter::Antialiasing, true);
- setFrameStyle(QFrame::NoFrame);
-}
-
-void FadeMessage::togglePopup()
-{
- if (m_message->isVisible()) {
- m_message->setVisible(false);
- m_animation->setDirection(QAbstractAnimation::Backward);
- } else {
- m_message->setVisible(true);
- m_animation->setDirection(QAbstractAnimation::Forward);
- }
- m_animation->start();
-}
-
-void FadeMessage::setupScene()
-{
- QGraphicsRectItem *parent = m_scene.addRect(0, 0, 800, 600);
- parent->setPen(Qt::NoPen);
- parent->setZValue(0);
-
- QGraphicsPixmapItem *bg = m_scene.addPixmap(QPixmap(":/background.jpg"));
- bg->setParentItem(parent);
- bg->setZValue(-1);
-
- for (int i = 1; i < 5; ++i)
- for (int j = 2; j < 5; ++j) {
- QGraphicsRectItem *item = m_scene.addRect(i * 50, (j - 1) * 50, 38, 38);
- item->setParentItem(parent);
- item->setZValue(1);
- int hue = 12 * (i * 5 + j);
- item->setBrush(QColor::fromHsv(hue, 128, 128));
- }
-
- QFont font;
- font.setPointSize(font.pointSize() * 2);
- font.setBold(true);
- QFontMetrics fontMetrics(font);
- int fh = fontMetrics.height();
-
- QString sceneText = "Qt Everywhere!";
- int sceneTextWidth = fontMetrics.horizontalAdvance(sceneText);
-
- QGraphicsRectItem *block = m_scene.addRect(50, 300, sceneTextWidth, fh + 3);
- block->setPen(Qt::NoPen);
- block->setBrush(QColor(102, 153, 51));
-
- QGraphicsTextItem *text = m_scene.addText(sceneText, font);
- text->setDefaultTextColor(Qt::white);
- text->setPos(50, 300);
- block->setZValue(2);
- block->hide();
-
- text->setParentItem(block);
- m_message = block;
-
- m_effect = new QGraphicsColorizeEffect;
- m_effect->setColor(QColor(122, 193, 66));
- m_effect->setStrength(0);
- m_effect->setEnabled(true);
- parent->setGraphicsEffect(m_effect);
-
- QPushButton *press = new QPushButton;
- press->setText(tr("Press me"));
- connect(press, &QAbstractButton::clicked, this, &FadeMessage::togglePopup);
- m_scene.addWidget(press);
-
- press->move(300, 500);
-}
diff --git a/examples/widgets/effects/fademessage/fademessage.h b/examples/widgets/effects/fademessage/fademessage.h
deleted file mode 100644
index 49923016cd..0000000000
--- a/examples/widgets/effects/fademessage/fademessage.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef FADEMESSAGE_H
-#define FADEMESSAGE_H
-
-#include <QGraphicsEffect>
-#include <QGraphicsView>
-#include <QPropertyAnimation>
-
-#include "fademessage.h"
-
-class FadeMessage: public QGraphicsView
-{
- Q_OBJECT
-
-public:
- FadeMessage(QWidget *parent = nullptr);
-
-private:
- void setupScene();
-
-private slots:
- void togglePopup();
-
-private:
- QGraphicsScene m_scene;
- QGraphicsColorizeEffect *m_effect;
- QGraphicsItem *m_message;
- QPropertyAnimation *m_animation;
-};
-
-#endif // FADEMESSAGE_H
diff --git a/examples/widgets/effects/fademessage/fademessage.pro b/examples/widgets/effects/fademessage/fademessage.pro
deleted file mode 100644
index 0beff1999a..0000000000
--- a/examples/widgets/effects/fademessage/fademessage.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QT += widgets
-
-SOURCES += main.cpp fademessage.cpp
-HEADERS += fademessage.h
-RESOURCES += fademessage.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/effects/fademessage
-INSTALLS += target
diff --git a/examples/widgets/effects/fademessage/fademessage.qrc b/examples/widgets/effects/fademessage/fademessage.qrc
deleted file mode 100644
index 9efea6a67d..0000000000
--- a/examples/widgets/effects/fademessage/fademessage.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/" >
- <file>background.jpg</file>
- </qresource>
-</RCC>
diff --git a/examples/widgets/effects/fademessage/main.cpp b/examples/widgets/effects/fademessage/main.cpp
deleted file mode 100644
index 66504bc432..0000000000
--- a/examples/widgets/effects/fademessage/main.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "fademessage.h"
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- FadeMessage widget;
- widget.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Popup Message with Effect"));
- widget.setFixedSize(400, 600);
- widget.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/gallery/CMakeLists.txt b/examples/widgets/gallery/CMakeLists.txt
index 60a9dca662..e0c87afb0b 100644
--- a/examples/widgets/gallery/CMakeLists.txt
+++ b/examples/widgets/gallery/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(gallery LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/gallery")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(gallery
main.cpp
widgetgallery.cpp widgetgallery.h
@@ -24,14 +18,21 @@ set_target_properties(gallery PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(gallery PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(gallery PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS gallery
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET gallery
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/gestures/CMakeLists.txt b/examples/widgets/gestures/CMakeLists.txt
index 9c58d0a3a2..0110ca90a6 100644
--- a/examples/widgets/gestures/CMakeLists.txt
+++ b/examples/widgets/gestures/CMakeLists.txt
@@ -1,7 +1,7 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-if(NOT TARGET Qt::Widgets)
+if(NOT TARGET Qt6::Widgets)
return()
endif()
qt_internal_add_example(imagegestures)
diff --git a/examples/widgets/gestures/imagegestures/CMakeLists.txt b/examples/widgets/gestures/imagegestures/CMakeLists.txt
index c67355e1f1..1e173dc63f 100644
--- a/examples/widgets/gestures/imagegestures/CMakeLists.txt
+++ b/examples/widgets/gestures/imagegestures/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(imagegestures LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/gestures/imagegestures")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(imagegestures
imagewidget.cpp imagewidget.h
main.cpp
@@ -25,14 +19,21 @@ set_target_properties(imagegestures PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(imagegestures PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(imagegestures PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS imagegestures
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET imagegestures
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/gestures/imagegestures/doc/src/imagegestures.qdoc b/examples/widgets/gestures/imagegestures/doc/src/imagegestures.qdoc
index 7722da680a..46053566ab 100644
--- a/examples/widgets/gestures/imagegestures/doc/src/imagegestures.qdoc
+++ b/examples/widgets/gestures/imagegestures/doc/src/imagegestures.qdoc
@@ -4,12 +4,13 @@
/*!
\example gestures/imagegestures
\title Image Gestures Example
+ \examplecategory {User Interface Components}
\brief Demonstrates the use of simple gestures in a widget.
This example shows how to enable gestures for a widget and use gesture input
to perform actions.
- \image imagegestures-example.jpg
+ \image imagegestures-example.png
We use two classes to create the user interface for the application: \c MainWidget
and \c ImageWidget. The \c MainWidget class is simply used as a container for the
diff --git a/examples/widgets/gestures/imagegestures/imagewidget.cpp b/examples/widgets/gestures/imagegestures/imagewidget.cpp
index e17bf3c0c0..189281cc11 100644
--- a/examples/widgets/gestures/imagegestures/imagewidget.cpp
+++ b/examples/widgets/gestures/imagegestures/imagewidget.cpp
@@ -41,6 +41,12 @@ void ImageWidget::paintEvent(QPaintEvent*)
{
QPainter p(this);
+ if (files.isEmpty() && !path.isEmpty()) {
+ p.drawText(rect(), Qt::AlignCenter|Qt::TextWordWrap,
+ tr("No supported image formats found"));
+ return;
+ }
+
const qreal iw = currentImage.width();
const qreal ih = currentImage.height();
const qreal wh = height();
@@ -144,20 +150,32 @@ void ImageWidget::resizeEvent(QResizeEvent*)
update();
}
-void ImageWidget::openDirectory(const QString &path)
+void ImageWidget::openDirectory(const QString &url)
{
- this->path = path;
+ path = url;
QDir dir(path);
- const QStringList nameFilters{"*.jpg", "*.png"};
- files = dir.entryList(nameFilters, QDir::Files|QDir::Readable, QDir::Name);
+
+ QStringList nameFilters;
+ const QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
+ for (const QByteArray &format : supportedFormats)
+ nameFilters.append(QLatin1String("*.") + QString::fromLatin1(format));
+ files = dir.entryInfoList(nameFilters, QDir::Files|QDir::Readable, QDir::Name);
position = 0;
goToImage(0);
update();
}
-QImage ImageWidget::loadImage(const QString &fileName) const
+/*
+ With Android's content scheme paths, it might not be possible to simply
+ append a file name to the chosen directory path to be able to open the image,
+ because usually paths are returned by an Android file provider and handling those
+ paths manually is not guaranteed to work. For that reason, it's better to keep
+ around QFileInfo objects and use absoluteFilePath().
+*/
+QImage ImageWidget::loadImage(const QFileInfo &fileInfo) const
{
+ const QString fileName = fileInfo.absoluteFilePath();
QImageReader reader(fileName);
reader.setAutoTransform(true);
qCDebug(lcExample) << "loading" << QDir::toNativeSeparators(fileName) << position << '/' << files.size();
@@ -187,7 +205,7 @@ void ImageWidget::goNextImage()
prevImage = currentImage;
currentImage = nextImage;
if (position+1 < files.size())
- nextImage = loadImage(path + QLatin1Char('/') + files.at(position+1));
+ nextImage = loadImage(files.at(position + 1));
else
nextImage = QImage();
}
@@ -204,7 +222,7 @@ void ImageWidget::goPrevImage()
nextImage = currentImage;
currentImage = prevImage;
if (position > 0)
- prevImage = loadImage(path + QLatin1Char('/') + files.at(position-1));
+ prevImage = loadImage(files.at(position - 1));
else
prevImage = QImage();
}
@@ -234,12 +252,12 @@ void ImageWidget::goToImage(int index)
position = index;
if (index > 0)
- prevImage = loadImage(path + QLatin1Char('/') + files.at(position-1));
+ prevImage = loadImage(files.at(position - 1));
else
prevImage = QImage();
- currentImage = loadImage(path + QLatin1Char('/') + files.at(position));
+ currentImage = loadImage(files.at(position));
if (position+1 < files.size())
- nextImage = loadImage(path + QLatin1Char('/') + files.at(position+1));
+ nextImage = loadImage(files.at(position + 1));
else
nextImage = QImage();
update();
diff --git a/examples/widgets/gestures/imagegestures/imagewidget.h b/examples/widgets/gestures/imagegestures/imagewidget.h
index 7e8142442a..1f4010baac 100644
--- a/examples/widgets/gestures/imagegestures/imagewidget.h
+++ b/examples/widgets/gestures/imagegestures/imagewidget.h
@@ -4,6 +4,7 @@
#ifndef IMAGEWIDGET_H
#define IMAGEWIDGET_H
+#include <QFileInfo>
#include <QImage>
#include <QLoggingCategory>
#include <QWidget>
@@ -24,7 +25,7 @@ class ImageWidget : public QWidget
public:
ImageWidget(QWidget *parent = nullptr);
- void openDirectory(const QString &path);
+ void openDirectory(const QString &url);
void grabGestures(const QList<Qt::GestureType> &gestures);
protected:
@@ -40,14 +41,14 @@ private:
void swipeTriggered(QSwipeGesture*);
//! [class definition begin]
- QImage loadImage(const QString &fileName) const;
+ QImage loadImage(const QFileInfo &fileInfo) const;
void loadImage();
void goNextImage();
void goPrevImage();
void goToImage(int index);
QString path;
- QStringList files;
+ QFileInfoList files;
int position;
QImage prevImage, nextImage;
diff --git a/examples/widgets/graphicsview/CMakeLists.txt b/examples/widgets/graphicsview/CMakeLists.txt
index 47ae1091ab..7e287f0f42 100644
--- a/examples/widgets/graphicsview/CMakeLists.txt
+++ b/examples/widgets/graphicsview/CMakeLists.txt
@@ -1,16 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
qt_internal_add_example(chip)
qt_internal_add_example(elasticnodes)
-qt_internal_add_example(embeddeddialogs)
qt_internal_add_example(collidingmice)
qt_internal_add_example(basicgraphicslayouts)
qt_internal_add_example(diagramscene)
-qt_internal_add_example(flowlayout)
-qt_internal_add_example(anchorlayout)
qt_internal_add_example(simpleanchorlayout)
-qt_internal_add_example(weatheranchorlayout)
if(QT_FEATURE_cursor AND QT_FEATURE_draganddrop)
qt_internal_add_example(dragdroprobot)
endif()
diff --git a/examples/widgets/graphicsview/anchorlayout/CMakeLists.txt b/examples/widgets/graphicsview/anchorlayout/CMakeLists.txt
deleted file mode 100644
index 1e5f7c0929..0000000000
--- a/examples/widgets/graphicsview/anchorlayout/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(anchorlayout LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/anchorlayout")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(anchorlayout
- main.cpp
-)
-
-set_target_properties(anchorlayout PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(anchorlayout PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS anchorlayout
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/graphicsview/anchorlayout/anchorlayout.pro b/examples/widgets/graphicsview/anchorlayout/anchorlayout.pro
deleted file mode 100644
index 1afba2747c..0000000000
--- a/examples/widgets/graphicsview/anchorlayout/anchorlayout.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-TARGET = anchorlayout
-
-QT += widgets
-
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/graphicsview/anchorlayout
-INSTALLS += target
diff --git a/examples/widgets/graphicsview/anchorlayout/main.cpp b/examples/widgets/graphicsview/anchorlayout/main.cpp
deleted file mode 100644
index ee8f94f236..0000000000
--- a/examples/widgets/graphicsview/anchorlayout/main.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-static QGraphicsProxyWidget *createItem(const QSizeF &minimum = QSizeF(100.0, 100.0),
- const QSizeF &preferred = QSize(150.0, 100.0),
- const QSizeF &maximum = QSizeF(200.0, 100.0),
- const QString &name = "0")
-{
- QGraphicsProxyWidget *w = new QGraphicsProxyWidget;
- w->setWidget(new QPushButton(name));
- w->setData(0, name);
- w->setMinimumSize(minimum);
- w->setPreferredSize(preferred);
- w->setMaximumSize(maximum);
-
- w->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
- return w;
-}
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- QGraphicsScene scene;
- scene.setSceneRect(0, 0, 800, 480);
-
- QSizeF minSize(30, 100);
- QSizeF prefSize(210, 100);
- QSizeF maxSize(300, 100);
-
- QGraphicsProxyWidget *a = createItem(minSize, prefSize, maxSize, "A");
- QGraphicsProxyWidget *b = createItem(minSize, prefSize, maxSize, "B");
- QGraphicsProxyWidget *c = createItem(minSize, prefSize, maxSize, "C");
- QGraphicsProxyWidget *d = createItem(minSize, prefSize, maxSize, "D");
- QGraphicsProxyWidget *e = createItem(minSize, prefSize, maxSize, "E");
- QGraphicsProxyWidget *f = createItem(QSizeF(30, 50), QSizeF(150, 50), maxSize, "F (overflow)");
- QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G (overflow)");
-
- QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
- l->setSpacing(0);
-
- QGraphicsWidget *w = new QGraphicsWidget(nullptr, Qt::Window);
- w->setPos(20, 20);
- w->setLayout(l);
-
- // vertical
- l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop);
- l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop);
-
- l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom);
- l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom);
- l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop);
- l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop);
-
- l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom);
- l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom);
-
- l->addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop);
- l->addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom);
- l->addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop);
- l->addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom);
-
- // horizontal
- l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
- l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft);
- l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
-
- l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft);
- l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft);
-
- l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight);
- l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight);
- l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft);
-
- l->addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft);
- l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft);
- l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight);
-
-
- scene.addItem(w);
- scene.setBackgroundBrush(Qt::darkGreen);
- QGraphicsView view(&scene);
-
- view.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/graphicsview/basicgraphicslayouts/CMakeLists.txt b/examples/widgets/graphicsview/basicgraphicslayouts/CMakeLists.txt
index b09d18c6c0..dae3884e8b 100644
--- a/examples/widgets/graphicsview/basicgraphicslayouts/CMakeLists.txt
+++ b/examples/widgets/graphicsview/basicgraphicslayouts/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(basicgraphicslayouts LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/basicgraphicslayouts")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(basicgraphicslayouts
layoutitem.cpp layoutitem.h
main.cpp
@@ -25,10 +19,10 @@ set_target_properties(basicgraphicslayouts PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(basicgraphicslayouts PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(basicgraphicslayouts PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -44,7 +38,14 @@ qt_add_resources(basicgraphicslayouts "basicgraphicslayouts"
)
install(TARGETS basicgraphicslayouts
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET basicgraphicslayouts
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/graphicsview/chip/CMakeLists.txt b/examples/widgets/graphicsview/chip/CMakeLists.txt
index 96f80bfc7c..81b2e19552 100644
--- a/examples/widgets/graphicsview/chip/CMakeLists.txt
+++ b/examples/widgets/graphicsview/chip/CMakeLists.txt
@@ -1,22 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(chip LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/chip")
-
find_package(Qt6
REQUIRED COMPONENTS Core Gui Widgets
OPTIONAL_COMPONENTS PrintSupport
)
+qt_standard_project_setup()
+
qt_add_executable(chip
chip.cpp chip.h
main.cpp
@@ -29,10 +23,10 @@ set_target_properties(chip PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(chip PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(chip PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -52,14 +46,19 @@ qt_add_resources(chip "images"
${images_resource_files}
)
-if(TARGET Qt::PrintSupport)
- target_link_libraries(chip PUBLIC
- Qt::PrintSupport
- )
+if(TARGET Qt6::PrintSupport)
+ target_link_libraries(chip PRIVATE Qt6::PrintSupport)
endif()
install(TARGETS chip
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET chip
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/graphicsview/chip/main.cpp b/examples/widgets/graphicsview/chip/main.cpp
index bf75db6a93..4ccd66bbb9 100644
--- a/examples/widgets/graphicsview/chip/main.cpp
+++ b/examples/widgets/graphicsview/chip/main.cpp
@@ -7,8 +7,6 @@
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(images);
-
QApplication app(argc, argv);
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
diff --git a/examples/widgets/graphicsview/chip/mainwindow.cpp b/examples/widgets/graphicsview/chip/mainwindow.cpp
index 00de1d852e..8b4f5b27fd 100644
--- a/examples/widgets/graphicsview/chip/mainwindow.cpp
+++ b/examples/widgets/graphicsview/chip/mainwindow.cpp
@@ -48,7 +48,6 @@ void MainWindow::populateScene()
// Populate scene
int xx = 0;
- int nitems = 0;
for (int i = -11000; i < 11000; i += 110) {
++xx;
int yy = 0;
@@ -61,8 +60,6 @@ void MainWindow::populateScene()
QGraphicsItem *item = new Chip(color, xx, yy);
item->setPos(QPointF(i, j));
scene->addItem(item);
-
- ++nitems;
}
}
}
diff --git a/examples/widgets/graphicsview/collidingmice/CMakeLists.txt b/examples/widgets/graphicsview/collidingmice/CMakeLists.txt
index 8f09a96bd3..226b72b051 100644
--- a/examples/widgets/graphicsview/collidingmice/CMakeLists.txt
+++ b/examples/widgets/graphicsview/collidingmice/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(collidingmice LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/collidingmice")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(collidingmice
main.cpp
mouse.cpp mouse.h
@@ -24,10 +18,10 @@ set_target_properties(collidingmice PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(collidingmice PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(collidingmice PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -43,7 +37,14 @@ qt_add_resources(collidingmice "mice"
)
install(TARGETS collidingmice
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET collidingmice
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/graphicsview/diagramscene/CMakeLists.txt b/examples/widgets/graphicsview/diagramscene/CMakeLists.txt
index 3eb908fad3..9db835478d 100644
--- a/examples/widgets/graphicsview/diagramscene/CMakeLists.txt
+++ b/examples/widgets/graphicsview/diagramscene/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(diagramscene LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/diagramscene")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(diagramscene
arrow.cpp arrow.h
diagramitem.cpp diagramitem.h
@@ -28,10 +22,10 @@ set_target_properties(diagramscene PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(diagramscene PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(diagramscene PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -61,7 +55,14 @@ qt_add_resources(diagramscene "diagramscene"
)
install(TARGETS diagramscene
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET diagramscene
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/graphicsview/diagramscene/diagramitem.cpp b/examples/widgets/graphicsview/diagramscene/diagramitem.cpp
index fe9e7584e3..82b832837b 100644
--- a/examples/widgets/graphicsview/diagramscene/diagramitem.cpp
+++ b/examples/widgets/graphicsview/diagramscene/diagramitem.cpp
@@ -105,7 +105,7 @@ void DiagramItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
QVariant DiagramItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemPositionChange) {
- for (Arrow *arrow : qAsConst(arrows))
+ for (Arrow *arrow : std::as_const(arrows))
arrow->updatePosition();
}
diff --git a/examples/widgets/graphicsview/diagramscene/main.cpp b/examples/widgets/graphicsview/diagramscene/main.cpp
index 56310b1751..699c33f079 100644
--- a/examples/widgets/graphicsview/diagramscene/main.cpp
+++ b/examples/widgets/graphicsview/diagramscene/main.cpp
@@ -7,8 +7,6 @@
int main(int argv, char *args[])
{
- Q_INIT_RESOURCE(diagramscene);
-
QApplication app(argv, args);
MainWindow mainWindow;
mainWindow.setGeometry(100, 100, 800, 500);
diff --git a/examples/widgets/graphicsview/diagramscene/mainwindow.cpp b/examples/widgets/graphicsview/diagramscene/mainwindow.cpp
index dc77b500cb..7588e43701 100644
--- a/examples/widgets/graphicsview/diagramscene/mainwindow.cpp
+++ b/examples/widgets/graphicsview/diagramscene/mainwindow.cpp
@@ -87,7 +87,7 @@ void MainWindow::buttonGroupClicked(QAbstractButton *button)
void MainWindow::deleteItem()
{
QList<QGraphicsItem *> selectedItems = scene->selectedItems();
- for (QGraphicsItem *item : qAsConst(selectedItems)) {
+ for (QGraphicsItem *item : std::as_const(selectedItems)) {
if (item->type() == Arrow::Type) {
scene->removeItem(item);
Arrow *arrow = qgraphicsitem_cast<Arrow *>(item);
@@ -98,7 +98,7 @@ void MainWindow::deleteItem()
}
selectedItems = scene->selectedItems();
- for (QGraphicsItem *item : qAsConst(selectedItems)) {
+ for (QGraphicsItem *item : std::as_const(selectedItems)) {
if (item->type() == DiagramItem::Type)
qgraphicsitem_cast<DiagramItem *>(item)->removeArrows();
scene->removeItem(item);
@@ -432,7 +432,7 @@ void MainWindow::createToolbars()
fontColorToolButton = new QToolButton;
fontColorToolButton->setPopupMode(QToolButton::MenuButtonPopup);
- fontColorToolButton->setMenu(createColorMenu(SLOT(textColorChanged()), Qt::black));
+ fontColorToolButton->setMenu(createColorMenu(&MainWindow::textColorChanged, Qt::black));
textAction = fontColorToolButton->menu()->defaultAction();
fontColorToolButton->setIcon(createColorToolButtonIcon(":/images/textpointer.png", Qt::black));
fontColorToolButton->setAutoFillBackground(true);
@@ -442,7 +442,7 @@ void MainWindow::createToolbars()
//! [26]
fillColorToolButton = new QToolButton;
fillColorToolButton->setPopupMode(QToolButton::MenuButtonPopup);
- fillColorToolButton->setMenu(createColorMenu(SLOT(itemColorChanged()), Qt::white));
+ fillColorToolButton->setMenu(createColorMenu(&MainWindow::itemColorChanged, Qt::white));
fillAction = fillColorToolButton->menu()->defaultAction();
fillColorToolButton->setIcon(createColorToolButtonIcon(
":/images/floodfill.png", Qt::white));
@@ -452,7 +452,7 @@ void MainWindow::createToolbars()
lineColorToolButton = new QToolButton;
lineColorToolButton->setPopupMode(QToolButton::MenuButtonPopup);
- lineColorToolButton->setMenu(createColorMenu(SLOT(lineColorChanged()), Qt::black));
+ lineColorToolButton->setMenu(createColorMenu(&MainWindow::lineColorChanged, Qt::black));
lineAction = lineColorToolButton->menu()->defaultAction();
lineColorToolButton->setIcon(createColorToolButtonIcon(
":/images/linecolor.png", Qt::black));
@@ -547,7 +547,8 @@ QWidget *MainWindow::createCellWidget(const QString &text, DiagramItem::DiagramT
//! [29]
//! [30]
-QMenu *MainWindow::createColorMenu(const char *slot, QColor defaultColor)
+template<typename PointerToMemberFunction>
+QMenu *MainWindow::createColorMenu(const PointerToMemberFunction &slot, QColor defaultColor)
{
QList<QColor> colors;
colors << Qt::black << Qt::white << Qt::red << Qt::blue << Qt::yellow;
@@ -560,7 +561,7 @@ QMenu *MainWindow::createColorMenu(const char *slot, QColor defaultColor)
QAction *action = new QAction(names.at(i), this);
action->setData(colors.at(i));
action->setIcon(createColorIcon(colors.at(i)));
- connect(action, SIGNAL(triggered()), this, slot);
+ connect(action, &QAction::triggered, this, slot);
colorMenu->addAction(action);
if (colors.at(i) == defaultColor)
colorMenu->setDefaultAction(action);
diff --git a/examples/widgets/graphicsview/diagramscene/mainwindow.h b/examples/widgets/graphicsview/diagramscene/mainwindow.h
index 34f98f6513..fe8a91901f 100644
--- a/examples/widgets/graphicsview/diagramscene/mainwindow.h
+++ b/examples/widgets/graphicsview/diagramscene/mainwindow.h
@@ -64,7 +64,9 @@ private:
const QString &image);
QWidget *createCellWidget(const QString &text,
DiagramItem::DiagramType type);
- QMenu *createColorMenu(const char *slot, QColor defaultColor);
+
+ template<typename PointerToMemberFunction>
+ QMenu *createColorMenu(const PointerToMemberFunction &slot, QColor defaultColor);
QIcon createColorToolButtonIcon(const QString &image, QColor color);
QIcon createColorIcon(QColor color);
diff --git a/examples/widgets/graphicsview/dragdroprobot/CMakeLists.txt b/examples/widgets/graphicsview/dragdroprobot/CMakeLists.txt
index 834feae2b5..df2425260e 100644
--- a/examples/widgets/graphicsview/dragdroprobot/CMakeLists.txt
+++ b/examples/widgets/graphicsview/dragdroprobot/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(dragdroprobot LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/dragdroprobot")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(dragdroprobot
coloritem.cpp coloritem.h
main.cpp
@@ -25,10 +19,10 @@ set_target_properties(dragdroprobot PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(dragdroprobot PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(dragdroprobot PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -44,7 +38,14 @@ qt_add_resources(dragdroprobot "robot"
)
install(TARGETS dragdroprobot
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET dragdroprobot
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/graphicsview/elasticnodes/CMakeLists.txt b/examples/widgets/graphicsview/elasticnodes/CMakeLists.txt
index 8e1ce46eb0..07299cd5a7 100644
--- a/examples/widgets/graphicsview/elasticnodes/CMakeLists.txt
+++ b/examples/widgets/graphicsview/elasticnodes/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(elasticnodes LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/elasticnodes")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(elasticnodes
edge.cpp edge.h
graphwidget.cpp graphwidget.h
@@ -26,14 +20,21 @@ set_target_properties(elasticnodes PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(elasticnodes PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(elasticnodes PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS elasticnodes
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET elasticnodes
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp b/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
index 3d8ca8e972..ede3d23137 100644
--- a/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
+++ b/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
@@ -123,11 +123,11 @@ void GraphWidget::timerEvent(QTimerEvent *event)
nodes << node;
}
- for (Node *node : qAsConst(nodes))
+ for (Node *node : std::as_const(nodes))
node->calculateForces();
bool itemsMoved = false;
- for (Node *node : qAsConst(nodes)) {
+ for (Node *node : std::as_const(nodes)) {
if (node->advancePosition())
itemsMoved = true;
}
diff --git a/examples/widgets/graphicsview/elasticnodes/node.cpp b/examples/widgets/graphicsview/elasticnodes/node.cpp
index fd8df0b32b..eb102f0aa4 100644
--- a/examples/widgets/graphicsview/elasticnodes/node.cpp
+++ b/examples/widgets/graphicsview/elasticnodes/node.cpp
@@ -67,7 +67,7 @@ void Node::calculateForces()
//! [4]
// Now subtract all forces pulling items together
double weight = (edgeList.size() + 1) * 10;
- for (const Edge *edge : qAsConst(edgeList)) {
+ for (const Edge *edge : std::as_const(edgeList)) {
QPointF vec;
if (edge->sourceNode() == this)
vec = mapToItem(edge->destNode(), 0, 0);
@@ -148,7 +148,7 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
{
switch (change) {
case ItemPositionHasChanged:
- for (Edge *edge : qAsConst(edgeList))
+ for (Edge *edge : std::as_const(edgeList))
edge->adjust();
graph->itemMoved();
break;
diff --git a/examples/widgets/graphicsview/embeddeddialogs/CMakeLists.txt b/examples/widgets/graphicsview/embeddeddialogs/CMakeLists.txt
deleted file mode 100644
index e0c84c2e90..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/CMakeLists.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(embeddeddialogs LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/embeddeddialogs")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(embeddeddialogs
- customproxy.cpp customproxy.h
- embeddeddialog.cpp embeddeddialog.h embeddeddialog.ui
- main.cpp
-)
-
-set_target_properties(embeddeddialogs PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(embeddeddialogs PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(embeddeddialogs_resource_files
- "No-Ones-Laughing-3.jpg"
-)
-
-qt_add_resources(embeddeddialogs "embeddeddialogs"
- PREFIX
- "/"
- FILES
- ${embeddeddialogs_resource_files}
-)
-
-install(TARGETS embeddeddialogs
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/graphicsview/embeddeddialogs/No-Ones-Laughing-3.jpg b/examples/widgets/graphicsview/embeddeddialogs/No-Ones-Laughing-3.jpg
deleted file mode 100644
index 445567fbda..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/No-Ones-Laughing-3.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/graphicsview/embeddeddialogs/customproxy.cpp b/examples/widgets/graphicsview/embeddeddialogs/customproxy.cpp
deleted file mode 100644
index 57a104f57d..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/customproxy.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "customproxy.h"
-
-#include <QGraphicsScene>
-#include <QPainter>
-#include <QStyleOptionGraphicsItem>
-
-CustomProxy::CustomProxy(QGraphicsItem *parent, Qt::WindowFlags wFlags)
- : QGraphicsProxyWidget(parent, wFlags), timeLine(new QTimeLine(250, this))
-{
- connect(timeLine, &QTimeLine::valueChanged,
- this, &CustomProxy::updateStep);
- connect(timeLine, &QTimeLine::stateChanged,
- this, &CustomProxy::stateChanged);
-}
-
-QRectF CustomProxy::boundingRect() const
-{
- return QGraphicsProxyWidget::boundingRect().adjusted(0, 0, 10, 10);
-}
-
-void CustomProxy::paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget)
-{
- const QColor color(0, 0, 0, 64);
-
- QRectF r = windowFrameRect();
- QRectF right(r.right(), r.top() + 10, 10, r.height() - 10);
- QRectF bottom(r.left() + 10, r.bottom(), r.width(), 10);
- bool intersectsRight = right.intersects(option->exposedRect);
- bool intersectsBottom = bottom.intersects(option->exposedRect);
- if (intersectsRight && intersectsBottom) {
- QPainterPath path;
- path.addRect(right);
- path.addRect(bottom);
- painter->setPen(Qt::NoPen);
- painter->setBrush(color);
- painter->drawPath(path);
- } else if (intersectsBottom) {
- painter->fillRect(bottom, color);
- } else if (intersectsRight) {
- painter->fillRect(right, color);
- }
-
- QGraphicsProxyWidget::paintWindowFrame(painter, option, widget);
-}
-
-void CustomProxy::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
-{
- QGraphicsProxyWidget::hoverEnterEvent(event);
- scene()->setActiveWindow(this);
- if (qFuzzyCompare(timeLine->currentValue(), 1))
- zoomIn();
-}
-
-void CustomProxy::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
-{
- QGraphicsProxyWidget::hoverLeaveEvent(event);
- if (!popupShown
- && (timeLine->direction() != QTimeLine::Backward || qFuzzyIsNull(timeLine->currentValue()))) {
- zoomOut();
- }
-}
-
-bool CustomProxy::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
-{
- if (watched->isWindow()
- && (event->type() == QEvent::UngrabMouse || event->type() == QEvent::GrabMouse)) {
- popupShown = watched->isVisible();
- if (!popupShown && !isUnderMouse())
- zoomOut();
- }
- return QGraphicsProxyWidget::sceneEventFilter(watched, event);
-}
-
-QVariant CustomProxy::itemChange(GraphicsItemChange change, const QVariant &value)
-{
- if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
- if (change == ItemChildAddedChange) {
- currentPopup = qvariant_cast<QGraphicsItem *>(value);
- currentPopup->setCacheMode(ItemCoordinateCache);
- if (scene())
- currentPopup->installSceneEventFilter(this);
- } else if (scene()) {
- currentPopup->removeSceneEventFilter(this);
- currentPopup = nullptr;
- }
- } else if (currentPopup && change == ItemSceneHasChanged) {
- currentPopup->installSceneEventFilter(this);
- }
- return QGraphicsProxyWidget::itemChange(change, value);
-}
-
-void CustomProxy::updateStep(qreal step)
-{
- QRectF r = boundingRect();
- setTransform(QTransform()
- .translate(r.width() / 2, r.height() / 2)
- .rotate(step * 30, Qt::XAxis)
- .rotate(step * 10, Qt::YAxis)
- .rotate(step * 5, Qt::ZAxis)
- .scale(1 + 1.5 * step, 1 + 1.5 * step)
- .translate(-r.width() / 2, -r.height() / 2));
-}
-
-void CustomProxy::stateChanged(QTimeLine::State state)
-{
- if (state == QTimeLine::Running) {
- if (timeLine->direction() == QTimeLine::Forward)
- setCacheMode(ItemCoordinateCache);
- } else if (state == QTimeLine::NotRunning) {
- if (timeLine->direction() == QTimeLine::Backward)
- setCacheMode(DeviceCoordinateCache);
- }
-}
-
-void CustomProxy::zoomIn()
-{
- if (timeLine->direction() != QTimeLine::Forward)
- timeLine->setDirection(QTimeLine::Forward);
- if (timeLine->state() == QTimeLine::NotRunning)
- timeLine->start();
-}
-
-void CustomProxy::zoomOut()
-{
- if (timeLine->direction() != QTimeLine::Backward)
- timeLine->setDirection(QTimeLine::Backward);
- if (timeLine->state() == QTimeLine::NotRunning)
- timeLine->start();
-}
diff --git a/examples/widgets/graphicsview/embeddeddialogs/customproxy.h b/examples/widgets/graphicsview/embeddeddialogs/customproxy.h
deleted file mode 100644
index 444d39e73e..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/customproxy.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef CUSTOMPROXY_H
-#define CUSTOMPROXY_H
-
-#include <QTimeLine>
-#include <QGraphicsProxyWidget>
-
-class CustomProxy : public QGraphicsProxyWidget
-{
- Q_OBJECT
-
-public:
- explicit CustomProxy(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = { });
-
- QRectF boundingRect() const override;
- void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget) override;
-
-protected:
- void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
- void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
- bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
- QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
-
-private slots:
- void updateStep(qreal step);
- void stateChanged(QTimeLine::State);
- void zoomIn();
- void zoomOut();
-
-private:
- QTimeLine *timeLine;
- QGraphicsItem *currentPopup = nullptr;
- bool popupShown = false;
-};
-
-#endif // CUSTOMPROXY_H
diff --git a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.cpp b/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.cpp
deleted file mode 100644
index 43d7fbf1e9..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "embeddeddialog.h"
-#include "ui_embeddeddialog.h"
-
-#include <QStyleFactory>
-
-EmbeddedDialog::EmbeddedDialog(QWidget *parent)
- : QDialog(parent)
- , ui(new Ui::EmbeddedDialog)
-{
- ui->setupUi(this);
- ui->layoutDirection->setCurrentIndex(layoutDirection() != Qt::LeftToRight);
-
- const QStringList styleKeys = QStyleFactory::keys();
- for (const QString &styleName : styleKeys) {
- ui->style->addItem(styleName);
- if (style()->objectName().toLower() == styleName.toLower())
- ui->style->setCurrentIndex(ui->style->count() - 1);
- }
-
- connect(ui->layoutDirection, &QComboBox::activated,
- this, &EmbeddedDialog::layoutDirectionChanged);
- connect(ui->spacing, &QSlider::valueChanged,
- this, &EmbeddedDialog::spacingChanged);
- connect(ui->fontComboBox, &QFontComboBox::currentFontChanged,
- this, &EmbeddedDialog::fontChanged);
- connect(ui->style, &QComboBox::textActivated,
- this, &EmbeddedDialog::styleChanged);
-}
-
-EmbeddedDialog::~EmbeddedDialog()
-{
- delete ui;
-}
-
-void EmbeddedDialog::layoutDirectionChanged(int index)
-{
- setLayoutDirection(index == 0 ? Qt::LeftToRight : Qt::RightToLeft);
-}
-
-void EmbeddedDialog::spacingChanged(int spacing)
-{
- layout()->setSpacing(spacing);
- adjustSize();
-}
-
-void EmbeddedDialog::fontChanged(const QFont &font)
-{
- setFont(font);
-}
-
-static void setStyleHelper(QWidget *widget, QStyle *style)
-{
- widget->setStyle(style);
- widget->setPalette(style->standardPalette());
- const QObjectList children = widget->children();
- for (QObject *child : children) {
- if (QWidget *childWidget = qobject_cast<QWidget *>(child))
- setStyleHelper(childWidget, style);
- }
-}
-
-void EmbeddedDialog::styleChanged(const QString &styleName)
-{
- QStyle *style = QStyleFactory::create(styleName);
- if (style)
- setStyleHelper(this, style);
-}
diff --git a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.h b/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.h
deleted file mode 100644
index d4c561799e..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef EMBEDDEDDIALOG_H
-#define EMBEDDEDDIALOG_H
-
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-namespace Ui {
-class EmbeddedDialog;
-}
-QT_END_NAMESPACE
-
-class EmbeddedDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- EmbeddedDialog(QWidget *parent = nullptr);
- ~EmbeddedDialog();
-
-private slots:
- void layoutDirectionChanged(int index);
- void spacingChanged(int spacing);
- void fontChanged(const QFont &font);
- void styleChanged(const QString &styleName);
-
-private:
- Ui::EmbeddedDialog *ui;
-};
-
-#endif // EMBEDDEDDIALOG_H
diff --git a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.ui b/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.ui
deleted file mode 100644
index 82aa5d7be3..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.ui
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>EmbeddedDialog</class>
- <widget class="QDialog" name="EmbeddedDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>407</width>
- <height>134</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Embedded Dialog</string>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Layout Direction:</string>
- </property>
- <property name="buddy">
- <cstring>layoutDirection</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="layoutDirection">
- <item>
- <property name="text">
- <string>Left to Right</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Right to Left</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Select Font:</string>
- </property>
- <property name="buddy">
- <cstring>fontComboBox</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QFontComboBox" name="fontComboBox"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Style:</string>
- </property>
- <property name="buddy">
- <cstring>style</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QComboBox" name="style"/>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Layout spacing:</string>
- </property>
- <property name="buddy">
- <cstring>spacing</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QSlider" name="spacing">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialogs.pro b/examples/widgets/graphicsview/embeddeddialogs/embeddeddialogs.pro
deleted file mode 100644
index 60c507fc3d..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialogs.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-QT += widgets
-requires(qtConfig(fontcombobox))
-
-SOURCES += main.cpp
-SOURCES += customproxy.cpp embeddeddialog.cpp
-HEADERS += customproxy.h embeddeddialog.h
-
-FORMS += embeddeddialog.ui
-RESOURCES += embeddeddialogs.qrc
-
-build_all:!build_pass {
- CONFIG -= build_all
- CONFIG += release
-}
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/graphicsview/embeddeddialogs
-INSTALLS += target
diff --git a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialogs.qrc b/examples/widgets/graphicsview/embeddeddialogs/embeddeddialogs.qrc
deleted file mode 100644
index 33be5038da..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialogs.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource>
- <file>No-Ones-Laughing-3.jpg</file>
- </qresource>
-</RCC>
diff --git a/examples/widgets/graphicsview/embeddeddialogs/main.cpp b/examples/widgets/graphicsview/embeddeddialogs/main.cpp
deleted file mode 100644
index f022b74814..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/main.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "customproxy.h"
-#include "embeddeddialog.h"
-
-#include <QApplication>
-#include <QGraphicsScene>
-#include <QGraphicsView>
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(embeddeddialogs);
- QApplication app(argc, argv);
-
- QGraphicsScene scene;
- scene.setStickyFocus(true);
- const int gridSize = 10;
-
- for (int y = 0; y < gridSize; ++y) {
- for (int x = 0; x < gridSize; ++x) {
- CustomProxy *proxy = new CustomProxy(nullptr, Qt::Window);
- proxy->setWidget(new EmbeddedDialog);
-
- QRectF rect = proxy->boundingRect();
-
- proxy->setPos(x * rect.width() * 1.05, y * rect.height() * 1.05);
- proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
-
- scene.addItem(proxy);
- }
- }
- scene.setSceneRect(scene.itemsBoundingRect());
-
- QGraphicsView view(&scene);
- view.scale(0.5, 0.5);
- view.setRenderHints(view.renderHints() | QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
- view.setBackgroundBrush(QPixmap(":/No-Ones-Laughing-3.jpg"));
- view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
- view.show();
- view.setWindowTitle("Embedded Dialogs Example");
- return app.exec();
-}
diff --git a/examples/widgets/graphicsview/flowlayout/CMakeLists.txt b/examples/widgets/graphicsview/flowlayout/CMakeLists.txt
deleted file mode 100644
index a0afadb181..0000000000
--- a/examples/widgets/graphicsview/flowlayout/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(flowlayout LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview_flowlayout")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(graphicsview_flowlayout
- flowlayout.cpp flowlayout.h
- main.cpp
- window.cpp window.h
-)
-
-set_target_properties(graphicsview_flowlayout PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(graphicsview_flowlayout PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS graphicsview_flowlayout
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/graphicsview/flowlayout/flowlayout.cpp b/examples/widgets/graphicsview/flowlayout/flowlayout.cpp
deleted file mode 100644
index 1f9fb25e75..0000000000
--- a/examples/widgets/graphicsview/flowlayout/flowlayout.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "flowlayout.h"
-
-#include <QtMath>
-
-FlowLayout::FlowLayout(QGraphicsLayoutItem *parent) : QGraphicsLayout(parent)
-{
- QSizePolicy sp = sizePolicy();
- sp.setHeightForWidth(true);
- setSizePolicy(sp);
-}
-
-void FlowLayout::insertItem(int index, QGraphicsLayoutItem *item)
-{
- item->setParentLayoutItem(this);
- if (index > m_items.count() || index < 0)
- index = m_items.count();
- m_items.insert(index, item);
- invalidate();
-}
-
-int FlowLayout::count() const
-{
- return m_items.count();
-}
-
-QGraphicsLayoutItem *FlowLayout::itemAt(int index) const
-{
- return m_items.value(index);
-}
-
-void FlowLayout::removeAt(int index)
-{
- m_items.removeAt(index);
- invalidate();
-}
-
-qreal FlowLayout::spacing(Qt::Orientation o) const
-{
- return m_spacing[int(o) - 1];
-}
-
-void FlowLayout::setSpacing(Qt::Orientations o, qreal spacing)
-{
- if (o & Qt::Horizontal)
- m_spacing[0] = spacing;
- if (o & Qt::Vertical)
- m_spacing[1] = spacing;
-}
-
-void FlowLayout::setGeometry(const QRectF &geom)
-{
- QGraphicsLayout::setGeometry(geom);
- doLayout(geom, true);
-}
-
-qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) const
-{
- qreal left, top, right, bottom;
- getContentsMargins(&left, &top, &right, &bottom);
- const qreal maxw = geom.width() - left - right;
-
- qreal x = 0;
- qreal y = 0;
- qreal maxRowHeight = 0;
- QSizeF pref;
- for (QGraphicsLayoutItem *item : m_items) {
- pref = item->effectiveSizeHint(Qt::PreferredSize);
- maxRowHeight = qMax(maxRowHeight, pref.height());
-
- qreal next_x;
- next_x = x + pref.width();
- if (next_x > maxw) {
- if (qFuzzyIsNull(x)) {
- pref.setWidth(maxw);
- } else {
- x = 0;
- next_x = pref.width();
- }
- y += maxRowHeight + spacing(Qt::Vertical);
- maxRowHeight = 0;
- }
-
- if (applyNewGeometry)
- item->setGeometry(QRectF(QPointF(left + x, top + y), pref));
- x = next_x + spacing(Qt::Horizontal);
- }
- maxRowHeight = qMax(maxRowHeight, pref.height());
- return top + y + maxRowHeight + bottom;
-}
-
-QSizeF FlowLayout::minSize(const QSizeF &constraint) const
-{
- QSizeF size(0, 0);
- qreal left, top, right, bottom;
- getContentsMargins(&left, &top, &right, &bottom);
- if (constraint.width() >= 0) { // height for width
- const qreal height = doLayout(QRectF(QPointF(0,0), constraint), false);
- size = QSizeF(constraint.width(), height);
- } else if (constraint.height() >= 0) { // width for height?
- // not supported
- } else {
- for (const QGraphicsLayoutItem *item : qAsConst(m_items))
- size = size.expandedTo(item->effectiveSizeHint(Qt::MinimumSize));
- size += QSizeF(left + right, top + bottom);
- }
- return size;
-}
-
-QSizeF FlowLayout::prefSize() const
-{
- qreal left, right;
- getContentsMargins(&left, nullptr, &right, nullptr);
-
- qreal maxh = 0;
- qreal totalWidth = 0;
- for (const QGraphicsLayoutItem *item : qAsConst(m_items)) {
- if (totalWidth > 0)
- totalWidth += spacing(Qt::Horizontal);
- QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize);
- totalWidth += pref.width();
- maxh = qMax(maxh, pref.height());
- }
- maxh += spacing(Qt::Vertical);
-
- const qreal goldenAspectRatio = 1.61803399;
- qreal w = qSqrt(totalWidth * maxh * goldenAspectRatio) + left + right;
-
- return minSize(QSizeF(w, -1));
-}
-
-QSizeF FlowLayout::maxSize() const
-{
- qreal totalWidth = 0;
- qreal totalHeight = 0;
- for (const QGraphicsLayoutItem *item : qAsConst(m_items)) {
- if (totalWidth > 0)
- totalWidth += spacing(Qt::Horizontal);
- if (totalHeight > 0)
- totalHeight += spacing(Qt::Vertical);
- QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize);
- totalWidth += pref.width();
- totalHeight += pref.height();
- }
-
- qreal left, top, right, bottom;
- getContentsMargins(&left, &top, &right, &bottom);
- return QSizeF(left + totalWidth + right, top + totalHeight + bottom);
-}
-
-QSizeF FlowLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
-{
- QSizeF sh = constraint;
- switch (which) {
- case Qt::PreferredSize:
- sh = prefSize();
- break;
- case Qt::MinimumSize:
- sh = minSize(constraint);
- break;
- case Qt::MaximumSize:
- sh = maxSize();
- break;
- default:
- break;
- }
- return sh;
-}
diff --git a/examples/widgets/graphicsview/flowlayout/flowlayout.h b/examples/widgets/graphicsview/flowlayout/flowlayout.h
deleted file mode 100644
index 43c469ac3c..0000000000
--- a/examples/widgets/graphicsview/flowlayout/flowlayout.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QGraphicsLayout>
-
-class FlowLayout : public QGraphicsLayout
-{
-public:
- FlowLayout(QGraphicsLayoutItem *parent = nullptr);
- inline void addItem(QGraphicsLayoutItem *item);
- void insertItem(int index, QGraphicsLayoutItem *item);
- void setSpacing(Qt::Orientations o, qreal spacing);
- qreal spacing(Qt::Orientation o) const;
-
- // inherited functions
- void setGeometry(const QRectF &geom) override;
-
- int count() const override;
- QGraphicsLayoutItem *itemAt(int index) const override;
- void removeAt(int index) override;
-
-protected:
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override;
-
-private:
- qreal doLayout(const QRectF &geom, bool applyNewGeometry) const;
- QSizeF minSize(const QSizeF &constraint) const;
- QSizeF prefSize() const;
- QSizeF maxSize() const;
-
- QList<QGraphicsLayoutItem *> m_items;
- qreal m_spacing[2] = {6, 6};
-};
-
-
-inline void FlowLayout::addItem(QGraphicsLayoutItem *item)
-{
- insertItem(-1, item);
-}
diff --git a/examples/widgets/graphicsview/flowlayout/flowlayout.pro b/examples/widgets/graphicsview/flowlayout/flowlayout.pro
deleted file mode 100644
index 7830e3a008..0000000000
--- a/examples/widgets/graphicsview/flowlayout/flowlayout.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT += widgets
-
-QMAKE_PROJECT_NAME = flowlayout_graphicsview
-
-HEADERS += flowlayout.h window.h
-SOURCES += flowlayout.cpp main.cpp window.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/graphicsview/flowlayout
-INSTALLS += target
diff --git a/examples/widgets/graphicsview/flowlayout/main.cpp b/examples/widgets/graphicsview/flowlayout/main.cpp
deleted file mode 100644
index 118b404870..0000000000
--- a/examples/widgets/graphicsview/flowlayout/main.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-//! [1]
-#include "window.h"
-
-#include <QApplication>
-#include <QGraphicsView>
-
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QGraphicsScene scene;
- QGraphicsView view(&scene);
- Window *w = new Window;
- scene.addItem(w);
-
- view.resize(400, 300);
- view.show();
-
- return app.exec();
-}
-//! [1]
diff --git a/examples/widgets/graphicsview/flowlayout/window.cpp b/examples/widgets/graphicsview/flowlayout/window.cpp
deleted file mode 100644
index ed9a5720d3..0000000000
--- a/examples/widgets/graphicsview/flowlayout/window.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "window.h"
-#include "flowlayout.h"
-
-#include <QGraphicsProxyWidget>
-#include <QLabel>
-
-Window::Window(QGraphicsItem *parent) : QGraphicsWidget(parent, Qt::Window)
-{
- FlowLayout *lay = new FlowLayout;
- const QString sentence(QLatin1String("I am not bothered by the fact that I am unknown."
- " I am bothered when I do not know others. (Confucius)"));
- const QList<QStringView> words = QStringView{ sentence }.split(QLatin1Char(' '), Qt::SkipEmptyParts);
- for (const QStringView &word : words) {
- QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this);
- QLabel *label = new QLabel(word.toString());
- label->setFrameStyle(QFrame::Box | QFrame::Plain);
- proxy->setWidget(label);
- lay->addItem(proxy);
- }
- setLayout(lay);
-}
diff --git a/examples/widgets/graphicsview/flowlayout/window.h b/examples/widgets/graphicsview/flowlayout/window.h
deleted file mode 100644
index 54c27929ac..0000000000
--- a/examples/widgets/graphicsview/flowlayout/window.h
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QGraphicsWidget>
-
-class Window : public QGraphicsWidget
-{
- Q_OBJECT
-public:
- Window(QGraphicsItem *parent = nullptr);
-};
diff --git a/examples/widgets/graphicsview/graphicsview.pro b/examples/widgets/graphicsview/graphicsview.pro
index 8becd8aa9d..d50f0b1adc 100644
--- a/examples/widgets/graphicsview/graphicsview.pro
+++ b/examples/widgets/graphicsview/graphicsview.pro
@@ -2,14 +2,10 @@ TEMPLATE = subdirs
SUBDIRS = \
chip \
elasticnodes \
- embeddeddialogs \
collidingmice \
basicgraphicslayouts \
diagramscene \
dragdroprobot \
- flowlayout \
- anchorlayout \
- simpleanchorlayout \
- weatheranchorlayout
+ simpleanchorlayout
contains(DEFINES, QT_NO_CURSOR)|!qtConfig(draganddrop): SUBDIRS -= dragdroprobot
diff --git a/examples/widgets/graphicsview/simpleanchorlayout/CMakeLists.txt b/examples/widgets/graphicsview/simpleanchorlayout/CMakeLists.txt
index 5f20c9c648..2f31e12bbf 100644
--- a/examples/widgets/graphicsview/simpleanchorlayout/CMakeLists.txt
+++ b/examples/widgets/graphicsview/simpleanchorlayout/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(simpleanchorlayout LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/simpleanchorlayout")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(simpleanchorlayout
main.cpp
)
@@ -23,14 +17,21 @@ set_target_properties(simpleanchorlayout PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(simpleanchorlayout PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(simpleanchorlayout PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS simpleanchorlayout
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET simpleanchorlayout
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/graphicsview/weatheranchorlayout/CMakeLists.txt b/examples/widgets/graphicsview/weatheranchorlayout/CMakeLists.txt
deleted file mode 100644
index d83571a6f6..0000000000
--- a/examples/widgets/graphicsview/weatheranchorlayout/CMakeLists.txt
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(weatheranchorlayout LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/weatheranchorlayout")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(weatheranchorlayout
- main.cpp
-)
-
-set_target_properties(weatheranchorlayout PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(weatheranchorlayout PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(weatheranchorlayout_resource_files
- "images/5days.jpg"
- "images/details.jpg"
- "images/place.jpg"
- "images/tabbar.jpg"
- "images/title.jpg"
- "images/weather-few-clouds.png"
-)
-
-qt_add_resources(weatheranchorlayout "weatheranchorlayout"
- PREFIX
- "/"
- FILES
- ${weatheranchorlayout_resource_files}
-)
-
-install(TARGETS weatheranchorlayout
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/graphicsview/weatheranchorlayout/images/5days.jpg b/examples/widgets/graphicsview/weatheranchorlayout/images/5days.jpg
deleted file mode 100644
index fd92ba8ba7..0000000000
--- a/examples/widgets/graphicsview/weatheranchorlayout/images/5days.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/graphicsview/weatheranchorlayout/images/details.jpg b/examples/widgets/graphicsview/weatheranchorlayout/images/details.jpg
deleted file mode 100644
index fde0448c69..0000000000
--- a/examples/widgets/graphicsview/weatheranchorlayout/images/details.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/graphicsview/weatheranchorlayout/images/place.jpg b/examples/widgets/graphicsview/weatheranchorlayout/images/place.jpg
deleted file mode 100644
index 03e5344330..0000000000
--- a/examples/widgets/graphicsview/weatheranchorlayout/images/place.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/graphicsview/weatheranchorlayout/images/tabbar.jpg b/examples/widgets/graphicsview/weatheranchorlayout/images/tabbar.jpg
deleted file mode 100644
index 7777662901..0000000000
--- a/examples/widgets/graphicsview/weatheranchorlayout/images/tabbar.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/graphicsview/weatheranchorlayout/images/title.jpg b/examples/widgets/graphicsview/weatheranchorlayout/images/title.jpg
deleted file mode 100644
index fa84c8156c..0000000000
--- a/examples/widgets/graphicsview/weatheranchorlayout/images/title.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/graphicsview/weatheranchorlayout/images/weather-few-clouds.png b/examples/widgets/graphicsview/weatheranchorlayout/images/weather-few-clouds.png
deleted file mode 100644
index eea6ce6529..0000000000
--- a/examples/widgets/graphicsview/weatheranchorlayout/images/weather-few-clouds.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/graphicsview/weatheranchorlayout/main.cpp b/examples/widgets/graphicsview/weatheranchorlayout/main.cpp
deleted file mode 100644
index 1151349f24..0000000000
--- a/examples/widgets/graphicsview/weatheranchorlayout/main.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-#include <QLabel>
-#include <QGraphicsAnchorLayout>
-#include <QGraphicsProxyWidget>
-#include <QGraphicsScene>
-#include <QGraphicsSceneResizeEvent>
-#include <QGraphicsView>
-#include <QGraphicsWidget>
-#include <QPainter>
-#include <QPushButton>
-
-
-class GraphicsView : public QGraphicsView
-{
-public:
- GraphicsView(QGraphicsScene *scene, QGraphicsWidget *widget)
- : QGraphicsView(scene), w(widget)
- {
- }
-
- void resizeEvent(QResizeEvent *event) override
- {
- w->setGeometry(0, 0, event->size().width(), event->size().height());
- }
-
- QGraphicsWidget *w;
-};
-
-class PixmapWidget : public QGraphicsLayoutItem
-{
-public:
- PixmapWidget(const QPixmap &pix)
- : QGraphicsLayoutItem(), original(new QGraphicsPixmapItem(pix))
- , r(QRectF(QPointF(0, 0), pix.size()))
- {
- setGraphicsItem(original);
- original->show();
- }
-
- ~PixmapWidget()
- {
- setGraphicsItem(nullptr);
- delete original;
- }
-
- void setZValue(qreal z)
- {
- original->setZValue(z);
- }
-
- void setGeometry(const QRectF &rect) override
- {
- original->setTransform(QTransform::fromScale(rect.width() / r.width(),
- rect.height() / r.height()), true);
- original->setPos(rect.x(), rect.y());
- r = rect;
- }
-
-protected:
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override
- {
- Q_UNUSED(constraint);
- QSizeF sh;
- switch (which) {
- case Qt::MinimumSize:
- sh = QSizeF(0, 0);
- break;
- case Qt::PreferredSize:
- sh = QSizeF(50, 50);
- break;
- case Qt::MaximumSize:
- sh = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
- break;
- default:
- break;
- }
- return sh;
- }
-
-private:
- QGraphicsPixmapItem *original;
- QRectF r;
-};
-
-
-class PlaceWidget : public QGraphicsWidget
-{
- Q_OBJECT
-
-public:
- PlaceWidget(const QPixmap &pix)
- : QGraphicsWidget()
- , original(pix)
- , scaled(pix)
- {
- }
-
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
- {
- const QPointF reflection(0, scaled.height() + 2);
-
- painter->drawPixmap(QPointF(), scaled);
-
- QPixmap tmp(scaled.size());
- tmp.fill(Qt::transparent);
- QPainter p(&tmp);
-
- // create gradient
- QPoint p1(scaled.width() / 2, 0);
- QPoint p2(scaled.width() / 2, scaled.height());
- QLinearGradient linearGrad(p1, p2);
- linearGrad.setColorAt(0, QColor(0, 0, 0, 0));
- linearGrad.setColorAt(0.65, QColor(0, 0, 0, 127));
- linearGrad.setColorAt(1, QColor(0, 0, 0, 255));
-
- // apply 'mask'
- p.setBrush(linearGrad);
- p.fillRect(0, 0, tmp.width(), tmp.height(), QBrush(linearGrad));
- p.fillRect(0, 0, tmp.width(), tmp.height(), QBrush(linearGrad));
-
- // paint the image flipped
- p.setCompositionMode(QPainter::CompositionMode_DestinationOver);
- p.drawPixmap(0, 0, QPixmap::fromImage(scaled.toImage().mirrored(false, true)));
- p.end();
-
- painter->drawPixmap(reflection, tmp);
- }
-
- void resizeEvent(QGraphicsSceneResizeEvent *event) override
- {
- QSize newSize = event->newSize().toSize();
- newSize.setHeight(newSize.height() / 2);
- scaled = original.scaled(newSize);
- }
-
- QRectF boundingRect() const override
- {
- QSize size(scaled.width(), scaled.height() * 2 + 2);
- return QRectF(QPointF(0, 0), size);
- }
-
-private:
- QPixmap original;
- QPixmap scaled;
-};
-
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(weatheranchorlayout);
-
- QApplication app(argc, argv);
-
- QGraphicsScene scene;
- scene.setSceneRect(0, 0, 800, 480);
-
- // pixmaps widgets
- PixmapWidget *title = new PixmapWidget(QPixmap(":/images/title.jpg"));
- PlaceWidget *place = new PlaceWidget(QPixmap(":/images/place.jpg"));
- PixmapWidget *details = new PixmapWidget(QPixmap(":/images/5days.jpg"));
- PixmapWidget *sunnyWeather = new PixmapWidget(QPixmap(":/images/weather-few-clouds.png"));
- PixmapWidget *tabbar = new PixmapWidget(QPixmap(":/images/tabbar.jpg"));
-
-
- // setup sizes
- title->setPreferredSize(QSizeF(348, 45));
- title->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
-
- place->setPreferredSize(QSizeF(96, 72));
- place->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
-
- details->setMinimumSize(QSizeF(200, 112));
- details->setPreferredSize(QSizeF(200, 112));
- details->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
-
- tabbar->setPreferredSize(QSizeF(70, 24));
- tabbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
-
- sunnyWeather->setPreferredSize(QSizeF(128, 97));
- sunnyWeather->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
- sunnyWeather->setZValue(9999);
-
- // start anchor layout
- QGraphicsAnchorLayout *layout = new QGraphicsAnchorLayout;
- layout->setSpacing(0);
-
- // setup the main widget
- QGraphicsWidget *widget = new QGraphicsWidget(nullptr, Qt::Window);
- QPalette p;
- p.setColor(QPalette::Window, Qt::black);
- widget->setPalette(p);
- widget->setPos(20, 20);
- widget->setLayout(layout);
-
- // vertical anchors
- QGraphicsAnchor *anchor = layout->addAnchor(title, Qt::AnchorTop, layout, Qt::AnchorTop);
- anchor = layout->addAnchor(place, Qt::AnchorTop, title, Qt::AnchorBottom);
- anchor->setSpacing(12);
- anchor = layout->addAnchor(place, Qt::AnchorBottom, layout, Qt::AnchorBottom);
- anchor->setSpacing(12);
-
- anchor = layout->addAnchor(sunnyWeather, Qt::AnchorTop, title, Qt::AnchorTop);
- anchor = layout->addAnchor(sunnyWeather, Qt::AnchorBottom, layout, Qt::AnchorVerticalCenter);
-
- anchor = layout->addAnchor(tabbar, Qt::AnchorTop, title, Qt::AnchorBottom);
- anchor->setSpacing(5);
- anchor = layout->addAnchor(details, Qt::AnchorTop, tabbar, Qt::AnchorBottom);
- anchor->setSpacing(2);
- anchor = layout->addAnchor(details, Qt::AnchorBottom, layout, Qt::AnchorBottom);
- anchor->setSpacing(12);
-
- // horizontal anchors
- anchor = layout->addAnchor(layout, Qt::AnchorLeft, title, Qt::AnchorLeft);
- anchor = layout->addAnchor(title, Qt::AnchorRight, layout, Qt::AnchorRight);
-
- anchor = layout->addAnchor(place, Qt::AnchorLeft, layout, Qt::AnchorLeft);
- anchor->setSpacing(15);
- anchor = layout->addAnchor(place, Qt::AnchorRight, details, Qt::AnchorLeft);
- anchor->setSpacing(35);
-
- anchor = layout->addAnchor(sunnyWeather, Qt::AnchorLeft, place, Qt::AnchorHorizontalCenter);
- anchor = layout->addAnchor(sunnyWeather, Qt::AnchorRight, layout, Qt::AnchorHorizontalCenter);
-
- anchor = layout->addAnchor(tabbar, Qt::AnchorHorizontalCenter, details, Qt::AnchorHorizontalCenter);
- anchor = layout->addAnchor(details, Qt::AnchorRight, layout, Qt::AnchorRight);
-
- // QGV setup
- scene.addItem(widget);
- scene.setBackgroundBrush(Qt::white);
- QGraphicsView *view = new QGraphicsView(&scene);
- view->show();
-
- return app.exec();
-}
-
-#include "main.moc"
diff --git a/examples/widgets/graphicsview/weatheranchorlayout/weatheranchorlayout.pro b/examples/widgets/graphicsview/weatheranchorlayout/weatheranchorlayout.pro
deleted file mode 100644
index db1c453cb4..0000000000
--- a/examples/widgets/graphicsview/weatheranchorlayout/weatheranchorlayout.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-QT += widgets
-
-SOURCES += main.cpp
-RESOURCES += weatheranchorlayout.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/graphicsview/weatheranchorlayout
-INSTALLS += target
diff --git a/examples/widgets/graphicsview/weatheranchorlayout/weatheranchorlayout.qrc b/examples/widgets/graphicsview/weatheranchorlayout/weatheranchorlayout.qrc
deleted file mode 100644
index e39f8c0423..0000000000
--- a/examples/widgets/graphicsview/weatheranchorlayout/weatheranchorlayout.qrc
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/5days.jpg</file>
- <file>images/title.jpg</file>
- <file>images/place.jpg</file>
- <file>images/tabbar.jpg</file>
- <file>images/details.jpg</file>
- <file>images/weather-few-clouds.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/itemviews/CMakeLists.txt b/examples/widgets/itemviews/CMakeLists.txt
index 04b50251e5..0c2912178f 100644
--- a/examples/widgets/itemviews/CMakeLists.txt
+++ b/examples/widgets/itemviews/CMakeLists.txt
@@ -1,28 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
qt_internal_add_example(addressbook)
qt_internal_add_example(basicsortfiltermodel)
-qt_internal_add_example(chart)
qt_internal_add_example(coloreditorfactory)
qt_internal_add_example(combowidgetmapper)
qt_internal_add_example(customsortfiltermodel)
-qt_internal_add_example(dirview)
qt_internal_add_example(editabletreemodel)
qt_internal_add_example(fetchmore)
-qt_internal_add_example(flattreeview)
qt_internal_add_example(frozencolumn)
-qt_internal_add_example(interview)
-qt_internal_add_example(pixelator)
-qt_internal_add_example(simpletreemodel)
-qt_internal_add_example(simplewidgetmapper)
-qt_internal_add_example(spinboxdelegate)
qt_internal_add_example(spreadsheet)
qt_internal_add_example(stardelegate)
-qt_internal_add_example(storageview)
-if(QT_FEATURE_draganddrop)
- qt_internal_add_example(puzzle)
-endif()
-if(TARGET Qt::Xml)
- qt_internal_add_example(simpledommodel)
-endif()
diff --git a/examples/widgets/itemviews/addressbook/CMakeLists.txt b/examples/widgets/itemviews/addressbook/CMakeLists.txt
index 3667570531..91e9cd03c9 100644
--- a/examples/widgets/itemviews/addressbook/CMakeLists.txt
+++ b/examples/widgets/itemviews/addressbook/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(addressbook LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/addressbook")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(addressbook
adddialog.cpp adddialog.h
addresswidget.cpp addresswidget.h
@@ -28,14 +22,21 @@ set_target_properties(addressbook PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(addressbook PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(addressbook PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS addressbook
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET addressbook
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/itemviews/addressbook/addresswidget.cpp b/examples/widgets/itemviews/addressbook/addresswidget.cpp
index 955a766750..bde1cdc334 100644
--- a/examples/widgets/itemviews/addressbook/addresswidget.cpp
+++ b/examples/widgets/itemviews/addressbook/addresswidget.cpp
@@ -146,7 +146,7 @@ void AddressWidget::setupTabs()
//! [1]
//! [7]
-void AddressWidget::readFromFile(const QString &fileName)
+void AddressWidget::readFromFile()
{
QFile file(fileName);
@@ -164,14 +164,14 @@ void AddressWidget::readFromFile(const QString &fileName)
QMessageBox::information(this, tr("No contacts in file"),
tr("The file you are attempting to open contains no contacts."));
} else {
- for (const auto &contact: qAsConst(contacts))
+ for (const auto &contact: std::as_const(contacts))
addEntry(contact.name, contact.address);
}
}
//! [7]
//! [6]
-void AddressWidget::writeToFile(const QString &fileName)
+void AddressWidget::writeToFile()
{
QFile file(fileName);
diff --git a/examples/widgets/itemviews/addressbook/addresswidget.h b/examples/widgets/itemviews/addressbook/addresswidget.h
index e9a910ef8f..c5c710286a 100644
--- a/examples/widgets/itemviews/addressbook/addresswidget.h
+++ b/examples/widgets/itemviews/addressbook/addresswidget.h
@@ -9,6 +9,7 @@
#include <QItemSelection>
#include <QTabWidget>
+#include <QStandardPaths>
QT_BEGIN_NAMESPACE
class QSortFilterProxyModel;
@@ -22,8 +23,8 @@ class AddressWidget : public QTabWidget
public:
AddressWidget(QWidget *parent = nullptr);
- void readFromFile(const QString &fileName);
- void writeToFile(const QString &fileName);
+ void readFromFile();
+ void writeToFile();
public slots:
void showAddEntryDialog();
@@ -37,6 +38,9 @@ signals:
private:
void setupTabs();
+ inline static QString fileName =
+ QStandardPaths::standardLocations(QStandardPaths::TempLocation).value(0)
+ + QStringLiteral("/addressbook.dat");
TableModel *table;
NewAddressTab *newAddressTab;
};
diff --git a/examples/widgets/itemviews/addressbook/mainwindow.cpp b/examples/widgets/itemviews/addressbook/mainwindow.cpp
index 6047047e9f..ce37b523f3 100644
--- a/examples/widgets/itemviews/addressbook/mainwindow.cpp
+++ b/examples/widgets/itemviews/addressbook/mainwindow.cpp
@@ -28,7 +28,7 @@ void MainWindow::createMenus()
connect(openAct, &QAction::triggered, this, &MainWindow::openFile);
//! [1a]
- QAction *saveAct = new QAction(tr("&Save As..."), this);
+ QAction *saveAct = new QAction(tr("&Save"), this);
fileMenu->addAction(saveAct);
connect(saveAct, &QAction::triggered, this, &MainWindow::saveFile);
@@ -66,18 +66,14 @@ void MainWindow::createMenus()
//! [2]
void MainWindow::openFile()
{
- QString fileName = QFileDialog::getOpenFileName(this);
- if (!fileName.isEmpty())
- addressWidget->readFromFile(fileName);
+ addressWidget->readFromFile();
}
//! [2]
//! [3]
void MainWindow::saveFile()
{
- QString fileName = QFileDialog::getSaveFileName(this);
- if (!fileName.isEmpty())
- addressWidget->writeToFile(fileName);
+ addressWidget->writeToFile();
}
//! [3]
diff --git a/examples/widgets/itemviews/basicsortfiltermodel/CMakeLists.txt b/examples/widgets/itemviews/basicsortfiltermodel/CMakeLists.txt
index de80b7b471..da15c4c196 100644
--- a/examples/widgets/itemviews/basicsortfiltermodel/CMakeLists.txt
+++ b/examples/widgets/itemviews/basicsortfiltermodel/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(basicsortfiltermodel LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/basicsortfiltermodel")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(basicsortfiltermodel
main.cpp
window.cpp window.h
@@ -24,14 +18,21 @@ set_target_properties(basicsortfiltermodel PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(basicsortfiltermodel PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(basicsortfiltermodel PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS basicsortfiltermodel
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET basicsortfiltermodel
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/itemviews/chart/CMakeLists.txt b/examples/widgets/itemviews/chart/CMakeLists.txt
deleted file mode 100644
index c52929b696..0000000000
--- a/examples/widgets/itemviews/chart/CMakeLists.txt
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(chart LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/chart")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(chart
- main.cpp
- mainwindow.cpp mainwindow.h
- pieview.cpp pieview.h
-)
-
-set_target_properties(chart PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(chart PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(chart_resource_files
- "qtdata.cht"
-)
-
-qt_add_resources(chart "chart"
- PREFIX
- "/Charts"
- FILES
- ${chart_resource_files}
-)
-
-if(UNIX AND NOT APPLE AND NOT HAIKU AND NOT INTEGRITY AND NOT VXWORKS)
- target_link_libraries(chart PUBLIC
- m
- )
-endif()
-
-install(TARGETS chart
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/itemviews/chart/chart.pro b/examples/widgets/itemviews/chart/chart.pro
deleted file mode 100644
index 323f6202e4..0000000000
--- a/examples/widgets/itemviews/chart/chart.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-QT += widgets
-requires(qtConfig(filedialog))
-
-HEADERS = mainwindow.h \
- pieview.h
-RESOURCES = chart.qrc
-SOURCES = main.cpp \
- mainwindow.cpp \
- pieview.cpp
-unix:!mac:!vxworks:!integrity:!haiku:LIBS += -lm
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/itemviews/chart
-INSTALLS += target
diff --git a/examples/widgets/itemviews/chart/chart.qrc b/examples/widgets/itemviews/chart/chart.qrc
deleted file mode 100644
index 7401d4d2f8..0000000000
--- a/examples/widgets/itemviews/chart/chart.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/Charts" >
- <file>qtdata.cht</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/itemviews/chart/main.cpp b/examples/widgets/itemviews/chart/main.cpp
deleted file mode 100644
index 14c3348099..0000000000
--- a/examples/widgets/itemviews/chart/main.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(chart);
-
- QApplication app(argc, argv);
- MainWindow window;
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/itemviews/chart/mainwindow.cpp b/examples/widgets/itemviews/chart/mainwindow.cpp
deleted file mode 100644
index 450f2e3a56..0000000000
--- a/examples/widgets/itemviews/chart/mainwindow.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "pieview.h"
-#include "mainwindow.h"
-
-#include <QtWidgets>
-
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
-{
- QMenu *fileMenu = new QMenu(tr("&File"), this);
- QAction *openAction = fileMenu->addAction(tr("&Open..."));
- openAction->setShortcuts(QKeySequence::Open);
- QAction *saveAction = fileMenu->addAction(tr("&Save As..."));
- saveAction->setShortcuts(QKeySequence::SaveAs);
- QAction *quitAction = fileMenu->addAction(tr("E&xit"));
- quitAction->setShortcuts(QKeySequence::Quit);
-
- setupModel();
- setupViews();
-
- connect(openAction, &QAction::triggered, this, &MainWindow::openFile);
- connect(saveAction, &QAction::triggered, this, &MainWindow::saveFile);
- connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
-
- menuBar()->addMenu(fileMenu);
- statusBar();
-
- loadFile(":/Charts/qtdata.cht");
-
- setWindowTitle(tr("Chart"));
- resize(870, 550);
-}
-
-void MainWindow::setupModel()
-{
- model = new QStandardItemModel(8, 2, this);
- model->setHeaderData(0, Qt::Horizontal, tr("Label"));
- model->setHeaderData(1, Qt::Horizontal, tr("Quantity"));
-}
-
-void MainWindow::setupViews()
-{
- QSplitter *splitter = new QSplitter;
- QTableView *table = new QTableView;
- pieChart = new PieView;
- splitter->addWidget(table);
- splitter->addWidget(pieChart);
- splitter->setStretchFactor(0, 0);
- splitter->setStretchFactor(1, 1);
-
- table->setModel(model);
- pieChart->setModel(model);
-
- QItemSelectionModel *selectionModel = new QItemSelectionModel(model);
- table->setSelectionModel(selectionModel);
- pieChart->setSelectionModel(selectionModel);
-
- QHeaderView *headerView = table->horizontalHeader();
- headerView->setStretchLastSection(true);
-
- setCentralWidget(splitter);
-}
-
-void MainWindow::openFile()
-{
- const QString fileName =
- QFileDialog::getOpenFileName(this, tr("Choose a data file"), "", "*.cht");
- if (!fileName.isEmpty())
- loadFile(fileName);
-}
-
-void MainWindow::loadFile(const QString &fileName)
-{
- QFile file(fileName);
- if (!file.open(QFile::ReadOnly | QFile::Text))
- return;
-
- QTextStream stream(&file);
-
- model->removeRows(0, model->rowCount(QModelIndex()), QModelIndex());
-
- int row = 0;
- while (!stream.atEnd()) {
- const QString line = stream.readLine();
- if (!line.isEmpty()) {
- model->insertRows(row, 1, QModelIndex());
-
- const QStringList pieces = line.split(QLatin1Char(','), Qt::SkipEmptyParts);
- if (pieces.size() < 3)
- continue;
- model->setData(model->index(row, 0, QModelIndex()),
- pieces.value(0));
- model->setData(model->index(row, 1, QModelIndex()),
- pieces.value(1));
- model->setData(model->index(row, 0, QModelIndex()),
- QColor(pieces.value(2)), Qt::DecorationRole);
- row++;
- }
- };
-
- file.close();
- statusBar()->showMessage(tr("Loaded %1").arg(fileName), 2000);
-}
-
-void MainWindow::saveFile()
-{
- QString fileName = QFileDialog::getSaveFileName(this,
- tr("Save file as"), "", "*.cht");
-
- if (fileName.isEmpty())
- return;
-
- QFile file(fileName);
- if (!file.open(QFile::WriteOnly | QFile::Text))
- return;
-
- QTextStream stream(&file);
- for (int row = 0; row < model->rowCount(QModelIndex()); ++row) {
-
- QStringList pieces;
-
- pieces.append(model->data(model->index(row, 0, QModelIndex()),
- Qt::DisplayRole).toString());
- pieces.append(model->data(model->index(row, 1, QModelIndex()),
- Qt::DisplayRole).toString());
- pieces.append(model->data(model->index(row, 0, QModelIndex()),
- Qt::DecorationRole).toString());
-
- stream << pieces.join(',') << "\n";
- }
-
- file.close();
- statusBar()->showMessage(tr("Saved %1").arg(fileName), 2000);
-}
diff --git a/examples/widgets/itemviews/chart/mainwindow.h b/examples/widgets/itemviews/chart/mainwindow.h
deleted file mode 100644
index f2a639c952..0000000000
--- a/examples/widgets/itemviews/chart/mainwindow.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QAbstractItemModel;
-class QAbstractItemView;
-QT_END_NAMESPACE
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow(QWidget *parent = nullptr);
-
-private slots:
- void openFile();
- void saveFile();
-
-private:
- void setupModel();
- void setupViews();
- void loadFile(const QString &path);
-
- QAbstractItemModel *model = nullptr;
- QAbstractItemView *pieChart = nullptr;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/widgets/itemviews/chart/pieview.cpp b/examples/widgets/itemviews/chart/pieview.cpp
deleted file mode 100644
index 0c3ce3bdb7..0000000000
--- a/examples/widgets/itemviews/chart/pieview.cpp
+++ /dev/null
@@ -1,510 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "pieview.h"
-
-#include <QtWidgets>
-
-PieView::PieView(QWidget *parent)
- : QAbstractItemView(parent)
-{
- horizontalScrollBar()->setRange(0, 0);
- verticalScrollBar()->setRange(0, 0);
-}
-
-void PieView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
- const QList<int> &roles)
-{
- QAbstractItemView::dataChanged(topLeft, bottomRight, roles);
-
- if (!roles.contains(Qt::DisplayRole))
- return;
-
- validItems = 0;
- totalValue = 0.0;
-
- for (int row = 0; row < model()->rowCount(rootIndex()); ++row) {
-
- QModelIndex index = model()->index(row, 1, rootIndex());
- double value = model()->data(index, Qt::DisplayRole).toDouble();
-
- if (value > 0.0) {
- totalValue += value;
- validItems++;
- }
- }
- viewport()->update();
-}
-
-bool PieView::edit(const QModelIndex &index, EditTrigger trigger, QEvent *event)
-{
- if (index.column() == 0)
- return QAbstractItemView::edit(index, trigger, event);
- else
- return false;
-}
-
-/*
- Returns the item that covers the coordinate given in the view.
-*/
-
-QModelIndex PieView::indexAt(const QPoint &point) const
-{
- if (validItems == 0)
- return QModelIndex();
-
- // Transform the view coordinates into contents widget coordinates.
- int wx = point.x() + horizontalScrollBar()->value();
- int wy = point.y() + verticalScrollBar()->value();
-
- if (wx < totalSize) {
- double cx = wx - totalSize / 2;
- double cy = totalSize / 2 - wy; // positive cy for items above the center
-
- // Determine the distance from the center point of the pie chart.
- double d = std::sqrt(std::pow(cx, 2) + std::pow(cy, 2));
-
- if (d == 0 || d > pieSize / 2)
- return QModelIndex();
-
- // Determine the angle of the point.
- double angle = qRadiansToDegrees(std::atan2(cy, cx));
- if (angle < 0)
- angle = 360 + angle;
-
- // Find the relevant slice of the pie.
- double startAngle = 0.0;
-
- for (int row = 0; row < model()->rowCount(rootIndex()); ++row) {
-
- QModelIndex index = model()->index(row, 1, rootIndex());
- double value = model()->data(index).toDouble();
-
- if (value > 0.0) {
- double sliceAngle = 360 * value / totalValue;
-
- if (angle >= startAngle && angle < (startAngle + sliceAngle))
- return model()->index(row, 1, rootIndex());
-
- startAngle += sliceAngle;
- }
- }
- } else {
- QStyleOptionViewItem option;
- initViewItemOption(&option);
- double itemHeight = QFontMetrics(option.font).height();
- int listItem = int((wy - margin) / itemHeight);
- int validRow = 0;
-
- for (int row = 0; row < model()->rowCount(rootIndex()); ++row) {
-
- QModelIndex index = model()->index(row, 1, rootIndex());
- if (model()->data(index).toDouble() > 0.0) {
-
- if (listItem == validRow)
- return model()->index(row, 0, rootIndex());
-
- // Update the list index that corresponds to the next valid row.
- ++validRow;
- }
- }
- }
-
- return QModelIndex();
-}
-
-bool PieView::isIndexHidden(const QModelIndex & /*index*/) const
-{
- return false;
-}
-
-/*
- Returns the rectangle of the item at position \a index in the
- model. The rectangle is in contents coordinates.
-*/
-
-QRect PieView::itemRect(const QModelIndex &index) const
-{
- if (!index.isValid())
- return QRect();
-
- // Check whether the index's row is in the list of rows represented
- // by slices.
- QModelIndex valueIndex;
-
- if (index.column() != 1)
- valueIndex = model()->index(index.row(), 1, rootIndex());
- else
- valueIndex = index;
-
- if (model()->data(valueIndex).toDouble() <= 0.0)
- return QRect();
-
- int listItem = 0;
- for (int row = index.row()-1; row >= 0; --row) {
- if (model()->data(model()->index(row, 1, rootIndex())).toDouble() > 0.0)
- listItem++;
- }
-
- switch (index.column()) {
- case 0: {
- QStyleOptionViewItem option;
- initViewItemOption(&option);
- const qreal itemHeight = QFontMetricsF(option.font).height();
- return QRect(totalSize,
- qRound(margin + listItem * itemHeight),
- totalSize - margin, qRound(itemHeight));
- }
- case 1:
- return viewport()->rect();
- }
- return QRect();
-}
-
-QRegion PieView::itemRegion(const QModelIndex &index) const
-{
- if (!index.isValid())
- return QRegion();
-
- if (index.column() != 1)
- return itemRect(index);
-
- if (model()->data(index).toDouble() <= 0.0)
- return QRegion();
-
- double startAngle = 0.0;
- for (int row = 0; row < model()->rowCount(rootIndex()); ++row) {
-
- QModelIndex sliceIndex = model()->index(row, 1, rootIndex());
- double value = model()->data(sliceIndex).toDouble();
-
- if (value > 0.0) {
- double angle = 360 * value / totalValue;
-
- if (sliceIndex == index) {
- QPainterPath slicePath;
- slicePath.moveTo(totalSize / 2, totalSize / 2);
- slicePath.arcTo(margin, margin, margin + pieSize, margin + pieSize,
- startAngle, angle);
- slicePath.closeSubpath();
-
- return QRegion(slicePath.toFillPolygon().toPolygon());
- }
-
- startAngle += angle;
- }
- }
-
- return QRegion();
-}
-
-int PieView::horizontalOffset() const
-{
- return horizontalScrollBar()->value();
-}
-
-void PieView::mousePressEvent(QMouseEvent *event)
-{
- QAbstractItemView::mousePressEvent(event);
- origin = event->position().toPoint();
- if (!rubberBand)
- rubberBand = new QRubberBand(QRubberBand::Rectangle, viewport());
- rubberBand->setGeometry(QRect(origin, QSize()));
- rubberBand->show();
-}
-
-void PieView::mouseMoveEvent(QMouseEvent *event)
-{
- if (rubberBand)
- rubberBand->setGeometry(QRect(origin, event->position().toPoint()).normalized());
- QAbstractItemView::mouseMoveEvent(event);
-}
-
-void PieView::mouseReleaseEvent(QMouseEvent *event)
-{
- QAbstractItemView::mouseReleaseEvent(event);
- if (rubberBand)
- rubberBand->hide();
- viewport()->update();
-}
-
-QModelIndex PieView::moveCursor(QAbstractItemView::CursorAction cursorAction,
- Qt::KeyboardModifiers /*modifiers*/)
-{
- QModelIndex current = currentIndex();
-
- switch (cursorAction) {
- case MoveLeft:
- case MoveUp:
- if (current.row() > 0)
- current = model()->index(current.row() - 1, current.column(),
- rootIndex());
- else
- current = model()->index(0, current.column(), rootIndex());
- break;
- case MoveRight:
- case MoveDown:
- if (current.row() < rows(current) - 1)
- current = model()->index(current.row() + 1, current.column(),
- rootIndex());
- else
- current = model()->index(rows(current) - 1, current.column(),
- rootIndex());
- break;
- default:
- break;
- }
-
- viewport()->update();
- return current;
-}
-
-void PieView::paintEvent(QPaintEvent *event)
-{
- QItemSelectionModel *selections = selectionModel();
- QStyleOptionViewItem option;
- initViewItemOption(&option);
-
- QBrush background = option.palette.base();
- QPen foreground(option.palette.color(QPalette::WindowText));
-
- QPainter painter(viewport());
- painter.setRenderHint(QPainter::Antialiasing);
-
- painter.fillRect(event->rect(), background);
- painter.setPen(foreground);
-
- // Viewport rectangles
- QRect pieRect = QRect(margin, margin, pieSize, pieSize);
-
- if (validItems <= 0)
- return;
-
- painter.save();
- painter.translate(pieRect.x() - horizontalScrollBar()->value(),
- pieRect.y() - verticalScrollBar()->value());
- painter.drawEllipse(0, 0, pieSize, pieSize);
- double startAngle = 0.0;
- int row;
-
- for (row = 0; row < model()->rowCount(rootIndex()); ++row) {
- QModelIndex index = model()->index(row, 1, rootIndex());
- double value = model()->data(index).toDouble();
-
- if (value > 0.0) {
- double angle = 360 * value / totalValue;
-
- QModelIndex colorIndex = model()->index(row, 0, rootIndex());
- QColor color = QColor(model()->data(colorIndex, Qt::DecorationRole).toString());
-
- if (currentIndex() == index)
- painter.setBrush(QBrush(color, Qt::Dense4Pattern));
- else if (selections->isSelected(index))
- painter.setBrush(QBrush(color, Qt::Dense3Pattern));
- else
- painter.setBrush(QBrush(color));
-
- painter.drawPie(0, 0, pieSize, pieSize, int(startAngle*16), int(angle*16));
-
- startAngle += angle;
- }
- }
- painter.restore();
-
- int keyNumber = 0;
-
- for (row = 0; row < model()->rowCount(rootIndex()); ++row) {
- QModelIndex index = model()->index(row, 1, rootIndex());
- double value = model()->data(index).toDouble();
-
- if (value > 0.0) {
- QModelIndex labelIndex = model()->index(row, 0, rootIndex());
-
- QStyleOptionViewItem option;
- initViewItemOption(&option);
-
- option.rect = visualRect(labelIndex);
- if (selections->isSelected(labelIndex))
- option.state |= QStyle::State_Selected;
- if (currentIndex() == labelIndex)
- option.state |= QStyle::State_HasFocus;
- itemDelegate()->paint(&painter, option, labelIndex);
-
- ++keyNumber;
- }
- }
-}
-
-void PieView::resizeEvent(QResizeEvent * /* event */)
-{
- updateGeometries();
-}
-
-int PieView::rows(const QModelIndex &index) const
-{
- return model()->rowCount(model()->parent(index));
-}
-
-void PieView::rowsInserted(const QModelIndex &parent, int start, int end)
-{
- for (int row = start; row <= end; ++row) {
- QModelIndex index = model()->index(row, 1, rootIndex());
- double value = model()->data(index).toDouble();
-
- if (value > 0.0) {
- totalValue += value;
- ++validItems;
- }
- }
-
- QAbstractItemView::rowsInserted(parent, start, end);
-}
-
-void PieView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
-{
- for (int row = start; row <= end; ++row) {
- QModelIndex index = model()->index(row, 1, rootIndex());
- double value = model()->data(index).toDouble();
- if (value > 0.0) {
- totalValue -= value;
- --validItems;
- }
- }
-
- QAbstractItemView::rowsAboutToBeRemoved(parent, start, end);
-}
-
-void PieView::scrollContentsBy(int dx, int dy)
-{
- viewport()->scroll(dx, dy);
-}
-
-void PieView::scrollTo(const QModelIndex &index, ScrollHint)
-{
- QRect area = viewport()->rect();
- QRect rect = visualRect(index);
-
- if (rect.left() < area.left()) {
- horizontalScrollBar()->setValue(
- horizontalScrollBar()->value() + rect.left() - area.left());
- } else if (rect.right() > area.right()) {
- horizontalScrollBar()->setValue(
- horizontalScrollBar()->value() + qMin(
- rect.right() - area.right(), rect.left() - area.left()));
- }
-
- if (rect.top() < area.top()) {
- verticalScrollBar()->setValue(
- verticalScrollBar()->value() + rect.top() - area.top());
- } else if (rect.bottom() > area.bottom()) {
- verticalScrollBar()->setValue(
- verticalScrollBar()->value() + qMin(
- rect.bottom() - area.bottom(), rect.top() - area.top()));
- }
-
- update();
-}
-
-/*
- Find the indices corresponding to the extent of the selection.
-*/
-
-void PieView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)
-{
- // Use content widget coordinates because we will use the itemRegion()
- // function to check for intersections.
-
- QRect contentsRect = rect.translated(
- horizontalScrollBar()->value(),
- verticalScrollBar()->value()).normalized();
-
- int rows = model()->rowCount(rootIndex());
- int columns = model()->columnCount(rootIndex());
- QModelIndexList indexes;
-
- for (int row = 0; row < rows; ++row) {
- for (int column = 0; column < columns; ++column) {
- QModelIndex index = model()->index(row, column, rootIndex());
- QRegion region = itemRegion(index);
- if (region.intersects(contentsRect))
- indexes.append(index);
- }
- }
-
- if (indexes.size() > 0) {
- int firstRow = indexes.at(0).row();
- int lastRow = firstRow;
- int firstColumn = indexes.at(0).column();
- int lastColumn = firstColumn;
-
- for (int i = 1; i < indexes.size(); ++i) {
- firstRow = qMin(firstRow, indexes.at(i).row());
- lastRow = qMax(lastRow, indexes.at(i).row());
- firstColumn = qMin(firstColumn, indexes.at(i).column());
- lastColumn = qMax(lastColumn, indexes.at(i).column());
- }
-
- QItemSelection selection(
- model()->index(firstRow, firstColumn, rootIndex()),
- model()->index(lastRow, lastColumn, rootIndex()));
- selectionModel()->select(selection, command);
- } else {
- QModelIndex noIndex;
- QItemSelection selection(noIndex, noIndex);
- selectionModel()->select(selection, command);
- }
-
- update();
-}
-
-void PieView::updateGeometries()
-{
- horizontalScrollBar()->setPageStep(viewport()->width());
- horizontalScrollBar()->setRange(0, qMax(0, 2 * totalSize - viewport()->width()));
- verticalScrollBar()->setPageStep(viewport()->height());
- verticalScrollBar()->setRange(0, qMax(0, totalSize - viewport()->height()));
-}
-
-int PieView::verticalOffset() const
-{
- return verticalScrollBar()->value();
-}
-
-/*
- Returns the position of the item in viewport coordinates.
-*/
-
-QRect PieView::visualRect(const QModelIndex &index) const
-{
- QRect rect = itemRect(index);
- if (!rect.isValid())
- return rect;
-
- return QRect(rect.left() - horizontalScrollBar()->value(),
- rect.top() - verticalScrollBar()->value(),
- rect.width(), rect.height());
-}
-
-/*
- Returns a region corresponding to the selection in viewport coordinates.
-*/
-
-QRegion PieView::visualRegionForSelection(const QItemSelection &selection) const
-{
- int ranges = selection.count();
-
- if (ranges == 0)
- return QRect();
-
- QRegion region;
- for (int i = 0; i < ranges; ++i) {
- const QItemSelectionRange &range = selection.at(i);
- for (int row = range.top(); row <= range.bottom(); ++row) {
- for (int col = range.left(); col <= range.right(); ++col) {
- QModelIndex index = model()->index(row, col, rootIndex());
- region += visualRect(index);
- }
- }
- }
- return region;
-}
diff --git a/examples/widgets/itemviews/chart/pieview.h b/examples/widgets/itemviews/chart/pieview.h
deleted file mode 100644
index 19c4a18ed0..0000000000
--- a/examples/widgets/itemviews/chart/pieview.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef PIEVIEW_H
-#define PIEVIEW_H
-
-#include <QAbstractItemView>
-
-//! [0]
-class PieView : public QAbstractItemView
-{
- Q_OBJECT
-
-public:
- PieView(QWidget *parent = nullptr);
-
- QRect visualRect(const QModelIndex &index) const override;
- void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
- QModelIndex indexAt(const QPoint &point) const override;
-
-protected slots:
- void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
- const QList<int> &roles = QList<int>()) override;
- void rowsInserted(const QModelIndex &parent, int start, int end) override;
- void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override;
-
-protected:
- bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event) override;
- QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction,
- Qt::KeyboardModifiers modifiers) override;
-
- int horizontalOffset() const override;
- int verticalOffset() const override;
-
- bool isIndexHidden(const QModelIndex &index) const override;
-
- void setSelection(const QRect&, QItemSelectionModel::SelectionFlags command) override;
-
- void mousePressEvent(QMouseEvent *event) override;
-
- void mouseMoveEvent(QMouseEvent *event) override;
- void mouseReleaseEvent(QMouseEvent *event) override;
-
- void paintEvent(QPaintEvent *event) override;
- void resizeEvent(QResizeEvent *event) override;
- void scrollContentsBy(int dx, int dy) override;
-
- QRegion visualRegionForSelection(const QItemSelection &selection) const override;
-
-private:
- QRect itemRect(const QModelIndex &item) const;
- QRegion itemRegion(const QModelIndex &index) const;
- int rows(const QModelIndex &index = QModelIndex()) const;
- void updateGeometries() override;
-
- int margin = 0;
- int totalSize = 300;
- int pieSize = totalSize - 2 * margin;
- int validItems = 0;
- double totalValue = 0.0;
- QRubberBand *rubberBand = nullptr;
- QPoint origin;
-};
-//! [0]
-
-#endif // PIEVIEW_H
diff --git a/examples/widgets/itemviews/chart/qtdata.cht b/examples/widgets/itemviews/chart/qtdata.cht
deleted file mode 100644
index 6386246c4b..0000000000
--- a/examples/widgets/itemviews/chart/qtdata.cht
+++ /dev/null
@@ -1,14 +0,0 @@
-Scientific Research,21,#99e600
-Engineering & Design,18,#99cc00
-Automotive,14,#99b300
-Aerospace,13,#9f991a
-Automation & Machine Tools,13,#a48033
-Medical & Bioinformatics,13,#a9664d
-Imaging & Special Effects,12,#ae4d66
-Defense,11,#b33380
-Test & Measurement Systems,9,#a64086
-Oil & Gas,9,#994d8d
-Entertainment & Broadcasting,7,#8d5a93
-Financial,6,#806699
-Consumer Electronics,4,#8073a6
-Other,38,#8080b3
diff --git a/examples/widgets/itemviews/coloreditorfactory/CMakeLists.txt b/examples/widgets/itemviews/coloreditorfactory/CMakeLists.txt
index 6df6bc51fb..5dbc780027 100644
--- a/examples/widgets/itemviews/coloreditorfactory/CMakeLists.txt
+++ b/examples/widgets/itemviews/coloreditorfactory/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(coloreditorfactory LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/coloreditorfactory")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(coloreditorfactory
colorlisteditor.cpp colorlisteditor.h
main.cpp
@@ -25,14 +19,21 @@ set_target_properties(coloreditorfactory PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(coloreditorfactory PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(coloreditorfactory PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS coloreditorfactory
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET coloreditorfactory
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/itemviews/combowidgetmapper/CMakeLists.txt b/examples/widgets/itemviews/combowidgetmapper/CMakeLists.txt
index a6c352d568..f95031b260 100644
--- a/examples/widgets/itemviews/combowidgetmapper/CMakeLists.txt
+++ b/examples/widgets/itemviews/combowidgetmapper/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(combowidgetmapper LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/combowidgetmapper")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(combowidgetmapper
main.cpp
window.cpp window.h
@@ -24,14 +18,21 @@ set_target_properties(combowidgetmapper PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(combowidgetmapper PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(combowidgetmapper PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS combowidgetmapper
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET combowidgetmapper
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/itemviews/customsortfiltermodel/CMakeLists.txt b/examples/widgets/itemviews/customsortfiltermodel/CMakeLists.txt
index f9aa2a1bbf..a1b2c41cf6 100644
--- a/examples/widgets/itemviews/customsortfiltermodel/CMakeLists.txt
+++ b/examples/widgets/itemviews/customsortfiltermodel/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(customsortfiltermodel LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/customsortfiltermodel")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(customsortfiltermodel
filterwidget.cpp filterwidget.h
main.cpp
@@ -26,10 +20,10 @@ set_target_properties(customsortfiltermodel PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(customsortfiltermodel PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(customsortfiltermodel PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -45,7 +39,14 @@ qt_add_resources(customsortfiltermodel "customsortfiltermodel"
)
install(TARGETS customsortfiltermodel
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET customsortfiltermodel
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/itemviews/dirview/CMakeLists.txt b/examples/widgets/itemviews/dirview/CMakeLists.txt
deleted file mode 100644
index 9754bff9a4..0000000000
--- a/examples/widgets/itemviews/dirview/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(dirview LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/dirview")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(dirview
- main.cpp
-)
-
-set_target_properties(dirview PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(dirview PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS dirview
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/itemviews/dirview/dirview.pro b/examples/widgets/itemviews/dirview/dirview.pro
deleted file mode 100644
index 981a64a7d6..0000000000
--- a/examples/widgets/itemviews/dirview/dirview.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-QT += widgets
-requires(qtConfig(treeview))
-
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/itemviews/dirview
-INSTALLS += target
diff --git a/examples/widgets/itemviews/dirview/main.cpp b/examples/widgets/itemviews/dirview/main.cpp
deleted file mode 100644
index 5db9338b67..0000000000
--- a/examples/widgets/itemviews/dirview/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-#include <QFileSystemModel>
-#include <QFileIconProvider>
-#include <QScreen>
-#include <QScroller>
-#include <QTreeView>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription("Qt Dir View Example");
- parser.addHelpOption();
- parser.addVersionOption();
- QCommandLineOption dontUseCustomDirectoryIconsOption("c", "Set QFileSystemModel::DontUseCustomDirectoryIcons");
- parser.addOption(dontUseCustomDirectoryIconsOption);
- QCommandLineOption dontWatchOption("w", "Set QFileSystemModel::DontWatch");
- parser.addOption(dontWatchOption);
- parser.addPositionalArgument("directory", "The directory to start in.");
- parser.process(app);
- const QString rootPath = parser.positionalArguments().isEmpty()
- ? QString() : parser.positionalArguments().first();
-
- QFileSystemModel model;
- QFileIconProvider iconProvider;
- model.setIconProvider(&iconProvider);
- model.setRootPath("");
- if (parser.isSet(dontUseCustomDirectoryIconsOption))
- model.setOption(QFileSystemModel::DontUseCustomDirectoryIcons);
- if (parser.isSet(dontWatchOption))
- model.setOption(QFileSystemModel::DontWatchForChanges);
- QTreeView tree;
- tree.setModel(&model);
- if (!rootPath.isEmpty()) {
- const QModelIndex rootIndex = model.index(QDir::cleanPath(rootPath));
- if (rootIndex.isValid())
- tree.setRootIndex(rootIndex);
- }
-
- // Demonstrating look and feel features
- tree.setAnimated(false);
- tree.setIndentation(20);
- tree.setSortingEnabled(true);
- const QSize availableSize = tree.screen()->availableGeometry().size();
- tree.resize(availableSize / 2);
- tree.setColumnWidth(0, tree.width() / 3);
-
- // Make it flickable on touchscreens
- QScroller::grabGesture(&tree, QScroller::TouchGesture);
-
- tree.setWindowTitle(QObject::tr("Dir View"));
- tree.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/itemviews/editabletreemodel/CMakeLists.txt b/examples/widgets/itemviews/editabletreemodel/CMakeLists.txt
index 8d372dbe73..e255cdbc63 100644
--- a/examples/widgets/itemviews/editabletreemodel/CMakeLists.txt
+++ b/examples/widgets/itemviews/editabletreemodel/CMakeLists.txt
@@ -1,19 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(editabletreemodel LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Test Widgets)
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/editabletreemodel")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
qt_add_executable(editabletreemodel
main.cpp
@@ -27,10 +20,10 @@ set_target_properties(editabletreemodel PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(editabletreemodel PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(editabletreemodel PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -46,7 +39,46 @@ qt_add_resources(editabletreemodel "editabletreemodel"
)
install(TARGETS editabletreemodel
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET editabletreemodel
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
+
+#! [1]
+# Unit Test
+
+include(CTest)
+
+qt_add_executable(editabletreemodel_tester
+ test.cpp
+ treeitem.cpp treeitem.h
+ treemodel.cpp treemodel.h)
+
+target_link_libraries(editabletreemodel_tester PRIVATE
+ Qt6::Core
+ Qt6::Test
+)
+
+if(ANDROID)
+ target_link_libraries(editabletreemodel_tester PRIVATE
+ Qt6::Gui
+ )
+endif()
+
+qt_add_resources(editabletreemodel_tester "editabletreemodel_tester"
+ PREFIX
+ "/"
+ FILES
+ ${editabletreemodel_resource_files}
)
+
+add_test(NAME editabletreemodel_tester
+ COMMAND editabletreemodel_tester)
+#! [1]
diff --git a/examples/widgets/itemviews/editabletreemodel/main.cpp b/examples/widgets/itemviews/editabletreemodel/main.cpp
index b7e7b3de1c..7ed4cf1dc4 100644
--- a/examples/widgets/itemviews/editabletreemodel/main.cpp
+++ b/examples/widgets/itemviews/editabletreemodel/main.cpp
@@ -4,13 +4,14 @@
#include "mainwindow.h"
#include <QApplication>
+#include <QScreen>
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(editabletreemodel);
-
QApplication app(argc, argv);
MainWindow window;
+ const auto screenSize = window.screen()->availableSize();
+ window.resize({screenSize.width() / 2, screenSize.height() * 2 / 3});
window.show();
- return app.exec();
+ return QCoreApplication::exec();
}
diff --git a/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp b/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp
index fa7b31746a..cf88932cdb 100644
--- a/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp
+++ b/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp
@@ -6,6 +6,8 @@
#include <QFile>
+using namespace Qt::StringLiterals;
+
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
@@ -13,14 +15,15 @@ MainWindow::MainWindow(QWidget *parent)
const QStringList headers({tr("Title"), tr("Description")});
- QFile file(":/default.txt");
- file.open(QIODevice::ReadOnly);
- TreeModel *model = new TreeModel(headers, file.readAll(), this);
+ QFile file(":/default.txt"_L1);
+ file.open(QIODevice::ReadOnly | QIODevice::Text);
+ auto *model = new TreeModel(headers, QString::fromUtf8(file.readAll()), this);
file.close();
view->setModel(model);
for (int column = 0; column < model->columnCount(); ++column)
view->resizeColumnToContents(column);
+ view->expandAll();
connect(exitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
diff --git a/examples/widgets/itemviews/editabletreemodel/test.cpp b/examples/widgets/itemviews/editabletreemodel/test.cpp
new file mode 100644
index 0000000000..c041fe9402
--- /dev/null
+++ b/examples/widgets/itemviews/editabletreemodel/test.cpp
@@ -0,0 +1,37 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "treemodel.h"
+
+#include <QAbstractItemModelTester>
+#include <QObject>
+#include <QTest>
+
+using namespace Qt::StringLiterals;
+
+//! [1]
+class TestEditableTreeModel : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testTreeModel();
+};
+
+void TestEditableTreeModel::testTreeModel()
+{
+ constexpr auto fileName = ":/default.txt"_L1;
+ QFile file(fileName);
+ QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Text),
+ qPrintable(fileName + " cannot be opened: "_L1 + file.errorString()));
+
+ const QStringList headers{"column1"_L1, "column2"_L1};
+ TreeModel model(headers, QString::fromUtf8(file.readAll()));
+
+ QAbstractItemModelTester tester(&model);
+}
+
+QTEST_APPLESS_MAIN(TestEditableTreeModel)
+
+#include "test.moc"
+//! [1]
diff --git a/examples/widgets/itemviews/editabletreemodel/treeitem.cpp b/examples/widgets/itemviews/editabletreemodel/treeitem.cpp
index 5784202b93..42d911823d 100644
--- a/examples/widgets/itemviews/editabletreemodel/treeitem.cpp
+++ b/examples/widgets/itemviews/editabletreemodel/treeitem.cpp
@@ -10,76 +10,74 @@
#include "treeitem.h"
//! [0]
-TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent)
- : itemData(data), parentItem(parent)
+TreeItem::TreeItem(QVariantList data, TreeItem *parent)
+ : itemData(std::move(data)), m_parentItem(parent)
{}
//! [0]
//! [1]
-TreeItem::~TreeItem()
+TreeItem *TreeItem::child(int number)
{
- qDeleteAll(childItems);
+ return (number >= 0 && number < childCount())
+ ? m_childItems.at(number).get() : nullptr;
}
//! [1]
//! [2]
-TreeItem *TreeItem::child(int number)
+int TreeItem::childCount() const
{
- if (number < 0 || number >= childItems.size())
- return nullptr;
- return childItems.at(number);
+ return int(m_childItems.size());
}
//! [2]
//! [3]
-int TreeItem::childCount() const
+int TreeItem::row() const
{
- return childItems.count();
+ if (!m_parentItem)
+ return 0;
+ const auto it = std::find_if(m_parentItem->m_childItems.cbegin(), m_parentItem->m_childItems.cend(),
+ [this](const std::unique_ptr<TreeItem> &treeItem) {
+ return treeItem.get() == this;
+ });
+
+ if (it != m_parentItem->m_childItems.cend())
+ return std::distance(m_parentItem->m_childItems.cbegin(), it);
+ Q_ASSERT(false); // should not happen
+ return -1;
}
//! [3]
//! [4]
-int TreeItem::childNumber() const
+int TreeItem::columnCount() const
{
- if (parentItem)
- return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
- return 0;
+ return int(itemData.count());
}
//! [4]
//! [5]
-int TreeItem::columnCount() const
+QVariant TreeItem::data(int column) const
{
- return itemData.count();
+ return itemData.value(column);
}
//! [5]
//! [6]
-QVariant TreeItem::data(int column) const
-{
- if (column < 0 || column >= itemData.size())
- return QVariant();
- return itemData.at(column);
-}
-//! [6]
-
-//! [7]
bool TreeItem::insertChildren(int position, int count, int columns)
{
- if (position < 0 || position > childItems.size())
+ if (position < 0 || position > qsizetype(m_childItems.size()))
return false;
for (int row = 0; row < count; ++row) {
- QList<QVariant> data(columns);
- TreeItem *item = new TreeItem(data, this);
- childItems.insert(position, item);
+ QVariantList data(columns);
+ m_childItems.insert(m_childItems.cbegin() + position,
+ std::make_unique<TreeItem>(data, this));
}
return true;
}
-//! [7]
+//! [6]
-//! [8]
+//! [7]
bool TreeItem::insertColumns(int position, int columns)
{
if (position < 0 || position > itemData.size())
@@ -88,32 +86,32 @@ bool TreeItem::insertColumns(int position, int columns)
for (int column = 0; column < columns; ++column)
itemData.insert(position, QVariant());
- for (TreeItem *child : qAsConst(childItems))
+ for (auto &child : std::as_const(m_childItems))
child->insertColumns(position, columns);
return true;
}
-//! [8]
+//! [7]
-//! [9]
+//! [8]
TreeItem *TreeItem::parent()
{
- return parentItem;
+ return m_parentItem;
}
-//! [9]
+//! [8]
-//! [10]
+//! [9]
bool TreeItem::removeChildren(int position, int count)
{
- if (position < 0 || position + count > childItems.size())
+ if (position < 0 || position + count > qsizetype(m_childItems.size()))
return false;
for (int row = 0; row < count; ++row)
- delete childItems.takeAt(position);
+ m_childItems.erase(m_childItems.cbegin() + position);
return true;
}
-//! [10]
+//! [9]
bool TreeItem::removeColumns(int position, int columns)
{
@@ -123,13 +121,13 @@ bool TreeItem::removeColumns(int position, int columns)
for (int column = 0; column < columns; ++column)
itemData.remove(position);
- for (TreeItem *child : qAsConst(childItems))
+ for (auto &child : std::as_const(m_childItems))
child->removeColumns(position, columns);
return true;
}
-//! [11]
+//! [10]
bool TreeItem::setData(int column, const QVariant &value)
{
if (column < 0 || column >= itemData.size())
@@ -138,4 +136,4 @@ bool TreeItem::setData(int column, const QVariant &value)
itemData[column] = value;
return true;
}
-//! [11]
+//! [10]
diff --git a/examples/widgets/itemviews/editabletreemodel/treeitem.h b/examples/widgets/itemviews/editabletreemodel/treeitem.h
index cbc818c081..8910312ade 100644
--- a/examples/widgets/itemviews/editabletreemodel/treeitem.h
+++ b/examples/widgets/itemviews/editabletreemodel/treeitem.h
@@ -11,8 +11,7 @@
class TreeItem
{
public:
- explicit TreeItem(const QList<QVariant> &data, TreeItem *parent = nullptr);
- ~TreeItem();
+ explicit TreeItem(QVariantList data, TreeItem *parent = nullptr);
TreeItem *child(int number);
int childCount() const;
@@ -23,13 +22,13 @@ public:
TreeItem *parent();
bool removeChildren(int position, int count);
bool removeColumns(int position, int columns);
- int childNumber() const;
+ int row() const;
bool setData(int column, const QVariant &value);
private:
- QList<TreeItem *> childItems;
- QList<QVariant> itemData;
- TreeItem *parentItem;
+ std::vector<std::unique_ptr<TreeItem>> m_childItems;
+ QVariantList itemData;
+ TreeItem *m_parentItem;
};
//! [0]
diff --git a/examples/widgets/itemviews/editabletreemodel/treemodel.cpp b/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
index 290ec186a8..6511b06780 100644
--- a/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
+++ b/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
@@ -4,26 +4,23 @@
#include "treemodel.h"
#include "treeitem.h"
-#include <QtWidgets>
+using namespace Qt::StringLiterals;
//! [0]
TreeModel::TreeModel(const QStringList &headers, const QString &data, QObject *parent)
: QAbstractItemModel(parent)
{
- QList<QVariant> rootData;
+ QVariantList rootData;
for (const QString &header : headers)
rootData << header;
- rootItem = new TreeItem(rootData);
- setupModelData(data.split('\n'), rootItem);
+ rootItem = std::make_unique<TreeItem>(rootData);
+ setupModelData(QStringView{data}.split(u'\n'));
}
//! [0]
//! [1]
-TreeModel::~TreeModel()
-{
- delete rootItem;
-}
+TreeModel::~TreeModel() = default;
//! [1]
//! [2]
@@ -37,10 +34,10 @@ int TreeModel::columnCount(const QModelIndex &parent) const
QVariant TreeModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
- return QVariant();
+ return {};
if (role != Qt::DisplayRole && role != Qt::EditRole)
- return QVariant();
+ return {};
TreeItem *item = getItem(index);
@@ -61,39 +58,35 @@ Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
TreeItem *TreeModel::getItem(const QModelIndex &index) const
{
if (index.isValid()) {
- TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
- if (item)
+ if (auto *item = static_cast<TreeItem*>(index.internalPointer()))
return item;
}
- return rootItem;
+ return rootItem.get();
}
//! [4]
QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
- if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
- return rootItem->data(section);
-
- return QVariant();
+ return (orientation == Qt::Horizontal && role == Qt::DisplayRole)
+ ? rootItem->data(section) : QVariant{};
}
//! [5]
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const
{
if (parent.isValid() && parent.column() != 0)
- return QModelIndex();
+ return {};
//! [5]
//! [6]
TreeItem *parentItem = getItem(parent);
if (!parentItem)
- return QModelIndex();
+ return {};
- TreeItem *childItem = parentItem->child(row);
- if (childItem)
+ if (auto *childItem = parentItem->child(row))
return createIndex(row, column, childItem);
- return QModelIndex();
+ return {};
}
//! [6]
@@ -125,15 +118,13 @@ bool TreeModel::insertRows(int position, int rows, const QModelIndex &parent)
QModelIndex TreeModel::parent(const QModelIndex &index) const
{
if (!index.isValid())
- return QModelIndex();
+ return {};
TreeItem *childItem = getItem(index);
TreeItem *parentItem = childItem ? childItem->parent() : nullptr;
- if (parentItem == rootItem || !parentItem)
- return QModelIndex();
-
- return createIndex(parentItem->childNumber(), 0, parentItem);
+ return (parentItem != rootItem.get() && parentItem != nullptr)
+ ? createIndex(parentItem->row(), 0, parentItem) : QModelIndex{};
}
//! [7]
@@ -202,55 +193,46 @@ bool TreeModel::setHeaderData(int section, Qt::Orientation orientation,
return result;
}
-void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
+void TreeModel::setupModelData(const QList<QStringView> &lines)
{
- QList<TreeItem *> parents;
- QList<int> indentations;
- parents << parent;
- indentations << 0;
-
- int number = 0;
-
- while (number < lines.count()) {
- int position = 0;
- while (position < lines[number].length()) {
- if (lines[number].at(position) != ' ')
- break;
- ++position;
- }
+ struct ParentIndentation
+ {
+ TreeItem *parent;
+ qsizetype indentation;
+ };
- const QString lineData = lines[number].mid(position).trimmed();
+ QList<ParentIndentation> state{{rootItem.get(), 0}};
+ for (const auto &line : lines) {
+ qsizetype position = 0;
+ for ( ; position < line.length() && line.at(position).isSpace(); ++position) {
+ }
+
+ const QStringView lineData = line.sliced(position).trimmed();
if (!lineData.isEmpty()) {
// Read the column data from the rest of the line.
- const QStringList columnStrings =
- lineData.split(QLatin1Char('\t'), Qt::SkipEmptyParts);
- QList<QVariant> columnData;
- columnData.reserve(columnStrings.size());
- for (const QString &columnString : columnStrings)
- columnData << columnString;
-
- if (position > indentations.last()) {
+ const auto columnStrings = lineData.split(u'\t', Qt::SkipEmptyParts);
+ QVariantList columnData;
+ columnData.reserve(columnStrings.count());
+ for (const auto &columnString : columnStrings)
+ columnData << columnString.toString();
+
+ if (position > state.constLast().indentation) {
// The last child of the current parent is now the new parent
// unless the current parent has no children.
-
- if (parents.last()->childCount() > 0) {
- parents << parents.last()->child(parents.last()->childCount()-1);
- indentations << position;
- }
+ auto *lastParent = state.constLast().parent;
+ if (lastParent->childCount() > 0)
+ state.append({lastParent->child(lastParent->childCount() - 1), position});
} else {
- while (position < indentations.last() && parents.count() > 0) {
- parents.pop_back();
- indentations.pop_back();
- }
+ while (position < state.constLast().indentation && !state.isEmpty())
+ state.removeLast();
}
// Append a new item to the current parent's list of children.
- TreeItem *parent = parents.last();
+ auto *parent = state.constLast().parent;
parent->insertChildren(parent->childCount(), 1, rootItem->columnCount());
for (int column = 0; column < columnData.size(); ++column)
- parent->child(parent->childCount() - 1)->setData(column, columnData[column]);
+ parent->child(parent->childCount() - 1)->setData(column, columnData.at(column));
}
- ++number;
}
}
diff --git a/examples/widgets/itemviews/editabletreemodel/treemodel.h b/examples/widgets/itemviews/editabletreemodel/treemodel.h
index 1482846c29..4f781c8144 100644
--- a/examples/widgets/itemviews/editabletreemodel/treemodel.h
+++ b/examples/widgets/itemviews/editabletreemodel/treemodel.h
@@ -16,9 +16,11 @@ class TreeModel : public QAbstractItemModel
Q_OBJECT
public:
+ Q_DISABLE_COPY_MOVE(TreeModel)
+
TreeModel(const QStringList &headers, const QString &data,
QObject *parent = nullptr);
- ~TreeModel();
+ ~TreeModel() override;
//! [0] //! [1]
QVariant data(const QModelIndex &index, int role) const override;
@@ -26,11 +28,11 @@ public:
int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column,
- const QModelIndex &parent = QModelIndex()) const override;
+ const QModelIndex &parent = {}) const override;
QModelIndex parent(const QModelIndex &index) const override;
- int rowCount(const QModelIndex &parent = QModelIndex()) const override;
- int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ int rowCount(const QModelIndex &parent = {}) const override;
+ int columnCount(const QModelIndex &parent = {}) const override;
//! [1]
//! [2]
@@ -41,19 +43,19 @@ public:
const QVariant &value, int role = Qt::EditRole) override;
bool insertColumns(int position, int columns,
- const QModelIndex &parent = QModelIndex()) override;
+ const QModelIndex &parent = {}) override;
bool removeColumns(int position, int columns,
- const QModelIndex &parent = QModelIndex()) override;
+ const QModelIndex &parent = {}) override;
bool insertRows(int position, int rows,
- const QModelIndex &parent = QModelIndex()) override;
+ const QModelIndex &parent = {}) override;
bool removeRows(int position, int rows,
- const QModelIndex &parent = QModelIndex()) override;
+ const QModelIndex &parent = {}) override;
private:
- void setupModelData(const QStringList &lines, TreeItem *parent);
+ void setupModelData(const QList<QStringView> &lines);
TreeItem *getItem(const QModelIndex &index) const;
- TreeItem *rootItem;
+ std::unique_ptr<TreeItem> rootItem;
};
//! [2]
diff --git a/examples/widgets/itemviews/fetchmore/CMakeLists.txt b/examples/widgets/itemviews/fetchmore/CMakeLists.txt
index 2abc71fc1e..856b0cc3ba 100644
--- a/examples/widgets/itemviews/fetchmore/CMakeLists.txt
+++ b/examples/widgets/itemviews/fetchmore/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(fetchmore LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/fetchmore")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(fetchmore
filelistmodel.cpp filelistmodel.h
main.cpp
@@ -25,14 +19,21 @@ set_target_properties(fetchmore PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(fetchmore PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(fetchmore PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS fetchmore
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET fetchmore
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/itemviews/flattreeview/CMakeLists.txt b/examples/widgets/itemviews/flattreeview/CMakeLists.txt
deleted file mode 100644
index 23ce2882d2..0000000000
--- a/examples/widgets/itemviews/flattreeview/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(flattreeview LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/flattreeview")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(flattreeview
- main.cpp
-)
-
-set_target_properties(flattreeview PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(flattreeview PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS flattreeview
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/itemviews/flattreeview/flattreeview.pro b/examples/widgets/itemviews/flattreeview/flattreeview.pro
deleted file mode 100644
index 05a6573d33..0000000000
--- a/examples/widgets/itemviews/flattreeview/flattreeview.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-QT += widgets
-
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/itemviews/flattreeview
-INSTALLS += target
diff --git a/examples/widgets/itemviews/flattreeview/main.cpp b/examples/widgets/itemviews/flattreeview/main.cpp
deleted file mode 100644
index f51e24da86..0000000000
--- a/examples/widgets/itemviews/flattreeview/main.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (C) 2017 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-/*
- main.cpp
-
- A simple example that shows a multi-column list using QTreeView.
- The data is not a tree, so the first column was made movable.
-*/
-
-#include <QApplication>
-#include <QHeaderView>
-#include <QStandardItemModel>
-#include <QTreeView>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QStandardItemModel model(4, 2);
- QTreeView treeView;
- treeView.setModel(&model);
- treeView.setRootIsDecorated(false);
- treeView.header()->setFirstSectionMovable(true);
- treeView.header()->setStretchLastSection(true);
-
- for (int row = 0; row < 4; ++row) {
- for (int column = 0; column < 2; ++column) {
- QModelIndex index = model.index(row, column, QModelIndex());
- model.setData(index, QVariant((row + 1) * (column + 1)));
- }
- }
-
- treeView.setWindowTitle(QObject::tr("Flat Tree View"));
- treeView.show();
- return app.exec();
-}
diff --git a/examples/widgets/itemviews/frozencolumn/CMakeLists.txt b/examples/widgets/itemviews/frozencolumn/CMakeLists.txt
index 88b2de98e4..4801dbffd6 100644
--- a/examples/widgets/itemviews/frozencolumn/CMakeLists.txt
+++ b/examples/widgets/itemviews/frozencolumn/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(frozencolumn LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/frozencolumn")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(frozencolumn
freezetablewidget.cpp freezetablewidget.h
main.cpp
@@ -24,10 +18,10 @@ set_target_properties(frozencolumn PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(frozencolumn PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(frozencolumn PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -43,7 +37,14 @@ qt_add_resources(frozencolumn "grades"
)
install(TARGETS frozencolumn
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET frozencolumn
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/itemviews/frozencolumn/main.cpp b/examples/widgets/itemviews/frozencolumn/main.cpp
index 901db76dd8..8cc4a1d774 100644
--- a/examples/widgets/itemviews/frozencolumn/main.cpp
+++ b/examples/widgets/itemviews/frozencolumn/main.cpp
@@ -10,8 +10,6 @@
int main(int argc, char* argv[])
{
- Q_INIT_RESOURCE(grades);
-
QApplication app( argc, argv );
QStandardItemModel *model=new QStandardItemModel();
@@ -46,4 +44,3 @@ int main(int argc, char* argv[])
tableView->show();
return app.exec();
}
-
diff --git a/examples/widgets/itemviews/interview/CMakeLists.txt b/examples/widgets/itemviews/interview/CMakeLists.txt
deleted file mode 100644
index 0bff4991c8..0000000000
--- a/examples/widgets/itemviews/interview/CMakeLists.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(interview LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/interview")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(interview
- main.cpp
- model.cpp model.h
-)
-
-set_target_properties(interview PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(interview PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(interview_resource_files
- "images/folder.png"
- "images/interview.png"
- "images/services.png"
-)
-
-qt_add_resources(interview "interview"
- PREFIX
- "/"
- FILES
- ${interview_resource_files}
-)
-
-install(TARGETS interview
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/itemviews/interview/README b/examples/widgets/itemviews/interview/README
deleted file mode 100644
index 50894428f6..0000000000
--- a/examples/widgets/itemviews/interview/README
+++ /dev/null
@@ -1,2 +0,0 @@
-The interview example shows the same model and selection being shared
-between three different views.
diff --git a/examples/widgets/itemviews/interview/images/folder.png b/examples/widgets/itemviews/interview/images/folder.png
deleted file mode 100644
index 589fd2df59..0000000000
--- a/examples/widgets/itemviews/interview/images/folder.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/itemviews/interview/images/interview.png b/examples/widgets/itemviews/interview/images/interview.png
deleted file mode 100644
index 0c3d690258..0000000000
--- a/examples/widgets/itemviews/interview/images/interview.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/itemviews/interview/images/services.png b/examples/widgets/itemviews/interview/images/services.png
deleted file mode 100644
index 6b2ad969d4..0000000000
--- a/examples/widgets/itemviews/interview/images/services.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/itemviews/interview/interview.pro b/examples/widgets/itemviews/interview/interview.pro
deleted file mode 100644
index 6d64f23eb9..0000000000
--- a/examples/widgets/itemviews/interview/interview.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TEMPLATE = app
-QT += widgets
-requires(qtConfig(treeview))
-
-HEADERS += model.h
-SOURCES += model.cpp main.cpp
-RESOURCES += interview.qrc
-
-build_all:!build_pass {
- CONFIG -= build_all
- CONFIG += release
-}
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/itemviews/interview
-INSTALLS += target
diff --git a/examples/widgets/itemviews/interview/interview.qrc b/examples/widgets/itemviews/interview/interview.qrc
deleted file mode 100644
index b28ea34d8a..0000000000
--- a/examples/widgets/itemviews/interview/interview.qrc
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/">
- <file>images/folder.png</file>
- <file>images/services.png</file>
- <file>images/interview.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/itemviews/interview/main.cpp b/examples/widgets/itemviews/interview/main.cpp
deleted file mode 100644
index 4707c9d2c8..0000000000
--- a/examples/widgets/itemviews/interview/main.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "model.h"
-
-#include <QApplication>
-#include <QHeaderView>
-#include <QListView>
-#include <QSplitter>
-#include <QTableView>
-#include <QTreeView>
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(interview);
-
- QApplication app(argc, argv);
- QSplitter page;
-
- QAbstractItemModel *data = new Model(1000, 10, &page);
- QItemSelectionModel *selections = new QItemSelectionModel(data);
-
- QTableView *table = new QTableView;
- table->setModel(data);
- table->setSelectionModel(selections);
- table->horizontalHeader()->setSectionsMovable(true);
- table->verticalHeader()->setSectionsMovable(true);
- // Set StaticContents to enable minimal repaints on resizes.
- table->viewport()->setAttribute(Qt::WA_StaticContents);
- page.addWidget(table);
-
- QTreeView *tree = new QTreeView;
- tree->setModel(data);
- tree->setSelectionModel(selections);
- tree->setUniformRowHeights(true);
- tree->header()->setStretchLastSection(false);
- tree->viewport()->setAttribute(Qt::WA_StaticContents);
- // Disable the focus rect to get minimal repaints when scrolling on Mac.
- tree->setAttribute(Qt::WA_MacShowFocusRect, false);
- page.addWidget(tree);
-
- QListView *list = new QListView;
- list->setModel(data);
- list->setSelectionModel(selections);
- list->setViewMode(QListView::IconMode);
- list->setSelectionMode(QAbstractItemView::ExtendedSelection);
- list->setAlternatingRowColors(false);
- list->viewport()->setAttribute(Qt::WA_StaticContents);
- list->setAttribute(Qt::WA_MacShowFocusRect, false);
- page.addWidget(list);
-
- page.setWindowIcon(QPixmap(":/images/interview.png"));
- page.setWindowTitle("Interview");
- page.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/itemviews/interview/model.cpp b/examples/widgets/itemviews/interview/model.cpp
deleted file mode 100644
index 9050ae6cc1..0000000000
--- a/examples/widgets/itemviews/interview/model.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "model.h"
-
-#include <QPixmap>
-
-Model::Model(int rows, int columns, QObject *parent)
- : QAbstractItemModel(parent),
- services(QPixmap(":/images/services.png")),
- rc(rows),
- cc(columns),
- tree(new QList<Node>(rows, Node()))
-{
-
-}
-
-Model::~Model()
-{
- delete tree;
-}
-
-QModelIndex Model::index(int row, int column, const QModelIndex &parent) const
-{
- if (row < rc && row >= 0 && column < cc && column >= 0) {
- Node *parentNode = static_cast<Node*>(parent.internalPointer());
- Node *childNode = node(row, parentNode);
- if (childNode)
- return createIndex(row, column, childNode);
- }
- return QModelIndex();
-}
-
-QModelIndex Model::parent(const QModelIndex &child) const
-{
- if (child.isValid()) {
- Node *childNode = static_cast<Node*>(child.internalPointer());
- Node *parentNode = parent(childNode);
- if (parentNode)
- return createIndex(row(parentNode), 0, parentNode);
- }
- return QModelIndex();
-}
-
-int Model::rowCount(const QModelIndex &parent) const
-{
- return (parent.isValid() && parent.column() != 0) ? 0 : rc;
-}
-
-int Model::columnCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent);
- return cc;
-}
-
-QVariant Model::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
- if (role == Qt::DisplayRole)
- return QVariant("Item " + QString::number(index.row()) + ':' + QString::number(index.column()));
- if (role == Qt::DecorationRole) {
- if (index.column() == 0)
- return iconProvider.icon(QFileIconProvider::Folder);
- return iconProvider.icon(QFileIconProvider::File);
- }
- return QVariant();
-}
-
-QVariant Model::headerData(int section, Qt::Orientation orientation, int role) const
-{
- if (role == Qt::DisplayRole)
- return QString::number(section);
- if (role == Qt::DecorationRole)
- return QVariant::fromValue(services);
- return QAbstractItemModel::headerData(section, orientation, role);
-}
-
-bool Model::hasChildren(const QModelIndex &parent) const
-{
- if (parent.isValid() && parent.column() != 0)
- return false;
- return rc > 0 && cc > 0;
-}
-
-Qt::ItemFlags Model::flags(const QModelIndex &index) const
-{
- if (!index.isValid())
- return {};
- return Qt::ItemIsDragEnabled|QAbstractItemModel::flags(index);
-}
-
-Model::Node *Model::node(int row, Node *parent) const
-{
- if (parent && !parent->children)
- parent->children = new QList<Node>(rc, Node(parent));
- QList<Node> *v = parent ? parent->children : tree;
- return const_cast<Node*>(&(v->at(row)));
-}
-
-Model::Node *Model::parent(Node *child) const
-{
- return child ? child->parent : nullptr;
-}
-
-int Model::row(Node *node) const
-{
- const Node *first = node->parent ? &(node->parent->children->at(0)) : &(tree->at(0));
- return node - first;
-}
diff --git a/examples/widgets/itemviews/interview/model.h b/examples/widgets/itemviews/interview/model.h
deleted file mode 100644
index 87ee740792..0000000000
--- a/examples/widgets/itemviews/interview/model.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MODEL_H
-#define MODEL_H
-
-#include <QAbstractItemModel>
-#include <QFileIconProvider>
-#include <QIcon>
-#include <QList>
-
-class Model : public QAbstractItemModel
-{
- Q_OBJECT
-
-public:
- Model(int rows, int columns, QObject *parent = nullptr);
- ~Model();
-
- QModelIndex index(int row, int column, const QModelIndex &parent) const override;
- QModelIndex parent(const QModelIndex &child) const override;
-
- int rowCount(const QModelIndex &parent) const override;
- int columnCount(const QModelIndex &parent) const override;
-
- QVariant data(const QModelIndex &index, int role) const override;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
-
- bool hasChildren(const QModelIndex &parent) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const override;
-
-private:
-
- struct Node
- {
- Node(Node *parent = nullptr) : parent(parent), children(nullptr) {}
- ~Node() { delete children; }
- Node *parent;
- QList<Node> *children;
- };
-
- Node *node(int row, Node *parent) const;
- Node *parent(Node *child) const;
- int row(Node *node) const;
-
- QIcon services;
- int rc;
- int cc;
- QList<Node> *tree;
- QFileIconProvider iconProvider;
-};
-
-#endif // MODEL_H
diff --git a/examples/widgets/itemviews/itemviews.pro b/examples/widgets/itemviews/itemviews.pro
index b4a002c156..92997782a2 100644
--- a/examples/widgets/itemviews/itemviews.pro
+++ b/examples/widgets/itemviews/itemviews.pro
@@ -1,24 +1,12 @@
TEMPLATE = subdirs
SUBDIRS = addressbook \
basicsortfiltermodel \
- chart \
coloreditorfactory \
combowidgetmapper \
customsortfiltermodel \
- dirview \
editabletreemodel \
fetchmore \
- flattreeview \
frozencolumn \
- interview \
- pixelator \
- puzzle \
- simpledommodel \
simpletreemodel \
- simplewidgetmapper \
- spinboxdelegate \
spreadsheet \
- stardelegate \
- storageview
-!qtConfig(draganddrop): SUBDIRS -= puzzle
-!qtHaveModule(xml): SUBDIRS -= simpledommodel
+ stardelegate
diff --git a/examples/widgets/itemviews/pixelator/CMakeLists.txt b/examples/widgets/itemviews/pixelator/CMakeLists.txt
deleted file mode 100644
index 6db3d92c93..0000000000
--- a/examples/widgets/itemviews/pixelator/CMakeLists.txt
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(pixelator LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/pixelator")
-
-find_package(Qt6
- REQUIRED COMPONENTS Core Gui Widgets
- OPTIONAL_COMPONENTS PrintSupport
-)
-
-qt_add_executable(pixelator
- imagemodel.cpp imagemodel.h
- main.cpp
- mainwindow.cpp mainwindow.h
- pixeldelegate.cpp pixeldelegate.h
-)
-
-set_target_properties(pixelator PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(pixelator PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(images_resource_files
- "images/qt.png"
-)
-
-qt_add_resources(pixelator "images"
- PREFIX
- "/"
- FILES
- ${images_resource_files}
-)
-
-if(TARGET Qt::PrintSupport)
- target_link_libraries(pixelator PUBLIC
- Qt::PrintSupport
- )
-endif()
-
-install(TARGETS pixelator
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/itemviews/pixelator/imagemodel.cpp b/examples/widgets/itemviews/pixelator/imagemodel.cpp
deleted file mode 100644
index 6b5b866522..0000000000
--- a/examples/widgets/itemviews/pixelator/imagemodel.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "imagemodel.h"
-
-//! [0]
-ImageModel::ImageModel(QObject *parent)
- : QAbstractTableModel(parent)
-{
-}
-//! [0]
-
-//! [1]
-void ImageModel::setImage(const QImage &image)
-{
- beginResetModel();
- modelImage = image;
- endResetModel();
-}
-//! [1]
-
-//! [2]
-int ImageModel::rowCount(const QModelIndex & /* parent */) const
-{
- return modelImage.height();
-}
-
-int ImageModel::columnCount(const QModelIndex & /* parent */) const
-//! [2] //! [3]
-{
- return modelImage.width();
-}
-//! [3]
-
-//! [4]
-QVariant ImageModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid() || role != Qt::DisplayRole)
- return QVariant();
- return qGray(modelImage.pixel(index.column(), index.row()));
-}
-//! [4]
-
-//! [5]
-QVariant ImageModel::headerData(int /* section */,
- Qt::Orientation /* orientation */,
- int role) const
-{
- if (role == Qt::SizeHintRole)
- return QSize(1, 1);
- return QVariant();
-}
-//! [5]
diff --git a/examples/widgets/itemviews/pixelator/imagemodel.h b/examples/widgets/itemviews/pixelator/imagemodel.h
deleted file mode 100644
index 050ac6b790..0000000000
--- a/examples/widgets/itemviews/pixelator/imagemodel.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef IMAGEMODEL_H
-#define IMAGEMODEL_H
-
-#include <QAbstractTableModel>
-#include <QImage>
-
-//! [0]
-class ImageModel : public QAbstractTableModel
-{
- Q_OBJECT
-
-public:
- ImageModel(QObject *parent = nullptr);
-
- void setImage(const QImage &image);
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const override;
- int columnCount(const QModelIndex &parent = QModelIndex()) const override;
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
- QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
-
-private:
- QImage modelImage;
-};
-//! [0]
-
-#endif // IMAGEMODEL_H
diff --git a/examples/widgets/itemviews/pixelator/images.qrc b/examples/widgets/itemviews/pixelator/images.qrc
deleted file mode 100644
index c105e13895..0000000000
--- a/examples/widgets/itemviews/pixelator/images.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/qt.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/itemviews/pixelator/images/qt.png b/examples/widgets/itemviews/pixelator/images/qt.png
deleted file mode 100644
index dd197cb59c..0000000000
--- a/examples/widgets/itemviews/pixelator/images/qt.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/itemviews/pixelator/main.cpp b/examples/widgets/itemviews/pixelator/main.cpp
deleted file mode 100644
index b5967311ab..0000000000
--- a/examples/widgets/itemviews/pixelator/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(images);
-
- QApplication app(argc, argv);
- MainWindow window;
- window.show();
- window.openImage(":/images/qt.png");
- return app.exec();
-}
diff --git a/examples/widgets/itemviews/pixelator/mainwindow.cpp b/examples/widgets/itemviews/pixelator/mainwindow.cpp
deleted file mode 100644
index 42f0a43844..0000000000
--- a/examples/widgets/itemviews/pixelator/mainwindow.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-#include "imagemodel.h"
-#include "pixeldelegate.h"
-
-#include <QtWidgets>
-#if defined(QT_PRINTSUPPORT_LIB)
-#include <QtPrintSupport/qtprintsupportglobal.h>
-#if QT_CONFIG(printdialog)
-#include <QPrinter>
-#include <QPrintDialog>
-#endif
-#endif
-
-//! [0]
-MainWindow::MainWindow()
-{
-//! [0]
- currentPath = QDir::homePath();
- model = new ImageModel(this);
-
- QWidget *centralWidget = new QWidget;
-
-//! [1]
- view = new QTableView;
- view->setShowGrid(false);
- view->horizontalHeader()->hide();
- view->verticalHeader()->hide();
- view->horizontalHeader()->setMinimumSectionSize(1);
- view->verticalHeader()->setMinimumSectionSize(1);
- view->setModel(model);
-//! [1]
-
-//! [2]
- PixelDelegate *delegate = new PixelDelegate(this);
- view->setItemDelegate(delegate);
-//! [2]
-
-//! [3]
- QLabel *pixelSizeLabel = new QLabel(tr("Pixel size:"));
- QSpinBox *pixelSizeSpinBox = new QSpinBox;
- pixelSizeSpinBox->setMinimum(4);
- pixelSizeSpinBox->setMaximum(32);
- pixelSizeSpinBox->setValue(12);
-//! [3]
-
- QMenu *fileMenu = new QMenu(tr("&File"), this);
- QAction *openAction = fileMenu->addAction(tr("&Open..."));
- openAction->setShortcuts(QKeySequence::Open);
-
- printAction = fileMenu->addAction(tr("&Print..."));
- printAction->setEnabled(false);
- printAction->setShortcut(QKeySequence::Print);
-
- QAction *quitAction = fileMenu->addAction(tr("E&xit"));
- quitAction->setShortcuts(QKeySequence::Quit);
-
- QMenu *helpMenu = new QMenu(tr("&Help"), this);
- QAction *aboutAction = helpMenu->addAction(tr("&About"));
-
- menuBar()->addMenu(fileMenu);
- menuBar()->addSeparator();
- menuBar()->addMenu(helpMenu);
-
- connect(openAction, &QAction::triggered, this, &MainWindow::chooseImage);
- connect(printAction, &QAction::triggered, this, &MainWindow::printImage);
- connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
- connect(aboutAction, &QAction::triggered, this, &MainWindow::showAboutBox);
-//! [4]
- connect(pixelSizeSpinBox, &QSpinBox::valueChanged,
- delegate, &PixelDelegate::setPixelSize);
- connect(pixelSizeSpinBox, &QSpinBox::valueChanged,
- this, &MainWindow::updateView);
-//! [4]
-
- QHBoxLayout *controlsLayout = new QHBoxLayout;
- controlsLayout->addWidget(pixelSizeLabel);
- controlsLayout->addWidget(pixelSizeSpinBox);
- controlsLayout->addStretch(1);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(view);
- mainLayout->addLayout(controlsLayout);
- centralWidget->setLayout(mainLayout);
-
- setCentralWidget(centralWidget);
-
- setWindowTitle(tr("Pixelator"));
- resize(640, 480);
-//! [5]
-}
-//! [5]
-
-void MainWindow::chooseImage()
-{
- QString fileName = QFileDialog::getOpenFileName(this,
- tr("Choose an image"), currentPath, "*");
-
- if (!fileName.isEmpty())
- openImage(fileName);
-}
-
-void MainWindow::openImage(const QString &fileName)
-{
- QImage image;
-
- if (image.load(fileName)) {
- model->setImage(image);
- if (!fileName.startsWith(":/")) {
- currentPath = fileName;
- setWindowTitle(tr("%1 - Pixelator").arg(currentPath));
- }
-
- printAction->setEnabled(true);
- updateView();
- }
-}
-
-void MainWindow::printImage()
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
- if (model->rowCount(QModelIndex())*model->columnCount(QModelIndex()) > 90000) {
- QMessageBox::StandardButton answer;
- answer = QMessageBox::question(this, tr("Large Image Size"),
- tr("The printed image may be very large. Are you sure that "
- "you want to print it?"),
- QMessageBox::Yes | QMessageBox::No);
- if (answer == QMessageBox::No)
- return;
- }
-
- QPrinter printer(QPrinter::HighResolution);
-
- QPrintDialog dlg(&printer, this);
- dlg.setWindowTitle(tr("Print Image"));
-
- if (dlg.exec() != QDialog::Accepted) {
- return;
- }
-
- QPainter painter;
- painter.begin(&printer);
-
- int rows = model->rowCount(QModelIndex());
- int columns = model->columnCount(QModelIndex());
- int sourceWidth = (columns + 1) * ItemSize;
- int sourceHeight = (rows + 1) * ItemSize;
-
- painter.save();
-
- double xscale = printer.pageRect(QPrinter::DevicePixel).width() / double(sourceWidth);
- double yscale = printer.pageRect(QPrinter::DevicePixel).height() / double(sourceHeight);
- double scale = qMin(xscale, yscale);
-
- painter.translate(printer.paperRect(QPrinter::DevicePixel).x() + printer.pageRect(QPrinter::DevicePixel).width() / 2,
- printer.paperRect(QPrinter::DevicePixel).y() + printer.pageRect(QPrinter::DevicePixel).height() / 2);
- painter.scale(scale, scale);
- painter.translate(-sourceWidth / 2, -sourceHeight / 2);
-
- QStyleOptionViewItem option;
- QModelIndex parent = QModelIndex();
-
- QProgressDialog progress(tr("Printing..."), tr("Cancel"), 0, rows, this);
- progress.setWindowModality(Qt::ApplicationModal);
- float y = ItemSize / 2;
-
- for (int row = 0; row < rows; ++row) {
- progress.setValue(row);
- qApp->processEvents();
- if (progress.wasCanceled())
- break;
-
- float x = ItemSize / 2;
-
- for (int column = 0; column < columns; ++column) {
- option.rect = QRect(int(x), int(y), ItemSize, ItemSize);
- view->itemDelegate()->paint(&painter, option,
- model->index(row, column, parent));
- x = x + ItemSize;
- }
- y = y + ItemSize;
- }
- progress.setValue(rows);
-
- painter.restore();
- painter.end();
-
- if (progress.wasCanceled()) {
- QMessageBox::information(this, tr("Printing canceled"),
- tr("The printing process was canceled."), QMessageBox::Cancel);
- }
-#else
- QMessageBox::information(this, tr("Printing canceled"),
- tr("Printing is not supported on this Qt build"), QMessageBox::Cancel);
-#endif
-}
-
-void MainWindow::showAboutBox()
-{
- QMessageBox::about(this, tr("About the Pixelator example"),
- tr("This example demonstrates how a standard view and a custom\n"
- "delegate can be used to produce a specialized representation\n"
- "of data in a simple custom model."));
-}
-
-//! [6]
-void MainWindow::updateView()
-{
- view->resizeColumnsToContents();
- view->resizeRowsToContents();
-}
-//! [6]
diff --git a/examples/widgets/itemviews/pixelator/mainwindow.h b/examples/widgets/itemviews/pixelator/mainwindow.h
deleted file mode 100644
index 9929e2f5af..0000000000
--- a/examples/widgets/itemviews/pixelator/mainwindow.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-
-class ImageModel;
-QT_BEGIN_NAMESPACE
-class QAction;
-class QTableView;
-QT_END_NAMESPACE
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
- void openImage(const QString &fileName);
-
-public slots:
- void chooseImage();
- void printImage();
- void showAboutBox();
- void updateView();
-
-private:
- ImageModel *model;
- QAction *printAction;
- QString currentPath;
- QTableView *view;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/widgets/itemviews/pixelator/pixelator.pro b/examples/widgets/itemviews/pixelator/pixelator.pro
deleted file mode 100644
index 421f626e28..0000000000
--- a/examples/widgets/itemviews/pixelator/pixelator.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-QT += widgets
-requires(qtConfig(tableview))
-qtHaveModule(printsupport): QT += printsupport
-
-HEADERS = imagemodel.h \
- mainwindow.h \
- pixeldelegate.h
-SOURCES = imagemodel.cpp \
- main.cpp \
- mainwindow.cpp \
- pixeldelegate.cpp
-RESOURCES += images.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/itemviews/pixelator
-INSTALLS += target
diff --git a/examples/widgets/itemviews/pixelator/pixeldelegate.cpp b/examples/widgets/itemviews/pixelator/pixeldelegate.cpp
deleted file mode 100644
index 3a104cd2c2..0000000000
--- a/examples/widgets/itemviews/pixelator/pixeldelegate.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "pixeldelegate.h"
-
-#include <QPainter>
-
-//! [0]
-PixelDelegate::PixelDelegate(QObject *parent)
- : QAbstractItemDelegate(parent), pixelSize(12)
-{}
-//! [0]
-
-//! [1]
-void PixelDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
- const QModelIndex &index) const
-{
-//! [2]
- if (option.state & QStyle::State_Selected)
- painter->fillRect(option.rect, option.palette.highlight());
-//! [1]
-
-//! [3]
- const int size = qMin(option.rect.width(), option.rect.height());
-//! [3] //! [4]
- const int brightness = index.model()->data(index, Qt::DisplayRole).toInt();
- const double radius = (size / 2.0) - (brightness / 255.0 * size / 2.0);
- if (qFuzzyIsNull(radius))
- return;
-//! [4]
-
-//! [5]
- painter->save();
-//! [5] //! [6]
- painter->setRenderHint(QPainter::Antialiasing, true);
-//! [6] //! [7]
- painter->setPen(Qt::NoPen);
-//! [7] //! [8]
- if (option.state & QStyle::State_Selected)
-//! [8] //! [9]
- painter->setBrush(option.palette.highlightedText());
- else
-//! [2]
- painter->setBrush(option.palette.text());
-//! [9]
-
-//! [10]
- painter->drawEllipse(QRectF(option.rect.x() + option.rect.width() / 2 - radius,
- option.rect.y() + option.rect.height() / 2 - radius,
- 2 * radius, 2 * radius));
- painter->restore();
-}
-//! [10]
-
-//! [11]
-QSize PixelDelegate::sizeHint(const QStyleOptionViewItem & /* option */,
- const QModelIndex & /* index */) const
-{
- return QSize(pixelSize, pixelSize);
-}
-//! [11]
-
-//! [12]
-void PixelDelegate::setPixelSize(int size)
-{
- pixelSize = size;
-}
-//! [12]
diff --git a/examples/widgets/itemviews/pixelator/pixeldelegate.h b/examples/widgets/itemviews/pixelator/pixeldelegate.h
deleted file mode 100644
index a4c435ce69..0000000000
--- a/examples/widgets/itemviews/pixelator/pixeldelegate.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef PIXELDELEGATE_H
-#define PIXELDELEGATE_H
-
-#include <QAbstractItemDelegate>
-#include <QModelIndex>
-#include <QSize>
-
-QT_BEGIN_NAMESPACE
-class QAbstractItemModel;
-class QObject;
-class QPainter;
-QT_END_NAMESPACE
-
-static constexpr int ItemSize = 256;
-
-//! [0]
-class PixelDelegate : public QAbstractItemDelegate
-{
- Q_OBJECT
-
-public:
- PixelDelegate(QObject *parent = nullptr);
-
- void paint(QPainter *painter, const QStyleOptionViewItem &option,
- const QModelIndex &index) const override;
-
- QSize sizeHint(const QStyleOptionViewItem &option,
- const QModelIndex &index) const override;
-
-public slots:
- void setPixelSize(int size);
-
-private:
- int pixelSize;
-};
-//! [0]
-
-#endif // PIXELDELEGATE_H
diff --git a/examples/widgets/itemviews/puzzle/CMakeLists.txt b/examples/widgets/itemviews/puzzle/CMakeLists.txt
deleted file mode 100644
index dc0b9d8322..0000000000
--- a/examples/widgets/itemviews/puzzle/CMakeLists.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(puzzle LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/puzzle")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(itemviews_puzzle
- main.cpp
- mainwindow.cpp mainwindow.h
- piecesmodel.cpp piecesmodel.h
- puzzlewidget.cpp puzzlewidget.h
-)
-
-set_target_properties(itemviews_puzzle PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(itemviews_puzzle PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(puzzle_resource_files
- "example.jpg"
-)
-
-qt_add_resources(itemviews_puzzle "puzzle"
- PREFIX
- "/images"
- FILES
- ${puzzle_resource_files}
-)
-
-install(TARGETS itemviews_puzzle
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/itemviews/puzzle/example.jpg b/examples/widgets/itemviews/puzzle/example.jpg
deleted file mode 100644
index 023203c57a..0000000000
--- a/examples/widgets/itemviews/puzzle/example.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/itemviews/puzzle/main.cpp b/examples/widgets/itemviews/puzzle/main.cpp
deleted file mode 100644
index 73fdd6513b..0000000000
--- a/examples/widgets/itemviews/puzzle/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(puzzle);
-
- QApplication app(argc, argv);
- MainWindow window;
- window.loadImage(QStringLiteral(":/images/example.jpg"));
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/itemviews/puzzle/mainwindow.cpp b/examples/widgets/itemviews/puzzle/mainwindow.cpp
deleted file mode 100644
index f4b221df20..0000000000
--- a/examples/widgets/itemviews/puzzle/mainwindow.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-#include "piecesmodel.h"
-#include "puzzlewidget.h"
-
-#include <QtWidgets>
-#include <stdlib.h>
-
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
-{
- setupMenus();
- setupWidgets();
- model = new PiecesModel(puzzleWidget->pieceSize(), this);
- piecesList->setModel(model);
-
- setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
- setWindowTitle(tr("Puzzle"));
-}
-
-void MainWindow::openImage()
-{
- const QString directory =
- QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).value(0, QDir::homePath());
- QFileDialog dialog(this, tr("Open Image"), directory);
- dialog.setAcceptMode(QFileDialog::AcceptOpen);
- dialog.setFileMode(QFileDialog::ExistingFile);
- QStringList mimeTypeFilters;
- for (const QByteArray &mimeTypeName : QImageReader::supportedMimeTypes())
- mimeTypeFilters.append(mimeTypeName);
- mimeTypeFilters.sort();
- dialog.setMimeTypeFilters(mimeTypeFilters);
- dialog.selectMimeTypeFilter("image/jpeg");
- if (dialog.exec() == QDialog::Accepted)
- loadImage(dialog.selectedFiles().constFirst());
-}
-
-void MainWindow::loadImage(const QString &fileName)
-{
- QPixmap newImage;
- if (!newImage.load(fileName)) {
- QMessageBox::warning(this, tr("Open Image"),
- tr("The image file could not be loaded."),
- QMessageBox::Close);
- return;
- }
- puzzleImage = newImage;
- setupPuzzle();
-}
-
-void MainWindow::setCompleted()
-{
- QMessageBox::information(this, tr("Puzzle Completed"),
- tr("Congratulations! You have completed the puzzle!\n"
- "Click OK to start again."),
- QMessageBox::Ok);
-
- setupPuzzle();
-}
-
-void MainWindow::setupPuzzle()
-{
- int size = qMin(puzzleImage.width(), puzzleImage.height());
- puzzleImage = puzzleImage.copy((puzzleImage.width() - size) / 2,
- (puzzleImage.height() - size) / 2, size, size).scaled(puzzleWidget->imageSize(),
- puzzleWidget->imageSize(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
-
- model->addPieces(puzzleImage);
- puzzleWidget->clear();
-}
-
-void MainWindow::setupMenus()
-{
- QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
-
- QAction *openAction = fileMenu->addAction(tr("&Open..."), this, &MainWindow::openImage);
- openAction->setShortcuts(QKeySequence::Open);
-
- QAction *exitAction = fileMenu->addAction(tr("E&xit"), qApp, &QCoreApplication::quit);
- exitAction->setShortcuts(QKeySequence::Quit);
-
- QMenu *gameMenu = menuBar()->addMenu(tr("&Game"));
-
- gameMenu->addAction(tr("&Restart"), this, &MainWindow::setupPuzzle);
-}
-
-void MainWindow::setupWidgets()
-{
- QFrame *frame = new QFrame;
- QHBoxLayout *frameLayout = new QHBoxLayout(frame);
-
- puzzleWidget = new PuzzleWidget(400);
-
- piecesList = new QListView;
- piecesList->setDragEnabled(true);
- piecesList->setViewMode(QListView::IconMode);
- piecesList->setIconSize(QSize(puzzleWidget->pieceSize() - 20, puzzleWidget->pieceSize() - 20));
- piecesList->setGridSize(QSize(puzzleWidget->pieceSize(), puzzleWidget->pieceSize()));
- piecesList->setSpacing(10);
- piecesList->setMovement(QListView::Snap);
- piecesList->setAcceptDrops(true);
- piecesList->setDropIndicatorShown(true);
-
- PiecesModel *model = new PiecesModel(puzzleWidget->pieceSize(), this);
- piecesList->setModel(model);
-
- connect(puzzleWidget, &PuzzleWidget::puzzleCompleted,
- this, &MainWindow::setCompleted, Qt::QueuedConnection);
-
- frameLayout->addWidget(piecesList);
- frameLayout->addWidget(puzzleWidget);
- setCentralWidget(frame);
-}
diff --git a/examples/widgets/itemviews/puzzle/mainwindow.h b/examples/widgets/itemviews/puzzle/mainwindow.h
deleted file mode 100644
index 56a59b805c..0000000000
--- a/examples/widgets/itemviews/puzzle/mainwindow.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include <QPixmap>
-
-class PuzzleWidget;
-class PiecesModel;
-QT_BEGIN_NAMESPACE
-class QListView;
-QT_END_NAMESPACE
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- explicit MainWindow(QWidget *parent = nullptr);
-
-public slots:
- void openImage();
- void loadImage(const QString &path);
- void setupPuzzle();
-
-private slots:
- void setCompleted();
-
-private:
- void setupMenus();
- void setupWidgets();
-
- QPixmap puzzleImage;
- QListView *piecesList;
- PuzzleWidget *puzzleWidget;
- PiecesModel *model;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/widgets/itemviews/puzzle/piecesmodel.cpp b/examples/widgets/itemviews/puzzle/piecesmodel.cpp
deleted file mode 100644
index 8e3ccf4aa3..0000000000
--- a/examples/widgets/itemviews/puzzle/piecesmodel.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "piecesmodel.h"
-
-#include <QIcon>
-#include <QMimeData>
-#include <QRandomGenerator>
-
-PiecesModel::PiecesModel(int pieceSize, QObject *parent)
- : QAbstractListModel(parent), m_PieceSize(pieceSize)
-{
-}
-
-QVariant PiecesModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- if (role == Qt::DecorationRole)
- return QIcon(pixmaps.value(index.row()).scaled(m_PieceSize, m_PieceSize,
- Qt::KeepAspectRatio, Qt::SmoothTransformation));
- else if (role == Qt::UserRole)
- return pixmaps.value(index.row());
- else if (role == Qt::UserRole + 1)
- return locations.value(index.row());
-
- return QVariant();
-}
-
-void PiecesModel::addPiece(const QPixmap &pixmap, const QPoint &location)
-{
- int row;
- if (QRandomGenerator::global()->bounded(2) == 1)
- row = 0;
- else
- row = pixmaps.size();
-
- beginInsertRows(QModelIndex(), row, row);
- pixmaps.insert(row, pixmap);
- locations.insert(row, location);
- endInsertRows();
-}
-
-Qt::ItemFlags PiecesModel::flags(const QModelIndex &index) const
-{
- if (index.isValid())
- return (QAbstractListModel::flags(index)|Qt::ItemIsDragEnabled);
-
- return Qt::ItemIsDropEnabled;
-}
-
-bool PiecesModel::removeRows(int row, int count, const QModelIndex &parent)
-{
- if (parent.isValid())
- return false;
-
- if (row >= pixmaps.size() || row + count <= 0)
- return false;
-
- int beginRow = qMax(0, row);
- int endRow = qMin(row + count - 1, pixmaps.size() - 1);
-
- beginRemoveRows(parent, beginRow, endRow);
-
- while (beginRow <= endRow) {
- pixmaps.removeAt(beginRow);
- locations.removeAt(beginRow);
- ++beginRow;
- }
-
- endRemoveRows();
- return true;
-}
-
-QStringList PiecesModel::mimeTypes() const
-{
- QStringList types;
- types << "image/x-puzzle-piece";
- return types;
-}
-
-QMimeData *PiecesModel::mimeData(const QModelIndexList &indexes) const
-{
- QMimeData *mimeData = new QMimeData();
- QByteArray encodedData;
-
- QDataStream stream(&encodedData, QDataStream::WriteOnly);
-
- for (const QModelIndex &index : indexes) {
- if (index.isValid()) {
- QPixmap pixmap = qvariant_cast<QPixmap>(data(index, Qt::UserRole));
- QPoint location = data(index, Qt::UserRole+1).toPoint();
- stream << pixmap << location;
- }
- }
-
- mimeData->setData("image/x-puzzle-piece", encodedData);
- return mimeData;
-}
-
-bool PiecesModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
- int row, int column, const QModelIndex &parent)
-{
- if (!data->hasFormat("image/x-puzzle-piece"))
- return false;
-
- if (action == Qt::IgnoreAction)
- return true;
-
- if (column > 0)
- return false;
-
- int endRow;
-
- if (!parent.isValid()) {
- if (row < 0)
- endRow = pixmaps.size();
- else
- endRow = qMin(row, pixmaps.size());
- } else {
- endRow = parent.row();
- }
-
- QByteArray encodedData = data->data("image/x-puzzle-piece");
- QDataStream stream(&encodedData, QDataStream::ReadOnly);
-
- while (!stream.atEnd()) {
- QPixmap pixmap;
- QPoint location;
- stream >> pixmap >> location;
-
- beginInsertRows(QModelIndex(), endRow, endRow);
- pixmaps.insert(endRow, pixmap);
- locations.insert(endRow, location);
- endInsertRows();
-
- ++endRow;
- }
-
- return true;
-}
-
-int PiecesModel::rowCount(const QModelIndex &parent) const
-{
- return parent.isValid() ? 0 : pixmaps.size();
-}
-
-Qt::DropActions PiecesModel::supportedDropActions() const
-{
- return Qt::CopyAction | Qt::MoveAction;
-}
-
-void PiecesModel::addPieces(const QPixmap &pixmap)
-{
- if (!pixmaps.isEmpty()) {
- beginRemoveRows(QModelIndex(), 0, pixmaps.size() - 1);
- pixmaps.clear();
- locations.clear();
- endRemoveRows();
- }
- for (int y = 0; y < 5; ++y) {
- for (int x = 0; x < 5; ++x) {
- QPixmap pieceImage = pixmap.copy(x*m_PieceSize, y*m_PieceSize, m_PieceSize, m_PieceSize);
- addPiece(pieceImage, QPoint(x, y));
- }
- }
-}
diff --git a/examples/widgets/itemviews/puzzle/piecesmodel.h b/examples/widgets/itemviews/puzzle/piecesmodel.h
deleted file mode 100644
index 878ed73a70..0000000000
--- a/examples/widgets/itemviews/puzzle/piecesmodel.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef PIECESLIST_H
-#define PIECESLIST_H
-
-#include <QAbstractListModel>
-#include <QPixmap>
-#include <QPoint>
-#include <QStringList>
-#include <QList>
-
-QT_BEGIN_NAMESPACE
-class QMimeData;
-QT_END_NAMESPACE
-
-class PiecesModel : public QAbstractListModel
-{
- Q_OBJECT
-
-public:
- explicit PiecesModel(int pieceSize, QObject *parent = nullptr);
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const override;
- bool removeRows(int row, int count, const QModelIndex &parent) override;
-
- bool dropMimeData(const QMimeData *data, Qt::DropAction action,
- int row, int column, const QModelIndex &parent) override;
- QMimeData *mimeData(const QModelIndexList &indexes) const override;
- QStringList mimeTypes() const override;
- int rowCount(const QModelIndex &parent) const override;
- Qt::DropActions supportedDropActions() const override;
-
- void addPiece(const QPixmap &pixmap, const QPoint &location);
- void addPieces(const QPixmap &pixmap);
-
-private:
- QList<QPoint> locations;
- QList<QPixmap> pixmaps;
-
- int m_PieceSize;
-};
-
-#endif // PIECESLIST_H
diff --git a/examples/widgets/itemviews/puzzle/puzzle.pro b/examples/widgets/itemviews/puzzle/puzzle.pro
deleted file mode 100644
index dcc27aae6a..0000000000
--- a/examples/widgets/itemviews/puzzle/puzzle.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-QT += widgets
-requires(qtConfig(listview))
-
-HEADERS = mainwindow.h \
- piecesmodel.h \
- puzzlewidget.h
-RESOURCES = puzzle.qrc
-SOURCES = main.cpp \
- mainwindow.cpp \
- piecesmodel.cpp \
- puzzlewidget.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/itemviews/puzzle
-INSTALLS += target
diff --git a/examples/widgets/itemviews/puzzle/puzzle.qrc b/examples/widgets/itemviews/puzzle/puzzle.qrc
deleted file mode 100644
index 4076cec026..0000000000
--- a/examples/widgets/itemviews/puzzle/puzzle.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/images">
- <file>example.jpg</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/itemviews/puzzle/puzzlewidget.cpp b/examples/widgets/itemviews/puzzle/puzzlewidget.cpp
deleted file mode 100644
index 15aa6ac94f..0000000000
--- a/examples/widgets/itemviews/puzzle/puzzlewidget.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "puzzlewidget.h"
-
-#include <QtWidgets>
-
-PuzzleWidget::PuzzleWidget(int imageSize, QWidget *parent)
- : QWidget(parent), m_ImageSize(imageSize)
-{
- setAcceptDrops(true);
- setMinimumSize(m_ImageSize, m_ImageSize);
- setMaximumSize(m_ImageSize, m_ImageSize);
-}
-
-void PuzzleWidget::clear()
-{
- pieces.clear();
- highlightedRect = QRect();
- inPlace = 0;
- update();
-}
-
-void PuzzleWidget::dragEnterEvent(QDragEnterEvent *event)
-{
- if (event->mimeData()->hasFormat("image/x-puzzle-piece"))
- event->accept();
- else
- event->ignore();
-}
-
-void PuzzleWidget::dragLeaveEvent(QDragLeaveEvent *event)
-{
- QRect updateRect = highlightedRect;
- highlightedRect = QRect();
- update(updateRect);
- event->accept();
-}
-
-void PuzzleWidget::dragMoveEvent(QDragMoveEvent *event)
-{
- QRect updateRect = highlightedRect.united(targetSquare(event->position().toPoint()));
-
- if (event->mimeData()->hasFormat("image/x-puzzle-piece")
- && findPiece(targetSquare(event->position().toPoint())) == -1) {
-
- highlightedRect = targetSquare(event->position().toPoint());
- event->setDropAction(Qt::MoveAction);
- event->accept();
- } else {
- highlightedRect = QRect();
- event->ignore();
- }
-
- update(updateRect);
-}
-
-void PuzzleWidget::dropEvent(QDropEvent *event)
-{
- if (event->mimeData()->hasFormat("image/x-puzzle-piece")
- && findPiece(targetSquare(event->position().toPoint())) == -1) {
-
- QByteArray pieceData = event->mimeData()->data("image/x-puzzle-piece");
- QDataStream dataStream(&pieceData, QIODevice::ReadOnly);
- Piece piece;
- piece.rect = targetSquare(event->position().toPoint());
- dataStream >> piece.pixmap >> piece.location;
-
- pieces.append(piece);
-
- highlightedRect = QRect();
- update(piece.rect);
-
- event->setDropAction(Qt::MoveAction);
- event->accept();
-
- if (piece.location == piece.rect.topLeft() / pieceSize()) {
- inPlace++;
- if (inPlace == 25)
- emit puzzleCompleted();
- }
- } else {
- highlightedRect = QRect();
- event->ignore();
- }
-}
-
-int PuzzleWidget::findPiece(const QRect &pieceRect) const
-{
- for (int i = 0, size = pieces.size(); i < size; ++i) {
- if (pieces.at(i).rect == pieceRect)
- return i;
- }
- return -1;
-}
-
-void PuzzleWidget::mousePressEvent(QMouseEvent *event)
-{
- QRect square = targetSquare(event->position().toPoint());
- int found = findPiece(square);
-
- if (found == -1)
- return;
-
- Piece piece = pieces.takeAt(found);
-
- if (piece.location == square.topLeft() / pieceSize())
- inPlace--;
-
- update(square);
-
- QByteArray itemData;
- QDataStream dataStream(&itemData, QIODevice::WriteOnly);
-
- dataStream << piece.pixmap << piece.location;
-
- QMimeData *mimeData = new QMimeData;
- mimeData->setData("image/x-puzzle-piece", itemData);
-
- QDrag *drag = new QDrag(this);
- drag->setMimeData(mimeData);
- drag->setHotSpot(event->position().toPoint() - square.topLeft());
- drag->setPixmap(piece.pixmap);
-
- if (drag->exec(Qt::MoveAction) == Qt::IgnoreAction) {
- pieces.insert(found, piece);
- update(targetSquare(event->position().toPoint()));
-
- if (piece.location == QPoint(square.x() / pieceSize(), square.y() / pieceSize()))
- inPlace++;
- }
-}
-
-void PuzzleWidget::paintEvent(QPaintEvent *event)
-{
- QPainter painter(this);
- painter.fillRect(event->rect(), Qt::white);
-
- if (highlightedRect.isValid()) {
- painter.setBrush(QColor("#ffcccc"));
- painter.setPen(Qt::NoPen);
- painter.drawRect(highlightedRect.adjusted(0, 0, -1, -1));
- }
-
- for (const Piece &piece : pieces)
- painter.drawPixmap(piece.rect, piece.pixmap);
-}
-
-const QRect PuzzleWidget::targetSquare(const QPoint &position) const
-{
- QPoint topLeft = QPoint(position.x() / pieceSize(), position.y() / pieceSize()) * pieceSize();
- return QRect(topLeft, QSize(pieceSize(), pieceSize()));
-}
-
-int PuzzleWidget::pieceSize() const
-{
- return m_ImageSize / 5;
-}
-
-int PuzzleWidget::imageSize() const
-{
- return m_ImageSize;
-}
diff --git a/examples/widgets/itemviews/puzzle/puzzlewidget.h b/examples/widgets/itemviews/puzzle/puzzlewidget.h
deleted file mode 100644
index d1c00872ec..0000000000
--- a/examples/widgets/itemviews/puzzle/puzzlewidget.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef PUZZLEWIDGET_H
-#define PUZZLEWIDGET_H
-
-#include <QPoint>
-#include <QPixmap>
-#include <QList>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QDragEnterEvent;
-class QDropEvent;
-class QMouseEvent;
-QT_END_NAMESPACE
-
-class PuzzleWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit PuzzleWidget(int imageSize, QWidget *parent = nullptr);
- void clear();
-
- int pieceSize() const;
- int imageSize() const;
-
-signals:
- void puzzleCompleted();
-
-protected:
- void dragEnterEvent(QDragEnterEvent *event) override;
- void dragLeaveEvent(QDragLeaveEvent *event) override;
- void dragMoveEvent(QDragMoveEvent *event) override;
- void dropEvent(QDropEvent *event) override;
- void mousePressEvent(QMouseEvent *event) override;
- void paintEvent(QPaintEvent *event) override;
-
-private:
- struct Piece {
- QPixmap pixmap;
- QRect rect;
- QPoint location;
- };
-
- int findPiece(const QRect &pieceRect) const;
- const QRect targetSquare(const QPoint &position) const;
-
- QList<Piece> pieces;
- QRect highlightedRect;
- int inPlace;
- int m_ImageSize;
-};
-
-#endif // PUZZLEWIDGET_H
diff --git a/examples/widgets/itemviews/simpledommodel/CMakeLists.txt b/examples/widgets/itemviews/simpledommodel/CMakeLists.txt
deleted file mode 100644
index 1d63e36847..0000000000
--- a/examples/widgets/itemviews/simpledommodel/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(simpledommodel LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/simpledommodel")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Xml)
-
-qt_add_executable(simpledommodel
- domitem.cpp domitem.h
- dommodel.cpp dommodel.h
- main.cpp
- mainwindow.cpp mainwindow.h
-)
-
-set_target_properties(simpledommodel PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(simpledommodel PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
- Qt::Xml
-)
-
-install(TARGETS simpledommodel
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/itemviews/simpledommodel/domitem.cpp b/examples/widgets/itemviews/simpledommodel/domitem.cpp
deleted file mode 100644
index b3e197b3db..0000000000
--- a/examples/widgets/itemviews/simpledommodel/domitem.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "domitem.h"
-
-#include <QtXml>
-
-//! [0]
-DomItem::DomItem(const QDomNode &node, int row, DomItem *parent)
- : domNode(node),
-//! [0]
- // Record the item's location within its parent.
-//! [1]
- parentItem(parent),
- rowNumber(row)
-{}
-//! [1]
-
-//! [2]
-DomItem::~DomItem()
-{
- qDeleteAll(childItems);
-}
-//! [2]
-
-//! [3]
-QDomNode DomItem::node() const
-{
- return domNode;
-}
-//! [3]
-
-//! [4]
-DomItem *DomItem::parent()
-{
- return parentItem;
-}
-//! [4]
-
-//! [5]
-DomItem *DomItem::child(int i)
-{
- DomItem *childItem = childItems.value(i);
- if (childItem)
- return childItem;
-
- // if child does not yet exist, create it
- if (i >= 0 && i < domNode.childNodes().count()) {
- QDomNode childNode = domNode.childNodes().item(i);
- childItem = new DomItem(childNode, i, this);
- childItems[i] = childItem;
- }
- return childItem;
-}
-//! [5]
-
-//! [6]
-int DomItem::row() const
-{
- return rowNumber;
-}
-//! [6]
diff --git a/examples/widgets/itemviews/simpledommodel/domitem.h b/examples/widgets/itemviews/simpledommodel/domitem.h
deleted file mode 100644
index 9b02d8e88c..0000000000
--- a/examples/widgets/itemviews/simpledommodel/domitem.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef DOMITEM_H
-#define DOMITEM_H
-
-#include <QDomNode>
-#include <QHash>
-
-//! [0]
-class DomItem
-{
-public:
- DomItem(const QDomNode &node, int row, DomItem *parent = nullptr);
- ~DomItem();
- DomItem *child(int i);
- DomItem *parent();
- QDomNode node() const;
- int row() const;
-
-private:
- QDomNode domNode;
- QHash<int, DomItem *> childItems;
- DomItem *parentItem;
- int rowNumber;
-};
-//! [0]
-
-#endif // DOMITEM_H
diff --git a/examples/widgets/itemviews/simpledommodel/dommodel.cpp b/examples/widgets/itemviews/simpledommodel/dommodel.cpp
deleted file mode 100644
index 17f05c8be3..0000000000
--- a/examples/widgets/itemviews/simpledommodel/dommodel.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "dommodel.h"
-#include "domitem.h"
-
-#include <QtXml>
-
-//! [0]
-DomModel::DomModel(const QDomDocument &document, QObject *parent)
- : QAbstractItemModel(parent),
- domDocument(document),
- rootItem(new DomItem(domDocument, 0))
-{
-}
-//! [0]
-
-//! [1]
-DomModel::~DomModel()
-{
- delete rootItem;
-}
-//! [1]
-
-//! [2]
-int DomModel::columnCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent);
- return 3;
-}
-//! [2]
-
-//! [3]
-QVariant DomModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- if (role != Qt::DisplayRole)
- return QVariant();
-
- const DomItem *item = static_cast<DomItem*>(index.internalPointer());
-
- const QDomNode node = item->node();
-//! [3] //! [4]
-
- switch (index.column()) {
- case 0:
- return node.nodeName();
- case 1:
- {
- const QDomNamedNodeMap attributeMap = node.attributes();
- QStringList attributes;
- for (int i = 0; i < attributeMap.count(); ++i) {
- QDomNode attribute = attributeMap.item(i);
- attributes << attribute.nodeName() + "=\""
- + attribute.nodeValue() + '"';
- }
- return attributes.join(' ');
- }
- case 2:
- return node.nodeValue().split('\n').join(' ');
- default:
- break;
- }
- return QVariant();
-}
-//! [4]
-
-//! [5]
-Qt::ItemFlags DomModel::flags(const QModelIndex &index) const
-{
- if (!index.isValid())
- return Qt::NoItemFlags;
-
- return QAbstractItemModel::flags(index);
-}
-//! [5]
-
-//! [6]
-QVariant DomModel::headerData(int section, Qt::Orientation orientation,
- int role) const
-{
- if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
- switch (section) {
- case 0:
- return tr("Name");
- case 1:
- return tr("Attributes");
- case 2:
- return tr("Value");
- default:
- break;
- }
- }
- return QVariant();
-}
-//! [6]
-
-//! [7]
-QModelIndex DomModel::index(int row, int column, const QModelIndex &parent) const
-{
- if (!hasIndex(row, column, parent))
- return QModelIndex();
-
- DomItem *parentItem;
-
- if (!parent.isValid())
- parentItem = rootItem;
- else
- parentItem = static_cast<DomItem*>(parent.internalPointer());
-//! [7]
-
-//! [8]
- DomItem *childItem = parentItem->child(row);
- if (childItem)
- return createIndex(row, column, childItem);
- return QModelIndex();
-}
-//! [8]
-
-//! [9]
-QModelIndex DomModel::parent(const QModelIndex &child) const
-{
- if (!child.isValid())
- return QModelIndex();
-
- DomItem *childItem = static_cast<DomItem*>(child.internalPointer());
- DomItem *parentItem = childItem->parent();
-
- if (!parentItem || parentItem == rootItem)
- return QModelIndex();
-
- return createIndex(parentItem->row(), 0, parentItem);
-}
-//! [9]
-
-//! [10]
-int DomModel::rowCount(const QModelIndex &parent) const
-{
- if (parent.column() > 0)
- return 0;
-
- DomItem *parentItem;
-
- if (!parent.isValid())
- parentItem = rootItem;
- else
- parentItem = static_cast<DomItem*>(parent.internalPointer());
-
- return parentItem->node().childNodes().count();
-}
-//! [10]
diff --git a/examples/widgets/itemviews/simpledommodel/dommodel.h b/examples/widgets/itemviews/simpledommodel/dommodel.h
deleted file mode 100644
index 109ab33e58..0000000000
--- a/examples/widgets/itemviews/simpledommodel/dommodel.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef DOMMODEL_H
-#define DOMMODEL_H
-
-#include <QAbstractItemModel>
-#include <QDomDocument>
-#include <QModelIndex>
-
-class DomItem;
-
-//! [0]
-class DomModel : public QAbstractItemModel
-{
- Q_OBJECT
-
-public:
- explicit DomModel(const QDomDocument &document, QObject *parent = nullptr);
- ~DomModel();
-
- QVariant data(const QModelIndex &index, int role) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const override;
- QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const override;
- QModelIndex index(int row, int column,
- const QModelIndex &parent = QModelIndex()) const override;
- QModelIndex parent(const QModelIndex &child) const override;
- int rowCount(const QModelIndex &parent = QModelIndex()) const override;
- int columnCount(const QModelIndex &parent = QModelIndex()) const override;
-
-private:
- QDomDocument domDocument;
- DomItem *rootItem;
-};
-//! [0]
-
-#endif // DOMMODEL_H
diff --git a/examples/widgets/itemviews/simpledommodel/main.cpp b/examples/widgets/itemviews/simpledommodel/main.cpp
deleted file mode 100644
index 2ea03356f2..0000000000
--- a/examples/widgets/itemviews/simpledommodel/main.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- MainWindow window;
- window.resize(640, 480);
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/itemviews/simpledommodel/mainwindow.cpp b/examples/widgets/itemviews/simpledommodel/mainwindow.cpp
deleted file mode 100644
index ad64863fbb..0000000000
--- a/examples/widgets/itemviews/simpledommodel/mainwindow.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-#include "dommodel.h"
-
-#include <QDomDocument>
-#include <QTreeView>
-#include <QMenuBar>
-#include <QFileDialog>
-
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent),
- model(new DomModel(QDomDocument(), this)),
- view(new QTreeView(this))
-{
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(tr("&Open..."), QKeySequence::Open, this, &MainWindow::openFile);
- fileMenu->addAction(tr("E&xit"), QKeySequence::Quit, this, &QWidget::close);
-
- view->setModel(model);
-
- setCentralWidget(view);
- setWindowTitle(tr("Simple DOM Model"));
-}
-
-void MainWindow::openFile()
-{
- QString filePath = QFileDialog::getOpenFileName(this, tr("Open File"),
- xmlPath, tr("XML files (*.xml);;HTML files (*.html);;"
- "SVG files (*.svg);;User Interface files (*.ui)"));
-
- if (!filePath.isEmpty()) {
- QFile file(filePath);
- if (file.open(QIODevice::ReadOnly)) {
- QDomDocument document;
- if (document.setContent(&file)) {
- DomModel *newModel = new DomModel(document, this);
- view->setModel(newModel);
- delete model;
- model = newModel;
- xmlPath = filePath;
- }
- file.close();
- }
- }
-}
diff --git a/examples/widgets/itemviews/simpledommodel/mainwindow.h b/examples/widgets/itemviews/simpledommodel/mainwindow.h
deleted file mode 100644
index a82f3956c8..0000000000
--- a/examples/widgets/itemviews/simpledommodel/mainwindow.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include <QString>
-
-class DomModel;
-QT_BEGIN_NAMESPACE
-class QMenu;
-class QTreeView;
-QT_END_NAMESPACE
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow(QWidget *parent = nullptr);
-
-public slots:
- void openFile();
-
-private:
- DomModel *model;
- QMenu *fileMenu;
- QString xmlPath;
- QTreeView *view;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/widgets/itemviews/simpledommodel/simpledommodel.pro b/examples/widgets/itemviews/simpledommodel/simpledommodel.pro
deleted file mode 100644
index 3d45920e36..0000000000
--- a/examples/widgets/itemviews/simpledommodel/simpledommodel.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-HEADERS = domitem.h \
- dommodel.h \
- mainwindow.h
-SOURCES = domitem.cpp \
- dommodel.cpp \
- main.cpp \
- mainwindow.cpp
-QT += xml widgets
-requires(qtConfig(filedialog))
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/itemviews/simpledommodel
-INSTALLS += target
-
diff --git a/examples/widgets/itemviews/simpletreemodel/CMakeLists.txt b/examples/widgets/itemviews/simpletreemodel/CMakeLists.txt
index f2ea8ae785..2fd31fae43 100644
--- a/examples/widgets/itemviews/simpletreemodel/CMakeLists.txt
+++ b/examples/widgets/itemviews/simpletreemodel/CMakeLists.txt
@@ -1,18 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(simpletreemodel LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Test Widgets)
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/simpletreemodel")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
qt_add_executable(simpletreemodel
main.cpp
@@ -25,10 +19,10 @@ set_target_properties(simpletreemodel PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(simpletreemodel PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(simpletreemodel PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -44,7 +38,46 @@ qt_add_resources(simpletreemodel "simpletreemodel"
)
install(TARGETS simpletreemodel
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET simpletreemodel
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
+
+#! [1]
+# Unit Test
+
+include(CTest)
+
+qt_add_executable(simpletreemodel_tester
+ test.cpp
+ treeitem.cpp treeitem.h
+ treemodel.cpp treemodel.h)
+
+target_link_libraries(simpletreemodel_tester PRIVATE
+ Qt6::Core
+ Qt6::Test
+)
+
+if(ANDROID)
+ target_link_libraries(simpletreemodel_tester PRIVATE
+ Qt6::Gui
+ )
+endif()
+
+qt_add_resources(simpletreemodel_tester "simpletreemodel"
+ PREFIX
+ "/"
+ FILES
+ ${simpletreemodel_resource_files}
)
+
+add_test(NAME simpletreemodel_tester
+ COMMAND simpletreemodel_tester)
+#! [1]
diff --git a/examples/widgets/itemviews/simpletreemodel/main.cpp b/examples/widgets/itemviews/simpletreemodel/main.cpp
index 10075a18e5..5800c595c8 100644
--- a/examples/widgets/itemviews/simpletreemodel/main.cpp
+++ b/examples/widgets/itemviews/simpletreemodel/main.cpp
@@ -5,22 +5,28 @@
#include <QApplication>
#include <QFile>
+#include <QScreen>
#include <QTreeView>
+using namespace Qt::StringLiterals;
+
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(simpletreemodel);
-
QApplication app(argc, argv);
- QFile file(":/default.txt");
- file.open(QIODevice::ReadOnly);
- TreeModel model(file.readAll());
+ QFile file(":/default.txt"_L1);
+ file.open(QIODevice::ReadOnly | QIODevice::Text);
+ TreeModel model(QString::fromUtf8(file.readAll()));
file.close();
QTreeView view;
view.setModel(&model);
- view.setWindowTitle(QObject::tr("Simple Tree Model"));
+ view.setWindowTitle(TreeModel::tr("Simple Tree Model"));
+ for (int c = 0; c < model.columnCount(); ++c)
+ view.resizeColumnToContents(c);
+ view.expandAll();
+ const auto screenSize = view.screen()->availableSize();
+ view.resize({screenSize.width() / 2, screenSize.height() * 2 / 3});
view.show();
- return app.exec();
+ return QCoreApplication::exec();
}
diff --git a/examples/widgets/itemviews/simpletreemodel/test.cpp b/examples/widgets/itemviews/simpletreemodel/test.cpp
new file mode 100644
index 0000000000..7e9479a396
--- /dev/null
+++ b/examples/widgets/itemviews/simpletreemodel/test.cpp
@@ -0,0 +1,35 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "treemodel.h"
+
+#include <QObject>
+#include <QAbstractItemModelTester>
+#include <QTest>
+
+using namespace Qt::StringLiterals;
+
+//! [1]
+class TestSimpleTreeModel : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testTreeModel();
+};
+
+void TestSimpleTreeModel::testTreeModel()
+{
+ constexpr auto fileName = ":/default.txt"_L1;
+ QFile file(fileName);
+ QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Text),
+ qPrintable(fileName + " cannot be opened: "_L1 + file.errorString()));
+ TreeModel model(QString::fromUtf8(file.readAll()));
+
+ QAbstractItemModelTester tester(&model);
+}
+
+QTEST_APPLESS_MAIN(TestSimpleTreeModel)
+
+#include "test.moc"
+//! [1]
diff --git a/examples/widgets/itemviews/simpletreemodel/treeitem.cpp b/examples/widgets/itemviews/simpletreemodel/treeitem.cpp
index 59292bbbca..67e021d622 100644
--- a/examples/widgets/itemviews/simpletreemodel/treeitem.cpp
+++ b/examples/widgets/itemviews/simpletreemodel/treeitem.cpp
@@ -10,70 +10,66 @@
#include "treeitem.h"
//! [0]
-TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent)
- : m_itemData(data), m_parentItem(parent)
+TreeItem::TreeItem(QVariantList data, TreeItem *parent)
+ : m_itemData(std::move(data)), m_parentItem(parent)
{}
//! [0]
//! [1]
-TreeItem::~TreeItem()
+void TreeItem::appendChild(std::unique_ptr<TreeItem> &&child)
{
- qDeleteAll(m_childItems);
+ m_childItems.push_back(std::move(child));
}
//! [1]
//! [2]
-void TreeItem::appendChild(TreeItem *item)
+TreeItem *TreeItem::child(int row)
{
- m_childItems.append(item);
+ return row >= 0 && row < childCount() ? m_childItems.at(row).get() : nullptr;
}
//! [2]
//! [3]
-TreeItem *TreeItem::child(int row)
+int TreeItem::childCount() const
{
- if (row < 0 || row >= m_childItems.size())
- return nullptr;
- return m_childItems.at(row);
+ return int(m_childItems.size());
}
//! [3]
//! [4]
-int TreeItem::childCount() const
+int TreeItem::columnCount() const
{
- return m_childItems.count();
+ return int(m_itemData.count());
}
//! [4]
//! [5]
-int TreeItem::columnCount() const
+QVariant TreeItem::data(int column) const
{
- return m_itemData.count();
+ return m_itemData.value(column);
}
//! [5]
//! [6]
-QVariant TreeItem::data(int column) const
-{
- if (column < 0 || column >= m_itemData.size())
- return QVariant();
- return m_itemData.at(column);
-}
-//! [6]
-
-//! [7]
TreeItem *TreeItem::parentItem()
{
return m_parentItem;
}
-//! [7]
+//! [6]
-//! [8]
+//! [7]
int TreeItem::row() const
{
- if (m_parentItem)
- return m_parentItem->m_childItems.indexOf(const_cast<TreeItem*>(this));
+ if (m_parentItem == nullptr)
+ return 0;
+ const auto it = std::find_if(m_parentItem->m_childItems.cbegin(), m_parentItem->m_childItems.cend(),
+ [this](const std::unique_ptr<TreeItem> &treeItem) {
+ return treeItem.get() == this;
+ });
- return 0;
+ if (it != m_parentItem->m_childItems.cend())
+ return std::distance(m_parentItem->m_childItems.cbegin(), it);
+ Q_ASSERT(false); // should not happen
+ return -1;
}
-//! [8]
+//! [7]
diff --git a/examples/widgets/itemviews/simpletreemodel/treeitem.h b/examples/widgets/itemviews/simpletreemodel/treeitem.h
index b2508b9058..b9002f06fd 100644
--- a/examples/widgets/itemviews/simpletreemodel/treeitem.h
+++ b/examples/widgets/itemviews/simpletreemodel/treeitem.h
@@ -11,10 +11,9 @@
class TreeItem
{
public:
- explicit TreeItem(const QList<QVariant> &data, TreeItem *parentItem = nullptr);
- ~TreeItem();
+ explicit TreeItem(QVariantList data, TreeItem *parentItem = nullptr);
- void appendChild(TreeItem *child);
+ void appendChild(std::unique_ptr<TreeItem> &&child);
TreeItem *child(int row);
int childCount() const;
@@ -24,8 +23,8 @@ public:
TreeItem *parentItem();
private:
- QList<TreeItem *> m_childItems;
- QList<QVariant> m_itemData;
+ std::vector<std::unique_ptr<TreeItem>> m_childItems;
+ QVariantList m_itemData;
TreeItem *m_parentItem;
};
//! [0]
diff --git a/examples/widgets/itemviews/simpletreemodel/treemodel.cpp b/examples/widgets/itemviews/simpletreemodel/treemodel.cpp
index 1665f18ebe..8538d99629 100644
--- a/examples/widgets/itemviews/simpletreemodel/treemodel.cpp
+++ b/examples/widgets/itemviews/simpletreemodel/treemodel.cpp
@@ -13,20 +13,19 @@
#include <QStringList>
+using namespace Qt::StringLiterals;
+
//! [0]
TreeModel::TreeModel(const QString &data, QObject *parent)
: QAbstractItemModel(parent)
+ , rootItem(std::make_unique<TreeItem>(QVariantList{tr("Title"), tr("Summary")}))
{
- rootItem = new TreeItem({tr("Title"), tr("Summary")});
- setupModelData(data.split('\n'), rootItem);
+ setupModelData(QStringView{data}.split(u'\n'), rootItem.get());
}
//! [0]
//! [1]
-TreeModel::~TreeModel()
-{
- delete rootItem;
-}
+TreeModel::~TreeModel() = default;
//! [1]
//! [2]
@@ -41,14 +40,10 @@ int TreeModel::columnCount(const QModelIndex &parent) const
//! [3]
QVariant TreeModel::data(const QModelIndex &index, int role) const
{
- if (!index.isValid())
- return QVariant();
-
- if (role != Qt::DisplayRole)
- return QVariant();
-
- TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
+ if (!index.isValid() || role != Qt::DisplayRole)
+ return {};
+ const auto *item = static_cast<const TreeItem*>(index.internalPointer());
return item->data(index.column());
}
//! [3]
@@ -56,10 +51,8 @@ QVariant TreeModel::data(const QModelIndex &index, int role) const
//! [4]
Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
{
- if (!index.isValid())
- return Qt::NoItemFlags;
-
- return QAbstractItemModel::flags(index);
+ return index.isValid()
+ ? QAbstractItemModel::flags(index) : Qt::ItemFlags(Qt::NoItemFlags);
}
//! [4]
@@ -67,10 +60,8 @@ Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
- if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
- return rootItem->data(section);
-
- return QVariant();
+ return orientation == Qt::Horizontal && role == Qt::DisplayRole
+ ? rootItem->data(section) : QVariant{};
}
//! [5]
@@ -78,19 +69,15 @@ QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const
{
if (!hasIndex(row, column, parent))
- return QModelIndex();
-
- TreeItem *parentItem;
+ return {};
- if (!parent.isValid())
- parentItem = rootItem;
- else
- parentItem = static_cast<TreeItem*>(parent.internalPointer());
+ TreeItem *parentItem = parent.isValid()
+ ? static_cast<TreeItem*>(parent.internalPointer())
+ : rootItem.get();
- TreeItem *childItem = parentItem->child(row);
- if (childItem)
+ if (auto *childItem = parentItem->child(row))
return createIndex(row, column, childItem);
- return QModelIndex();
+ return {};
}
//! [6]
@@ -98,80 +85,68 @@ QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) con
QModelIndex TreeModel::parent(const QModelIndex &index) const
{
if (!index.isValid())
- return QModelIndex();
+ return {};
- TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
+ auto *childItem = static_cast<TreeItem*>(index.internalPointer());
TreeItem *parentItem = childItem->parentItem();
- if (parentItem == rootItem)
- return QModelIndex();
-
- return createIndex(parentItem->row(), 0, parentItem);
+ return parentItem != rootItem.get()
+ ? createIndex(parentItem->row(), 0, parentItem) : QModelIndex{};
}
//! [7]
//! [8]
int TreeModel::rowCount(const QModelIndex &parent) const
{
- TreeItem *parentItem;
if (parent.column() > 0)
return 0;
- if (!parent.isValid())
- parentItem = rootItem;
- else
- parentItem = static_cast<TreeItem*>(parent.internalPointer());
+ const TreeItem *parentItem = parent.isValid()
+ ? static_cast<const TreeItem*>(parent.internalPointer())
+ : rootItem.get();
return parentItem->childCount();
}
//! [8]
-void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
+void TreeModel::setupModelData(const QList<QStringView> &lines, TreeItem *parent)
{
- QList<TreeItem *> parents;
- QList<int> indentations;
- parents << parent;
- indentations << 0;
-
- int number = 0;
-
- while (number < lines.count()) {
- int position = 0;
- while (position < lines[number].length()) {
- if (lines[number].at(position) != ' ')
- break;
- position++;
- }
+ struct ParentIndentation
+ {
+ TreeItem *parent;
+ qsizetype indentation;
+ };
- const QString lineData = lines[number].mid(position).trimmed();
+ QList<ParentIndentation> state{{parent, 0}};
+ for (const auto &line : lines) {
+ qsizetype position = 0;
+ for ( ; position < line.length() && line.at(position).isSpace(); ++position) {
+ }
+
+ const QStringView lineData = line.sliced(position).trimmed();
if (!lineData.isEmpty()) {
// Read the column data from the rest of the line.
- const QStringList columnStrings =
- lineData.split(QLatin1Char('\t'), Qt::SkipEmptyParts);
- QList<QVariant> columnData;
+ const auto columnStrings = lineData.split(u'\t', Qt::SkipEmptyParts);
+ QVariantList columnData;
columnData.reserve(columnStrings.count());
- for (const QString &columnString : columnStrings)
- columnData << columnString;
+ for (const auto &columnString : columnStrings)
+ columnData << columnString.toString();
- if (position > indentations.last()) {
+ if (position > state.constLast().indentation) {
// The last child of the current parent is now the new parent
// unless the current parent has no children.
-
- if (parents.last()->childCount() > 0) {
- parents << parents.last()->child(parents.last()->childCount()-1);
- indentations << position;
- }
+ auto *lastParent = state.constLast().parent;
+ if (lastParent->childCount() > 0)
+ state.append({lastParent->child(lastParent->childCount() - 1), position});
} else {
- while (position < indentations.last() && parents.count() > 0) {
- parents.pop_back();
- indentations.pop_back();
- }
+ while (position < state.constLast().indentation && !state.isEmpty())
+ state.removeLast();
}
// Append a new item to the current parent's list of children.
- parents.last()->appendChild(new TreeItem(columnData, parents.last()));
+ auto *lastParent = state.constLast().parent;
+ lastParent->appendChild(std::make_unique<TreeItem>(columnData, lastParent));
}
- ++number;
}
}
diff --git a/examples/widgets/itemviews/simpletreemodel/treemodel.h b/examples/widgets/itemviews/simpletreemodel/treemodel.h
index aa93c33494..1a42fa585f 100644
--- a/examples/widgets/itemviews/simpletreemodel/treemodel.h
+++ b/examples/widgets/itemviews/simpletreemodel/treemodel.h
@@ -16,23 +16,25 @@ class TreeModel : public QAbstractItemModel
Q_OBJECT
public:
+ Q_DISABLE_COPY_MOVE(TreeModel)
+
explicit TreeModel(const QString &data, QObject *parent = nullptr);
- ~TreeModel();
+ ~TreeModel() override;
QVariant data(const QModelIndex &index, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column,
- const QModelIndex &parent = QModelIndex()) const override;
+ const QModelIndex &parent = {}) const override;
QModelIndex parent(const QModelIndex &index) const override;
- int rowCount(const QModelIndex &parent = QModelIndex()) const override;
- int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ int rowCount(const QModelIndex &parent = {}) const override;
+ int columnCount(const QModelIndex &parent = {}) const override;
private:
- void setupModelData(const QStringList &lines, TreeItem *parent);
+ static void setupModelData(const QList<QStringView> &lines, TreeItem *parent);
- TreeItem *rootItem;
+ std::unique_ptr<TreeItem> rootItem;
};
//! [0]
diff --git a/examples/widgets/itemviews/simplewidgetmapper/CMakeLists.txt b/examples/widgets/itemviews/simplewidgetmapper/CMakeLists.txt
deleted file mode 100644
index 1564d8d3a1..0000000000
--- a/examples/widgets/itemviews/simplewidgetmapper/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(simplewidgetmapper LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/simplewidgetmapper")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(simplewidgetmapper
- main.cpp
- window.cpp window.h
-)
-
-set_target_properties(simplewidgetmapper PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(simplewidgetmapper PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS simplewidgetmapper
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/itemviews/simplewidgetmapper/main.cpp b/examples/widgets/itemviews/simplewidgetmapper/main.cpp
deleted file mode 100644
index 2709c948f9..0000000000
--- a/examples/widgets/itemviews/simplewidgetmapper/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "window.h"
-
-#include <QApplication>
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
- Window window;
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/itemviews/simplewidgetmapper/simplewidgetmapper.pro b/examples/widgets/itemviews/simplewidgetmapper/simplewidgetmapper.pro
deleted file mode 100644
index f86a16bd3f..0000000000
--- a/examples/widgets/itemviews/simplewidgetmapper/simplewidgetmapper.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT += widgets
-requires(qtConfig(datawidgetmapper))
-
-HEADERS = window.h
-SOURCES = main.cpp \
- window.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/itemviews/simplewidgetmapper
-INSTALLS += target
diff --git a/examples/widgets/itemviews/simplewidgetmapper/window.cpp b/examples/widgets/itemviews/simplewidgetmapper/window.cpp
deleted file mode 100644
index f7ef05dbd5..0000000000
--- a/examples/widgets/itemviews/simplewidgetmapper/window.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "window.h"
-
-#include <QtWidgets>
-
-//! [Set up widgets]
-Window::Window(QWidget *parent)
- : QWidget(parent)
-{
- setupModel();
-
- nameLabel = new QLabel(tr("Na&me:"));
- nameEdit = new QLineEdit();
- addressLabel = new QLabel(tr("&Address:"));
- addressEdit = new QTextEdit();
- ageLabel = new QLabel(tr("A&ge (in years):"));
- ageSpinBox = new QSpinBox();
- nextButton = new QPushButton(tr("&Next"));
- previousButton = new QPushButton(tr("&Previous"));
-
- nameLabel->setBuddy(nameEdit);
- addressLabel->setBuddy(addressEdit);
- ageLabel->setBuddy(ageSpinBox);
-//! [Set up widgets]
-
-//! [Set up the mapper]
- mapper = new QDataWidgetMapper(this);
- mapper->setModel(model);
- mapper->addMapping(nameEdit, 0);
- mapper->addMapping(addressEdit, 1);
- mapper->addMapping(ageSpinBox, 2);
-
- connect(previousButton, &QAbstractButton::clicked, mapper, &QDataWidgetMapper::toPrevious);
- connect(nextButton, &QAbstractButton::clicked, mapper, &QDataWidgetMapper::toNext);
- connect(mapper, &QDataWidgetMapper::currentIndexChanged, this, &Window::updateButtons);
-//! [Set up the mapper]
-
-//! [Set up the layout]
- QGridLayout *layout = new QGridLayout();
- layout->addWidget(nameLabel, 0, 0, 1, 1);
- layout->addWidget(nameEdit, 0, 1, 1, 1);
- layout->addWidget(previousButton, 0, 2, 1, 1);
- layout->addWidget(addressLabel, 1, 0, 1, 1);
- layout->addWidget(addressEdit, 1, 1, 2, 1);
- layout->addWidget(nextButton, 1, 2, 1, 1);
- layout->addWidget(ageLabel, 3, 0, 1, 1);
- layout->addWidget(ageSpinBox, 3, 1, 1, 1);
- setLayout(layout);
-
- setWindowTitle(tr("Simple Widget Mapper"));
- mapper->toFirst();
-}
-//! [Set up the layout]
-
-//! [Set up the model]
-void Window::setupModel()
-{
- model = new QStandardItemModel(5, 3, this);
-
- QStringList names;
- names << "Alice" << "Bob" << "Carol" << "Donald" << "Emma";
-
- QStringList addresses;
- addresses << "<qt>123 Main Street<br/>Market Town</qt>"
- << "<qt>PO Box 32<br/>Mail Handling Service"
- "<br/>Service City</qt>"
- << "<qt>The Lighthouse<br/>Remote Island</qt>"
- << "<qt>47338 Park Avenue<br/>Big City</qt>"
- << "<qt>Research Station<br/>Base Camp<br/>Big Mountain</qt>";
-
- QStringList ages;
- ages << "20" << "31" << "32" << "19" << "26";
-
- for (int row = 0; row < 5; ++row) {
- QStandardItem *item = new QStandardItem(names[row]);
- model->setItem(row, 0, item);
- item = new QStandardItem(addresses[row]);
- model->setItem(row, 1, item);
- item = new QStandardItem(ages[row]);
- model->setItem(row, 2, item);
- }
-}
-//! [Set up the model]
-
-//! [Slot for updating the buttons]
-void Window::updateButtons(int row)
-{
- previousButton->setEnabled(row > 0);
- nextButton->setEnabled(row < model->rowCount() - 1);
-}
-//! [Slot for updating the buttons]
diff --git a/examples/widgets/itemviews/simplewidgetmapper/window.h b/examples/widgets/itemviews/simplewidgetmapper/window.h
deleted file mode 100644
index 1502c00df1..0000000000
--- a/examples/widgets/itemviews/simplewidgetmapper/window.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QDataWidgetMapper;
-class QLabel;
-class QLineEdit;
-class QPushButton;
-class QSpinBox;
-class QStandardItemModel;
-class QTextEdit;
-QT_END_NAMESPACE
-
-//! [Window definition]
-class Window : public QWidget
-{
- Q_OBJECT
-
-public:
- Window(QWidget *parent = nullptr);
-
-private slots:
- void updateButtons(int row);
-
-private:
- void setupModel();
-
- QLabel *nameLabel;
- QLabel *addressLabel;
- QLabel *ageLabel;
- QLineEdit *nameEdit;
- QTextEdit *addressEdit;
- QSpinBox *ageSpinBox;
- QPushButton *nextButton;
- QPushButton *previousButton;
-
- QStandardItemModel *model;
- QDataWidgetMapper *mapper;
-};
-//! [Window definition]
-
-#endif // WINDOW_H
diff --git a/examples/widgets/itemviews/spinboxdelegate/CMakeLists.txt b/examples/widgets/itemviews/spinboxdelegate/CMakeLists.txt
deleted file mode 100644
index 0c64cb378a..0000000000
--- a/examples/widgets/itemviews/spinboxdelegate/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(spinboxdelegate LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/spinboxdelegate")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(spinboxdelegate
- delegate.cpp delegate.h
- main.cpp
-)
-
-set_target_properties(spinboxdelegate PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(spinboxdelegate PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS spinboxdelegate
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/itemviews/spinboxdelegate/delegate.cpp b/examples/widgets/itemviews/spinboxdelegate/delegate.cpp
deleted file mode 100644
index 6aa2b9be42..0000000000
--- a/examples/widgets/itemviews/spinboxdelegate/delegate.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-/*
- delegate.cpp
-
- A delegate that allows the user to change integer values from the model
- using a spin box widget.
-*/
-
-#include "delegate.h"
-
-#include <QSpinBox>
-
-//! [0]
-SpinBoxDelegate::SpinBoxDelegate(QObject *parent)
- : QStyledItemDelegate(parent)
-{
-}
-//! [0]
-
-//! [1]
-QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
- const QStyleOptionViewItem &/* option */,
- const QModelIndex &/* index */) const
-{
- QSpinBox *editor = new QSpinBox(parent);
- editor->setFrame(false);
- editor->setMinimum(0);
- editor->setMaximum(100);
-
- return editor;
-}
-//! [1]
-
-//! [2]
-void SpinBoxDelegate::setEditorData(QWidget *editor,
- const QModelIndex &index) const
-{
- int value = index.model()->data(index, Qt::EditRole).toInt();
-
- QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
- spinBox->setValue(value);
-}
-//! [2]
-
-//! [3]
-void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
- const QModelIndex &index) const
-{
- QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
- spinBox->interpretText();
- int value = spinBox->value();
-
- model->setData(index, value, Qt::EditRole);
-}
-//! [3]
-
-//! [4]
-void SpinBoxDelegate::updateEditorGeometry(QWidget *editor,
- const QStyleOptionViewItem &option,
- const QModelIndex &/* index */) const
-{
- editor->setGeometry(option.rect);
-}
-//! [4]
diff --git a/examples/widgets/itemviews/spinboxdelegate/main.cpp b/examples/widgets/itemviews/spinboxdelegate/main.cpp
deleted file mode 100644
index 51277036bc..0000000000
--- a/examples/widgets/itemviews/spinboxdelegate/main.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-/*
- main.cpp
-
- A simple example that shows how a view can use a custom delegate to edit
- data obtained from a model.
-*/
-
-#include "delegate.h"
-
-#include <QApplication>
-#include <QHeaderView>
-#include <QStandardItemModel>
-#include <QTableView>
-
-//! [0]
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QStandardItemModel model(4, 2);
- QTableView tableView;
- tableView.setModel(&model);
-
- SpinBoxDelegate delegate;
- tableView.setItemDelegate(&delegate);
-//! [0]
-
- tableView.horizontalHeader()->setStretchLastSection(true);
-
-//! [1]
- for (int row = 0; row < 4; ++row) {
- for (int column = 0; column < 2; ++column) {
- QModelIndex index = model.index(row, column, QModelIndex());
- model.setData(index, QVariant((row + 1) * (column + 1)));
- }
-//! [1] //! [2]
- }
-//! [2]
-
-//! [3]
- tableView.setWindowTitle(QObject::tr("Spin Box Delegate"));
- tableView.show();
- return app.exec();
-}
-//! [3]
diff --git a/examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.pro b/examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.pro
deleted file mode 100644
index 2a6fed223a..0000000000
--- a/examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT += widgets
-requires(qtConfig(tableview))
-
-HEADERS = delegate.h
-SOURCES = delegate.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/itemviews/spinboxdelegate
-INSTALLS += target
diff --git a/examples/widgets/itemviews/spreadsheet/CMakeLists.txt b/examples/widgets/itemviews/spreadsheet/CMakeLists.txt
index b931ba4bd0..b6521f0c2f 100644
--- a/examples/widgets/itemviews/spreadsheet/CMakeLists.txt
+++ b/examples/widgets/itemviews/spreadsheet/CMakeLists.txt
@@ -1,22 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(spreadsheet LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/spreadsheet")
-
find_package(Qt6
REQUIRED COMPONENTS Core Gui Widgets
OPTIONAL_COMPONENTS PrintSupport
)
+qt_standard_project_setup()
+
qt_add_executable(spreadsheet
main.cpp
printview.cpp printview.h
@@ -30,14 +24,14 @@ set_target_properties(spreadsheet PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(spreadsheet PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(spreadsheet PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
-if (TARGET Qt::PrintSupport)
- target_link_libraries(spreadsheet PUBLIC Qt::PrintSupport)
+if (TARGET Qt6::PrintSupport)
+ target_link_libraries(spreadsheet PRIVATE Qt6::PrintSupport)
endif()
# Resources:
@@ -52,14 +46,15 @@ qt_add_resources(spreadsheet "spreadsheet"
${spreadsheet_resource_files}
)
-if(TARGET Qt::PrintSupport)
- target_link_libraries(spreadsheet PUBLIC
- Qt::PrintSupport
- )
-endif()
-
install(TARGETS spreadsheet
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET spreadsheet
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/itemviews/spreadsheet/main.cpp b/examples/widgets/itemviews/spreadsheet/main.cpp
index 13bd0c93fc..3c2d676e88 100644
--- a/examples/widgets/itemviews/spreadsheet/main.cpp
+++ b/examples/widgets/itemviews/spreadsheet/main.cpp
@@ -8,8 +8,6 @@
int main(int argc, char **argv)
{
- Q_INIT_RESOURCE(spreadsheet);
-
QApplication app(argc, argv);
SpreadSheet sheet(10, 6);
sheet.setWindowIcon(QPixmap(":/images/interview.png"));
@@ -17,5 +15,3 @@ int main(int argc, char **argv)
sheet.layout()->setSizeConstraint(QLayout::SetFixedSize);
return app.exec();
}
-
-
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp b/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp
index d26ad7f49d..37a307b26e 100644
--- a/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp
@@ -106,9 +106,11 @@ void SpreadSheet::createActions()
secondSeparator->setSeparator(true);
}
+//! [implicit tr context]
void SpreadSheet::setupMenuBar()
{
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
+//! [implicit tr context]
fileMenu->addAction(printAction);
fileMenu->addAction(exitAction);
diff --git a/examples/widgets/itemviews/stardelegate/CMakeLists.txt b/examples/widgets/itemviews/stardelegate/CMakeLists.txt
index 265b0186d5..500a03f59b 100644
--- a/examples/widgets/itemviews/stardelegate/CMakeLists.txt
+++ b/examples/widgets/itemviews/stardelegate/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(stardelegate LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/stardelegate")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(stardelegate
main.cpp
stardelegate.cpp stardelegate.h
@@ -26,14 +20,21 @@ set_target_properties(stardelegate PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(stardelegate PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(stardelegate PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS stardelegate
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET stardelegate
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/itemviews/storageview/CMakeLists.txt b/examples/widgets/itemviews/storageview/CMakeLists.txt
deleted file mode 100644
index b393b5b20f..0000000000
--- a/examples/widgets/itemviews/storageview/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(storageview LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/storageview")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(storageview
- main.cpp
- storagemodel.cpp storagemodel.h
-)
-
-set_target_properties(storageview PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(storageview PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS storageview
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/itemviews/storageview/main.cpp b/examples/widgets/itemviews/storageview/main.cpp
deleted file mode 100644
index 3bd5392736..0000000000
--- a/examples/widgets/itemviews/storageview/main.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// Copyright (C) 2016 Ivan Komissarov
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-#include <QShortcut>
-#include <QTreeView>
-
-#include "storagemodel.h"
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
-
- QTreeView view;
- view.resize(640, 480);
- view.setWindowTitle("Storage View");
- view.setSelectionBehavior(QAbstractItemView::SelectRows);
-
- StorageModel *model = new StorageModel(&view);
- model->refresh();
- QShortcut *refreshShortcut = new QShortcut(QKeySequence::Refresh, &view);
- QObject::connect(refreshShortcut, &QShortcut::activated, model, &StorageModel::refresh);
- view.setModel(model);
-
- int columnCount = view.model()->columnCount();
- for (int c = 0; c < columnCount; ++c)
- view.resizeColumnToContents(c);
- view.show();
-
- return a.exec();
-}
diff --git a/examples/widgets/itemviews/storageview/storagemodel.cpp b/examples/widgets/itemviews/storageview/storagemodel.cpp
deleted file mode 100644
index 194f8723f6..0000000000
--- a/examples/widgets/itemviews/storageview/storagemodel.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// Copyright (C) 2016 Ivan Komissarov
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "storagemodel.h"
-
-#include <QDir>
-#include <QLocale>
-
-void StorageModel::refresh()
-{
- beginResetModel();
- m_volumes = QStorageInfo::mountedVolumes();
- std::sort(m_volumes.begin(), m_volumes.end(),
- [](const QStorageInfo &st1, const QStorageInfo &st2) {
- static const QString rootSortString = QStringLiteral(" ");
- return (st1.isRoot() ? rootSortString : st1.rootPath())
- < (st2.isRoot() ? rootSortString : st2.rootPath());
- });
- endResetModel();
-}
-
-int StorageModel::columnCount(const QModelIndex &/*parent*/) const
-{
- return ColumnCount;
-}
-
-int StorageModel::rowCount(const QModelIndex &parent) const
-{
- if (parent.isValid())
- return 0;
- return m_volumes.count();
-}
-
-Qt::ItemFlags StorageModel::flags(const QModelIndex &index) const
-{
- Qt::ItemFlags result = QAbstractTableModel::flags(index);
- switch (index.column()) {
- case ColumnAvailable:
- case ColumnIsReady:
- case ColumnIsReadOnly:
- case ColumnIsValid:
- result |= Qt::ItemIsUserCheckable;
- break;
- default:
- break;
- }
- return result;
-}
-
-QVariant StorageModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- if (role == Qt::DisplayRole) {
- const QStorageInfo &volume = m_volumes.at(index.row());
- switch (index.column()) {
- case ColumnRootPath:
- return QDir::toNativeSeparators(volume.rootPath());
- case ColumnName:
- return volume.name();
- case ColumnDevice:
- return volume.device();
- case ColumnFileSystemName:
- return volume.fileSystemType();
- case ColumnTotal:
- return QLocale().formattedDataSize(volume.bytesTotal());
- case ColumnFree:
- return QLocale().formattedDataSize(volume.bytesFree());
- case ColumnAvailable:
- return QLocale().formattedDataSize(volume.bytesAvailable());
- default:
- break;
- }
- } else if (role == Qt::CheckStateRole) {
- const QStorageInfo &volume = m_volumes.at(index.row());
- switch (index.column()) {
- case ColumnIsReady:
- return volume.isReady();
- case ColumnIsReadOnly:
- return volume.isReadOnly();
- case ColumnIsValid:
- return volume.isValid();
- default:
- break;
- }
- } else if (role == Qt::TextAlignmentRole) {
- switch (index.column()) {
- case ColumnTotal:
- case ColumnFree:
- case ColumnAvailable:
- return Qt::AlignTrailing;
- default:
- break;
- }
- return Qt::AlignLeading;
- } else if (role == Qt::ToolTipRole) {
- QLocale locale;
- const QStorageInfo &volume = m_volumes.at(index.row());
- return tr("Root path : %1\n"
- "Name: %2\n"
- "Display Name: %3\n"
- "Device: %4\n"
- "FileSystem: %5\n"
- "Total size: %6\n"
- "Free size: %7\n"
- "Available size: %8\n"
- "Is Ready: %9\n"
- "Is Read-only: %10\n"
- "Is Valid: %11\n"
- "Is Root: %12"
- ).
- arg(QDir::toNativeSeparators(volume.rootPath())).
- arg(volume.name()).
- arg(volume.displayName()).
- arg(QString::fromUtf8(volume.device())).
- arg(QString::fromUtf8(volume.fileSystemType())).
- arg(locale.formattedDataSize(volume.bytesTotal())).
- arg(locale.formattedDataSize(volume.bytesFree())).
- arg(locale.formattedDataSize(volume.bytesAvailable())).
- arg(volume.isReady() ? tr("true") : tr("false")).
- arg(volume.isReadOnly() ? tr("true") : tr("false")).
- arg(volume.isValid() ? tr("true") : tr("false")).
- arg(volume.isRoot() ? tr("true") : tr("false"));
- }
- return QVariant();
-}
-
-QVariant StorageModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- if (orientation != Qt::Horizontal)
- return QVariant();
-
- if (role != Qt::DisplayRole)
- return QVariant();
-
- switch (section) {
- case ColumnRootPath:
- return tr("Root Path");
- case ColumnName:
- return tr("Volume Name");
- case ColumnDevice:
- return tr("Device");
- case ColumnFileSystemName:
- return tr("File System");
- case ColumnTotal:
- return tr("Total");
- case ColumnFree:
- return tr("Free");
- case ColumnAvailable:
- return tr("Available");
- case ColumnIsReady:
- return tr("Ready");
- case ColumnIsReadOnly:
- return tr("Read-only");
- case ColumnIsValid:
- return tr("Valid");
- default:
- break;
- }
-
- return QVariant();
-}
diff --git a/examples/widgets/itemviews/storageview/storagemodel.h b/examples/widgets/itemviews/storageview/storagemodel.h
deleted file mode 100644
index f8cc3289c8..0000000000
--- a/examples/widgets/itemviews/storageview/storagemodel.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// Copyright (C) 2016 Ivan Komissarov
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef STORAGEMODEL_H
-#define STORAGEMODEL_H
-
-#include <QAbstractTableModel>
-#include <QStorageInfo>
-
-class StorageModel : public QAbstractTableModel
-{
- Q_OBJECT
- Q_DISABLE_COPY(StorageModel)
-public:
- enum Column {
- ColumnRootPath = 0,
- ColumnName,
- ColumnDevice,
- ColumnFileSystemName,
- ColumnTotal,
- ColumnFree,
- ColumnAvailable,
- ColumnIsReady,
- ColumnIsReadOnly,
- ColumnIsValid,
- ColumnCount
- };
-
- using QAbstractTableModel::QAbstractTableModel;
-
- int columnCount(const QModelIndex &parent) const override;
- int rowCount(const QModelIndex &parent) const override;
-
- QVariant data(const QModelIndex &index, int role) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const override;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
-
-public slots:
- void refresh();
-
-private:
- QList<QStorageInfo> m_volumes;
-};
-
-#endif // STORAGEMODEL_H
diff --git a/examples/widgets/itemviews/storageview/storageview.pro b/examples/widgets/itemviews/storageview/storageview.pro
deleted file mode 100644
index 2fdb78e7b8..0000000000
--- a/examples/widgets/itemviews/storageview/storageview.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-QT += core gui widgets
-requires(qtConfig(treeview))
-TARGET = storageview
-TEMPLATE = app
-SOURCES += storagemodel.cpp \
- main.cpp
-HEADERS += \
- storagemodel.h
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/itemviews/storageview
-INSTALLS += target
diff --git a/examples/widgets/layouts/CMakeLists.txt b/examples/widgets/layouts/CMakeLists.txt
index 60299638c4..7e679fadd3 100644
--- a/examples/widgets/layouts/CMakeLists.txt
+++ b/examples/widgets/layouts/CMakeLists.txt
@@ -1,7 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
qt_internal_add_example(basiclayouts)
-qt_internal_add_example(borderlayout)
-qt_internal_add_example(dynamiclayouts)
qt_internal_add_example(flowlayout)
diff --git a/examples/widgets/layouts/basiclayouts/CMakeLists.txt b/examples/widgets/layouts/basiclayouts/CMakeLists.txt
index cf175a8204..5f126c308a 100644
--- a/examples/widgets/layouts/basiclayouts/CMakeLists.txt
+++ b/examples/widgets/layouts/basiclayouts/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(basiclayouts LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/layouts/basiclayouts")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(basiclayouts
dialog.cpp dialog.h
main.cpp
@@ -24,14 +18,21 @@ set_target_properties(basiclayouts PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(basiclayouts PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(basiclayouts PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS basiclayouts
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET basiclayouts
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/layouts/basiclayouts/main.cpp b/examples/widgets/layouts/basiclayouts/main.cpp
index 32aabb2722..865e0d1579 100644
--- a/examples/widgets/layouts/basiclayouts/main.cpp
+++ b/examples/widgets/layouts/basiclayouts/main.cpp
@@ -9,11 +9,7 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Dialog dialog;
-#ifdef Q_OS_ANDROID
- dialog.showMaximized();
-#else
dialog.show();
-#endif
return app.exec();
}
diff --git a/examples/widgets/layouts/borderlayout/CMakeLists.txt b/examples/widgets/layouts/borderlayout/CMakeLists.txt
deleted file mode 100644
index aa76e7d1ec..0000000000
--- a/examples/widgets/layouts/borderlayout/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(borderlayout LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/layouts/borderlayout")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(borderlayout
- borderlayout.cpp borderlayout.h
- main.cpp
- window.cpp window.h
-)
-
-set_target_properties(borderlayout PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(borderlayout PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS borderlayout
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/layouts/borderlayout/borderlayout.cpp b/examples/widgets/layouts/borderlayout/borderlayout.cpp
deleted file mode 100644
index 4dad24da0d..0000000000
--- a/examples/widgets/layouts/borderlayout/borderlayout.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "borderlayout.h"
-
-BorderLayout::BorderLayout(QWidget *parent, const QMargins &margins, int spacing)
- : QLayout(parent)
-{
- setContentsMargins(margins);
- setSpacing(spacing);
-}
-
-BorderLayout::BorderLayout(int spacing)
-{
- setSpacing(spacing);
-}
-
-
-BorderLayout::~BorderLayout()
-{
- QLayoutItem *l;
- while ((l = takeAt(0)))
- delete l;
-}
-
-void BorderLayout::addItem(QLayoutItem *item)
-{
- add(item, West);
-}
-
-void BorderLayout::addWidget(QWidget *widget, Position position)
-{
- add(new QWidgetItem(widget), position);
-}
-
-Qt::Orientations BorderLayout::expandingDirections() const
-{
- return Qt::Horizontal | Qt::Vertical;
-}
-
-bool BorderLayout::hasHeightForWidth() const
-{
- return false;
-}
-
-int BorderLayout::count() const
-{
- return list.size();
-}
-
-QLayoutItem *BorderLayout::itemAt(int index) const
-{
- ItemWrapper *wrapper = list.value(index);
- return wrapper ? wrapper->item : nullptr;
-}
-
-QSize BorderLayout::minimumSize() const
-{
- return calculateSize(MinimumSize);
-}
-
-void BorderLayout::setGeometry(const QRect &rect)
-{
- ItemWrapper *center = nullptr;
- int eastWidth = 0;
- int westWidth = 0;
- int northHeight = 0;
- int southHeight = 0;
- int centerHeight = 0;
- int i;
-
- QLayout::setGeometry(rect);
-
- for (i = 0; i < list.size(); ++i) {
- ItemWrapper *wrapper = list.at(i);
- QLayoutItem *item = wrapper->item;
- Position position = wrapper->position;
-
- if (position == North) {
- item->setGeometry(QRect(rect.x(), northHeight, rect.width(),
- item->sizeHint().height()));
-
- northHeight += item->geometry().height() + spacing();
- } else if (position == South) {
- item->setGeometry(QRect(item->geometry().x(),
- item->geometry().y(), rect.width(),
- item->sizeHint().height()));
-
- southHeight += item->geometry().height() + spacing();
-
- item->setGeometry(QRect(rect.x(),
- rect.y() + rect.height() - southHeight + spacing(),
- item->geometry().width(),
- item->geometry().height()));
- } else if (position == Center) {
- center = wrapper;
- }
- }
-
- centerHeight = rect.height() - northHeight - southHeight;
-
- for (i = 0; i < list.size(); ++i) {
- ItemWrapper *wrapper = list.at(i);
- QLayoutItem *item = wrapper->item;
- Position position = wrapper->position;
-
- if (position == West) {
- item->setGeometry(QRect(rect.x() + westWidth, northHeight,
- item->sizeHint().width(), centerHeight));
-
- westWidth += item->geometry().width() + spacing();
- } else if (position == East) {
- item->setGeometry(QRect(item->geometry().x(), item->geometry().y(),
- item->sizeHint().width(), centerHeight));
-
- eastWidth += item->geometry().width() + spacing();
-
- item->setGeometry(QRect(
- rect.x() + rect.width() - eastWidth + spacing(),
- northHeight, item->geometry().width(),
- item->geometry().height()));
- }
- }
-
- if (center)
- center->item->setGeometry(QRect(westWidth, northHeight,
- rect.width() - eastWidth - westWidth,
- centerHeight));
-}
-
-QSize BorderLayout::sizeHint() const
-{
- return calculateSize(SizeHint);
-}
-
-QLayoutItem *BorderLayout::takeAt(int index)
-{
- if (index >= 0 && index < list.size()) {
- ItemWrapper *layoutStruct = list.takeAt(index);
- return layoutStruct->item;
- }
- return nullptr;
-}
-
-void BorderLayout::add(QLayoutItem *item, Position position)
-{
- list.append(new ItemWrapper(item, position));
-}
-
-QSize BorderLayout::calculateSize(SizeType sizeType) const
-{
- QSize totalSize;
-
- for (int i = 0; i < list.size(); ++i) {
- ItemWrapper *wrapper = list.at(i);
- Position position = wrapper->position;
- QSize itemSize;
-
- if (sizeType == MinimumSize)
- itemSize = wrapper->item->minimumSize();
- else // (sizeType == SizeHint)
- itemSize = wrapper->item->sizeHint();
-
- if (position == North || position == South || position == Center)
- totalSize.rheight() += itemSize.height();
-
- if (position == West || position == East || position == Center)
- totalSize.rwidth() += itemSize.width();
- }
- return totalSize;
-}
diff --git a/examples/widgets/layouts/borderlayout/borderlayout.h b/examples/widgets/layouts/borderlayout/borderlayout.h
deleted file mode 100644
index c1d3ae7204..0000000000
--- a/examples/widgets/layouts/borderlayout/borderlayout.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef BORDERLAYOUT_H
-#define BORDERLAYOUT_H
-
-#include <QLayout>
-#include <QRect>
-
-class BorderLayout : public QLayout
-{
-public:
- enum Position { West, North, South, East, Center };
-
- explicit BorderLayout(QWidget *parent, const QMargins &margins = QMargins(), int spacing = -1);
- BorderLayout(int spacing = -1);
- ~BorderLayout();
-
- void addItem(QLayoutItem *item) override;
- void addWidget(QWidget *widget, Position position);
- Qt::Orientations expandingDirections() const override;
- bool hasHeightForWidth() const override;
- int count() const override;
- QLayoutItem *itemAt(int index) const override;
- QSize minimumSize() const override;
- void setGeometry(const QRect &rect) override;
- QSize sizeHint() const override;
- QLayoutItem *takeAt(int index) override;
-
- void add(QLayoutItem *item, Position position);
-
-private:
- struct ItemWrapper
- {
- ItemWrapper(QLayoutItem *i, Position p) {
- item = i;
- position = p;
- }
-
- QLayoutItem *item;
- Position position;
- };
-
- enum SizeType { MinimumSize, SizeHint };
- QSize calculateSize(SizeType sizeType) const;
-
- QList<ItemWrapper *> list;
-};
-
-#endif // BORDERLAYOUT_H
diff --git a/examples/widgets/layouts/borderlayout/borderlayout.pro b/examples/widgets/layouts/borderlayout/borderlayout.pro
deleted file mode 100644
index 53c9647bd7..0000000000
--- a/examples/widgets/layouts/borderlayout/borderlayout.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += widgets
-
-HEADERS = borderlayout.h \
- window.h
-SOURCES = borderlayout.cpp \
- main.cpp \
- window.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/layouts/borderlayout
-INSTALLS += target
diff --git a/examples/widgets/layouts/borderlayout/main.cpp b/examples/widgets/layouts/borderlayout/main.cpp
deleted file mode 100644
index 27409403a5..0000000000
--- a/examples/widgets/layouts/borderlayout/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "window.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- Window window;
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/layouts/borderlayout/window.cpp b/examples/widgets/layouts/borderlayout/window.cpp
deleted file mode 100644
index ea3b6a6fe8..0000000000
--- a/examples/widgets/layouts/borderlayout/window.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "borderlayout.h"
-#include "window.h"
-#include <QTextBrowser>
-#include <QLabel>
-
-Window::Window()
-{
- QTextBrowser *centralWidget = new QTextBrowser;
- centralWidget->setPlainText(tr("Central widget"));
-
- BorderLayout *layout = new BorderLayout;
- layout->addWidget(centralWidget, BorderLayout::Center);
- layout->addWidget(createLabel("North"), BorderLayout::North);
- layout->addWidget(createLabel("West"), BorderLayout::West);
- layout->addWidget(createLabel("East 1"), BorderLayout::East);
- layout->addWidget(createLabel("East 2") , BorderLayout::East);
- layout->addWidget(createLabel("South"), BorderLayout::South);
- setLayout(layout);
-
- setWindowTitle(tr("Border Layout"));
-}
-
-QLabel *Window::createLabel(const QString &text)
-{
- QLabel *label = new QLabel(text);
- label->setFrameStyle(QFrame::Box | QFrame::Raised);
- return label;
-}
diff --git a/examples/widgets/layouts/borderlayout/window.h b/examples/widgets/layouts/borderlayout/window.h
deleted file mode 100644
index 9e97d0e8fb..0000000000
--- a/examples/widgets/layouts/borderlayout/window.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-QT_END_NAMESPACE
-
-class Window : public QWidget
-{
- Q_OBJECT
-
-public:
- Window();
-
-private:
- QLabel *createLabel(const QString &text);
-};
-
-#endif // WINDOW_H
diff --git a/examples/widgets/layouts/dynamiclayouts/CMakeLists.txt b/examples/widgets/layouts/dynamiclayouts/CMakeLists.txt
deleted file mode 100644
index ad636576ce..0000000000
--- a/examples/widgets/layouts/dynamiclayouts/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(dynamiclayouts LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/layouts/dynamiclayouts")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(dynamiclayouts
- dialog.cpp dialog.h
- main.cpp
-)
-
-set_target_properties(dynamiclayouts PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(dynamiclayouts PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS dynamiclayouts
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/layouts/dynamiclayouts/dialog.cpp b/examples/widgets/layouts/dynamiclayouts/dialog.cpp
deleted file mode 100644
index 8dc3d069bc..0000000000
--- a/examples/widgets/layouts/dynamiclayouts/dialog.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-#include "dialog.h"
-
-Dialog::Dialog(QWidget *parent)
- : QDialog(parent)
-{
- createRotatableGroupBox();
- createOptionsGroupBox();
- createButtonBox();
-
- mainLayout = new QGridLayout;
- mainLayout->addWidget(rotatableGroupBox, 0, 0);
- mainLayout->addWidget(optionsGroupBox, 1, 0);
- mainLayout->addWidget(buttonBox, 2, 0);
- setLayout(mainLayout);
-
- mainLayout->setSizeConstraint(QLayout::SetMinimumSize);
-
- setWindowTitle(tr("Dynamic Layouts"));
-}
-
-void Dialog::buttonsOrientationChanged(int index)
-{
- mainLayout->setSizeConstraint(QLayout::SetNoConstraint);
- setMinimumSize(0, 0);
-
- Qt::Orientation orientation = Qt::Orientation(
- buttonsOrientationComboBox->itemData(index).toInt());
-
- if (orientation == buttonBox->orientation())
- return;
-
- mainLayout->removeWidget(buttonBox);
-
- int spacing = mainLayout->spacing();
-
- QSize oldSizeHint = buttonBox->sizeHint() + QSize(spacing, spacing);
- buttonBox->setOrientation(orientation);
- QSize newSizeHint = buttonBox->sizeHint() + QSize(spacing, spacing);
-
- if (orientation == Qt::Horizontal) {
- mainLayout->addWidget(buttonBox, 2, 0);
- resize(size() + QSize(-oldSizeHint.width(), newSizeHint.height()));
- } else {
- mainLayout->addWidget(buttonBox, 0, 3, 2, 1);
- resize(size() + QSize(newSizeHint.width(), -oldSizeHint.height()));
- }
-
- mainLayout->setSizeConstraint(QLayout::SetDefaultConstraint);
-}
-
-void Dialog::rotateWidgets()
-{
- Q_ASSERT(rotatableWidgets.count() % 2 == 0);
-
- for (QWidget *widget : qAsConst(rotatableWidgets))
- rotatableLayout->removeWidget(widget);
-
- rotatableWidgets.enqueue(rotatableWidgets.dequeue());
-
- const int n = rotatableWidgets.count();
- for (int i = 0; i < n / 2; ++i) {
- rotatableLayout->addWidget(rotatableWidgets[n - i - 1], 0, i);
- rotatableLayout->addWidget(rotatableWidgets[i], 1, i);
- }
-}
-
-void Dialog::help()
-{
- QMessageBox::information(this, tr("Dynamic Layouts Help"),
- tr("This example shows how to change layouts "
- "dynamically."));
-}
-
-void Dialog::createRotatableGroupBox()
-{
- rotatableGroupBox = new QGroupBox(tr("Rotatable Widgets"));
-
- rotatableWidgets.enqueue(new QSpinBox);
- rotatableWidgets.enqueue(new QSlider);
- rotatableWidgets.enqueue(new QDial);
- rotatableWidgets.enqueue(new QProgressBar);
-
- int n = rotatableWidgets.count();
- for (int i = 0; i < n; ++i) {
- connect(rotatableWidgets[i], SIGNAL(valueChanged(int)),
- rotatableWidgets[(i + 1) % n], SLOT(setValue(int)));
- }
-
- rotatableLayout = new QGridLayout;
- rotatableGroupBox->setLayout(rotatableLayout);
-
- rotateWidgets();
-}
-
-void Dialog::createOptionsGroupBox()
-{
- optionsGroupBox = new QGroupBox(tr("Options"));
-
- buttonsOrientationLabel = new QLabel(tr("Orientation of buttons:"));
-
- buttonsOrientationComboBox = new QComboBox;
- buttonsOrientationComboBox->addItem(tr("Horizontal"), Qt::Horizontal);
- buttonsOrientationComboBox->addItem(tr("Vertical"), Qt::Vertical);
-
- connect(buttonsOrientationComboBox,
- &QComboBox::currentIndexChanged,
- this,
- &Dialog::buttonsOrientationChanged);
-
- optionsLayout = new QGridLayout;
- optionsLayout->addWidget(buttonsOrientationLabel, 0, 0);
- optionsLayout->addWidget(buttonsOrientationComboBox, 0, 1);
- optionsLayout->setColumnStretch(2, 1);
- optionsGroupBox->setLayout(optionsLayout);
-}
-
-void Dialog::createButtonBox()
-{
- buttonBox = new QDialogButtonBox;
-
- closeButton = buttonBox->addButton(QDialogButtonBox::Close);
- helpButton = buttonBox->addButton(QDialogButtonBox::Help);
- rotateWidgetsButton = buttonBox->addButton(tr("Rotate &Widgets"),
- QDialogButtonBox::ActionRole);
-
- connect(rotateWidgetsButton, &QPushButton::clicked, this, &Dialog::rotateWidgets);
- connect(closeButton, &QPushButton::clicked, this, &Dialog::close);
- connect(helpButton, &QPushButton::clicked, this, &Dialog::help);
-}
-
-
diff --git a/examples/widgets/layouts/dynamiclayouts/dialog.h b/examples/widgets/layouts/dynamiclayouts/dialog.h
deleted file mode 100644
index 89424cee8a..0000000000
--- a/examples/widgets/layouts/dynamiclayouts/dialog.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef DIALOG_H
-#define DIALOG_H
-
-#include <QDialog>
-#include <QQueue>
-
-QT_BEGIN_NAMESPACE
-class QComboBox;
-class QDialogButtonBox;
-class QGridLayout;
-class QGroupBox;
-class QLabel;
-class QPushButton;
-QT_END_NAMESPACE
-
-class Dialog : public QDialog
-{
- Q_OBJECT
-
-public:
- Dialog(QWidget *parent = nullptr);
-
-private slots:
- void buttonsOrientationChanged(int index);
- void rotateWidgets();
- void help();
-
-private:
- void createRotatableGroupBox();
- void createOptionsGroupBox();
- void createButtonBox();
-
- QGroupBox *rotatableGroupBox;
- QQueue<QWidget *> rotatableWidgets;
-
- QGroupBox *optionsGroupBox;
- QLabel *buttonsOrientationLabel;
- QComboBox *buttonsOrientationComboBox;
-
- QDialogButtonBox *buttonBox;
- QPushButton *closeButton;
- QPushButton *helpButton;
- QPushButton *rotateWidgetsButton;
-
- QGridLayout *mainLayout;
- QGridLayout *rotatableLayout;
- QGridLayout *optionsLayout;
-};
-
-#endif // DIALOG_H
diff --git a/examples/widgets/layouts/dynamiclayouts/dynamiclayouts.pro b/examples/widgets/layouts/dynamiclayouts/dynamiclayouts.pro
deleted file mode 100644
index dcd4288698..0000000000
--- a/examples/widgets/layouts/dynamiclayouts/dynamiclayouts.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT += widgets
-requires(qtConfig(combobox))
-
-HEADERS = dialog.h
-SOURCES = dialog.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/layouts/dynamiclayouts
-INSTALLS += target
diff --git a/examples/widgets/layouts/dynamiclayouts/main.cpp b/examples/widgets/layouts/dynamiclayouts/main.cpp
deleted file mode 100644
index 32aabb2722..0000000000
--- a/examples/widgets/layouts/dynamiclayouts/main.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "dialog.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- Dialog dialog;
-#ifdef Q_OS_ANDROID
- dialog.showMaximized();
-#else
- dialog.show();
-#endif
-
- return app.exec();
-}
diff --git a/examples/widgets/layouts/flowlayout/CMakeLists.txt b/examples/widgets/layouts/flowlayout/CMakeLists.txt
index b6b72c86c2..9693d409b7 100644
--- a/examples/widgets/layouts/flowlayout/CMakeLists.txt
+++ b/examples/widgets/layouts/flowlayout/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(flowlayout LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/layouts/flowlayout")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(flowlayout
flowlayout.cpp flowlayout.h
main.cpp
@@ -25,14 +19,21 @@ set_target_properties(flowlayout PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(flowlayout PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(flowlayout PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS flowlayout
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET flowlayout
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/layouts/flowlayout/flowlayout.cpp b/examples/widgets/layouts/flowlayout/flowlayout.cpp
index b4cba9fe69..0565053096 100644
--- a/examples/widgets/layouts/flowlayout/flowlayout.cpp
+++ b/examples/widgets/layouts/flowlayout/flowlayout.cpp
@@ -108,7 +108,7 @@ QSize FlowLayout::sizeHint() const
QSize FlowLayout::minimumSize() const
{
QSize size;
- for (const QLayoutItem *item : qAsConst(itemList))
+ for (const QLayoutItem *item : std::as_const(itemList))
size = size.expandedTo(item->minimumSize());
const QMargins margins = contentsMargins();
@@ -129,7 +129,7 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
//! [9]
//! [10]
- for (QLayoutItem *item : qAsConst(itemList)) {
+ for (QLayoutItem *item : std::as_const(itemList)) {
const QWidget *wid = item->widget();
int spaceX = horizontalSpacing();
if (spaceX == -1)
diff --git a/examples/widgets/layouts/layouts.pro b/examples/widgets/layouts/layouts.pro
index c641e8cf7f..c0b5453f02 100644
--- a/examples/widgets/layouts/layouts.pro
+++ b/examples/widgets/layouts/layouts.pro
@@ -1,5 +1,3 @@
TEMPLATE = subdirs
SUBDIRS = basiclayouts \
- borderlayout \
- dynamiclayouts \
flowlayout
diff --git a/examples/widgets/mainwindows/CMakeLists.txt b/examples/widgets/mainwindows/CMakeLists.txt
index 93c9e23514..5b7079ed04 100644
--- a/examples/widgets/mainwindows/CMakeLists.txt
+++ b/examples/widgets/mainwindows/CMakeLists.txt
@@ -1,9 +1,4 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-qt_internal_add_example(application)
-qt_internal_add_example(dockwidgets)
-qt_internal_add_example(mainwindow)
-qt_internal_add_example(mdi)
qt_internal_add_example(menus)
-qt_internal_add_example(sdi)
diff --git a/examples/widgets/mainwindows/application/CMakeLists.txt b/examples/widgets/mainwindows/application/CMakeLists.txt
deleted file mode 100644
index ab4216ec87..0000000000
--- a/examples/widgets/mainwindows/application/CMakeLists.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(application LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/mainwindows/application")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(application
- main.cpp
- mainwindow.cpp mainwindow.h
-)
-
-set_target_properties(application PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(application PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(application_resource_files
- "images/copy.png"
- "images/cut.png"
- "images/new.png"
- "images/open.png"
- "images/paste.png"
- "images/save.png"
-)
-
-qt_add_resources(application "application"
- PREFIX
- "/"
- FILES
- ${application_resource_files}
-)
-
-install(TARGETS application
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/mainwindows/application/application.pro b/examples/widgets/mainwindows/application/application.pro
deleted file mode 100644
index e55655a934..0000000000
--- a/examples/widgets/mainwindows/application/application.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-QT += widgets
-requires(qtConfig(filedialog))
-
-HEADERS = mainwindow.h
-SOURCES = main.cpp \
- mainwindow.cpp
-#! [0]
-RESOURCES = application.qrc
-#! [0]
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/mainwindows/application
-INSTALLS += target
diff --git a/examples/widgets/mainwindows/application/application.qrc b/examples/widgets/mainwindows/application/application.qrc
deleted file mode 100644
index 0a776fab4d..0000000000
--- a/examples/widgets/mainwindows/application/application.qrc
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/copy.png</file>
- <file>images/cut.png</file>
- <file>images/new.png</file>
- <file>images/open.png</file>
- <file>images/paste.png</file>
- <file>images/save.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/mainwindows/application/images/copy.png b/examples/widgets/mainwindows/application/images/copy.png
deleted file mode 100644
index 2aeb28288f..0000000000
--- a/examples/widgets/mainwindows/application/images/copy.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/application/images/cut.png b/examples/widgets/mainwindows/application/images/cut.png
deleted file mode 100644
index 54638e9386..0000000000
--- a/examples/widgets/mainwindows/application/images/cut.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/application/images/new.png b/examples/widgets/mainwindows/application/images/new.png
deleted file mode 100644
index 12131b0100..0000000000
--- a/examples/widgets/mainwindows/application/images/new.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/application/images/open.png b/examples/widgets/mainwindows/application/images/open.png
deleted file mode 100644
index 45fa2883a7..0000000000
--- a/examples/widgets/mainwindows/application/images/open.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/application/images/paste.png b/examples/widgets/mainwindows/application/images/paste.png
deleted file mode 100644
index c14425cad1..0000000000
--- a/examples/widgets/mainwindows/application/images/paste.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/application/images/save.png b/examples/widgets/mainwindows/application/images/save.png
deleted file mode 100644
index e65a29d5f1..0000000000
--- a/examples/widgets/mainwindows/application/images/save.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/application/main.cpp b/examples/widgets/mainwindows/application/main.cpp
deleted file mode 100644
index 0437f91f73..0000000000
--- a/examples/widgets/mainwindows/application/main.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-//! [0]
-#include <QApplication>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(application);
-
- QApplication app(argc, argv);
- QCoreApplication::setOrganizationName("QtProject");
- QCoreApplication::setApplicationName("Application Example");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription(QCoreApplication::applicationName());
- parser.addHelpOption();
- parser.addVersionOption();
- parser.addPositionalArgument("file", "The file to open.");
- parser.process(app);
-
- MainWindow mainWin;
- if (!parser.positionalArguments().isEmpty())
- mainWin.loadFile(parser.positionalArguments().first());
- mainWin.show();
- return app.exec();
-}
-//! [0]
diff --git a/examples/widgets/mainwindows/application/mainwindow.cpp b/examples/widgets/mainwindows/application/mainwindow.cpp
deleted file mode 100644
index d49060e9b6..0000000000
--- a/examples/widgets/mainwindows/application/mainwindow.cpp
+++ /dev/null
@@ -1,370 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-//! [0]
-#include <QtWidgets>
-
-#include "mainwindow.h"
-//! [0]
-
-//! [1]
-MainWindow::MainWindow()
- : textEdit(new QPlainTextEdit)
-//! [1] //! [2]
-{
- setCentralWidget(textEdit);
-
- createActions();
- createStatusBar();
-
- readSettings();
-
- connect(textEdit->document(), &QTextDocument::contentsChanged,
- this, &MainWindow::documentWasModified);
-
-#ifndef QT_NO_SESSIONMANAGER
- connect(qApp, &QGuiApplication::commitDataRequest,
- this, &MainWindow::commitData);
-#endif
-
- setCurrentFile(QString());
- setUnifiedTitleAndToolBarOnMac(true);
-}
-//! [2]
-
-//! [3]
-void MainWindow::closeEvent(QCloseEvent *event)
-//! [3] //! [4]
-{
- if (maybeSave()) {
- writeSettings();
- event->accept();
- } else {
- event->ignore();
- }
-}
-//! [4]
-
-//! [5]
-void MainWindow::newFile()
-//! [5] //! [6]
-{
- if (maybeSave()) {
- textEdit->clear();
- setCurrentFile(QString());
- }
-}
-//! [6]
-
-//! [7]
-void MainWindow::open()
-//! [7] //! [8]
-{
- if (maybeSave()) {
- QString fileName = QFileDialog::getOpenFileName(this);
- if (!fileName.isEmpty())
- loadFile(fileName);
- }
-}
-//! [8]
-
-//! [9]
-bool MainWindow::save()
-//! [9] //! [10]
-{
- if (curFile.isEmpty()) {
- return saveAs();
- } else {
- return saveFile(curFile);
- }
-}
-//! [10]
-
-//! [11]
-bool MainWindow::saveAs()
-//! [11] //! [12]
-{
- QFileDialog dialog(this);
- dialog.setWindowModality(Qt::WindowModal);
- dialog.setAcceptMode(QFileDialog::AcceptSave);
- if (dialog.exec() != QDialog::Accepted)
- return false;
- return saveFile(dialog.selectedFiles().first());
-}
-//! [12]
-
-//! [13]
-void MainWindow::about()
-//! [13] //! [14]
-{
- QMessageBox::about(this, tr("About Application"),
- tr("The <b>Application</b> example demonstrates how to "
- "write modern GUI applications using Qt, with a menu bar, "
- "toolbars, and a status bar."));
-}
-//! [14]
-
-//! [15]
-void MainWindow::documentWasModified()
-//! [15] //! [16]
-{
- setWindowModified(textEdit->document()->isModified());
-}
-//! [16]
-
-//! [17]
-void MainWindow::createActions()
-//! [17] //! [18]
-{
-
- QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
- QToolBar *fileToolBar = addToolBar(tr("File"));
- const QIcon newIcon = QIcon::fromTheme("document-new", QIcon(":/images/new.png"));
- QAction *newAct = new QAction(newIcon, tr("&New"), this);
- newAct->setShortcuts(QKeySequence::New);
- newAct->setStatusTip(tr("Create a new file"));
- connect(newAct, &QAction::triggered, this, &MainWindow::newFile);
- fileMenu->addAction(newAct);
- fileToolBar->addAction(newAct);
-
-//! [19]
- const QIcon openIcon = QIcon::fromTheme("document-open", QIcon(":/images/open.png"));
- QAction *openAct = new QAction(openIcon, tr("&Open..."), this);
- openAct->setShortcuts(QKeySequence::Open);
- openAct->setStatusTip(tr("Open an existing file"));
- connect(openAct, &QAction::triggered, this, &MainWindow::open);
- fileMenu->addAction(openAct);
- fileToolBar->addAction(openAct);
-//! [18] //! [19]
-
- const QIcon saveIcon = QIcon::fromTheme("document-save", QIcon(":/images/save.png"));
- QAction *saveAct = new QAction(saveIcon, tr("&Save"), this);
- saveAct->setShortcuts(QKeySequence::Save);
- saveAct->setStatusTip(tr("Save the document to disk"));
- connect(saveAct, &QAction::triggered, this, &MainWindow::save);
- fileMenu->addAction(saveAct);
- fileToolBar->addAction(saveAct);
-
- const QIcon saveAsIcon = QIcon::fromTheme("document-save-as");
- QAction *saveAsAct = fileMenu->addAction(saveAsIcon, tr("Save &As..."), this, &MainWindow::saveAs);
- saveAsAct->setShortcuts(QKeySequence::SaveAs);
- saveAsAct->setStatusTip(tr("Save the document under a new name"));
-
-//! [20]
-
- fileMenu->addSeparator();
-
- const QIcon exitIcon = QIcon::fromTheme("application-exit");
- QAction *exitAct = fileMenu->addAction(exitIcon, tr("E&xit"), this, &QWidget::close);
- exitAct->setShortcuts(QKeySequence::Quit);
-//! [20]
- exitAct->setStatusTip(tr("Exit the application"));
-
-//! [21]
- QMenu *editMenu = menuBar()->addMenu(tr("&Edit"));
- QToolBar *editToolBar = addToolBar(tr("Edit"));
-//!
-#ifndef QT_NO_CLIPBOARD
- const QIcon cutIcon = QIcon::fromTheme("edit-cut", QIcon(":/images/cut.png"));
- QAction *cutAct = new QAction(cutIcon, tr("Cu&t"), this);
-//! [21]
- cutAct->setShortcuts(QKeySequence::Cut);
- cutAct->setStatusTip(tr("Cut the current selection's contents to the "
- "clipboard"));
- connect(cutAct, &QAction::triggered, textEdit, &QPlainTextEdit::cut);
- editMenu->addAction(cutAct);
- editToolBar->addAction(cutAct);
-
- const QIcon copyIcon = QIcon::fromTheme("edit-copy", QIcon(":/images/copy.png"));
- QAction *copyAct = new QAction(copyIcon, tr("&Copy"), this);
- copyAct->setShortcuts(QKeySequence::Copy);
- copyAct->setStatusTip(tr("Copy the current selection's contents to the "
- "clipboard"));
- connect(copyAct, &QAction::triggered, textEdit, &QPlainTextEdit::copy);
- editMenu->addAction(copyAct);
- editToolBar->addAction(copyAct);
-
- const QIcon pasteIcon = QIcon::fromTheme("edit-paste", QIcon(":/images/paste.png"));
- QAction *pasteAct = new QAction(pasteIcon, tr("&Paste"), this);
- pasteAct->setShortcuts(QKeySequence::Paste);
- pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
- "selection"));
- connect(pasteAct, &QAction::triggered, textEdit, &QPlainTextEdit::paste);
- editMenu->addAction(pasteAct);
- editToolBar->addAction(pasteAct);
-
- menuBar()->addSeparator();
-
-#endif // !QT_NO_CLIPBOARD
-
- QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
- QAction *aboutAct = helpMenu->addAction(tr("&About"), this, &MainWindow::about);
- aboutAct->setStatusTip(tr("Show the application's About box"));
-
-//! [22]
-
- QAction *aboutQtAct = helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
- aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
-//! [22]
-
-//! [23]
-#ifndef QT_NO_CLIPBOARD
- cutAct->setEnabled(false);
-//! [23] //! [24]
- copyAct->setEnabled(false);
- connect(textEdit, &QPlainTextEdit::copyAvailable, cutAct, &QAction::setEnabled);
- connect(textEdit, &QPlainTextEdit::copyAvailable, copyAct, &QAction::setEnabled);
-#endif // !QT_NO_CLIPBOARD
-}
-//! [24]
-
-//! [32]
-void MainWindow::createStatusBar()
-//! [32] //! [33]
-{
- statusBar()->showMessage(tr("Ready"));
-}
-//! [33]
-
-//! [34] //! [35]
-void MainWindow::readSettings()
-//! [34] //! [36]
-{
- QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
- const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
- if (geometry.isEmpty()) {
- const QRect availableGeometry = screen()->availableGeometry();
- resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
- move((availableGeometry.width() - width()) / 2,
- (availableGeometry.height() - height()) / 2);
- } else {
- restoreGeometry(geometry);
- }
-}
-//! [35] //! [36]
-
-//! [37] //! [38]
-void MainWindow::writeSettings()
-//! [37] //! [39]
-{
- QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
- settings.setValue("geometry", saveGeometry());
-}
-//! [38] //! [39]
-
-//! [40]
-bool MainWindow::maybeSave()
-//! [40] //! [41]
-{
- if (!textEdit->document()->isModified())
- return true;
- const QMessageBox::StandardButton ret
- = QMessageBox::warning(this, tr("Application"),
- tr("The document has been modified.\n"
- "Do you want to save your changes?"),
- QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
- switch (ret) {
- case QMessageBox::Save:
- return save();
- case QMessageBox::Cancel:
- return false;
- default:
- break;
- }
- return true;
-}
-//! [41]
-
-//! [42]
-void MainWindow::loadFile(const QString &fileName)
-//! [42] //! [43]
-{
- QFile file(fileName);
- if (!file.open(QFile::ReadOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("Application"),
- tr("Cannot read file %1:\n%2.")
- .arg(QDir::toNativeSeparators(fileName), file.errorString()));
- return;
- }
-
- QTextStream in(&file);
-#ifndef QT_NO_CURSOR
- QGuiApplication::setOverrideCursor(Qt::WaitCursor);
-#endif
- textEdit->setPlainText(in.readAll());
-#ifndef QT_NO_CURSOR
- QGuiApplication::restoreOverrideCursor();
-#endif
-
- setCurrentFile(fileName);
- statusBar()->showMessage(tr("File loaded"), 2000);
-}
-//! [43]
-
-//! [44]
-bool MainWindow::saveFile(const QString &fileName)
-//! [44] //! [45]
-{
- QString errorMessage;
-
- QGuiApplication::setOverrideCursor(Qt::WaitCursor);
- QSaveFile file(fileName);
- if (file.open(QFile::WriteOnly | QFile::Text)) {
- QTextStream out(&file);
- out << textEdit->toPlainText();
- if (!file.commit()) {
- errorMessage = tr("Cannot write file %1:\n%2.")
- .arg(QDir::toNativeSeparators(fileName), file.errorString());
- }
- } else {
- errorMessage = tr("Cannot open file %1 for writing:\n%2.")
- .arg(QDir::toNativeSeparators(fileName), file.errorString());
- }
- QGuiApplication::restoreOverrideCursor();
-
- if (!errorMessage.isEmpty()) {
- QMessageBox::warning(this, tr("Application"), errorMessage);
- return false;
- }
-
- setCurrentFile(fileName);
- statusBar()->showMessage(tr("File saved"), 2000);
- return true;
-}
-//! [45]
-
-//! [46]
-void MainWindow::setCurrentFile(const QString &fileName)
-//! [46] //! [47]
-{
- curFile = fileName;
- textEdit->document()->setModified(false);
- setWindowModified(false);
-
- QString shownName = curFile;
- if (curFile.isEmpty())
- shownName = "untitled.txt";
- setWindowFilePath(shownName);
-}
-//! [47]
-
-//! [48]
-QString MainWindow::strippedName(const QString &fullFileName)
-//! [48] //! [49]
-{
- return QFileInfo(fullFileName).fileName();
-}
-//! [49]
-#ifndef QT_NO_SESSIONMANAGER
-void MainWindow::commitData(QSessionManager &manager)
-{
- if (manager.allowsInteraction()) {
- if (!maybeSave())
- manager.cancel();
- } else {
- // Non-interactive: save without asking
- if (textEdit->document()->isModified())
- save();
- }
-}
-#endif
diff --git a/examples/widgets/mainwindows/application/mainwindow.h b/examples/widgets/mainwindows/application/mainwindow.h
deleted file mode 100644
index caeaf70400..0000000000
--- a/examples/widgets/mainwindows/application/mainwindow.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QMenu;
-class QPlainTextEdit;
-class QSessionManager;
-QT_END_NAMESPACE
-
-//! [0]
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
- void loadFile(const QString &fileName);
-
-protected:
- void closeEvent(QCloseEvent *event) override;
-
-private slots:
- void newFile();
- void open();
- bool save();
- bool saveAs();
- void about();
- void documentWasModified();
-#ifndef QT_NO_SESSIONMANAGER
- void commitData(QSessionManager &);
-#endif
-
-private:
- void createActions();
- void createStatusBar();
- void readSettings();
- void writeSettings();
- bool maybeSave();
- bool saveFile(const QString &fileName);
- void setCurrentFile(const QString &fileName);
- QString strippedName(const QString &fullFileName);
-
- QPlainTextEdit *textEdit;
- QString curFile;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/mainwindows/dockwidgets/CMakeLists.txt b/examples/widgets/mainwindows/dockwidgets/CMakeLists.txt
deleted file mode 100644
index d3b9394232..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/CMakeLists.txt
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(dockwidgets LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/mainwindows/dockwidgets")
-
-find_package(Qt6
- REQUIRED COMPONENTS Core Gui Widgets
- OPTIONAL_COMPONENTS PrintSupport
-)
-
-qt_add_executable(dockwidgets
- main.cpp
- mainwindow.cpp mainwindow.h
-)
-
-set_target_properties(dockwidgets PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(dockwidgets PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-if (TARGET Qt::PrintSupport)
- target_link_libraries(dockwidgets PUBLIC Qt::PrintSupport)
-endif()
-
-# Resources:
-set(dockwidgets_resource_files
- "images/new.png"
- "images/print.png"
- "images/save.png"
- "images/undo.png"
-)
-
-qt_add_resources(dockwidgets "dockwidgets"
- PREFIX
- "/"
- FILES
- ${dockwidgets_resource_files}
-)
-
-if(TARGET Qt::PrintSupport)
- target_link_libraries(dockwidgets PUBLIC
- Qt::PrintSupport
- )
-endif()
-
-install(TARGETS dockwidgets
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/mainwindows/dockwidgets/dockwidgets.pro b/examples/widgets/mainwindows/dockwidgets/dockwidgets.pro
deleted file mode 100644
index 3acded5ed3..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/dockwidgets.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-QT += widgets
-requires(qtConfig(listwidget))
-qtHaveModule(printsupport): QT += printsupport
-
-HEADERS = mainwindow.h
-SOURCES = main.cpp \
- mainwindow.cpp
-RESOURCES = dockwidgets.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/mainwindows/dockwidgets
-INSTALLS += target
diff --git a/examples/widgets/mainwindows/dockwidgets/dockwidgets.qrc b/examples/widgets/mainwindows/dockwidgets/dockwidgets.qrc
deleted file mode 100644
index 968feac7ea..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/dockwidgets.qrc
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/new.png</file>
- <file>images/print.png</file>
- <file>images/save.png</file>
- <file>images/undo.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/mainwindows/dockwidgets/images/new.png b/examples/widgets/mainwindows/dockwidgets/images/new.png
deleted file mode 100644
index dd795cfffc..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/images/new.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/dockwidgets/images/print.png b/examples/widgets/mainwindows/dockwidgets/images/print.png
deleted file mode 100644
index 2afb769ee2..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/images/print.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/dockwidgets/images/save.png b/examples/widgets/mainwindows/dockwidgets/images/save.png
deleted file mode 100644
index 46eac82ad1..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/images/save.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/dockwidgets/images/undo.png b/examples/widgets/mainwindows/dockwidgets/images/undo.png
deleted file mode 100644
index eee23d24a3..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/images/undo.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/dockwidgets/main.cpp b/examples/widgets/mainwindows/dockwidgets/main.cpp
deleted file mode 100644
index 35ed609035..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/main.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- Q_INIT_RESOURCE(dockwidgets);
- MainWindow mainWin;
- mainWin.show();
- return app.exec();
-}
diff --git a/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp b/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp
deleted file mode 100644
index cd1189d8df..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp
+++ /dev/null
@@ -1,298 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-//! [0]
-#include <QtWidgets>
-#if defined(QT_PRINTSUPPORT_LIB)
-#include <QtPrintSupport/qtprintsupportglobal.h>
-#if QT_CONFIG(printdialog)
-#include <QtPrintSupport>
-#endif
-#endif
-
-#include "mainwindow.h"
-//! [0]
-
-//! [1]
-MainWindow::MainWindow()
- : textEdit(new QTextEdit)
-{
- setCentralWidget(textEdit);
-
- createActions();
- createStatusBar();
- createDockWindows();
-
- setWindowTitle(tr("Dock Widgets"));
-
- newLetter();
- setUnifiedTitleAndToolBarOnMac(true);
-}
-//! [1]
-
-//! [2]
-void MainWindow::newLetter()
-{
- textEdit->clear();
-
- QTextCursor cursor(textEdit->textCursor());
- cursor.movePosition(QTextCursor::Start);
- QTextFrame *topFrame = cursor.currentFrame();
- QTextFrameFormat topFrameFormat = topFrame->frameFormat();
- topFrameFormat.setPadding(16);
- topFrame->setFrameFormat(topFrameFormat);
-
- QTextCharFormat textFormat;
- QTextCharFormat boldFormat;
- boldFormat.setFontWeight(QFont::Bold);
- QTextCharFormat italicFormat;
- italicFormat.setFontItalic(true);
-
- QTextTableFormat tableFormat;
- tableFormat.setBorder(1);
- tableFormat.setCellPadding(16);
- tableFormat.setAlignment(Qt::AlignRight);
- cursor.insertTable(1, 1, tableFormat);
- cursor.insertText("The Firm", boldFormat);
- cursor.insertBlock();
- cursor.insertText("321 City Street", textFormat);
- cursor.insertBlock();
- cursor.insertText("Industry Park");
- cursor.insertBlock();
- cursor.insertText("Some Country");
- cursor.setPosition(topFrame->lastPosition());
- cursor.insertText(QDate::currentDate().toString("d MMMM yyyy"), textFormat);
- cursor.insertBlock();
- cursor.insertBlock();
- cursor.insertText("Dear ", textFormat);
- cursor.insertText("NAME", italicFormat);
- cursor.insertText(",", textFormat);
- for (int i = 0; i < 3; ++i)
- cursor.insertBlock();
- cursor.insertText(tr("Yours sincerely,"), textFormat);
- for (int i = 0; i < 3; ++i)
- cursor.insertBlock();
- cursor.insertText("The Boss", textFormat);
- cursor.insertBlock();
- cursor.insertText("ADDRESS", italicFormat);
-}
-//! [2]
-
-//! [3]
-void MainWindow::print()
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
- QTextDocument *document = textEdit->document();
- QPrinter printer;
-
- QPrintDialog dlg(&printer, this);
- if (dlg.exec() != QDialog::Accepted) {
- return;
- }
-
- document->print(&printer);
- statusBar()->showMessage(tr("Ready"), 2000);
-#endif
-}
-//! [3]
-
-//! [4]
-void MainWindow::save()
-{
- QMimeDatabase mimeDatabase;
- QString fileName = QFileDialog::getSaveFileName(this,
- tr("Choose a file name"), ".",
- mimeDatabase.mimeTypeForName("text/html").filterString());
- if (fileName.isEmpty())
- return;
- QFile file(fileName);
- if (!file.open(QFile::WriteOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("Dock Widgets"),
- tr("Cannot write file %1:\n%2.")
- .arg(QDir::toNativeSeparators(fileName), file.errorString()));
- return;
- }
-
- QTextStream out(&file);
- QGuiApplication::setOverrideCursor(Qt::WaitCursor);
- out << textEdit->toHtml();
- QGuiApplication::restoreOverrideCursor();
-
- statusBar()->showMessage(tr("Saved '%1'").arg(fileName), 2000);
-}
-//! [4]
-
-//! [5]
-void MainWindow::undo()
-{
- QTextDocument *document = textEdit->document();
- document->undo();
-}
-//! [5]
-
-//! [6]
-void MainWindow::insertCustomer(const QString &customer)
-{
- if (customer.isEmpty())
- return;
- QStringList customerList = customer.split(", ");
- QTextDocument *document = textEdit->document();
- QTextCursor cursor = document->find("NAME");
- if (!cursor.isNull()) {
- cursor.beginEditBlock();
- cursor.insertText(customerList.at(0));
- QTextCursor oldcursor = cursor;
- cursor = document->find("ADDRESS");
- if (!cursor.isNull()) {
- for (int i = 1; i < customerList.size(); ++i) {
- cursor.insertBlock();
- cursor.insertText(customerList.at(i));
- }
- cursor.endEditBlock();
- }
- else
- oldcursor.endEditBlock();
- }
-}
-//! [6]
-
-//! [7]
-void MainWindow::addParagraph(const QString &paragraph)
-{
- if (paragraph.isEmpty())
- return;
- QTextDocument *document = textEdit->document();
- QTextCursor cursor = document->find(tr("Yours sincerely,"));
- if (cursor.isNull())
- return;
- cursor.beginEditBlock();
- cursor.movePosition(QTextCursor::PreviousBlock, QTextCursor::MoveAnchor, 2);
- cursor.insertBlock();
- cursor.insertText(paragraph);
- cursor.insertBlock();
- cursor.endEditBlock();
-
-}
-//! [7]
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About Dock Widgets"),
- tr("The <b>Dock Widgets</b> example demonstrates how to "
- "use Qt's dock widgets. You can enter your own text, "
- "click a customer to add a customer name and "
- "address, and click standard paragraphs to add them."));
-}
-
-void MainWindow::createActions()
-{
- QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
- QToolBar *fileToolBar = addToolBar(tr("File"));
-
- const QIcon newIcon = QIcon::fromTheme("document-new", QIcon(":/images/new.png"));
- QAction *newLetterAct = new QAction(newIcon, tr("&New Letter"), this);
- newLetterAct->setShortcuts(QKeySequence::New);
- newLetterAct->setStatusTip(tr("Create a new form letter"));
- connect(newLetterAct, &QAction::triggered, this, &MainWindow::newLetter);
- fileMenu->addAction(newLetterAct);
- fileToolBar->addAction(newLetterAct);
-
- const QIcon saveIcon = QIcon::fromTheme("document-save", QIcon(":/images/save.png"));
- QAction *saveAct = new QAction(saveIcon, tr("&Save..."), this);
- saveAct->setShortcuts(QKeySequence::Save);
- saveAct->setStatusTip(tr("Save the current form letter"));
- connect(saveAct, &QAction::triggered, this, &MainWindow::save);
- fileMenu->addAction(saveAct);
- fileToolBar->addAction(saveAct);
-
- const QIcon printIcon = QIcon::fromTheme("document-print", QIcon(":/images/print.png"));
- QAction *printAct = new QAction(printIcon, tr("&Print..."), this);
- printAct->setShortcuts(QKeySequence::Print);
- printAct->setStatusTip(tr("Print the current form letter"));
- connect(printAct, &QAction::triggered, this, &MainWindow::print);
- fileMenu->addAction(printAct);
- fileToolBar->addAction(printAct);
-
- fileMenu->addSeparator();
-
- QAction *quitAct = fileMenu->addAction(tr("&Quit"), this, &QWidget::close);
- quitAct->setShortcuts(QKeySequence::Quit);
- quitAct->setStatusTip(tr("Quit the application"));
-
- QMenu *editMenu = menuBar()->addMenu(tr("&Edit"));
- QToolBar *editToolBar = addToolBar(tr("Edit"));
- const QIcon undoIcon = QIcon::fromTheme("edit-undo", QIcon(":/images/undo.png"));
- QAction *undoAct = new QAction(undoIcon, tr("&Undo"), this);
- undoAct->setShortcuts(QKeySequence::Undo);
- undoAct->setStatusTip(tr("Undo the last editing action"));
- connect(undoAct, &QAction::triggered, this, &MainWindow::undo);
- editMenu->addAction(undoAct);
- editToolBar->addAction(undoAct);
-
- viewMenu = menuBar()->addMenu(tr("&View"));
-
- menuBar()->addSeparator();
-
- QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
-
- QAction *aboutAct = helpMenu->addAction(tr("&About"), this, &MainWindow::about);
- aboutAct->setStatusTip(tr("Show the application's About box"));
-
- QAction *aboutQtAct = helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
- aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
-}
-
-//! [8]
-void MainWindow::createStatusBar()
-{
- statusBar()->showMessage(tr("Ready"));
-}
-//! [8]
-
-//! [9]
-void MainWindow::createDockWindows()
-{
- QDockWidget *dock = new QDockWidget(tr("Customers"), this);
- dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- customerList = new QListWidget(dock);
- customerList->addItems(QStringList()
- << "John Doe, Harmony Enterprises, 12 Lakeside, Ambleton"
- << "Jane Doe, Memorabilia, 23 Watersedge, Beaton"
- << "Tammy Shea, Tiblanka, 38 Sea Views, Carlton"
- << "Tim Sheen, Caraba Gifts, 48 Ocean Way, Deal"
- << "Sol Harvey, Chicos Coffee, 53 New Springs, Eccleston"
- << "Sally Hobart, Tiroli Tea, 67 Long River, Fedula");
- dock->setWidget(customerList);
- addDockWidget(Qt::RightDockWidgetArea, dock);
- viewMenu->addAction(dock->toggleViewAction());
-
- dock = new QDockWidget(tr("Paragraphs"), this);
- paragraphsList = new QListWidget(dock);
- paragraphsList->addItems(QStringList()
- << "Thank you for your payment which we have received today."
- << "Your order has been dispatched and should be with you "
- "within 28 days."
- << "We have dispatched those items that were in stock. The "
- "rest of your order will be dispatched once all the "
- "remaining items have arrived at our warehouse. No "
- "additional shipping charges will be made."
- << "You made a small overpayment (less than $5) which we "
- "will keep on account for you, or return at your request."
- << "You made a small underpayment (less than $1), but we have "
- "sent your order anyway. We'll add this underpayment to "
- "your next bill."
- << "Unfortunately you did not send enough money. Please remit "
- "an additional $. Your order will be dispatched as soon as "
- "the complete amount has been received."
- << "You made an overpayment (more than $5). Do you wish to "
- "buy more items, or should we return the excess to you?");
- dock->setWidget(paragraphsList);
- addDockWidget(Qt::RightDockWidgetArea, dock);
- viewMenu->addAction(dock->toggleViewAction());
-
- connect(customerList, &QListWidget::currentTextChanged,
- this, &MainWindow::insertCustomer);
- connect(paragraphsList, &QListWidget::currentTextChanged,
- this, &MainWindow::addParagraph);
-}
-//! [9]
diff --git a/examples/widgets/mainwindows/dockwidgets/mainwindow.h b/examples/widgets/mainwindows/dockwidgets/mainwindow.h
deleted file mode 100644
index 67890e8a61..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/mainwindow.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QListWidget;
-class QMenu;
-class QTextEdit;
-QT_END_NAMESPACE
-
-//! [0]
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
-private slots:
- void newLetter();
- void save();
- void print();
- void undo();
- void about();
- void insertCustomer(const QString &customer);
- void addParagraph(const QString &paragraph);
-
-private:
- void createActions();
- void createStatusBar();
- void createDockWindows();
-
- QTextEdit *textEdit;
- QListWidget *customerList;
- QListWidget *paragraphsList;
-
- QMenu *viewMenu;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/mainwindows/mainwindow/CMakeLists.txt b/examples/widgets/mainwindows/mainwindow/CMakeLists.txt
deleted file mode 100644
index 6d1330884d..0000000000
--- a/examples/widgets/mainwindows/mainwindow/CMakeLists.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(mainwindow LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/mainwindows/mainwindow")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(mainwindow
- colorswatch.cpp colorswatch.h
- main.cpp
- mainwindow.cpp mainwindow.h
- toolbar.cpp toolbar.h
-)
-
-set_target_properties(mainwindow PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(mainwindow PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(mainwindow_resource_files
- "qt.png"
- "titlebarCenter.png"
- "titlebarLeft.png"
- "titlebarRight.png"
-)
-
-qt_add_resources(mainwindow "mainwindow"
- PREFIX
- "/res"
- FILES
- ${mainwindow_resource_files}
-)
-
-install(TARGETS mainwindow
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/mainwindows/mainwindow/colorswatch.cpp b/examples/widgets/mainwindows/mainwindow/colorswatch.cpp
deleted file mode 100644
index 678f00054c..0000000000
--- a/examples/widgets/mainwindows/mainwindow/colorswatch.cpp
+++ /dev/null
@@ -1,685 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "colorswatch.h"
-
-#include <QActionGroup>
-#include <QtEvents>
-#include <QFrame>
-#include <QMainWindow>
-#include <QMenu>
-#include <QPainter>
-#include <QImage>
-#include <QColor>
-#include <QDialog>
-#include <QDialogButtonBox>
-#include <QGridLayout>
-#include <QSignalBlocker>
-#include <QSpinBox>
-#include <QLabel>
-#include <QPainterPath>
-#include <QPushButton>
-#include <QHBoxLayout>
-#include <QBitmap>
-#include <QtDebug>
-
-#undef DEBUG_SIZEHINTS
-
-QColor bgColorForName(const QString &name)
-{
- if (name == "Black")
- return QColor("#D8D8D8");
- if (name == "White")
- return QColor("#F1F1F1");
- if (name == "Red")
- return QColor("#F1D8D8");
- if (name == "Green")
- return QColor("#D8E4D8");
- if (name == "Blue")
- return QColor("#D8D8F1");
- if (name == "Yellow")
- return QColor("#F1F0D8");
- return QColor(name).lighter(110);
-}
-
-QColor fgColorForName(const QString &name)
-{
- if (name == "Black")
- return QColor("#6C6C6C");
- if (name == "White")
- return QColor("#F8F8F8");
- if (name == "Red")
- return QColor("#F86C6C");
- if (name == "Green")
- return QColor("#6CB26C");
- if (name == "Blue")
- return QColor("#6C6CF8");
- if (name == "Yellow")
- return QColor("#F8F76C");
- return QColor(name);
-}
-
-class ColorDock : public QFrame
-{
- Q_OBJECT
-public:
- explicit ColorDock(const QString &c, QWidget *parent);
-
- QSize sizeHint() const override { return szHint; }
- QSize minimumSizeHint() const override { return minSzHint; }
-
- void setCustomSizeHint(const QSize &size);
-
-public slots:
- void changeSizeHints();
-
-protected:
- void paintEvent(QPaintEvent *) override;
-
-private:
- const QString color;
- QSize szHint;
- QSize minSzHint;
-};
-
-ColorDock::ColorDock(const QString &c, QWidget *parent)
- : QFrame(parent)
- , color(c)
- , szHint(-1, -1)
- , minSzHint(125, 75)
-{
- QFont font = this->font();
- font.setPointSize(8);
- setFont(font);
-}
-
-void ColorDock::paintEvent(QPaintEvent *)
-{
- QPainter p(this);
- p.setRenderHint(QPainter::Antialiasing);
- p.fillRect(rect(), bgColorForName(color));
-
- p.save();
-
- extern void render_qt_text(QPainter *, int, int, const QColor &);
- render_qt_text(&p, width(), height(), fgColorForName(color));
-
- p.restore();
-
-#ifdef DEBUG_SIZEHINTS
- p.setRenderHint(QPainter::Antialiasing, false);
-
- QSize sz = size();
- QSize szHint = sizeHint();
- QSize minSzHint = minimumSizeHint();
- QSize maxSz = maximumSize();
- QString text = QString::fromLatin1("sz: %1x%2\nszHint: %3x%4\nminSzHint: %5x%6\n"
- "maxSz: %8x%9")
- .arg(sz.width()).arg(sz.height())
- .arg(szHint.width()).arg(szHint.height())
- .arg(minSzHint.width()).arg(minSzHint.height())
- .arg(maxSz.width()).arg(maxSz.height());
-
- QRect r = fontMetrics().boundingRect(rect(), Qt::AlignLeft|Qt::AlignTop, text);
- r.adjust(-2, -2, 1, 1);
- p.translate(4, 4);
- QColor bg = Qt::yellow;
- bg.setAlpha(120);
- p.setBrush(bg);
- p.setPen(Qt::black);
- p.drawRect(r);
- p.drawText(rect(), Qt::AlignLeft|Qt::AlignTop, text);
-#endif // DEBUG_SIZEHINTS
-}
-
-static QSpinBox *createSpinBox(int value, QWidget *parent, int max = 1000)
-{
- QSpinBox *result = new QSpinBox(parent);
- result->setMinimum(-1);
- result->setMaximum(max);
- result->setValue(value);
- return result;
-}
-
-void ColorDock::changeSizeHints()
-{
- QDialog dialog(this);
- dialog.setWindowFlags(dialog.windowFlags() & ~Qt::WindowContextHelpButtonHint);
- dialog.setWindowTitle(color);
-
- QVBoxLayout *topLayout = new QVBoxLayout(&dialog);
-
- QGridLayout *inputLayout = new QGridLayout();
- topLayout->addLayout(inputLayout);
-
- inputLayout->addWidget(new QLabel(tr("Size Hint:"), &dialog), 0, 0);
- inputLayout->addWidget(new QLabel(tr("Min Size Hint:"), &dialog), 1, 0);
- inputLayout->addWidget(new QLabel(tr("Max Size:"), &dialog), 2, 0);
- inputLayout->addWidget(new QLabel(tr("Dock Widget Max Size:"), &dialog), 3, 0);
-
- QSpinBox *szHintW = createSpinBox(szHint.width(), &dialog);
- inputLayout->addWidget(szHintW, 0, 1);
- QSpinBox *szHintH = createSpinBox(szHint.height(), &dialog);
- inputLayout->addWidget(szHintH, 0, 2);
-
- QSpinBox *minSzHintW = createSpinBox(minSzHint.width(), &dialog);
- inputLayout->addWidget(minSzHintW, 1, 1);
- QSpinBox *minSzHintH = createSpinBox(minSzHint.height(), &dialog);
- inputLayout->addWidget(minSzHintH, 1, 2);
-
- QSize maxSz = maximumSize();
- QSpinBox *maxSzW = createSpinBox(maxSz.width(), &dialog, QWIDGETSIZE_MAX);
- inputLayout->addWidget(maxSzW, 2, 1);
- QSpinBox *maxSzH = createSpinBox(maxSz.height(), &dialog, QWIDGETSIZE_MAX);
- inputLayout->addWidget(maxSzH, 2, 2);
-
- QSize dwMaxSz = parentWidget()->maximumSize();
- QSpinBox *dwMaxSzW = createSpinBox(dwMaxSz.width(), &dialog, QWIDGETSIZE_MAX);
- inputLayout->addWidget(dwMaxSzW, 3, 1);
- QSpinBox *dwMaxSzH = createSpinBox(dwMaxSz.height(), &dialog, QWIDGETSIZE_MAX);
- inputLayout->addWidget(dwMaxSzH, 3, 2);
-
- inputLayout->setColumnStretch(1, 1);
- inputLayout->setColumnStretch(2, 1);
-
- topLayout->addStretch();
-
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
- connect(buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
- connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
-
- topLayout->addWidget(buttonBox);
-
- if (dialog.exec() != QDialog::Accepted)
- return;
-
- szHint = QSize(szHintW->value(), szHintH->value());
- minSzHint = QSize(minSzHintW->value(), minSzHintH->value());
- maxSz = QSize(maxSzW->value(), maxSzH->value());
- setMaximumSize(maxSz);
- dwMaxSz = QSize(dwMaxSzW->value(), dwMaxSzH->value());
- parentWidget()->setMaximumSize(dwMaxSz);
- updateGeometry();
- update();
-}
-
-void ColorDock::setCustomSizeHint(const QSize &size)
-{
- if (szHint != size) {
- szHint = size;
- updateGeometry();
- }
-}
-
-ColorSwatch::ColorSwatch(const QString &colorName, QMainWindow *parent, Qt::WindowFlags flags)
- : QDockWidget(parent, flags), mainWindow(parent)
-{
- setObjectName(colorName + QLatin1String(" Dock Widget"));
- setWindowTitle(objectName() + QLatin1String(" [*]"));
-
- ColorDock *swatch = new ColorDock(colorName, this);
- swatch->setFrameStyle(QFrame::Box | QFrame::Sunken);
-
- setWidget(swatch);
-
- closableAction = new QAction(tr("Closable"), this);
- closableAction->setCheckable(true);
- connect(closableAction, &QAction::triggered, this, &ColorSwatch::changeClosable);
-
- movableAction = new QAction(tr("Movable"), this);
- movableAction->setCheckable(true);
- connect(movableAction, &QAction::triggered, this, &ColorSwatch::changeMovable);
-
- floatableAction = new QAction(tr("Floatable"), this);
- floatableAction->setCheckable(true);
- connect(floatableAction, &QAction::triggered, this, &ColorSwatch::changeFloatable);
-
- verticalTitleBarAction = new QAction(tr("Vertical title bar"), this);
- verticalTitleBarAction->setCheckable(true);
- connect(verticalTitleBarAction, &QAction::triggered,
- this, &ColorSwatch::changeVerticalTitleBar);
-
- floatingAction = new QAction(tr("Floating"), this);
- floatingAction->setCheckable(true);
- connect(floatingAction, &QAction::triggered, this, &ColorSwatch::changeFloating);
-
- allowedAreasActions = new QActionGroup(this);
- allowedAreasActions->setExclusive(false);
-
- allowLeftAction = new QAction(tr("Allow on Left"), this);
- allowLeftAction->setCheckable(true);
- connect(allowLeftAction, &QAction::triggered, this, &ColorSwatch::allowLeft);
-
- allowRightAction = new QAction(tr("Allow on Right"), this);
- allowRightAction->setCheckable(true);
- connect(allowRightAction, &QAction::triggered, this, &ColorSwatch::allowRight);
-
- allowTopAction = new QAction(tr("Allow on Top"), this);
- allowTopAction->setCheckable(true);
- connect(allowTopAction, &QAction::triggered, this, &ColorSwatch::allowTop);
-
- allowBottomAction = new QAction(tr("Allow on Bottom"), this);
- allowBottomAction->setCheckable(true);
- connect(allowBottomAction, &QAction::triggered, this, &ColorSwatch::allowBottom);
-
- allowedAreasActions->addAction(allowLeftAction);
- allowedAreasActions->addAction(allowRightAction);
- allowedAreasActions->addAction(allowTopAction);
- allowedAreasActions->addAction(allowBottomAction);
-
- areaActions = new QActionGroup(this);
- areaActions->setExclusive(true);
-
- leftAction = new QAction(tr("Place on Left") , this);
- leftAction->setCheckable(true);
- connect(leftAction, &QAction::triggered, this, &ColorSwatch::placeLeft);
-
- rightAction = new QAction(tr("Place on Right") , this);
- rightAction->setCheckable(true);
- connect(rightAction, &QAction::triggered, this, &ColorSwatch::placeRight);
-
- topAction = new QAction(tr("Place on Top") , this);
- topAction->setCheckable(true);
- connect(topAction, &QAction::triggered, this, &ColorSwatch::placeTop);
-
- bottomAction = new QAction(tr("Place on Bottom") , this);
- bottomAction->setCheckable(true);
- connect(bottomAction, &QAction::triggered, this, &ColorSwatch::placeBottom);
-
- areaActions->addAction(leftAction);
- areaActions->addAction(rightAction);
- areaActions->addAction(topAction);
- areaActions->addAction(bottomAction);
-
- connect(movableAction, &QAction::triggered, areaActions, &QActionGroup::setEnabled);
-
- connect(movableAction, &QAction::triggered, allowedAreasActions, &QActionGroup::setEnabled);
-
- connect(floatableAction, &QAction::triggered, floatingAction, &QAction::setEnabled);
-
- connect(floatingAction, &QAction::triggered, floatableAction, &QAction::setDisabled);
- connect(movableAction, &QAction::triggered, floatableAction, &QAction::setEnabled);
-
- tabMenu = new QMenu(this);
- tabMenu->setTitle(tr("Tab into"));
- connect(tabMenu, &QMenu::triggered, this, &ColorSwatch::tabInto);
-
- splitHMenu = new QMenu(this);
- splitHMenu->setTitle(tr("Split horizontally into"));
- connect(splitHMenu, &QMenu::triggered, this, &ColorSwatch::splitInto);
-
- splitVMenu = new QMenu(this);
- splitVMenu->setTitle(tr("Split vertically into"));
- connect(splitVMenu, &QMenu::triggered, this, &ColorSwatch::splitInto);
-
- QAction *windowModifiedAction = new QAction(tr("Modified"), this);
- windowModifiedAction->setCheckable(true);
- windowModifiedAction->setChecked(false);
- connect(windowModifiedAction, &QAction::toggled, this, &QWidget::setWindowModified);
-
- menu = new QMenu(colorName, this);
- menu->addAction(toggleViewAction());
- menu->addAction(tr("Raise"), this, &QWidget::raise);
- menu->addAction(tr("Change Size Hints..."), swatch, &ColorDock::changeSizeHints);
-
- menu->addSeparator();
- menu->addAction(closableAction);
- menu->addAction(movableAction);
- menu->addAction(floatableAction);
- menu->addAction(floatingAction);
- menu->addAction(verticalTitleBarAction);
- menu->addSeparator();
- menu->addActions(allowedAreasActions->actions());
- menu->addSeparator();
- menu->addActions(areaActions->actions());
- menu->addSeparator();
- menu->addMenu(splitHMenu);
- menu->addMenu(splitVMenu);
- menu->addMenu(tabMenu);
- menu->addSeparator();
- menu->addAction(windowModifiedAction);
-
- connect(menu, &QMenu::aboutToShow, this, &ColorSwatch::updateContextMenu);
-
- if (colorName == QLatin1String("Black")) {
- leftAction->setShortcut(Qt::CTRL | Qt::Key_W);
- rightAction->setShortcut(Qt::CTRL | Qt::Key_E);
- toggleViewAction()->setShortcut(Qt::CTRL | Qt::Key_R);
- }
-}
-
-void ColorSwatch::updateContextMenu()
-{
- const Qt::DockWidgetArea area = mainWindow->dockWidgetArea(this);
- const Qt::DockWidgetAreas areas = allowedAreas();
-
- closableAction->setChecked(features() & QDockWidget::DockWidgetClosable);
- if (windowType() == Qt::Drawer) {
- floatableAction->setEnabled(false);
- floatingAction->setEnabled(false);
- movableAction->setEnabled(false);
- verticalTitleBarAction->setChecked(false);
- } else {
- floatableAction->setChecked(features() & QDockWidget::DockWidgetFloatable);
- floatingAction->setChecked(isWindow());
- // done after floating, to get 'floatable' correctly initialized
- movableAction->setChecked(features() & QDockWidget::DockWidgetMovable);
- verticalTitleBarAction
- ->setChecked(features() & QDockWidget::DockWidgetVerticalTitleBar);
- }
-
- allowLeftAction->setChecked(isAreaAllowed(Qt::LeftDockWidgetArea));
- allowRightAction->setChecked(isAreaAllowed(Qt::RightDockWidgetArea));
- allowTopAction->setChecked(isAreaAllowed(Qt::TopDockWidgetArea));
- allowBottomAction->setChecked(isAreaAllowed(Qt::BottomDockWidgetArea));
-
- if (allowedAreasActions->isEnabled()) {
- allowLeftAction->setEnabled(area != Qt::LeftDockWidgetArea);
- allowRightAction->setEnabled(area != Qt::RightDockWidgetArea);
- allowTopAction->setEnabled(area != Qt::TopDockWidgetArea);
- allowBottomAction->setEnabled(area != Qt::BottomDockWidgetArea);
- }
-
- {
- const QSignalBlocker blocker(leftAction);
- leftAction->setChecked(area == Qt::LeftDockWidgetArea);
- }
- {
- const QSignalBlocker blocker(rightAction);
- rightAction->setChecked(area == Qt::RightDockWidgetArea);
- }
- {
- const QSignalBlocker blocker(topAction);
- topAction->setChecked(area == Qt::TopDockWidgetArea);
- }
- {
- const QSignalBlocker blocker(bottomAction);
- bottomAction->setChecked(area == Qt::BottomDockWidgetArea);
- }
-
- if (areaActions->isEnabled()) {
- leftAction->setEnabled(areas & Qt::LeftDockWidgetArea);
- rightAction->setEnabled(areas & Qt::RightDockWidgetArea);
- topAction->setEnabled(areas & Qt::TopDockWidgetArea);
- bottomAction->setEnabled(areas & Qt::BottomDockWidgetArea);
- }
-
- tabMenu->clear();
- splitHMenu->clear();
- splitVMenu->clear();
- const QList<ColorSwatch *> dockList = mainWindow->findChildren<ColorSwatch*>();
- for (const ColorSwatch *dock : dockList) {
- tabMenu->addAction(dock->objectName());
- splitHMenu->addAction(dock->objectName());
- splitVMenu->addAction(dock->objectName());
- }
-}
-
-static ColorSwatch *findByName(const QMainWindow *mainWindow, const QString &name)
-{
- const QList<ColorSwatch *> dockList = mainWindow->findChildren<ColorSwatch*>();
- for (ColorSwatch *dock : dockList) {
- if (name == dock->objectName())
- return dock;
- }
- return nullptr;
-}
-
-void ColorSwatch::splitInto(QAction *action)
-{
- ColorSwatch *target = findByName(mainWindow, action->text());
- if (!target)
- return;
-
- const Qt::Orientation o = action->parent() == splitHMenu
- ? Qt::Horizontal : Qt::Vertical;
- mainWindow->splitDockWidget(target, this, o);
-}
-
-void ColorSwatch::tabInto(QAction *action)
-{
- if (ColorSwatch *target = findByName(mainWindow, action->text()))
- mainWindow->tabifyDockWidget(target, this);
-}
-
-#ifndef QT_NO_CONTEXTMENU
-void ColorSwatch::contextMenuEvent(QContextMenuEvent *event)
-{
- event->accept();
- menu->popup(event->globalPos());
-}
-#endif // QT_NO_CONTEXTMENU
-
-void ColorSwatch::resizeEvent(QResizeEvent *e)
-{
- if (BlueTitleBar *btb = qobject_cast<BlueTitleBar*>(titleBarWidget()))
- btb->updateMask();
-
- QDockWidget::resizeEvent(e);
-}
-
-void ColorSwatch::allow(Qt::DockWidgetArea area, bool a)
-{
- Qt::DockWidgetAreas areas = allowedAreas();
- areas = a ? areas | area : areas & ~area;
- setAllowedAreas(areas);
-
- if (areaActions->isEnabled()) {
- leftAction->setEnabled(areas & Qt::LeftDockWidgetArea);
- rightAction->setEnabled(areas & Qt::RightDockWidgetArea);
- topAction->setEnabled(areas & Qt::TopDockWidgetArea);
- bottomAction->setEnabled(areas & Qt::BottomDockWidgetArea);
- }
-}
-
-void ColorSwatch::place(Qt::DockWidgetArea area, bool p)
-{
- if (!p)
- return;
-
- mainWindow->addDockWidget(area, this);
-
- if (allowedAreasActions->isEnabled()) {
- allowLeftAction->setEnabled(area != Qt::LeftDockWidgetArea);
- allowRightAction->setEnabled(area != Qt::RightDockWidgetArea);
- allowTopAction->setEnabled(area != Qt::TopDockWidgetArea);
- allowBottomAction->setEnabled(area != Qt::BottomDockWidgetArea);
- }
-}
-
-void ColorSwatch::setCustomSizeHint(const QSize &size)
-{
- if (ColorDock *dock = qobject_cast<ColorDock*>(widget()))
- dock->setCustomSizeHint(size);
-}
-
-void ColorSwatch::changeClosable(bool on)
-{ setFeatures(on ? features() | DockWidgetClosable : features() & ~DockWidgetClosable); }
-
-void ColorSwatch::changeMovable(bool on)
-{ setFeatures(on ? features() | DockWidgetMovable : features() & ~DockWidgetMovable); }
-
-void ColorSwatch::changeFloatable(bool on)
-{ setFeatures(on ? features() | DockWidgetFloatable : features() & ~DockWidgetFloatable); }
-
-void ColorSwatch::changeFloating(bool floating)
-{ setFloating(floating); }
-
-void ColorSwatch::allowLeft(bool a)
-{ allow(Qt::LeftDockWidgetArea, a); }
-
-void ColorSwatch::allowRight(bool a)
-{ allow(Qt::RightDockWidgetArea, a); }
-
-void ColorSwatch::allowTop(bool a)
-{ allow(Qt::TopDockWidgetArea, a); }
-
-void ColorSwatch::allowBottom(bool a)
-{ allow(Qt::BottomDockWidgetArea, a); }
-
-void ColorSwatch::placeLeft(bool p)
-{ place(Qt::LeftDockWidgetArea, p); }
-
-void ColorSwatch::placeRight(bool p)
-{ place(Qt::RightDockWidgetArea, p); }
-
-void ColorSwatch::placeTop(bool p)
-{ place(Qt::TopDockWidgetArea, p); }
-
-void ColorSwatch::placeBottom(bool p)
-{ place(Qt::BottomDockWidgetArea, p); }
-
-void ColorSwatch::changeVerticalTitleBar(bool on)
-{
- setFeatures(on ? features() | DockWidgetVerticalTitleBar
- : features() & ~DockWidgetVerticalTitleBar);
-}
-
-QSize BlueTitleBar::minimumSizeHint() const
-{
- QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
- Q_ASSERT(dw);
- QSize result(leftPm.width() + rightPm.width(), centerPm.height());
- if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar)
- result.transpose();
- return result;
-}
-
-BlueTitleBar::BlueTitleBar(QWidget *parent)
- : QWidget(parent)
- , leftPm(QPixmap(":/res/titlebarLeft.png"))
- , centerPm(QPixmap(":/res/titlebarCenter.png"))
- , rightPm(QPixmap(":/res/titlebarRight.png"))
-{
-}
-
-void BlueTitleBar::paintEvent(QPaintEvent*)
-{
- QPainter painter(this);
- QRect rect = this->rect();
-
- QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
- Q_ASSERT(dw);
-
- if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) {
- QSize s = rect.size();
- s.transpose();
- rect.setSize(s);
-
- painter.translate(rect.left(), rect.top() + rect.width());
- painter.rotate(-90);
- painter.translate(-rect.left(), -rect.top());
- }
-
- painter.drawPixmap(rect.topLeft(), leftPm);
- painter.drawPixmap(rect.topRight() - QPoint(rightPm.width() - 1, 0), rightPm);
- QBrush brush(centerPm);
- painter.fillRect(rect.left() + leftPm.width(), rect.top(),
- rect.width() - leftPm.width() - rightPm.width(),
- centerPm.height(), centerPm);
-}
-
-void BlueTitleBar::mouseReleaseEvent(QMouseEvent *event)
-{
- QPoint pos = event->position().toPoint();
-
- QRect rect = this->rect();
-
- QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
- Q_ASSERT(dw);
-
- if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) {
- QPoint p = pos;
- pos.setX(rect.left() + rect.bottom() - p.y());
- pos.setY(rect.top() + p.x() - rect.left());
-
- QSize s = rect.size();
- s.transpose();
- rect.setSize(s);
- }
-
- const int buttonRight = 7;
- const int buttonWidth = 20;
- int right = rect.right() - pos.x();
- int button = (right - buttonRight)/buttonWidth;
- switch (button) {
- case 0:
- event->accept();
- dw->close();
- break;
- case 1:
- event->accept();
- dw->setFloating(!dw->isFloating());
- break;
- case 2: {
- event->accept();
- QDockWidget::DockWidgetFeatures features = dw->features();
- if (features & QDockWidget::DockWidgetVerticalTitleBar)
- features &= ~QDockWidget::DockWidgetVerticalTitleBar;
- else
- features |= QDockWidget::DockWidgetVerticalTitleBar;
- dw->setFeatures(features);
- break;
- }
- default:
- event->ignore();
- break;
- }
-}
-
-void BlueTitleBar::updateMask()
-{
- QDockWidget *dw = qobject_cast<QDockWidget*>(parent());
- Q_ASSERT(dw);
-
- QRect rect = dw->rect();
- QBitmap bitmap(dw->size());
-
- {
- QPainter painter(&bitmap);
-
- // initialize to transparent
- painter.fillRect(rect, Qt::color0);
-
- QRect contents = rect;
- contents.setTopLeft(geometry().bottomLeft());
- contents.setRight(geometry().right());
- contents.setBottom(contents.bottom()-y());
- painter.fillRect(contents, Qt::color1);
-
- // let's paint the titlebar
- QRect titleRect = this->geometry();
-
- if (dw->features() & QDockWidget::DockWidgetVerticalTitleBar) {
- QSize s = rect.size();
- s.transpose();
- rect.setSize(s);
-
- QSize s2 = size();
- s2.transpose();
- titleRect.setSize(s2);
-
- painter.translate(rect.left(), rect.top() + rect.width());
- painter.rotate(-90);
- painter.translate(-rect.left(), -rect.top());
- }
-
- contents.setTopLeft(titleRect.bottomLeft());
- contents.setRight(titleRect.right());
- contents.setBottom(rect.bottom()-y());
-
- QRect rect = titleRect;
-
- painter.drawPixmap(rect.topLeft(), leftPm.mask());
- painter.fillRect(rect.left() + leftPm.width(), rect.top(),
- rect.width() - leftPm.width() - rightPm.width(),
- centerPm.height(), Qt::color1);
- painter.drawPixmap(rect.topRight() - QPoint(rightPm.width() - 1, 0), rightPm.mask());
-
- painter.fillRect(contents, Qt::color1);
- }
-
- dw->setMask(bitmap);
-}
-
-#include "colorswatch.moc"
diff --git a/examples/widgets/mainwindows/mainwindow/colorswatch.h b/examples/widgets/mainwindows/mainwindow/colorswatch.h
deleted file mode 100644
index 5b144bd428..0000000000
--- a/examples/widgets/mainwindows/mainwindow/colorswatch.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef COLORSWATCH_H
-#define COLORSWATCH_H
-
-#include <QDockWidget>
-
-QT_FORWARD_DECLARE_CLASS(QAction)
-QT_FORWARD_DECLARE_CLASS(QActionGroup)
-QT_FORWARD_DECLARE_CLASS(QMenu)
-
-class ColorSwatch : public QDockWidget
-{
- Q_OBJECT
-
-public:
- explicit ColorSwatch(const QString &colorName, QMainWindow *parent = nullptr, Qt::WindowFlags flags = { });
-
- void setCustomSizeHint(const QSize &size);
- QMenu *colorSwatchMenu() const { return menu; }
-
-protected:
-#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *event) override;
-#endif // QT_NO_CONTEXTMENU
- void resizeEvent(QResizeEvent *e) override;
-
-private slots:
- void changeClosable(bool on);
- void changeMovable(bool on);
- void changeFloatable(bool on);
- void changeFloating(bool on);
- void changeVerticalTitleBar(bool on);
- void updateContextMenu();
-
- void allowLeft(bool a);
- void allowRight(bool a);
- void allowTop(bool a);
- void allowBottom(bool a);
-
- void placeLeft(bool p);
- void placeRight(bool p);
- void placeTop(bool p);
- void placeBottom(bool p);
-
- void splitInto(QAction *action);
- void tabInto(QAction *action);
-
-private:
- void allow(Qt::DockWidgetArea area, bool allow);
- void place(Qt::DockWidgetArea area, bool place);
-
- QAction *closableAction;
- QAction *movableAction;
- QAction *floatableAction;
- QAction *floatingAction;
- QAction *verticalTitleBarAction;
-
- QActionGroup *allowedAreasActions;
- QAction *allowLeftAction;
- QAction *allowRightAction;
- QAction *allowTopAction;
- QAction *allowBottomAction;
-
- QActionGroup *areaActions;
- QAction *leftAction;
- QAction *rightAction;
- QAction *topAction;
- QAction *bottomAction;
-
- QMenu *tabMenu;
- QMenu *splitHMenu;
- QMenu *splitVMenu;
- QMenu *menu;
-
- QMainWindow *mainWindow;
-};
-
-class BlueTitleBar : public QWidget
-{
- Q_OBJECT
-public:
- explicit BlueTitleBar(QWidget *parent = nullptr);
-
- QSize sizeHint() const override { return minimumSizeHint(); }
- QSize minimumSizeHint() const override;
-
-protected:
- void paintEvent(QPaintEvent *event) override;
- void mouseReleaseEvent(QMouseEvent *event) override;
-
-public slots:
- void updateMask();
-
-private:
- const QPixmap leftPm;
- const QPixmap centerPm;
- const QPixmap rightPm;
-};
-
-#endif // COLORSWATCH_H
diff --git a/examples/widgets/mainwindows/mainwindow/main.cpp b/examples/widgets/mainwindows/mainwindow/main.cpp
deleted file mode 100644
index 66aa99ee75..0000000000
--- a/examples/widgets/mainwindows/mainwindow/main.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-
-#include <QApplication>
-#include <QPainterPath>
-#include <QPainter>
-#include <QMap>
-#include <QDebug>
-
-void render_qt_text(QPainter *painter, int w, int h, const QColor &color)
-{
- QPainterPath path;
- path.moveTo(-0.083695, 0.283849);
- path.cubicTo(-0.049581, 0.349613, -0.012720, 0.397969, 0.026886, 0.428917);
- path.cubicTo(0.066493, 0.459865, 0.111593, 0.477595, 0.162186, 0.482108);
- path.lineTo(0.162186, 0.500000);
- path.cubicTo(0.115929, 0.498066, 0.066565, 0.487669, 0.014094, 0.468810);
- path.cubicTo(-0.038378, 0.449952, -0.088103, 0.423839, -0.135082, 0.390474);
- path.cubicTo(-0.182061, 0.357108, -0.222608, 0.321567, -0.256722, 0.283849);
- path.cubicTo(-0.304712, 0.262250, -0.342874, 0.239362, -0.371206, 0.215184);
- path.cubicTo(-0.411969, 0.179078, -0.443625, 0.134671, -0.466175, 0.081963);
- path.cubicTo(-0.488725, 0.029255, -0.500000, -0.033043, -0.500000, -0.104932);
- path.cubicTo(-0.500000, -0.218407, -0.467042, -0.312621, -0.401127, -0.387573);
- path.cubicTo(-0.335212, -0.462524, -0.255421, -0.500000, -0.161752, -0.500000);
- path.cubicTo(-0.072998, -0.500000, 0.003903, -0.462444, 0.068951, -0.387331);
- path.cubicTo(0.133998, -0.312218, 0.166522, -0.217440, 0.166522, -0.102998);
- path.cubicTo(0.166522, -0.010155, 0.143394, 0.071325, 0.097138, 0.141441);
- path.cubicTo(0.050882, 0.211557, -0.009396, 0.259026, -0.083695, 0.283849);
- path.moveTo(-0.167823, -0.456963);
- path.cubicTo(-0.228823, -0.456963, -0.277826, -0.432624, -0.314831, -0.383946);
- path.cubicTo(-0.361665, -0.323340, -0.385082, -0.230335, -0.385082, -0.104932);
- path.cubicTo(-0.385082, 0.017569, -0.361376, 0.112025, -0.313964, 0.178433);
- path.cubicTo(-0.277248, 0.229368, -0.228534, 0.254836, -0.167823, 0.254836);
- path.cubicTo(-0.105088, 0.254836, -0.054496, 0.229368, -0.016045, 0.178433);
- path.cubicTo(0.029055, 0.117827, 0.051605, 0.028691, 0.051605, -0.088975);
- path.cubicTo(0.051605, -0.179562, 0.039318, -0.255803, 0.014744, -0.317698);
- path.cubicTo(-0.004337, -0.365409, -0.029705, -0.400548, -0.061362, -0.423114);
- path.cubicTo(-0.093018, -0.445680, -0.128505, -0.456963, -0.167823, -0.456963);
- path.moveTo(0.379011, -0.404739);
- path.lineTo(0.379011, -0.236460);
- path.lineTo(0.486123, -0.236460);
- path.lineTo(0.486123, -0.197292);
- path.lineTo(0.379011, -0.197292);
- path.lineTo(0.379011, 0.134913);
- path.cubicTo(0.379011, 0.168117, 0.383276, 0.190442, 0.391804, 0.201886);
- path.cubicTo(0.400332, 0.213330, 0.411246, 0.219052, 0.424545, 0.219052);
- path.cubicTo(0.435531, 0.219052, 0.446227, 0.215264, 0.456635, 0.207689);
- path.cubicTo(0.467042, 0.200113, 0.474993, 0.188910, 0.480486, 0.174081);
- path.lineTo(0.500000, 0.174081);
- path.cubicTo(0.488436, 0.210509, 0.471957, 0.237911, 0.450564, 0.256286);
- path.cubicTo(0.429170, 0.274662, 0.407054, 0.283849, 0.384215, 0.283849);
- path.cubicTo(0.368893, 0.283849, 0.353859, 0.279094, 0.339115, 0.269584);
- path.cubicTo(0.324371, 0.260074, 0.313530, 0.246534, 0.306592, 0.228965);
- path.cubicTo(0.299653, 0.211396, 0.296184, 0.184075, 0.296184, 0.147002);
- path.lineTo(0.296184, -0.197292);
- path.lineTo(0.223330, -0.197292);
- path.lineTo(0.223330, -0.215667);
- path.cubicTo(0.241833, -0.224049, 0.260697, -0.237992, 0.279922, -0.257495);
- path.cubicTo(0.299147, -0.276999, 0.316276, -0.300129, 0.331310, -0.326886);
- path.cubicTo(0.338826, -0.341070, 0.349523, -0.367021, 0.363400, -0.404739);
- path.lineTo(0.379011, -0.404739);
- path.moveTo(-0.535993, 0.275629);
-
- painter->translate(w / 2, h / 2);
- double scale = qMin(w, h) * 8 / 10.0;
- painter->scale(scale, scale);
-
- painter->setRenderHint(QPainter::Antialiasing);
-
- painter->save();
- painter->translate(.1, .1);
- painter->fillPath(path, QColor(0, 0, 0, 63));
- painter->restore();
-
- painter->setBrush(color);
- painter->setPen(QPen(Qt::black, 0.02, Qt::SolidLine, Qt::FlatCap, Qt::RoundJoin));
- painter->drawPath(path);
-}
-
-static void usage()
-{
- qWarning() << "Usage: mainwindow [-SizeHint<color> <width>x<height>] ...";
- exit(1);
-}
-
-enum ParseCommandLineArgumentsResult {
- CommandLineArgumentsOk,
- CommandLineArgumentsError,
- HelpRequested
-};
-
-static ParseCommandLineArgumentsResult
- parseCustomSizeHints(const QStringList &arguments, MainWindow::CustomSizeHintMap *result)
-{
- result->clear();
- const int argumentCount = arguments.size();
- for (int i = 1; i < argumentCount; ++i) {
- const QString &arg = arguments.at(i);
- if (arg.startsWith(QLatin1String("-SizeHint"))) {
- const QString name = arg.mid(9);
- if (name.isEmpty())
- return CommandLineArgumentsError;
- if (++i == argumentCount)
- return CommandLineArgumentsError;
- const QStringView sizeStr{ arguments.at(i) };
- const int idx = sizeStr.indexOf(QLatin1Char('x'));
- if (idx == -1)
- return CommandLineArgumentsError;
- bool ok;
- const int w = sizeStr.left(idx).toInt(&ok);
- if (!ok)
- return CommandLineArgumentsError;
- const int h = sizeStr.mid(idx + 1).toInt(&ok);
- if (!ok)
- return CommandLineArgumentsError;
- result->insert(name, QSize(w, h));
- } else if (arg == QLatin1String("-h") || arg == QLatin1String("--help")) {
- return HelpRequested;
- } else {
- return CommandLineArgumentsError;
- }
- }
-
- return CommandLineArgumentsOk;
-}
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
- MainWindow::CustomSizeHintMap customSizeHints;
- switch (parseCustomSizeHints(QCoreApplication::arguments(), &customSizeHints)) {
- case CommandLineArgumentsOk:
- break;
- case CommandLineArgumentsError:
- usage();
- return -1;
- case HelpRequested:
- usage();
- return 0;
- }
- MainWindow mainWin(customSizeHints);
- mainWin.resize(800, 600);
- mainWin.show();
- return app.exec();
-}
diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
deleted file mode 100644
index f2ea0d0697..0000000000
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
+++ /dev/null
@@ -1,444 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-#include "colorswatch.h"
-#include "toolbar.h"
-
-#include <QActionGroup>
-#include <QLayout>
-#include <QMenu>
-#include <QMenuBar>
-#include <QStatusBar>
-#include <QTextEdit>
-#include <QFile>
-#include <QDataStream>
-#include <QFileDialog>
-#include <QDialogButtonBox>
-#include <QMessageBox>
-#include <QApplication>
-#include <QPainter>
-#include <QMouseEvent>
-#include <QLineEdit>
-#include <QComboBox>
-#include <QLabel>
-#include <QPushButton>
-#include <QTextEdit>
-#include <QDebug>
-
-static const char message[] =
- "<p><b>Qt Main Window Example</b></p>"
-
- "<p>This is a demonstration of the QMainWindow, QToolBar and "
- "QDockWidget classes.</p>"
-
- "<p>The tool bar and dock widgets can be dragged around and rearranged "
- "using the mouse or via the menu.</p>"
-
- "<p>Each dock widget contains a colored frame and a context "
- "(right-click) menu.</p>"
-
-#ifdef Q_OS_MAC
- "<p>On OS X, the \"Black\" dock widget has been created as a "
- "<em>Drawer</em>, which is a special kind of QDockWidget.</p>"
-#endif
- ;
-
-Q_DECLARE_METATYPE(QDockWidget::DockWidgetFeatures)
-
-MainWindow::MainWindow(const CustomSizeHintMap &customSizeHints,
- QWidget *parent, Qt::WindowFlags flags)
- : QMainWindow(parent, flags)
-{
- Q_UNUSED(message);
- setObjectName("MainWindow");
- setWindowTitle("Qt Main Window Example");
-
- QTextEdit *center = new QTextEdit(this);
- center->setReadOnly(true);
- center->setMinimumSize(400, 205);
- setCentralWidget(center);
-
- setupToolBar();
- setupMenuBar();
- setupDockWidgets(customSizeHints);
-
- statusBar()->showMessage(tr("Status Bar"));
-}
-
-void MainWindow::actionTriggered(QAction *action)
-{
- qDebug("action '%s' triggered", action->text().toLocal8Bit().data());
-}
-
-void MainWindow::setupToolBar()
-{
-#ifdef Q_OS_MACOS
- setUnifiedTitleAndToolBarOnMac(true);
-#endif
-
- for (int i = 0; i < 3; ++i) {
- ToolBar *tb = new ToolBar(QString::fromLatin1("Tool Bar %1").arg(i + 1), this);
- toolBars.append(tb);
- addToolBar(tb);
- }
-}
-
-void MainWindow::setupMenuBar()
-{
- QMenu *menu = menuBar()->addMenu(tr("&File"));
-
- menu->addAction(tr("Save layout..."), this, &MainWindow::saveLayout);
- menu->addAction(tr("Load layout..."), this, &MainWindow::loadLayout);
- menu->addAction(tr("Switch layout direction"),this, &MainWindow::switchLayoutDirection);
-
- menu->addSeparator();
- menu->addAction(tr("&Quit"), this, &QWidget::close);
-
- mainWindowMenu = menuBar()->addMenu(tr("Main window"));
-
- QAction *action = mainWindowMenu->addAction(tr("Animated docks"));
- action->setCheckable(true);
- action->setChecked(dockOptions() & AnimatedDocks);
- connect(action, &QAction::toggled, this, &MainWindow::setDockOptions);
-
- action = mainWindowMenu->addAction(tr("Allow nested docks"));
- action->setCheckable(true);
- action->setChecked(dockOptions() & AllowNestedDocks);
- connect(action, &QAction::toggled, this, &MainWindow::setDockOptions);
-
- action = mainWindowMenu->addAction(tr("Allow tabbed docks"));
- action->setCheckable(true);
- action->setChecked(dockOptions() & AllowTabbedDocks);
- connect(action, &QAction::toggled, this, &MainWindow::setDockOptions);
-
- action = mainWindowMenu->addAction(tr("Force tabbed docks"));
- action->setCheckable(true);
- action->setChecked(dockOptions() & ForceTabbedDocks);
- connect(action, &QAction::toggled, this, &MainWindow::setDockOptions);
-
- action = mainWindowMenu->addAction(tr("Vertical tabs"));
- action->setCheckable(true);
- action->setChecked(dockOptions() & VerticalTabs);
- connect(action, &QAction::toggled, this, &MainWindow::setDockOptions);
-
- action = mainWindowMenu->addAction(tr("Grouped dragging"));
- action->setCheckable(true);
- action->setChecked(dockOptions() & GroupedDragging);
- connect(action, &QAction::toggled, this, &MainWindow::setDockOptions);
-
- QMenu *toolBarMenu = menuBar()->addMenu(tr("Tool bars"));
- for (int i = 0; i < toolBars.count(); ++i)
- toolBarMenu->addMenu(toolBars.at(i)->toolbarMenu());
-
-#ifdef Q_OS_MACOS
- toolBarMenu->addSeparator();
-
- action = toolBarMenu->addAction(tr("Unified"));
- action->setCheckable(true);
- action->setChecked(unifiedTitleAndToolBarOnMac());
- connect(action, &QAction::toggled, this, &QMainWindow::setUnifiedTitleAndToolBarOnMac);
-#endif
-
- dockWidgetMenu = menuBar()->addMenu(tr("&Dock Widgets"));
-
- QMenu *aboutMenu = menuBar()->addMenu(tr("About"));
- QAction *aboutAct = aboutMenu->addAction(tr("&About"), this, &MainWindow::about);
- aboutAct->setStatusTip(tr("Show the application's About box"));
-
- QAction *aboutQtAct = aboutMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
- aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
-}
-
-void MainWindow::setDockOptions()
-{
- DockOptions opts;
- QList<QAction*> actions = mainWindowMenu->actions();
-
- if (actions.at(0)->isChecked())
- opts |= AnimatedDocks;
- if (actions.at(1)->isChecked())
- opts |= AllowNestedDocks;
- if (actions.at(2)->isChecked())
- opts |= AllowTabbedDocks;
- if (actions.at(3)->isChecked())
- opts |= ForceTabbedDocks;
- if (actions.at(4)->isChecked())
- opts |= VerticalTabs;
- if (actions.at(5)->isChecked())
- opts |= GroupedDragging;
-
- QMainWindow::setDockOptions(opts);
-}
-
-void MainWindow::saveLayout()
-{
- QString fileName
- = QFileDialog::getSaveFileName(this, tr("Save layout"));
- if (fileName.isEmpty())
- return;
- QFile file(fileName);
- if (!file.open(QFile::WriteOnly)) {
- QString msg = tr("Failed to open %1\n%2")
- .arg(QDir::toNativeSeparators(fileName), file.errorString());
- QMessageBox::warning(this, tr("Error"), msg);
- return;
- }
-
- QByteArray geo_data = saveGeometry();
- QByteArray layout_data = saveState();
-
- bool ok = file.putChar((uchar)geo_data.size());
- if (ok)
- ok = file.write(geo_data) == geo_data.size();
- if (ok)
- ok = file.write(layout_data) == layout_data.size();
-
- if (!ok) {
- QString msg = tr("Error writing to %1\n%2")
- .arg(QDir::toNativeSeparators(fileName), file.errorString());
- QMessageBox::warning(this, tr("Error"), msg);
- return;
- }
-}
-
-void MainWindow::loadLayout()
-{
- QString fileName
- = QFileDialog::getOpenFileName(this, tr("Load layout"));
- if (fileName.isEmpty())
- return;
- QFile file(fileName);
- if (!file.open(QFile::ReadOnly)) {
- QString msg = tr("Failed to open %1\n%2")
- .arg(QDir::toNativeSeparators(fileName), file.errorString());
- QMessageBox::warning(this, tr("Error"), msg);
- return;
- }
-
- uchar geo_size;
- QByteArray geo_data;
- QByteArray layout_data;
-
- bool ok = file.getChar((char*)&geo_size);
- if (ok) {
- geo_data = file.read(geo_size);
- ok = geo_data.size() == geo_size;
- }
- if (ok) {
- layout_data = file.readAll();
- ok = layout_data.size() > 0;
- }
-
- if (ok)
- ok = restoreGeometry(geo_data);
- if (ok)
- ok = restoreState(layout_data);
-
- if (!ok) {
- QString msg = tr("Error reading %1").arg(QDir::toNativeSeparators(fileName));
- QMessageBox::warning(this, tr("Error"), msg);
- return;
- }
-}
-
-static QAction *addCornerAction(const QString &text, QMainWindow *mw, QMenu *menu, QActionGroup *group,
- Qt::Corner c, Qt::DockWidgetArea a)
-{
- QAction *result = menu->addAction(text, mw, [=]() { mw->setCorner(c, a); });
- result->setCheckable(true);
- group->addAction(result);
- return result;
-}
-
-void MainWindow::setupDockWidgets(const CustomSizeHintMap &customSizeHints)
-{
- qRegisterMetaType<QDockWidget::DockWidgetFeatures>();
-
- QMenu *cornerMenu = dockWidgetMenu->addMenu(tr("Top left corner"));
- QActionGroup *group = new QActionGroup(this);
- group->setExclusive(true);
- QAction *cornerAction = addCornerAction(tr("Top dock area"), this, cornerMenu, group, Qt::TopLeftCorner, Qt::TopDockWidgetArea);
- cornerAction->setChecked(true);
- addCornerAction(tr("Left dock area"), this, cornerMenu, group, Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
-
- cornerMenu = dockWidgetMenu->addMenu(tr("Top right corner"));
- group = new QActionGroup(this);
- group->setExclusive(true);
- cornerAction = addCornerAction(tr("Top dock area"), this, cornerMenu, group, Qt::TopRightCorner, Qt::TopDockWidgetArea);
- cornerAction->setChecked(true);
- addCornerAction(tr("Right dock area"), this, cornerMenu, group, Qt::TopRightCorner, Qt::RightDockWidgetArea);
-
- cornerMenu = dockWidgetMenu->addMenu(tr("Bottom left corner"));
- group = new QActionGroup(this);
- group->setExclusive(true);
- cornerAction = addCornerAction(tr("Bottom dock area"), this, cornerMenu, group, Qt::BottomLeftCorner, Qt::BottomDockWidgetArea);
- cornerAction->setChecked(true);
- addCornerAction(tr("Left dock area"), this, cornerMenu, group, Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
-
- cornerMenu = dockWidgetMenu->addMenu(tr("Bottom right corner"));
- group = new QActionGroup(this);
- group->setExclusive(true);
- cornerAction = addCornerAction(tr("Bottom dock area"), this, cornerMenu, group, Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
- cornerAction->setChecked(true);
- addCornerAction(tr("Right dock area"), this, cornerMenu, group, Qt::BottomRightCorner, Qt::RightDockWidgetArea);
-
- dockWidgetMenu->addSeparator();
-
- static const struct Set {
- const char * name;
- uint flags;
- Qt::DockWidgetArea area;
- } sets [] = {
-#ifndef Q_OS_MAC
- { "Black", 0, Qt::LeftDockWidgetArea },
-#else
- { "Black", Qt::Drawer, Qt::LeftDockWidgetArea },
-#endif
- { "White", 0, Qt::RightDockWidgetArea },
- { "Red", 0, Qt::TopDockWidgetArea },
- { "Green", 0, Qt::TopDockWidgetArea },
- { "Blue", 0, Qt::BottomDockWidgetArea },
- { "Yellow", 0, Qt::BottomDockWidgetArea }
- };
- const int setCount = sizeof(sets) / sizeof(Set);
-
- const QIcon qtIcon(QPixmap(":/res/qt.png"));
- for (int i = 0; i < setCount; ++i) {
- ColorSwatch *swatch = new ColorSwatch(tr(sets[i].name), this, Qt::WindowFlags(sets[i].flags));
- if (i % 2)
- swatch->setWindowIcon(qtIcon);
- if (qstrcmp(sets[i].name, "Blue") == 0) {
- BlueTitleBar *titlebar = new BlueTitleBar(swatch);
- swatch->setTitleBarWidget(titlebar);
- connect(swatch, &QDockWidget::topLevelChanged, titlebar, &BlueTitleBar::updateMask);
- connect(swatch, &QDockWidget::featuresChanged, titlebar, &BlueTitleBar::updateMask, Qt::QueuedConnection);
- }
-
- QString name = QString::fromLatin1(sets[i].name);
- if (customSizeHints.contains(name))
- swatch->setCustomSizeHint(customSizeHints.value(name));
-
- addDockWidget(sets[i].area, swatch);
- dockWidgetMenu->addMenu(swatch->colorSwatchMenu());
- }
-
- destroyDockWidgetMenu = new QMenu(tr("Destroy dock widget"), this);
- destroyDockWidgetMenu->setEnabled(false);
- connect(destroyDockWidgetMenu, &QMenu::triggered, this, &MainWindow::destroyDockWidget);
-
- dockWidgetMenu->addSeparator();
- dockWidgetMenu->addAction(tr("Add dock widget..."), this, &MainWindow::createDockWidget);
- dockWidgetMenu->addMenu(destroyDockWidgetMenu);
-}
-
-void MainWindow::switchLayoutDirection()
-{
- if (layoutDirection() == Qt::LeftToRight)
- QApplication::setLayoutDirection(Qt::RightToLeft);
- else
- QApplication::setLayoutDirection(Qt::LeftToRight);
-}
-
-class CreateDockWidgetDialog : public QDialog
-{
-public:
- explicit CreateDockWidgetDialog(QWidget *parent = nullptr);
-
- QString enteredObjectName() const { return m_objectName->text(); }
- Qt::DockWidgetArea location() const;
-
-private:
- QLineEdit *m_objectName;
- QComboBox *m_location;
-};
-
-CreateDockWidgetDialog::CreateDockWidgetDialog(QWidget *parent)
- : QDialog(parent)
- , m_objectName(new QLineEdit(this))
- , m_location(new QComboBox(this))
-{
- setWindowTitle(tr("Add Dock Widget"));
- setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
- QGridLayout *layout = new QGridLayout(this);
-
- layout->addWidget(new QLabel(tr("Object name:")), 0, 0);
- layout->addWidget(m_objectName, 0, 1);
-
- layout->addWidget(new QLabel(tr("Location:")), 1, 0);
- m_location->setEditable(false);
- m_location->addItem(tr("Top"));
- m_location->addItem(tr("Left"));
- m_location->addItem(tr("Right"));
- m_location->addItem(tr("Bottom"));
- m_location->addItem(tr("Restore"));
- layout->addWidget(m_location, 1, 1);
-
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
- connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
- layout->addWidget(buttonBox, 2, 0, 1, 2);
-}
-
-Qt::DockWidgetArea CreateDockWidgetDialog::location() const
-{
- switch (m_location->currentIndex()) {
- case 0: return Qt::TopDockWidgetArea;
- case 1: return Qt::LeftDockWidgetArea;
- case 2: return Qt::RightDockWidgetArea;
- case 3: return Qt::BottomDockWidgetArea;
- default:
- break;
- }
- return Qt::NoDockWidgetArea;
-}
-
-void MainWindow::createDockWidget()
-{
- CreateDockWidgetDialog dialog(this);
- if (dialog.exec() == QDialog::Rejected)
- return;
-
- QDockWidget *dw = new QDockWidget;
- const QString name = dialog.enteredObjectName();
- dw->setObjectName(name);
- dw->setWindowTitle(name);
- dw->setWidget(new QTextEdit);
-
- Qt::DockWidgetArea area = dialog.location();
- switch (area) {
- case Qt::LeftDockWidgetArea:
- case Qt::RightDockWidgetArea:
- case Qt::TopDockWidgetArea:
- case Qt::BottomDockWidgetArea:
- addDockWidget(area, dw);
- break;
- default:
- if (!restoreDockWidget(dw)) {
- QMessageBox::warning(this, QString(), tr("Failed to restore dock widget"));
- delete dw;
- return;
- }
- break;
- }
-
- extraDockWidgets.append(dw);
- destroyDockWidgetMenu->setEnabled(true);
- destroyDockWidgetMenu->addAction(new QAction(name, this));
-}
-
-void MainWindow::destroyDockWidget(QAction *action)
-{
- int index = destroyDockWidgetMenu->actions().indexOf(action);
- delete extraDockWidgets.takeAt(index);
- destroyDockWidgetMenu->removeAction(action);
- action->deleteLater();
-
- if (destroyDockWidgetMenu->isEmpty())
- destroyDockWidgetMenu->setEnabled(false);
-}
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About MainWindows"), message);
-}
diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.h b/examples/widgets/mainwindows/mainwindow/mainwindow.h
deleted file mode 100644
index ec522d1a51..0000000000
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include <QMap>
-#include <QString>
-#include <QSize>
-
-class ToolBar;
-QT_FORWARD_DECLARE_CLASS(QMenu)
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- typedef QMap<QString, QSize> CustomSizeHintMap;
-
- explicit MainWindow(const CustomSizeHintMap &customSizeHints,
- QWidget *parent = nullptr,
- Qt::WindowFlags flags = { });
-
-public slots:
- void actionTriggered(QAction *action);
- void saveLayout();
- void loadLayout();
- void switchLayoutDirection();
- void setDockOptions();
-
- void createDockWidget();
- void destroyDockWidget(QAction *action);
-
- void about();
-
-private:
- void setupToolBar();
- void setupMenuBar();
- void setupDockWidgets(const CustomSizeHintMap &customSizeHints);
-
- QList<ToolBar*> toolBars;
- QMenu *dockWidgetMenu;
- QMenu *mainWindowMenu;
- QList<QDockWidget *> extraDockWidgets;
- QMenu *destroyDockWidgetMenu;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.pro b/examples/widgets/mainwindows/mainwindow/mainwindow.pro
deleted file mode 100644
index 446d07ee6e..0000000000
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TEMPLATE = app
-QT += widgets
-requires(qtConfig(combobox))
-
-HEADERS += colorswatch.h mainwindow.h toolbar.h
-SOURCES += colorswatch.cpp mainwindow.cpp toolbar.cpp main.cpp
-build_all:!build_pass {
- CONFIG -= build_all
- CONFIG += release
-}
-
-RESOURCES += mainwindow.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/mainwindows/mainwindow
-INSTALLS += target
diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.qrc b/examples/widgets/mainwindows/mainwindow/mainwindow.qrc
deleted file mode 100644
index 47ff22a3e4..0000000000
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.qrc
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/res">
- <file>qt.png</file>
- <file>titlebarLeft.png</file>
- <file>titlebarCenter.png</file>
- <file>titlebarRight.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/mainwindows/mainwindow/qt.png b/examples/widgets/mainwindows/mainwindow/qt.png
deleted file mode 100644
index 4f68e162de..0000000000
--- a/examples/widgets/mainwindows/mainwindow/qt.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mainwindow/titlebarCenter.png b/examples/widgets/mainwindows/mainwindow/titlebarCenter.png
deleted file mode 100644
index 5cc141355c..0000000000
--- a/examples/widgets/mainwindows/mainwindow/titlebarCenter.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mainwindow/titlebarLeft.png b/examples/widgets/mainwindows/mainwindow/titlebarLeft.png
deleted file mode 100644
index 315166202b..0000000000
--- a/examples/widgets/mainwindows/mainwindow/titlebarLeft.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mainwindow/titlebarRight.png b/examples/widgets/mainwindows/mainwindow/titlebarRight.png
deleted file mode 100644
index a4505268ec..0000000000
--- a/examples/widgets/mainwindows/mainwindow/titlebarRight.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mainwindow/toolbar.cpp b/examples/widgets/mainwindows/mainwindow/toolbar.cpp
deleted file mode 100644
index 66f26d7a72..0000000000
--- a/examples/widgets/mainwindows/mainwindow/toolbar.cpp
+++ /dev/null
@@ -1,316 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "toolbar.h"
-
-#include <QRandomGenerator>
-
-#include <QActionGroup>
-#include <QMainWindow>
-#include <QMenu>
-#include <QPainter>
-#include <QPainterPath>
-#include <QSpinBox>
-#include <QLabel>
-#include <QToolTip>
-
-#include <stdlib.h>
-
-static QPixmap genIcon(const QSize &iconSize, const QString &, const QColor &color, qreal pixelRatio)
-{
- int w = qRound(iconSize.width() * pixelRatio);
- int h = qRound(iconSize.height() * pixelRatio);
-
- QImage image(w, h, QImage::Format_ARGB32_Premultiplied);
- image.fill(0);
-
- QPainter p(&image);
-
- extern void render_qt_text(QPainter *, int, int, const QColor &);
- render_qt_text(&p, w, h, color);
-
- QPixmap pm = QPixmap::fromImage(image, Qt::DiffuseDither | Qt::DiffuseAlphaDither);
- pm.setDevicePixelRatio(pixelRatio);
- return pm;
-}
-
-static QPixmap genIcon(const QSize &iconSize, int number, const QColor &color, qreal pixelRatio)
-{ return genIcon(iconSize, QString::number(number), color, pixelRatio); }
-
-ToolBar::ToolBar(const QString &title, QWidget *parent)
- : QToolBar(parent)
- , spinbox(nullptr)
- , spinboxAction(nullptr)
-{
- setWindowTitle(title);
- setObjectName(title);
-
- setIconSize(QSize(32, 32));
-
- qreal dpr = devicePixelRatio();
- menu = new QMenu("One", this);
- menu->setIcon(genIcon(iconSize(), 1, Qt::black, dpr));
- menu->addAction(genIcon(iconSize(), "A", Qt::blue, dpr), "A");
- menu->addAction(genIcon(iconSize(), "B", Qt::blue, dpr), "B");
- menu->addAction(genIcon(iconSize(), "C", Qt::blue, dpr), "C");
- addAction(menu->menuAction());
-
- QAction *two = addAction(genIcon(iconSize(), 2, Qt::white, dpr), "Two");
- QFont boldFont;
- boldFont.setBold(true);
- two->setFont(boldFont);
-
- addAction(genIcon(iconSize(), 3, Qt::red, dpr), "Three");
- addAction(genIcon(iconSize(), 4, Qt::green, dpr), "Four");
- addAction(genIcon(iconSize(), 5, Qt::blue, dpr), "Five");
- addAction(genIcon(iconSize(), 6, Qt::yellow, dpr), "Six");
- orderAction = new QAction(this);
- orderAction->setText(tr("Order Items in Tool Bar"));
- connect(orderAction, &QAction::triggered, this, &ToolBar::order);
-
- randomizeAction = new QAction(this);
- randomizeAction->setText(tr("Randomize Items in Tool Bar"));
- connect(randomizeAction, &QAction::triggered, this, &ToolBar::randomize);
-
- addSpinBoxAction = new QAction(this);
- addSpinBoxAction->setText(tr("Add Spin Box"));
- connect(addSpinBoxAction, &QAction::triggered, this, &ToolBar::addSpinBox);
-
- removeSpinBoxAction = new QAction(this);
- removeSpinBoxAction->setText(tr("Remove Spin Box"));
- removeSpinBoxAction->setEnabled(false);
- connect(removeSpinBoxAction, &QAction::triggered, this, &ToolBar::removeSpinBox);
-
- movableAction = new QAction(tr("Movable"), this);
- movableAction->setCheckable(true);
- connect(movableAction, &QAction::triggered, this, &ToolBar::changeMovable);
-
- allowedAreasActions = new QActionGroup(this);
- allowedAreasActions->setExclusive(false);
-
- allowLeftAction = new QAction(tr("Allow on Left"), this);
- allowLeftAction->setCheckable(true);
- connect(allowLeftAction, &QAction::triggered, this, &ToolBar::allowLeft);
-
- allowRightAction = new QAction(tr("Allow on Right"), this);
- allowRightAction->setCheckable(true);
- connect(allowRightAction, &QAction::triggered, this, &ToolBar::allowRight);
-
- allowTopAction = new QAction(tr("Allow on Top"), this);
- allowTopAction->setCheckable(true);
- connect(allowTopAction, &QAction::triggered, this, &ToolBar::allowTop);
-
- allowBottomAction = new QAction(tr("Allow on Bottom"), this);
- allowBottomAction->setCheckable(true);
- connect(allowBottomAction, &QAction::triggered, this, &ToolBar::allowBottom);
-
- allowedAreasActions->addAction(allowLeftAction);
- allowedAreasActions->addAction(allowRightAction);
- allowedAreasActions->addAction(allowTopAction);
- allowedAreasActions->addAction(allowBottomAction);
-
- areaActions = new QActionGroup(this);
- areaActions->setExclusive(true);
-
- leftAction = new QAction(tr("Place on Left") , this);
- leftAction->setCheckable(true);
- connect(leftAction, &QAction::triggered, this, &ToolBar::placeLeft);
-
- rightAction = new QAction(tr("Place on Right") , this);
- rightAction->setCheckable(true);
- connect(rightAction, &QAction::triggered, this, &ToolBar::placeRight);
-
- topAction = new QAction(tr("Place on Top") , this);
- topAction->setCheckable(true);
- connect(topAction, &QAction::triggered, this, &ToolBar::placeTop);
-
- bottomAction = new QAction(tr("Place on Bottom") , this);
- bottomAction->setCheckable(true);
- connect(bottomAction, &QAction::triggered, this, &ToolBar::placeBottom);
-
- areaActions->addAction(leftAction);
- areaActions->addAction(rightAction);
- areaActions->addAction(topAction);
- areaActions->addAction(bottomAction);
-
- connect(movableAction, &QAction::triggered, areaActions, &QActionGroup::setEnabled);
-
- connect(movableAction, &QAction::triggered, allowedAreasActions, &QActionGroup::setEnabled);
-
- menu = new QMenu(title, this);
- menu->addAction(toggleViewAction());
- menu->addSeparator();
- menu->addAction(orderAction);
- menu->addAction(randomizeAction);
- menu->addSeparator();
- menu->addAction(addSpinBoxAction);
- menu->addAction(removeSpinBoxAction);
- menu->addSeparator();
- menu->addAction(movableAction);
- menu->addSeparator();
- menu->addActions(allowedAreasActions->actions());
- menu->addSeparator();
- menu->addActions(areaActions->actions());
- menu->addSeparator();
- menu->addAction(tr("Insert break"), this, &ToolBar::insertToolBarBreak);
-
- connect(menu, &QMenu::aboutToShow, this, &ToolBar::updateMenu);
-
- randomize();
-}
-
-void ToolBar::updateMenu()
-{
- QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
- Q_ASSERT(mainWindow);
-
- const Qt::ToolBarArea area = mainWindow->toolBarArea(this);
- const Qt::ToolBarAreas areas = allowedAreas();
-
- movableAction->setChecked(isMovable());
-
- allowLeftAction->setChecked(isAreaAllowed(Qt::LeftToolBarArea));
- allowRightAction->setChecked(isAreaAllowed(Qt::RightToolBarArea));
- allowTopAction->setChecked(isAreaAllowed(Qt::TopToolBarArea));
- allowBottomAction->setChecked(isAreaAllowed(Qt::BottomToolBarArea));
-
- if (allowedAreasActions->isEnabled()) {
- allowLeftAction->setEnabled(area != Qt::LeftToolBarArea);
- allowRightAction->setEnabled(area != Qt::RightToolBarArea);
- allowTopAction->setEnabled(area != Qt::TopToolBarArea);
- allowBottomAction->setEnabled(area != Qt::BottomToolBarArea);
- }
-
- leftAction->setChecked(area == Qt::LeftToolBarArea);
- rightAction->setChecked(area == Qt::RightToolBarArea);
- topAction->setChecked(area == Qt::TopToolBarArea);
- bottomAction->setChecked(area == Qt::BottomToolBarArea);
-
- if (areaActions->isEnabled()) {
- leftAction->setEnabled(areas & Qt::LeftToolBarArea);
- rightAction->setEnabled(areas & Qt::RightToolBarArea);
- topAction->setEnabled(areas & Qt::TopToolBarArea);
- bottomAction->setEnabled(areas & Qt::BottomToolBarArea);
- }
-}
-
-void ToolBar::order()
-{
- QList<QAction *> ordered;
- QList<QAction *> actions1 = actions();
- const QList<QAction *> childActions = findChildren<QAction *>();
- for (QAction *action : childActions) {
- if (!actions1.contains(action))
- continue;
- actions1.removeAll(action);
- ordered.append(action);
- }
-
- clear();
- addActions(ordered);
-
- orderAction->setEnabled(false);
-}
-
-void ToolBar::randomize()
-{
- QList<QAction *> randomized;
- QList<QAction *> actions = this->actions();
- while (!actions.isEmpty()) {
- QAction *action = actions.takeAt(QRandomGenerator::global()->bounded(actions.size()));
- randomized.append(action);
- }
- clear();
- addActions(randomized);
-
- orderAction->setEnabled(true);
-}
-
-void ToolBar::addSpinBox()
-{
- if (!spinbox)
- spinbox = new QSpinBox(this);
- if (!spinboxAction)
- spinboxAction = addWidget(spinbox);
- else
- addAction(spinboxAction);
-
- addSpinBoxAction->setEnabled(false);
- removeSpinBoxAction->setEnabled(true);
-}
-
-void ToolBar::removeSpinBox()
-{
- if (spinboxAction)
- removeAction(spinboxAction);
-
- addSpinBoxAction->setEnabled(true);
- removeSpinBoxAction->setEnabled(false);
-}
-
-void ToolBar::allow(Qt::ToolBarArea area, bool a)
-{
- Qt::ToolBarAreas areas = allowedAreas();
- areas = a ? areas | area : areas & ~area;
- setAllowedAreas(areas);
-
- if (areaActions->isEnabled()) {
- leftAction->setEnabled(areas & Qt::LeftToolBarArea);
- rightAction->setEnabled(areas & Qt::RightToolBarArea);
- topAction->setEnabled(areas & Qt::TopToolBarArea);
- bottomAction->setEnabled(areas & Qt::BottomToolBarArea);
- }
-}
-
-void ToolBar::place(Qt::ToolBarArea area, bool p)
-{
- if (!p)
- return;
-
- QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
- Q_ASSERT(mainWindow);
-
- mainWindow->addToolBar(area, this);
-
- if (allowedAreasActions->isEnabled()) {
- allowLeftAction->setEnabled(area != Qt::LeftToolBarArea);
- allowRightAction->setEnabled(area != Qt::RightToolBarArea);
- allowTopAction->setEnabled(area != Qt::TopToolBarArea);
- allowBottomAction->setEnabled(area != Qt::BottomToolBarArea);
- }
-}
-
-void ToolBar::changeMovable(bool movable)
-{ setMovable(movable); }
-
-void ToolBar::allowLeft(bool a)
-{ allow(Qt::LeftToolBarArea, a); }
-
-void ToolBar::allowRight(bool a)
-{ allow(Qt::RightToolBarArea, a); }
-
-void ToolBar::allowTop(bool a)
-{ allow(Qt::TopToolBarArea, a); }
-
-void ToolBar::allowBottom(bool a)
-{ allow(Qt::BottomToolBarArea, a); }
-
-void ToolBar::placeLeft(bool p)
-{ place(Qt::LeftToolBarArea, p); }
-
-void ToolBar::placeRight(bool p)
-{ place(Qt::RightToolBarArea, p); }
-
-void ToolBar::placeTop(bool p)
-{ place(Qt::TopToolBarArea, p); }
-
-void ToolBar::placeBottom(bool p)
-{ place(Qt::BottomToolBarArea, p); }
-
-void ToolBar::insertToolBarBreak()
-{
- QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
- Q_ASSERT(mainWindow);
-
- mainWindow->insertToolBarBreak(this);
-}
diff --git a/examples/widgets/mainwindows/mainwindow/toolbar.h b/examples/widgets/mainwindows/mainwindow/toolbar.h
deleted file mode 100644
index 14eca61684..0000000000
--- a/examples/widgets/mainwindows/mainwindow/toolbar.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef TOOLBAR_H
-#define TOOLBAR_H
-
-#include <QToolBar>
-
-QT_FORWARD_DECLARE_CLASS(QAction)
-QT_FORWARD_DECLARE_CLASS(QActionGroup)
-QT_FORWARD_DECLARE_CLASS(QMenu)
-QT_FORWARD_DECLARE_CLASS(QSpinBox)
-
-class ToolBar : public QToolBar
-{
- Q_OBJECT
-
-public:
- explicit ToolBar(const QString &title, QWidget *parent);
-
- QMenu *toolbarMenu() const { return menu; }
-
-private slots:
- void order();
- void randomize();
- void addSpinBox();
- void removeSpinBox();
-
- void changeMovable(bool movable);
-
- void allowLeft(bool a);
- void allowRight(bool a);
- void allowTop(bool a);
- void allowBottom(bool a);
-
- void placeLeft(bool p);
- void placeRight(bool p);
- void placeTop(bool p);
- void placeBottom(bool p);
-
- void updateMenu();
- void insertToolBarBreak();
-
-private:
- void allow(Qt::ToolBarArea area, bool allow);
- void place(Qt::ToolBarArea area, bool place);
-
- QSpinBox *spinbox;
- QAction *spinboxAction;
-
- QMenu *menu;
- QAction *orderAction;
- QAction *randomizeAction;
- QAction *addSpinBoxAction;
- QAction *removeSpinBoxAction;
-
- QAction *movableAction;
-
- QActionGroup *allowedAreasActions;
- QAction *allowLeftAction;
- QAction *allowRightAction;
- QAction *allowTopAction;
- QAction *allowBottomAction;
-
- QActionGroup *areaActions;
- QAction *leftAction;
- QAction *rightAction;
- QAction *topAction;
- QAction *bottomAction;
-};
-
-#endif // TOOLBAR_H
diff --git a/examples/widgets/mainwindows/mainwindows.pro b/examples/widgets/mainwindows/mainwindows.pro
index dcda89abaf..75f664f6ec 100644
--- a/examples/widgets/mainwindows/mainwindows.pro
+++ b/examples/widgets/mainwindows/mainwindows.pro
@@ -1,7 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS = application \
- dockwidgets \
- mainwindow \
- mdi \
- menus \
- sdi
+SUBDIRS = menus
diff --git a/examples/widgets/mainwindows/mdi/CMakeLists.txt b/examples/widgets/mainwindows/mdi/CMakeLists.txt
deleted file mode 100644
index 3f327a3733..0000000000
--- a/examples/widgets/mainwindows/mdi/CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(mdi LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/mainwindows/mdi")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(mdi
- main.cpp
- mainwindow.cpp mainwindow.h
- mdichild.cpp mdichild.h
-)
-
-set_target_properties(mdi PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(mdi PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(mdi_resource_files
- "images/copy.png"
- "images/cut.png"
- "images/new.png"
- "images/open.png"
- "images/paste.png"
- "images/save.png"
-)
-
-qt_add_resources(mdi "mdi"
- PREFIX
- "/"
- FILES
- ${mdi_resource_files}
-)
-
-install(TARGETS mdi
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/mainwindows/mdi/images/copy.png b/examples/widgets/mainwindows/mdi/images/copy.png
deleted file mode 100644
index 2aeb28288f..0000000000
--- a/examples/widgets/mainwindows/mdi/images/copy.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mdi/images/cut.png b/examples/widgets/mainwindows/mdi/images/cut.png
deleted file mode 100644
index 54638e9386..0000000000
--- a/examples/widgets/mainwindows/mdi/images/cut.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mdi/images/new.png b/examples/widgets/mainwindows/mdi/images/new.png
deleted file mode 100644
index 12131b0100..0000000000
--- a/examples/widgets/mainwindows/mdi/images/new.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mdi/images/open.png b/examples/widgets/mainwindows/mdi/images/open.png
deleted file mode 100644
index 45fa2883a7..0000000000
--- a/examples/widgets/mainwindows/mdi/images/open.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mdi/images/paste.png b/examples/widgets/mainwindows/mdi/images/paste.png
deleted file mode 100644
index c14425cad1..0000000000
--- a/examples/widgets/mainwindows/mdi/images/paste.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mdi/images/save.png b/examples/widgets/mainwindows/mdi/images/save.png
deleted file mode 100644
index e65a29d5f1..0000000000
--- a/examples/widgets/mainwindows/mdi/images/save.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/mdi/main.cpp b/examples/widgets/mainwindows/mdi/main.cpp
deleted file mode 100644
index 09f3082201..0000000000
--- a/examples/widgets/mainwindows/mdi/main.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(mdi);
-
- QApplication app(argc, argv);
- QCoreApplication::setApplicationName("MDI Example");
- QCoreApplication::setOrganizationName("QtProject");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription("Qt MDI Example");
- parser.addHelpOption();
- parser.addVersionOption();
- parser.addPositionalArgument("file", "The file to open.");
- parser.process(app);
-
- MainWindow mainWin;
- const QStringList posArgs = parser.positionalArguments();
- for (const QString &fileName : posArgs)
- mainWin.openFile(fileName);
- mainWin.show();
- return app.exec();
-}
diff --git a/examples/widgets/mainwindows/mdi/mainwindow.cpp b/examples/widgets/mainwindows/mdi/mainwindow.cpp
deleted file mode 100644
index 250ee786fb..0000000000
--- a/examples/widgets/mainwindows/mdi/mainwindow.cpp
+++ /dev/null
@@ -1,461 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-#include "mainwindow.h"
-#include "mdichild.h"
-
-MainWindow::MainWindow()
- : mdiArea(new QMdiArea)
-{
- mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
- mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
- setCentralWidget(mdiArea);
- connect(mdiArea, &QMdiArea::subWindowActivated,
- this, &MainWindow::updateMenus);
-
- createActions();
- createStatusBar();
- updateMenus();
-
- readSettings();
-
- setWindowTitle(tr("MDI"));
- setUnifiedTitleAndToolBarOnMac(true);
-}
-
-void MainWindow::closeEvent(QCloseEvent *event)
-{
- mdiArea->closeAllSubWindows();
- if (mdiArea->currentSubWindow()) {
- event->ignore();
- } else {
- writeSettings();
- event->accept();
- }
-}
-
-void MainWindow::newFile()
-{
- MdiChild *child = createMdiChild();
- child->newFile();
- child->show();
-}
-
-void MainWindow::open()
-{
- const QString fileName = QFileDialog::getOpenFileName(this);
- if (!fileName.isEmpty())
- openFile(fileName);
-}
-
-bool MainWindow::openFile(const QString &fileName)
-{
- if (QMdiSubWindow *existing = findMdiChild(fileName)) {
- mdiArea->setActiveSubWindow(existing);
- return true;
- }
- const bool succeeded = loadFile(fileName);
- if (succeeded)
- statusBar()->showMessage(tr("File loaded"), 2000);
- return succeeded;
-}
-
-bool MainWindow::loadFile(const QString &fileName)
-{
- MdiChild *child = createMdiChild();
- const bool succeeded = child->loadFile(fileName);
- if (succeeded)
- child->show();
- else
- child->close();
- MainWindow::prependToRecentFiles(fileName);
- return succeeded;
-}
-
-static inline QString recentFilesKey() { return QStringLiteral("recentFileList"); }
-static inline QString fileKey() { return QStringLiteral("file"); }
-
-static QStringList readRecentFiles(QSettings &settings)
-{
- QStringList result;
- const int count = settings.beginReadArray(recentFilesKey());
- for (int i = 0; i < count; ++i) {
- settings.setArrayIndex(i);
- result.append(settings.value(fileKey()).toString());
- }
- settings.endArray();
- return result;
-}
-
-static void writeRecentFiles(const QStringList &files, QSettings &settings)
-{
- const int count = files.size();
- settings.beginWriteArray(recentFilesKey());
- for (int i = 0; i < count; ++i) {
- settings.setArrayIndex(i);
- settings.setValue(fileKey(), files.at(i));
- }
- settings.endArray();
-}
-
-bool MainWindow::hasRecentFiles()
-{
- QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
- const int count = settings.beginReadArray(recentFilesKey());
- settings.endArray();
- return count > 0;
-}
-
-void MainWindow::prependToRecentFiles(const QString &fileName)
-{
- QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
-
- const QStringList oldRecentFiles = readRecentFiles(settings);
- QStringList recentFiles = oldRecentFiles;
- recentFiles.removeAll(fileName);
- recentFiles.prepend(fileName);
- if (oldRecentFiles != recentFiles)
- writeRecentFiles(recentFiles, settings);
-
- setRecentFilesVisible(!recentFiles.isEmpty());
-}
-
-void MainWindow::setRecentFilesVisible(bool visible)
-{
- recentFileSubMenuAct->setVisible(visible);
- recentFileSeparator->setVisible(visible);
-}
-
-void MainWindow::updateRecentFileActions()
-{
- QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
-
- const QStringList recentFiles = readRecentFiles(settings);
- const int count = qMin(int(MaxRecentFiles), recentFiles.size());
- int i = 0;
- for ( ; i < count; ++i) {
- const QString fileName = QFileInfo(recentFiles.at(i)).fileName();
- recentFileActs[i]->setText(tr("&%1 %2").arg(i + 1).arg(fileName));
- recentFileActs[i]->setData(recentFiles.at(i));
- recentFileActs[i]->setVisible(true);
- }
- for ( ; i < MaxRecentFiles; ++i)
- recentFileActs[i]->setVisible(false);
-}
-
-void MainWindow::openRecentFile()
-{
- if (const QAction *action = qobject_cast<const QAction *>(sender()))
- openFile(action->data().toString());
-}
-
-void MainWindow::save()
-{
- if (activeMdiChild() && activeMdiChild()->save())
- statusBar()->showMessage(tr("File saved"), 2000);
-}
-
-void MainWindow::saveAs()
-{
- MdiChild *child = activeMdiChild();
- if (child && child->saveAs()) {
- statusBar()->showMessage(tr("File saved"), 2000);
- MainWindow::prependToRecentFiles(child->currentFile());
- }
-}
-
-#ifndef QT_NO_CLIPBOARD
-void MainWindow::cut()
-{
- if (activeMdiChild())
- activeMdiChild()->cut();
-}
-
-void MainWindow::copy()
-{
- if (activeMdiChild())
- activeMdiChild()->copy();
-}
-
-void MainWindow::paste()
-{
- if (activeMdiChild())
- activeMdiChild()->paste();
-}
-#endif
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About MDI"),
- tr("The <b>MDI</b> example demonstrates how to write multiple "
- "document interface applications using Qt."));
-}
-
-void MainWindow::updateMenus()
-{
- bool hasMdiChild = (activeMdiChild() != nullptr);
- saveAct->setEnabled(hasMdiChild);
- saveAsAct->setEnabled(hasMdiChild);
-#ifndef QT_NO_CLIPBOARD
- pasteAct->setEnabled(hasMdiChild);
-#endif
- closeAct->setEnabled(hasMdiChild);
- closeAllAct->setEnabled(hasMdiChild);
- tileAct->setEnabled(hasMdiChild);
- cascadeAct->setEnabled(hasMdiChild);
- nextAct->setEnabled(hasMdiChild);
- previousAct->setEnabled(hasMdiChild);
- windowMenuSeparatorAct->setVisible(hasMdiChild);
-
-#ifndef QT_NO_CLIPBOARD
- bool hasSelection = (activeMdiChild() &&
- activeMdiChild()->textCursor().hasSelection());
- cutAct->setEnabled(hasSelection);
- copyAct->setEnabled(hasSelection);
-#endif
-}
-
-void MainWindow::updateWindowMenu()
-{
- windowMenu->clear();
- windowMenu->addAction(closeAct);
- windowMenu->addAction(closeAllAct);
- windowMenu->addSeparator();
- windowMenu->addAction(tileAct);
- windowMenu->addAction(cascadeAct);
- windowMenu->addSeparator();
- windowMenu->addAction(nextAct);
- windowMenu->addAction(previousAct);
- windowMenu->addAction(windowMenuSeparatorAct);
-
- QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
- windowMenuSeparatorAct->setVisible(!windows.isEmpty());
-
- for (int i = 0; i < windows.size(); ++i) {
- QMdiSubWindow *mdiSubWindow = windows.at(i);
- MdiChild *child = qobject_cast<MdiChild *>(mdiSubWindow->widget());
-
- QString text;
- if (i < 9) {
- text = tr("&%1 %2").arg(i + 1)
- .arg(child->userFriendlyCurrentFile());
- } else {
- text = tr("%1 %2").arg(i + 1)
- .arg(child->userFriendlyCurrentFile());
- }
- QAction *action = windowMenu->addAction(text, mdiSubWindow, [this, mdiSubWindow]() {
- mdiArea->setActiveSubWindow(mdiSubWindow);
- });
- action->setCheckable(true);
- action ->setChecked(child == activeMdiChild());
- }
-}
-
-MdiChild *MainWindow::createMdiChild()
-{
- MdiChild *child = new MdiChild;
- mdiArea->addSubWindow(child);
-
-#ifndef QT_NO_CLIPBOARD
- connect(child, &QTextEdit::copyAvailable, cutAct, &QAction::setEnabled);
- connect(child, &QTextEdit::copyAvailable, copyAct, &QAction::setEnabled);
-#endif
-
- return child;
-}
-
-void MainWindow::createActions()
-{
- QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
- QToolBar *fileToolBar = addToolBar(tr("File"));
-
- const QIcon newIcon = QIcon::fromTheme("document-new", QIcon(":/images/new.png"));
- newAct = new QAction(newIcon, tr("&New"), this);
- newAct->setShortcuts(QKeySequence::New);
- newAct->setStatusTip(tr("Create a new file"));
- connect(newAct, &QAction::triggered, this, &MainWindow::newFile);
- fileMenu->addAction(newAct);
- fileToolBar->addAction(newAct);
-
- const QIcon openIcon = QIcon::fromTheme("document-open", QIcon(":/images/open.png"));
- QAction *openAct = new QAction(openIcon, tr("&Open..."), this);
- openAct->setShortcuts(QKeySequence::Open);
- openAct->setStatusTip(tr("Open an existing file"));
- connect(openAct, &QAction::triggered, this, &MainWindow::open);
- fileMenu->addAction(openAct);
- fileToolBar->addAction(openAct);
-
- const QIcon saveIcon = QIcon::fromTheme("document-save", QIcon(":/images/save.png"));
- saveAct = new QAction(saveIcon, tr("&Save"), this);
- saveAct->setShortcuts(QKeySequence::Save);
- saveAct->setStatusTip(tr("Save the document to disk"));
- connect(saveAct, &QAction::triggered, this, &MainWindow::save);
- fileToolBar->addAction(saveAct);
-
- const QIcon saveAsIcon = QIcon::fromTheme("document-save-as");
- saveAsAct = new QAction(saveAsIcon, tr("Save &As..."), this);
- saveAsAct->setShortcuts(QKeySequence::SaveAs);
- saveAsAct->setStatusTip(tr("Save the document under a new name"));
- connect(saveAsAct, &QAction::triggered, this, &MainWindow::saveAs);
- fileMenu->addAction(saveAsAct);
-
- fileMenu->addSeparator();
-
- QMenu *recentMenu = fileMenu->addMenu(tr("Recent..."));
- connect(recentMenu, &QMenu::aboutToShow, this, &MainWindow::updateRecentFileActions);
- recentFileSubMenuAct = recentMenu->menuAction();
-
- for (int i = 0; i < MaxRecentFiles; ++i) {
- recentFileActs[i] = recentMenu->addAction(QString(), this, &MainWindow::openRecentFile);
- recentFileActs[i]->setVisible(false);
- }
-
- recentFileSeparator = fileMenu->addSeparator();
-
- setRecentFilesVisible(MainWindow::hasRecentFiles());
-
- fileMenu->addAction(tr("Switch layout direction"), this, &MainWindow::switchLayoutDirection);
-
- fileMenu->addSeparator();
-
-//! [0]
- const QIcon exitIcon = QIcon::fromTheme("application-exit");
- QAction *exitAct = fileMenu->addAction(exitIcon, tr("E&xit"), qApp, &QApplication::quit);
- exitAct->setShortcuts(QKeySequence::Quit);
- exitAct->setStatusTip(tr("Exit the application"));
- fileMenu->addAction(exitAct);
-//! [0]
-
-#ifndef QT_NO_CLIPBOARD
- QMenu *editMenu = menuBar()->addMenu(tr("&Edit"));
- QToolBar *editToolBar = addToolBar(tr("Edit"));
-
- const QIcon cutIcon = QIcon::fromTheme("edit-cut", QIcon(":/images/cut.png"));
- cutAct = new QAction(cutIcon, tr("Cu&t"), this);
- cutAct->setShortcuts(QKeySequence::Cut);
- cutAct->setStatusTip(tr("Cut the current selection's contents to the "
- "clipboard"));
- connect(cutAct, &QAction::triggered, this, &MainWindow::cut);
- editMenu->addAction(cutAct);
- editToolBar->addAction(cutAct);
-
- const QIcon copyIcon = QIcon::fromTheme("edit-copy", QIcon(":/images/copy.png"));
- copyAct = new QAction(copyIcon, tr("&Copy"), this);
- copyAct->setShortcuts(QKeySequence::Copy);
- copyAct->setStatusTip(tr("Copy the current selection's contents to the "
- "clipboard"));
- connect(copyAct, &QAction::triggered, this, &MainWindow::copy);
- editMenu->addAction(copyAct);
- editToolBar->addAction(copyAct);
-
- const QIcon pasteIcon = QIcon::fromTheme("edit-paste", QIcon(":/images/paste.png"));
- pasteAct = new QAction(pasteIcon, tr("&Paste"), this);
- pasteAct->setShortcuts(QKeySequence::Paste);
- pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
- "selection"));
- connect(pasteAct, &QAction::triggered, this, &MainWindow::paste);
- editMenu->addAction(pasteAct);
- editToolBar->addAction(pasteAct);
-#endif
-
- windowMenu = menuBar()->addMenu(tr("&Window"));
- connect(windowMenu, &QMenu::aboutToShow, this, &MainWindow::updateWindowMenu);
-
- closeAct = new QAction(tr("Cl&ose"), this);
- closeAct->setStatusTip(tr("Close the active window"));
- connect(closeAct, &QAction::triggered,
- mdiArea, &QMdiArea::closeActiveSubWindow);
-
- closeAllAct = new QAction(tr("Close &All"), this);
- closeAllAct->setStatusTip(tr("Close all the windows"));
- connect(closeAllAct, &QAction::triggered, mdiArea, &QMdiArea::closeAllSubWindows);
-
- tileAct = new QAction(tr("&Tile"), this);
- tileAct->setStatusTip(tr("Tile the windows"));
- connect(tileAct, &QAction::triggered, mdiArea, &QMdiArea::tileSubWindows);
-
- cascadeAct = new QAction(tr("&Cascade"), this);
- cascadeAct->setStatusTip(tr("Cascade the windows"));
- connect(cascadeAct, &QAction::triggered, mdiArea, &QMdiArea::cascadeSubWindows);
-
- nextAct = new QAction(tr("Ne&xt"), this);
- nextAct->setShortcuts(QKeySequence::NextChild);
- nextAct->setStatusTip(tr("Move the focus to the next window"));
- connect(nextAct, &QAction::triggered, mdiArea, &QMdiArea::activateNextSubWindow);
-
- previousAct = new QAction(tr("Pre&vious"), this);
- previousAct->setShortcuts(QKeySequence::PreviousChild);
- previousAct->setStatusTip(tr("Move the focus to the previous "
- "window"));
- connect(previousAct, &QAction::triggered, mdiArea, &QMdiArea::activatePreviousSubWindow);
-
- windowMenuSeparatorAct = new QAction(this);
- windowMenuSeparatorAct->setSeparator(true);
-
- updateWindowMenu();
-
- menuBar()->addSeparator();
-
- QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
-
- QAction *aboutAct = helpMenu->addAction(tr("&About"), this, &MainWindow::about);
- aboutAct->setStatusTip(tr("Show the application's About box"));
-
- QAction *aboutQtAct = helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
- aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
-}
-
-void MainWindow::createStatusBar()
-{
- statusBar()->showMessage(tr("Ready"));
-}
-
-void MainWindow::readSettings()
-{
- QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
- const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
- if (geometry.isEmpty()) {
- const QRect availableGeometry = screen()->availableGeometry();
- resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
- move((availableGeometry.width() - width()) / 2,
- (availableGeometry.height() - height()) / 2);
- } else {
- restoreGeometry(geometry);
- }
-}
-
-void MainWindow::writeSettings()
-{
- QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
- settings.setValue("geometry", saveGeometry());
-}
-
-MdiChild *MainWindow::activeMdiChild() const
-{
- if (QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow())
- return qobject_cast<MdiChild *>(activeSubWindow->widget());
- return nullptr;
-}
-
-QMdiSubWindow *MainWindow::findMdiChild(const QString &fileName) const
-{
- QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath();
-
- const QList<QMdiSubWindow *> subWindows = mdiArea->subWindowList();
- for (QMdiSubWindow *window : subWindows) {
- MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget());
- if (mdiChild->currentFile() == canonicalFilePath)
- return window;
- }
- return nullptr;
-}
-
-void MainWindow::switchLayoutDirection()
-{
- if (layoutDirection() == Qt::LeftToRight)
- QGuiApplication::setLayoutDirection(Qt::RightToLeft);
- else
- QGuiApplication::setLayoutDirection(Qt::LeftToRight);
-}
diff --git a/examples/widgets/mainwindows/mdi/mainwindow.h b/examples/widgets/mainwindows/mdi/mainwindow.h
deleted file mode 100644
index 8fec975c6e..0000000000
--- a/examples/widgets/mainwindows/mdi/mainwindow.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-
-class MdiChild;
-QT_BEGIN_NAMESPACE
-class QAction;
-class QMenu;
-class QMdiArea;
-class QMdiSubWindow;
-QT_END_NAMESPACE
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
- bool openFile(const QString &fileName);
-
-protected:
- void closeEvent(QCloseEvent *event) override;
-
-private slots:
- void newFile();
- void open();
- void save();
- void saveAs();
- void updateRecentFileActions();
- void openRecentFile();
-#ifndef QT_NO_CLIPBOARD
- void cut();
- void copy();
- void paste();
-#endif
- void about();
- void updateMenus();
- void updateWindowMenu();
- MdiChild *createMdiChild();
- void switchLayoutDirection();
-
-private:
- enum { MaxRecentFiles = 5 };
-
- void createActions();
- void createStatusBar();
- void readSettings();
- void writeSettings();
- bool loadFile(const QString &fileName);
- static bool hasRecentFiles();
- void prependToRecentFiles(const QString &fileName);
- void setRecentFilesVisible(bool visible);
- MdiChild *activeMdiChild() const;
- QMdiSubWindow *findMdiChild(const QString &fileName) const;
-
- QMdiArea *mdiArea;
-
- QMenu *windowMenu;
- QAction *newAct;
- QAction *saveAct;
- QAction *saveAsAct;
- QAction *recentFileActs[MaxRecentFiles];
- QAction *recentFileSeparator;
- QAction *recentFileSubMenuAct;
-#ifndef QT_NO_CLIPBOARD
- QAction *cutAct;
- QAction *copyAct;
- QAction *pasteAct;
-#endif
- QAction *closeAct;
- QAction *closeAllAct;
- QAction *tileAct;
- QAction *cascadeAct;
- QAction *nextAct;
- QAction *previousAct;
- QAction *windowMenuSeparatorAct;
-};
-
-#endif
diff --git a/examples/widgets/mainwindows/mdi/mdi.pro b/examples/widgets/mainwindows/mdi/mdi.pro
deleted file mode 100644
index f2c236f7e2..0000000000
--- a/examples/widgets/mainwindows/mdi/mdi.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-QT += widgets
-requires(qtConfig(filedialog))
-
-HEADERS = mainwindow.h \
- mdichild.h
-SOURCES = main.cpp \
- mainwindow.cpp \
- mdichild.cpp
-RESOURCES = mdi.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/mainwindows/mdi
-INSTALLS += target
diff --git a/examples/widgets/mainwindows/mdi/mdi.qrc b/examples/widgets/mainwindows/mdi/mdi.qrc
deleted file mode 100644
index 0a776fab4d..0000000000
--- a/examples/widgets/mainwindows/mdi/mdi.qrc
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/copy.png</file>
- <file>images/cut.png</file>
- <file>images/new.png</file>
- <file>images/open.png</file>
- <file>images/paste.png</file>
- <file>images/save.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/mainwindows/mdi/mdichild.cpp b/examples/widgets/mainwindows/mdi/mdichild.cpp
deleted file mode 100644
index 8f96ec623d..0000000000
--- a/examples/widgets/mainwindows/mdi/mdichild.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-#include "mdichild.h"
-
-MdiChild::MdiChild()
-{
- setAttribute(Qt::WA_DeleteOnClose);
- isUntitled = true;
-}
-
-void MdiChild::newFile()
-{
- static int sequenceNumber = 1;
-
- isUntitled = true;
- curFile = tr("document%1.txt").arg(sequenceNumber++);
- setWindowTitle(curFile + "[*]");
-
- connect(document(), &QTextDocument::contentsChanged,
- this, &MdiChild::documentWasModified);
-}
-
-bool MdiChild::loadFile(const QString &fileName)
-{
- QFile file(fileName);
- if (!file.open(QFile::ReadOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("MDI"),
- tr("Cannot read file %1:\n%2.")
- .arg(fileName)
- .arg(file.errorString()));
- return false;
- }
-
- QTextStream in(&file);
- QGuiApplication::setOverrideCursor(Qt::WaitCursor);
- setPlainText(in.readAll());
- QGuiApplication::restoreOverrideCursor();
-
- setCurrentFile(fileName);
-
- connect(document(), &QTextDocument::contentsChanged,
- this, &MdiChild::documentWasModified);
-
- return true;
-}
-
-bool MdiChild::save()
-{
- if (isUntitled) {
- return saveAs();
- } else {
- return saveFile(curFile);
- }
-}
-
-bool MdiChild::saveAs()
-{
- QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
- curFile);
- if (fileName.isEmpty())
- return false;
-
- return saveFile(fileName);
-}
-
-bool MdiChild::saveFile(const QString &fileName)
-{
- QString errorMessage;
-
- QGuiApplication::setOverrideCursor(Qt::WaitCursor);
- QSaveFile file(fileName);
- if (file.open(QFile::WriteOnly | QFile::Text)) {
- QTextStream out(&file);
- out << toPlainText();
- if (!file.commit()) {
- errorMessage = tr("Cannot write file %1:\n%2.")
- .arg(QDir::toNativeSeparators(fileName), file.errorString());
- }
- } else {
- errorMessage = tr("Cannot open file %1 for writing:\n%2.")
- .arg(QDir::toNativeSeparators(fileName), file.errorString());
- }
- QGuiApplication::restoreOverrideCursor();
-
- if (!errorMessage.isEmpty()) {
- QMessageBox::warning(this, tr("MDI"), errorMessage);
- return false;
- }
-
- setCurrentFile(fileName);
- return true;
-}
-
-QString MdiChild::userFriendlyCurrentFile()
-{
- return strippedName(curFile);
-}
-
-void MdiChild::closeEvent(QCloseEvent *event)
-{
- if (maybeSave()) {
- event->accept();
- } else {
- event->ignore();
- }
-}
-
-void MdiChild::documentWasModified()
-{
- setWindowModified(document()->isModified());
-}
-
-bool MdiChild::maybeSave()
-{
- if (!document()->isModified())
- return true;
- const QMessageBox::StandardButton ret
- = QMessageBox::warning(this, tr("MDI"),
- tr("'%1' has been modified.\n"
- "Do you want to save your changes?")
- .arg(userFriendlyCurrentFile()),
- QMessageBox::Save | QMessageBox::Discard
- | QMessageBox::Cancel);
- switch (ret) {
- case QMessageBox::Save:
- return save();
- case QMessageBox::Cancel:
- return false;
- default:
- break;
- }
- return true;
-}
-
-void MdiChild::setCurrentFile(const QString &fileName)
-{
- curFile = QFileInfo(fileName).canonicalFilePath();
- isUntitled = false;
- document()->setModified(false);
- setWindowModified(false);
- setWindowTitle(userFriendlyCurrentFile() + "[*]");
-}
-
-QString MdiChild::strippedName(const QString &fullFileName)
-{
- return QFileInfo(fullFileName).fileName();
-}
diff --git a/examples/widgets/mainwindows/mdi/mdichild.h b/examples/widgets/mainwindows/mdi/mdichild.h
deleted file mode 100644
index ba9c3d8f1c..0000000000
--- a/examples/widgets/mainwindows/mdi/mdichild.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MDICHILD_H
-#define MDICHILD_H
-
-#include <QTextEdit>
-
-class MdiChild : public QTextEdit
-{
- Q_OBJECT
-
-public:
- MdiChild();
-
- void newFile();
- bool loadFile(const QString &fileName);
- bool save();
- bool saveAs();
- bool saveFile(const QString &fileName);
- QString userFriendlyCurrentFile();
- QString currentFile() { return curFile; }
-
-protected:
- void closeEvent(QCloseEvent *event) override;
-
-private slots:
- void documentWasModified();
-
-private:
- bool maybeSave();
- void setCurrentFile(const QString &fileName);
- QString strippedName(const QString &fullFileName);
-
- QString curFile;
- bool isUntitled;
-};
-
-#endif
diff --git a/examples/widgets/mainwindows/menus/CMakeLists.txt b/examples/widgets/mainwindows/menus/CMakeLists.txt
index e2dc7a4df4..9b3735eff8 100644
--- a/examples/widgets/mainwindows/menus/CMakeLists.txt
+++ b/examples/widgets/mainwindows/menus/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(menus LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/mainwindows/menus")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(menus
main.cpp
mainwindow.cpp mainwindow.h
@@ -24,14 +18,21 @@ set_target_properties(menus PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(menus PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(menus PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS menus
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET menus
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/mainwindows/menus/mainwindow.cpp b/examples/widgets/mainwindows/menus/mainwindow.cpp
index 114eb7d27b..c003d9f568 100644
--- a/examples/widgets/mainwindows/menus/mainwindow.cpp
+++ b/examples/widgets/mainwindows/menus/mainwindow.cpp
@@ -160,62 +160,73 @@ void MainWindow::aboutQt()
void MainWindow::createActions()
{
//! [5]
- newAct = new QAction(tr("&New"), this);
+ newAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::DocumentNew),
+ tr("&New"), this);
newAct->setShortcuts(QKeySequence::New);
newAct->setStatusTip(tr("Create a new file"));
connect(newAct, &QAction::triggered, this, &MainWindow::newFile);
//! [4]
- openAct = new QAction(tr("&Open..."), this);
+ openAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::DocumentOpen),
+ tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open an existing file"));
connect(openAct, &QAction::triggered, this, &MainWindow::open);
//! [5]
- saveAct = new QAction(tr("&Save"), this);
+ saveAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::DocumentSave),
+ tr("&Save"), this);
saveAct->setShortcuts(QKeySequence::Save);
saveAct->setStatusTip(tr("Save the document to disk"));
connect(saveAct, &QAction::triggered, this, &MainWindow::save);
- printAct = new QAction(tr("&Print..."), this);
+ printAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::DocumentPrint),
+ tr("&Print..."), this);
printAct->setShortcuts(QKeySequence::Print);
printAct->setStatusTip(tr("Print the document"));
connect(printAct, &QAction::triggered, this, &MainWindow::print);
- exitAct = new QAction(tr("E&xit"), this);
+ exitAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::ApplicationExit),
+ tr("E&xit"), this);
exitAct->setShortcuts(QKeySequence::Quit);
exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, &QAction::triggered, this, &QWidget::close);
- undoAct = new QAction(tr("&Undo"), this);
+ undoAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::EditUndo),
+ tr("&Undo"), this);
undoAct->setShortcuts(QKeySequence::Undo);
undoAct->setStatusTip(tr("Undo the last operation"));
connect(undoAct, &QAction::triggered, this, &MainWindow::undo);
- redoAct = new QAction(tr("&Redo"), this);
+ redoAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::EditRedo),
+ tr("&Redo"), this);
redoAct->setShortcuts(QKeySequence::Redo);
redoAct->setStatusTip(tr("Redo the last operation"));
connect(redoAct, &QAction::triggered, this, &MainWindow::redo);
- cutAct = new QAction(tr("Cu&t"), this);
+ cutAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::EditCut),
+ tr("Cu&t"), this);
cutAct->setShortcuts(QKeySequence::Cut);
cutAct->setStatusTip(tr("Cut the current selection's contents to the "
"clipboard"));
connect(cutAct, &QAction::triggered, this, &MainWindow::cut);
- copyAct = new QAction(tr("&Copy"), this);
+ copyAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::EditCopy),
+ tr("&Copy"), this);
copyAct->setShortcuts(QKeySequence::Copy);
copyAct->setStatusTip(tr("Copy the current selection's contents to the "
"clipboard"));
connect(copyAct, &QAction::triggered, this, &MainWindow::copy);
- pasteAct = new QAction(tr("&Paste"), this);
+ pasteAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::EditPaste),
+ tr("&Paste"), this);
pasteAct->setShortcuts(QKeySequence::Paste);
pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
"selection"));
connect(pasteAct, &QAction::triggered, this, &MainWindow::paste);
- boldAct = new QAction(tr("&Bold"), this);
+ boldAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::FormatTextBold),
+ tr("&Bold"), this);
boldAct->setCheckable(true);
boldAct->setShortcut(QKeySequence::Bold);
boldAct->setStatusTip(tr("Make the text bold"));
@@ -225,7 +236,8 @@ void MainWindow::createActions()
boldFont.setBold(true);
boldAct->setFont(boldFont);
- italicAct = new QAction(tr("&Italic"), this);
+ italicAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::FormatTextItalic),
+ tr("&Italic"), this);
italicAct->setCheckable(true);
italicAct->setShortcut(QKeySequence::Italic);
italicAct->setStatusTip(tr("Make the text italic"));
@@ -245,7 +257,8 @@ void MainWindow::createActions()
connect(setParagraphSpacingAct, &QAction::triggered,
this, &MainWindow::setParagraphSpacing);
- aboutAct = new QAction(tr("&About"), this);
+ aboutAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::HelpAbout),
+ tr("&About"), this);
aboutAct->setStatusTip(tr("Show the application's About box"));
connect(aboutAct, &QAction::triggered, this, &MainWindow::about);
@@ -254,25 +267,29 @@ void MainWindow::createActions()
connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt);
connect(aboutQtAct, &QAction::triggered, this, &MainWindow::aboutQt);
- leftAlignAct = new QAction(tr("&Left Align"), this);
+ leftAlignAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::FormatJustifyLeft),
+ tr("&Left Align"), this);
leftAlignAct->setCheckable(true);
leftAlignAct->setShortcut(tr("Ctrl+L"));
leftAlignAct->setStatusTip(tr("Left align the selected text"));
connect(leftAlignAct, &QAction::triggered, this, &MainWindow::leftAlign);
- rightAlignAct = new QAction(tr("&Right Align"), this);
+ rightAlignAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::FormatJustifyRight),
+ tr("&Right Align"), this);
rightAlignAct->setCheckable(true);
rightAlignAct->setShortcut(tr("Ctrl+R"));
rightAlignAct->setStatusTip(tr("Right align the selected text"));
connect(rightAlignAct, &QAction::triggered, this, &MainWindow::rightAlign);
- justifyAct = new QAction(tr("&Justify"), this);
+ justifyAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::FormatJustifyFill),
+ tr("&Justify"), this);
justifyAct->setCheckable(true);
justifyAct->setShortcut(tr("Ctrl+J"));
justifyAct->setStatusTip(tr("Justify the selected text"));
connect(justifyAct, &QAction::triggered, this, &MainWindow::justify);
- centerAct = new QAction(tr("&Center"), this);
+ centerAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::FormatJustifyCenter),
+ tr("&Center"), this);
centerAct->setCheckable(true);
centerAct->setShortcut(tr("Ctrl+E"));
centerAct->setStatusTip(tr("Center the selected text"));
diff --git a/examples/widgets/mainwindows/sdi/CMakeLists.txt b/examples/widgets/mainwindows/sdi/CMakeLists.txt
deleted file mode 100644
index d2205f454a..0000000000
--- a/examples/widgets/mainwindows/sdi/CMakeLists.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(sdi LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/mainwindows/sdi")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(sdi
- main.cpp
- mainwindow.cpp mainwindow.h
-)
-
-set_target_properties(sdi PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(sdi PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(sdi_resource_files
- "images/copy.png"
- "images/cut.png"
- "images/new.png"
- "images/open.png"
- "images/paste.png"
- "images/save.png"
-)
-
-qt_add_resources(sdi "sdi"
- PREFIX
- "/"
- FILES
- ${sdi_resource_files}
-)
-
-install(TARGETS sdi
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/mainwindows/sdi/images/copy.png b/examples/widgets/mainwindows/sdi/images/copy.png
deleted file mode 100644
index 2aeb28288f..0000000000
--- a/examples/widgets/mainwindows/sdi/images/copy.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/sdi/images/cut.png b/examples/widgets/mainwindows/sdi/images/cut.png
deleted file mode 100644
index 54638e9386..0000000000
--- a/examples/widgets/mainwindows/sdi/images/cut.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/sdi/images/new.png b/examples/widgets/mainwindows/sdi/images/new.png
deleted file mode 100644
index 12131b0100..0000000000
--- a/examples/widgets/mainwindows/sdi/images/new.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/sdi/images/open.png b/examples/widgets/mainwindows/sdi/images/open.png
deleted file mode 100644
index 45fa2883a7..0000000000
--- a/examples/widgets/mainwindows/sdi/images/open.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/sdi/images/paste.png b/examples/widgets/mainwindows/sdi/images/paste.png
deleted file mode 100644
index c14425cad1..0000000000
--- a/examples/widgets/mainwindows/sdi/images/paste.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/sdi/images/save.png b/examples/widgets/mainwindows/sdi/images/save.png
deleted file mode 100644
index e65a29d5f1..0000000000
--- a/examples/widgets/mainwindows/sdi/images/save.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/mainwindows/sdi/main.cpp b/examples/widgets/mainwindows/sdi/main.cpp
deleted file mode 100644
index 139bc45690..0000000000
--- a/examples/widgets/mainwindows/sdi/main.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-#include <QCommandLineParser>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(sdi);
- QApplication app(argc, argv);
- QCoreApplication::setApplicationName("SDI Example");
- QCoreApplication::setOrganizationName("QtProject");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription(QCoreApplication::applicationName());
- parser.addHelpOption();
- parser.addVersionOption();
- parser.addPositionalArgument("file", "The file(s) to open.");
- parser.process(app);
-
- MainWindow *mainWin = nullptr;
- const QStringList posArgs = parser.positionalArguments();
- for (const QString &file : posArgs) {
- MainWindow *newWin = new MainWindow(file);
- newWin->tile(mainWin);
- newWin->show();
- mainWin = newWin;
- }
-
- if (!mainWin)
- mainWin = new MainWindow;
- mainWin->show();
-
- return app.exec();
-}
diff --git a/examples/widgets/mainwindows/sdi/mainwindow.cpp b/examples/widgets/mainwindows/sdi/mainwindow.cpp
deleted file mode 100644
index 23800c98c0..0000000000
--- a/examples/widgets/mainwindows/sdi/mainwindow.cpp
+++ /dev/null
@@ -1,445 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-#include "mainwindow.h"
-
-MainWindow::MainWindow()
-{
- init();
- setCurrentFile(QString());
-}
-
-MainWindow::MainWindow(const QString &fileName)
-{
- init();
- loadFile(fileName);
-}
-
-void MainWindow::closeEvent(QCloseEvent *event)
-{
- if (maybeSave()) {
- writeSettings();
- event->accept();
- } else {
- event->ignore();
- }
-}
-
-void MainWindow::newFile()
-{
- MainWindow *other = new MainWindow;
- other->tile(this);
- other->show();
-}
-
-void MainWindow::open()
-{
- const QString fileName = QFileDialog::getOpenFileName(this);
- if (!fileName.isEmpty())
- openFile(fileName);
-}
-
-void MainWindow::openFile(const QString &fileName)
-{
- MainWindow *existing = findMainWindow(fileName);
- if (existing) {
- existing->show();
- existing->raise();
- existing->activateWindow();
- return;
- }
-
- if (isUntitled && textEdit->document()->isEmpty() && !isWindowModified()) {
- loadFile(fileName);
- return;
- }
-
- MainWindow *other = new MainWindow(fileName);
- if (other->isUntitled) {
- delete other;
- return;
- }
- other->tile(this);
- other->show();
-}
-
-bool MainWindow::save()
-{
- return isUntitled ? saveAs() : saveFile(curFile);
-}
-
-bool MainWindow::saveAs()
-{
- QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
- curFile);
- if (fileName.isEmpty())
- return false;
-
- return saveFile(fileName);
-}
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About SDI"),
- tr("The <b>SDI</b> example demonstrates how to write single "
- "document interface applications using Qt."));
-}
-
-void MainWindow::documentWasModified()
-{
- setWindowModified(true);
-}
-
-void MainWindow::init()
-{
- setAttribute(Qt::WA_DeleteOnClose);
-
- isUntitled = true;
-
- textEdit = new QTextEdit;
- setCentralWidget(textEdit);
-
- createActions();
- createStatusBar();
-
- readSettings();
-
- connect(textEdit->document(), &QTextDocument::contentsChanged,
- this, &MainWindow::documentWasModified);
-
- setUnifiedTitleAndToolBarOnMac(true);
-}
-
-void MainWindow::tile(const QMainWindow *previous)
-{
- if (!previous)
- return;
- int topFrameWidth = previous->geometry().top() - previous->pos().y();
- if (!topFrameWidth)
- topFrameWidth = 40;
- const QPoint pos = previous->pos() + 2 * QPoint(topFrameWidth, topFrameWidth);
- if (screen()->availableGeometry().contains(rect().bottomRight() + pos))
- move(pos);
-}
-
-//! [implicit tr context]
-void MainWindow::createActions()
-{
- QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
-//! [implicit tr context]
- QToolBar *fileToolBar = addToolBar(tr("File"));
-
- const QIcon newIcon = QIcon::fromTheme("document-new", QIcon(":/images/new.png"));
- QAction *newAct = new QAction(newIcon, tr("&New"), this);
- newAct->setShortcuts(QKeySequence::New);
- newAct->setStatusTip(tr("Create a new file"));
- connect(newAct, &QAction::triggered, this, &MainWindow::newFile);
- fileMenu->addAction(newAct);
- fileToolBar->addAction(newAct);
-
- const QIcon openIcon = QIcon::fromTheme("document-open", QIcon(":/images/open.png"));
- QAction *openAct = new QAction(openIcon, tr("&Open..."), this);
- openAct->setShortcuts(QKeySequence::Open);
- openAct->setStatusTip(tr("Open an existing file"));
- connect(openAct, &QAction::triggered, this, &MainWindow::open);
- fileMenu->addAction(openAct);
- fileToolBar->addAction(openAct);
-
- const QIcon saveIcon = QIcon::fromTheme("document-save", QIcon(":/images/save.png"));
- QAction *saveAct = new QAction(saveIcon, tr("&Save"), this);
- saveAct->setShortcuts(QKeySequence::Save);
- saveAct->setStatusTip(tr("Save the document to disk"));
- connect(saveAct, &QAction::triggered, this, &MainWindow::save);
- fileMenu->addAction(saveAct);
- fileToolBar->addAction(saveAct);
-
- const QIcon saveAsIcon = QIcon::fromTheme("document-save-as");
- QAction *saveAsAct = fileMenu->addAction(saveAsIcon, tr("Save &As..."), this, &MainWindow::saveAs);
- saveAsAct->setShortcuts(QKeySequence::SaveAs);
- saveAsAct->setStatusTip(tr("Save the document under a new name"));
-
- fileMenu->addSeparator();
-
- QMenu *recentMenu = fileMenu->addMenu(tr("Recent..."));
- connect(recentMenu, &QMenu::aboutToShow, this, &MainWindow::updateRecentFileActions);
- recentFileSubMenuAct = recentMenu->menuAction();
-
- for (int i = 0; i < MaxRecentFiles; ++i) {
- recentFileActs[i] = recentMenu->addAction(QString(), this, &MainWindow::openRecentFile);
- recentFileActs[i]->setVisible(false);
- }
-
- recentFileSeparator = fileMenu->addSeparator();
-
- setRecentFilesVisible(MainWindow::hasRecentFiles());
-
- QAction *closeAct = fileMenu->addAction(tr("&Close"), this, &QWidget::close);
- closeAct->setShortcut(tr("Ctrl+W"));
- closeAct->setStatusTip(tr("Close this window"));
-
- const QIcon exitIcon = QIcon::fromTheme("application-exit");
- QAction *exitAct = fileMenu->addAction(exitIcon, tr("E&xit"), qApp, &QApplication::quit);
- exitAct->setShortcuts(QKeySequence::Quit);
- exitAct->setStatusTip(tr("Exit the application"));
-
- QMenu *editMenu = menuBar()->addMenu(tr("&Edit"));
- QToolBar *editToolBar = addToolBar(tr("Edit"));
-
-#ifndef QT_NO_CLIPBOARD
- const QIcon cutIcon = QIcon::fromTheme("edit-cut", QIcon(":/images/cut.png"));
- QAction *cutAct = new QAction(cutIcon, tr("Cu&t"), this);
- cutAct->setShortcuts(QKeySequence::Cut);
- cutAct->setStatusTip(tr("Cut the current selection's contents to the "
- "clipboard"));
- connect(cutAct, &QAction::triggered, textEdit, &QTextEdit::cut);
- editMenu->addAction(cutAct);
- editToolBar->addAction(cutAct);
-
- const QIcon copyIcon = QIcon::fromTheme("edit-copy", QIcon(":/images/copy.png"));
- QAction *copyAct = new QAction(copyIcon, tr("&Copy"), this);
- copyAct->setShortcuts(QKeySequence::Copy);
- copyAct->setStatusTip(tr("Copy the current selection's contents to the "
- "clipboard"));
- connect(copyAct, &QAction::triggered, textEdit, &QTextEdit::copy);
- editMenu->addAction(copyAct);
- editToolBar->addAction(copyAct);
-
- const QIcon pasteIcon = QIcon::fromTheme("edit-paste", QIcon(":/images/paste.png"));
- QAction *pasteAct = new QAction(pasteIcon, tr("&Paste"), this);
- pasteAct->setShortcuts(QKeySequence::Paste);
- pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
- "selection"));
- connect(pasteAct, &QAction::triggered, textEdit, &QTextEdit::paste);
- editMenu->addAction(pasteAct);
- editToolBar->addAction(pasteAct);
-
- menuBar()->addSeparator();
-#endif // !QT_NO_CLIPBOARD
-
- QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
- QAction *aboutAct = helpMenu->addAction(tr("&About"), this, &MainWindow::about);
- aboutAct->setStatusTip(tr("Show the application's About box"));
-
- QAction *aboutQtAct = helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
- aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
-
-#ifndef QT_NO_CLIPBOARD
- cutAct->setEnabled(false);
- copyAct->setEnabled(false);
- connect(textEdit, &QTextEdit::copyAvailable, cutAct, &QAction::setEnabled);
- connect(textEdit, &QTextEdit::copyAvailable, copyAct, &QAction::setEnabled);
-#endif // !QT_NO_CLIPBOARD
-}
-
-void MainWindow::createStatusBar()
-{
- statusBar()->showMessage(tr("Ready"));
-}
-
-void MainWindow::readSettings()
-{
- QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
- const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
- if (geometry.isEmpty()) {
- const QRect availableGeometry = screen()->availableGeometry();
- resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
- move((availableGeometry.width() - width()) / 2,
- (availableGeometry.height() - height()) / 2);
- } else {
- restoreGeometry(geometry);
- }
-}
-
-void MainWindow::writeSettings()
-{
- QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
- settings.setValue("geometry", saveGeometry());
-}
-
-bool MainWindow::maybeSave()
-{
- if (!textEdit->document()->isModified())
- return true;
- const QMessageBox::StandardButton ret
- = QMessageBox::warning(this, tr("SDI"),
- tr("The document has been modified.\n"
- "Do you want to save your changes?"),
- QMessageBox::Save | QMessageBox::Discard
- | QMessageBox::Cancel);
- switch (ret) {
- case QMessageBox::Save:
- return save();
- case QMessageBox::Cancel:
- return false;
- default:
- break;
- }
- return true;
-}
-
-void MainWindow::loadFile(const QString &fileName)
-{
-
- QFile file(fileName);
- if (!file.open(QFile::ReadOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("SDI"),
- tr("Cannot read file %1:\n%2.")
- .arg(QDir::toNativeSeparators(fileName), file.errorString()));
- return;
- }
-
- QTextStream in(&file);
- QGuiApplication::setOverrideCursor(Qt::WaitCursor);
- textEdit->setPlainText(in.readAll());
- QGuiApplication::restoreOverrideCursor();
-
- setCurrentFile(fileName);
- statusBar()->showMessage(tr("File loaded"), 2000);
-}
-
-void MainWindow::setRecentFilesVisible(bool visible)
-{
- recentFileSubMenuAct->setVisible(visible);
- recentFileSeparator->setVisible(visible);
-}
-
-static inline QString recentFilesKey() { return QStringLiteral("recentFileList"); }
-static inline QString fileKey() { return QStringLiteral("file"); }
-
-static QStringList readRecentFiles(QSettings &settings)
-{
- QStringList result;
- const int count = settings.beginReadArray(recentFilesKey());
- for (int i = 0; i < count; ++i) {
- settings.setArrayIndex(i);
- result.append(settings.value(fileKey()).toString());
- }
- settings.endArray();
- return result;
-}
-
-static void writeRecentFiles(const QStringList &files, QSettings &settings)
-{
- const int count = files.size();
- settings.beginWriteArray(recentFilesKey());
- for (int i = 0; i < count; ++i) {
- settings.setArrayIndex(i);
- settings.setValue(fileKey(), files.at(i));
- }
- settings.endArray();
-}
-
-bool MainWindow::hasRecentFiles()
-{
- QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
- const int count = settings.beginReadArray(recentFilesKey());
- settings.endArray();
- return count > 0;
-}
-
-void MainWindow::prependToRecentFiles(const QString &fileName)
-{
- QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
-
- const QStringList oldRecentFiles = readRecentFiles(settings);
- QStringList recentFiles = oldRecentFiles;
- recentFiles.removeAll(fileName);
- recentFiles.prepend(fileName);
- if (oldRecentFiles != recentFiles)
- writeRecentFiles(recentFiles, settings);
-
- setRecentFilesVisible(!recentFiles.isEmpty());
-}
-
-void MainWindow::updateRecentFileActions()
-{
- QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
-
- const QStringList recentFiles = readRecentFiles(settings);
- const int count = qMin(int(MaxRecentFiles), recentFiles.size());
- int i = 0;
- for ( ; i < count; ++i) {
- const QString fileName = MainWindow::strippedName(recentFiles.at(i));
- recentFileActs[i]->setText(tr("&%1 %2").arg(i + 1).arg(fileName));
- recentFileActs[i]->setData(recentFiles.at(i));
- recentFileActs[i]->setVisible(true);
- }
- for ( ; i < MaxRecentFiles; ++i)
- recentFileActs[i]->setVisible(false);
-}
-
-void MainWindow::openRecentFile()
-{
- if (const QAction *action = qobject_cast<const QAction *>(sender()))
- openFile(action->data().toString());
-}
-
-bool MainWindow::saveFile(const QString &fileName)
-{
- QString errorMessage;
-
- QGuiApplication::setOverrideCursor(Qt::WaitCursor);
- QSaveFile file(fileName);
- if (file.open(QFile::WriteOnly | QFile::Text)) {
- QTextStream out(&file);
- out << textEdit->toPlainText();
- if (!file.commit()) {
- errorMessage = tr("Cannot write file %1:\n%2.")
- .arg(QDir::toNativeSeparators(fileName), file.errorString());
- }
- } else {
- errorMessage = tr("Cannot open file %1 for writing:\n%2.")
- .arg(QDir::toNativeSeparators(fileName), file.errorString());
- }
- QGuiApplication::restoreOverrideCursor();
-
- if (!errorMessage.isEmpty()) {
- QMessageBox::warning(this, tr("SDI"), errorMessage);
- return false;
- }
-
- setCurrentFile(fileName);
- statusBar()->showMessage(tr("File saved"), 2000);
- return true;
-}
-
-void MainWindow::setCurrentFile(const QString &fileName)
-{
- static int sequenceNumber = 1;
-
- isUntitled = fileName.isEmpty();
- if (isUntitled) {
- curFile = tr("document%1.txt").arg(sequenceNumber++);
- } else {
- curFile = QFileInfo(fileName).canonicalFilePath();
- }
-
- textEdit->document()->setModified(false);
- setWindowModified(false);
-
- if (!isUntitled && windowFilePath() != curFile)
- MainWindow::prependToRecentFiles(curFile);
-
- setWindowFilePath(curFile);
-}
-
-QString MainWindow::strippedName(const QString &fullFileName)
-{
- return QFileInfo(fullFileName).fileName();
-}
-
-MainWindow *MainWindow::findMainWindow(const QString &fileName) const
-{
- QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath();
-
- const QList<QWidget *> topLevelWidgets = QApplication::topLevelWidgets();
- for (QWidget *widget : topLevelWidgets) {
- MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
- if (mainWin && mainWin->curFile == canonicalFilePath)
- return mainWin;
- }
-
- return nullptr;
-}
diff --git a/examples/widgets/mainwindows/sdi/mainwindow.h b/examples/widgets/mainwindows/sdi/mainwindow.h
deleted file mode 100644
index 44062cb4a2..0000000000
--- a/examples/widgets/mainwindows/sdi/mainwindow.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include <QList>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QMenu;
-class QTextEdit;
-QT_END_NAMESPACE
-
-//! [class definition with macro]
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-//! [class definition with macro]
- explicit MainWindow(const QString &fileName);
-
- void tile(const QMainWindow *previous);
-
-protected:
- void closeEvent(QCloseEvent *event) override;
-
-private slots:
- void newFile();
- void open();
- bool save();
- bool saveAs();
- void updateRecentFileActions();
- void openRecentFile();
- void about();
- void documentWasModified();
-
-private:
- enum { MaxRecentFiles = 5 };
-
- void init();
- void createActions();
- void createStatusBar();
- void readSettings();
- void writeSettings();
- bool maybeSave();
- void openFile(const QString &fileName);
- void loadFile(const QString &fileName);
- static bool hasRecentFiles();
- void prependToRecentFiles(const QString &fileName);
- void setRecentFilesVisible(bool visible);
- bool saveFile(const QString &fileName);
- void setCurrentFile(const QString &fileName);
- static QString strippedName(const QString &fullFileName);
- MainWindow *findMainWindow(const QString &fileName) const;
-
- QTextEdit *textEdit;
-
- QAction *recentFileActs[MaxRecentFiles];
- QAction *recentFileSeparator;
- QAction *recentFileSubMenuAct;
-
- QString curFile;
- bool isUntitled;
-};
-
-#endif
diff --git a/examples/widgets/mainwindows/sdi/sdi.pro b/examples/widgets/mainwindows/sdi/sdi.pro
deleted file mode 100644
index 30d07b0665..0000000000
--- a/examples/widgets/mainwindows/sdi/sdi.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += widgets
-requires(qtConfig(filedialog))
-
-HEADERS = mainwindow.h
-SOURCES = main.cpp \
- mainwindow.cpp
-RESOURCES = sdi.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/mainwindows/sdi
-INSTALLS += target
diff --git a/examples/widgets/mainwindows/sdi/sdi.qrc b/examples/widgets/mainwindows/sdi/sdi.qrc
deleted file mode 100644
index 0a776fab4d..0000000000
--- a/examples/widgets/mainwindows/sdi/sdi.qrc
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/copy.png</file>
- <file>images/cut.png</file>
- <file>images/new.png</file>
- <file>images/open.png</file>
- <file>images/paste.png</file>
- <file>images/save.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/painting/CMakeLists.txt b/examples/widgets/painting/CMakeLists.txt
index df0bfe9007..8a0b625e4d 100644
--- a/examples/widgets/painting/CMakeLists.txt
+++ b/examples/widgets/painting/CMakeLists.txt
@@ -1,14 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
qt_internal_add_example(basicdrawing)
-qt_internal_add_example(concentriccircles)
qt_internal_add_example(affine)
-# qt_internal_add_example(composition) # FIXME: Seems buggy wrt. usesOpenGL function
+qt_internal_add_example(composition)
qt_internal_add_example(deform)
qt_internal_add_example(gradients)
qt_internal_add_example(pathstroke)
qt_internal_add_example(imagecomposition)
qt_internal_add_example(painterpaths)
qt_internal_add_example(transformations)
-qt_internal_add_example(fontsampler)
diff --git a/examples/widgets/painting/affine/CMakeLists.txt b/examples/widgets/painting/affine/CMakeLists.txt
index c686da3ece..dd39086620 100644
--- a/examples/widgets/painting/affine/CMakeLists.txt
+++ b/examples/widgets/painting/affine/CMakeLists.txt
@@ -1,24 +1,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(affine LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/affine")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(affine
- # remove files from ../shared
- #../shared/arthurstyle.cpp ../shared/arthurstyle.h
- #../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- #../shared/hoverpoints.cpp ../shared/hoverpoints.h
main.cpp
xform.cpp xform.h
)
@@ -28,18 +18,14 @@ set_target_properties(affine PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_include_directories(affine PUBLIC
- ../shared
-)
-
if(NOT TARGET painting_shared::painting_shared)
include(../shared/use_lib.cmake)
endif()
-target_link_libraries(affine PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(affine PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
painting_shared::painting_shared
)
@@ -104,19 +90,15 @@ qt_add_resources(affine "affine"
${affine_resource_files}
)
-# remove files from ../shared
-#if(QT_FEATURE_opengl)
- #target_sources(affine PUBLIC
- #../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h
- #)
-
- #target_link_libraries(affine PUBLIC
- #Qt::OpenGL
- #)
-#endif()
-
install(TARGETS affine
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET affine
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/painting/affine/main.cpp b/examples/widgets/painting/affine/main.cpp
index a0ded9bfe3..1f9c2399c9 100644
--- a/examples/widgets/painting/affine/main.cpp
+++ b/examples/widgets/painting/affine/main.cpp
@@ -7,10 +7,6 @@
int main(int argc, char **argv)
{
- Q_INIT_RESOURCE(affine);
-#ifdef Q_OS_ANDROID
- qputenv("QT_SCALE_FACTOR", "2");
-#endif
QApplication app(argc, argv);
XFormWidget xformWidget(nullptr);
diff --git a/examples/widgets/painting/affine/xform.cpp b/examples/widgets/painting/affine/xform.cpp
index 87d653acd3..5754490eed 100644
--- a/examples/widgets/painting/affine/xform.cpp
+++ b/examples/widgets/painting/affine/xform.cpp
@@ -777,12 +777,6 @@ XFormWidget::XFormWidget(QWidget *parent)
QPushButton *showSourceButton = new QPushButton(mainGroup);
showSourceButton->setText(tr("Show Source"));
-#if QT_CONFIG(opengl)
- QPushButton *enableOpenGLButton = new QPushButton(mainGroup);
- enableOpenGLButton->setText(tr("Use OpenGL"));
- enableOpenGLButton->setCheckable(true);
- enableOpenGLButton->setChecked(view->usesOpenGL());
-#endif
QPushButton *whatsThisButton = new QPushButton(mainGroup);
whatsThisButton->setText(tr("What's This?"));
whatsThisButton->setCheckable(true);
@@ -812,9 +806,6 @@ XFormWidget::XFormWidget(QWidget *parent)
mainGroupLayout->addWidget(resetButton);
mainGroupLayout->addWidget(animateButton);
mainGroupLayout->addWidget(showSourceButton);
-#if QT_CONFIG(opengl)
- mainGroupLayout->addWidget(enableOpenGLButton);
-#endif
mainGroupLayout->addWidget(whatsThisButton);
mainGroup->setLayout(mainGroupLayout);
@@ -852,9 +843,6 @@ XFormWidget::XFormWidget(QWidget *parent)
connect(view, &XFormView::descriptionEnabledChanged, view->hoverPoints(), &HoverPoints::setDisabled);
connect(view, &XFormView::descriptionEnabledChanged, whatsThisButton, &QPushButton::setChecked);
connect(showSourceButton, &QPushButton::clicked, view, &XFormView::showSource);
-#if QT_CONFIG(opengl)
- connect(enableOpenGLButton, &QPushButton::clicked, view, &XFormView::enableOpenGL);
-#endif
view->loadSourceFile(":res/affine/xform.cpp");
view->loadDescription(":res/affine/xform.html");
diff --git a/examples/widgets/painting/basicdrawing/CMakeLists.txt b/examples/widgets/painting/basicdrawing/CMakeLists.txt
index 92f9d39cfc..c3fb855709 100644
--- a/examples/widgets/painting/basicdrawing/CMakeLists.txt
+++ b/examples/widgets/painting/basicdrawing/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(basicdrawing LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/basicdrawing")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(basicdrawing
main.cpp
renderarea.cpp renderarea.h
@@ -25,10 +19,10 @@ set_target_properties(basicdrawing PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(basicdrawing PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(basicdrawing PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -45,7 +39,14 @@ qt_add_resources(basicdrawing "basicdrawing"
)
install(TARGETS basicdrawing
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET basicdrawing
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/painting/basicdrawing/main.cpp b/examples/widgets/painting/basicdrawing/main.cpp
index 67a6d84562..1d8fd919b2 100644
--- a/examples/widgets/painting/basicdrawing/main.cpp
+++ b/examples/widgets/painting/basicdrawing/main.cpp
@@ -7,8 +7,6 @@
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(basicdrawing);
-
QApplication app(argc, argv);
Window window;
window.show();
diff --git a/examples/widgets/painting/composition/CMakeLists.txt b/examples/widgets/painting/composition/CMakeLists.txt
index 338f47addb..b88ee42e41 100644
--- a/examples/widgets/painting/composition/CMakeLists.txt
+++ b/examples/widgets/painting/composition/CMakeLists.txt
@@ -1,24 +1,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(composition LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/composition")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(composition
- # remove files from ../shared
- #../shared/arthurstyle.cpp ../shared/arthurstyle.h
- #../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- #../shared/hoverpoints.cpp ../shared/hoverpoints.h
composition.cpp composition.h
main.cpp
)
@@ -28,18 +18,14 @@ set_target_properties(composition PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_include_directories(composition PUBLIC
- ../shared
-)
-
if(NOT TARGET painting_shared::painting_shared)
include(../shared/use_lib.cmake)
endif()
-target_link_libraries(composition PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(composition PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
painting_shared::painting_shared
)
@@ -105,19 +91,15 @@ qt_add_resources(composition "composition"
${composition_resource_files}
)
-# remove files from ../shared
-#if(QT_FEATURE_opengl)
- #target_sources(affine PUBLIC
- #../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h
- #)
-
- #target_link_libraries(affine PUBLIC
- #Qt::OpenGL
- #)
-#endif()
-
install(TARGETS composition
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET composition
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/painting/composition/composition.cpp b/examples/widgets/painting/composition/composition.cpp
index 93ca5259aa..b4fb4fa3f7 100644
--- a/examples/widgets/painting/composition/composition.cpp
+++ b/examples/widgets/painting/composition/composition.cpp
@@ -10,11 +10,6 @@
#include <QMouseEvent>
#include <qmath.h>
-#if QT_CONFIG(opengl)
-#include <QOpenGLFunctions>
-#include <QOpenGLWindow>
-#endif
-
const int animationInterval = 15; // update every 16 ms = ~60FPS
CompositionWidget::CompositionWidget(QWidget *parent)
@@ -94,12 +89,6 @@ CompositionWidget::CompositionWidget(QWidget *parent)
QPushButton *showSourceButton = new QPushButton(mainGroup);
showSourceButton->setText(tr("Show Source"));
-#if QT_CONFIG(opengl)
- QPushButton *enableOpenGLButton = new QPushButton(mainGroup);
- enableOpenGLButton->setText(tr("Use OpenGL"));
- enableOpenGLButton->setCheckable(true);
- enableOpenGLButton->setChecked(view->usesOpenGL());
-#endif
QPushButton *whatsThisButton = new QPushButton(mainGroup);
whatsThisButton->setText(tr("What's This?"));
whatsThisButton->setCheckable(true);
@@ -121,9 +110,6 @@ CompositionWidget::CompositionWidget(QWidget *parent)
mainGroupLayout->addWidget(animateButton);
mainGroupLayout->addWidget(whatsThisButton);
mainGroupLayout->addWidget(showSourceButton);
-#if QT_CONFIG(opengl)
- mainGroupLayout->addWidget(enableOpenGLButton);
-#endif
QGridLayout *modesLayout = new QGridLayout(modesGroup);
modesLayout->addWidget(rbClear, 0, 0);
@@ -165,9 +151,6 @@ CompositionWidget::CompositionWidget(QWidget *parent)
connect(whatsThisButton, &QAbstractButton::clicked, view, &ArthurFrame::setDescriptionEnabled);
connect(view, &ArthurFrame::descriptionEnabledChanged, whatsThisButton, &QAbstractButton::setChecked);
connect(showSourceButton, &QAbstractButton::clicked, view, &ArthurFrame::showSource);
-#if QT_CONFIG(opengl)
- connect(enableOpenGLButton, &QAbstractButton::clicked, view, &ArthurFrame::enableOpenGL);
-#endif
connect(animateButton, &QAbstractButton::toggled, view, &CompositionRenderer::setAnimationEnabled);
circleColorSlider->setValue(270);
@@ -217,9 +200,6 @@ CompositionRenderer::CompositionRenderer(QWidget *parent)
m_circle_pos = QPoint(200, 100);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
-#if QT_CONFIG(opengl)
- m_pbuffer_size = 1024;
-#endif
}
CompositionRenderer::~CompositionRenderer()
@@ -312,86 +292,25 @@ void CompositionRenderer::drawSource(QPainter &p)
void CompositionRenderer::paint(QPainter *painter)
{
-#if QT_CONFIG(opengl)
- if (usesOpenGL() && glWindow()->isValid()) {
-
- if (!m_blitter.isCreated())
- m_blitter.create();
-
- int new_pbuf_size = m_pbuffer_size;
- while (size().width() > new_pbuf_size || size().height() > new_pbuf_size)
- new_pbuf_size *= 2;
-
- while (size().width() < new_pbuf_size/2 && size().height() < new_pbuf_size/2)
- new_pbuf_size /= 2;
-
- if (!m_fbo || new_pbuf_size != m_pbuffer_size) {
- m_fbo.reset(new QFboPaintDevice(QSize(new_pbuf_size, new_pbuf_size), false, false));
- m_pbuffer_size = new_pbuf_size;
- }
-
- if (size() != m_previous_size) {
- m_previous_size = size();
- QPainter p(m_fbo.get());
- p.setCompositionMode(QPainter::CompositionMode_Source);
- p.fillRect(QRect(QPoint(0, 0), size()), Qt::transparent);
- p.setCompositionMode(QPainter::CompositionMode_SourceOver);
- drawBase(p);
- p.end();
- m_base_tex = m_fbo->takeTexture();
- }
-
- painter->beginNativePainting();
- {
- QPainter p(m_fbo.get());
- p.beginNativePainting();
- m_blitter.bind();
- const QRect targetRect(QPoint(0, 0), m_fbo->size());
- const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, QRect(QPoint(0, 0), m_fbo->size()));
- m_blitter.blit(m_base_tex, target, QOpenGLTextureBlitter::OriginBottomLeft);
- m_blitter.release();
- p.endNativePainting();
- drawSource(p);
- p.end();
- m_compositing_tex = m_fbo->takeTexture();
- }
- painter->endNativePainting();
-
- painter->beginNativePainting();
- auto *funcs = QOpenGLContext::currentContext()->functions();
- funcs->glEnable(GL_BLEND);
- funcs->glBlendEquation(GL_FUNC_ADD);
- funcs->glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- m_blitter.bind();
- const QRect targetRect(QPoint(0, 0), m_fbo->size());
- const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, QRect(QPoint(0, 0), size()));
- m_blitter.blit(m_compositing_tex, target, QOpenGLTextureBlitter::OriginBottomLeft);
- m_blitter.release();
- painter->endNativePainting();
- } else
-#endif
- {
- // using a QImage
- if (m_buffer.size() != size()) {
- m_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied);
- m_base_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied);
+ if (m_buffer.size() != size()) {
+ m_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied);
+ m_base_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied);
- m_base_buffer.fill(0);
+ m_base_buffer.fill(0);
- QPainter p(&m_base_buffer);
+ QPainter p(&m_base_buffer);
- drawBase(p);
- }
-
- memcpy(m_buffer.bits(), m_base_buffer.bits(), m_buffer.sizeInBytes());
+ drawBase(p);
+ }
- {
- QPainter p(&m_buffer);
- drawSource(p);
- }
+ memcpy(m_buffer.bits(), m_base_buffer.bits(), m_buffer.sizeInBytes());
- painter->drawImage(0, 0, m_buffer);
+ {
+ QPainter p(&m_buffer);
+ drawSource(p);
}
+
+ painter->drawImage(0, 0, m_buffer);
}
void CompositionRenderer::mousePressEvent(QMouseEvent *e)
@@ -439,12 +358,6 @@ void CompositionRenderer::setCirclePos(const QPointF &pos)
const QRect oldRect = rectangle_around(m_circle_pos).toAlignedRect();
m_circle_pos = pos;
const QRect newRect = rectangle_around(m_circle_pos).toAlignedRect();
-#if QT_CONFIG(opengl)
- if (usesOpenGL()) {
- update();
- return;
- }
-#endif
update(oldRect | newRect);
}
diff --git a/examples/widgets/painting/composition/composition.h b/examples/widgets/painting/composition/composition.h
index b2fa2c5bb1..6a5206da08 100644
--- a/examples/widgets/painting/composition/composition.h
+++ b/examples/widgets/painting/composition/composition.h
@@ -6,11 +6,6 @@
#include "arthurwidgets.h"
-#if QT_CONFIG(opengl)
-#include "fbopaintdevice.h"
-#include <QOpenGLTextureBlitter>
-#endif
-
#include <QPainter>
#include <QEvent>
@@ -143,15 +138,6 @@ private:
ObjectType m_current_object;
bool m_animation_enabled;
int m_animationTimer;
-
-#if QT_CONFIG(opengl)
- std::unique_ptr<QFboPaintDevice> m_fbo;
- int m_pbuffer_size; // width==height==size of pbuffer
- uint m_base_tex;
- uint m_compositing_tex;
- QSize m_previous_size;
- QOpenGLTextureBlitter m_blitter;
-#endif
};
#endif // COMPOSITION_H
diff --git a/examples/widgets/painting/concentriccircles/CMakeLists.txt b/examples/widgets/painting/concentriccircles/CMakeLists.txt
deleted file mode 100644
index 74549cc9d7..0000000000
--- a/examples/widgets/painting/concentriccircles/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(concentriccircles LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/concentriccircles")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(concentriccircles
- circlewidget.cpp circlewidget.h
- main.cpp
- window.cpp window.h
-)
-
-set_target_properties(concentriccircles PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(concentriccircles PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS concentriccircles
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/painting/concentriccircles/circlewidget.cpp b/examples/widgets/painting/concentriccircles/circlewidget.cpp
deleted file mode 100644
index febaa5d709..0000000000
--- a/examples/widgets/painting/concentriccircles/circlewidget.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "circlewidget.h"
-
-#include <QPainter>
-
-#include <stdlib.h>
-
-//! [0]
-CircleWidget::CircleWidget(QWidget *parent)
- : QWidget(parent)
-{
- floatBased = false;
- antialiased = false;
- frameNo = 0;
-
- setBackgroundRole(QPalette::Base);
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
-}
-//! [0]
-
-//! [1]
-void CircleWidget::setFloatBased(bool floatBased)
-{
- this->floatBased = floatBased;
- update();
-}
-//! [1]
-
-//! [2]
-void CircleWidget::setAntialiased(bool antialiased)
-{
- this->antialiased = antialiased;
- update();
-}
-//! [2]
-
-//! [3]
-QSize CircleWidget::minimumSizeHint() const
-{
- return QSize(50, 50);
-}
-//! [3]
-
-//! [4]
-QSize CircleWidget::sizeHint() const
-{
- return QSize(180, 180);
-}
-//! [4]
-
-//! [5]
-void CircleWidget::nextAnimationFrame()
-{
- ++frameNo;
- update();
-}
-//! [5]
-
-//! [6]
-void CircleWidget::paintEvent(QPaintEvent *)
-{
- QPainter painter(this);
- painter.setRenderHint(QPainter::Antialiasing, antialiased);
- painter.translate(width() / 2, height() / 2);
-//! [6]
-
-//! [7]
- for (int diameter = 0; diameter < 256; diameter += 9) {
- int delta = abs((frameNo % 128) - diameter / 2);
- int alpha = 255 - (delta * delta) / 4 - diameter;
-//! [7] //! [8]
- if (alpha > 0) {
- painter.setPen(QPen(QColor(0, diameter / 2, 127, alpha), 3));
-
- if (floatBased)
- painter.drawEllipse(QRectF(-diameter / 2.0, -diameter / 2.0, diameter, diameter));
- else
- painter.drawEllipse(QRect(-diameter / 2, -diameter / 2, diameter, diameter));
- }
- }
-}
-//! [8]
diff --git a/examples/widgets/painting/concentriccircles/circlewidget.h b/examples/widgets/painting/concentriccircles/circlewidget.h
deleted file mode 100644
index 5632ee1d72..0000000000
--- a/examples/widgets/painting/concentriccircles/circlewidget.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef CIRCLEWIDGET_H
-#define CIRCLEWIDGET_H
-
-#include <QWidget>
-
-//! [0]
-class CircleWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- CircleWidget(QWidget *parent = nullptr);
-
- void setFloatBased(bool floatBased);
- void setAntialiased(bool antialiased);
-
- QSize minimumSizeHint() const override;
- QSize sizeHint() const override;
-
-public slots:
- void nextAnimationFrame();
-
-protected:
- void paintEvent(QPaintEvent *event) override;
-
-private:
- bool floatBased;
- bool antialiased;
- int frameNo;
-};
-//! [0]
-
-#endif // CIRCLEWIDGET_H
diff --git a/examples/widgets/painting/concentriccircles/concentriccircles.pro b/examples/widgets/painting/concentriccircles/concentriccircles.pro
deleted file mode 100644
index 844c01a9c2..0000000000
--- a/examples/widgets/painting/concentriccircles/concentriccircles.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += widgets
-
-HEADERS = circlewidget.h \
- window.h
-SOURCES = circlewidget.cpp \
- main.cpp \
- window.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/painting/concentriccircles
-INSTALLS += target
diff --git a/examples/widgets/painting/concentriccircles/main.cpp b/examples/widgets/painting/concentriccircles/main.cpp
deleted file mode 100644
index 1d8fd919b2..0000000000
--- a/examples/widgets/painting/concentriccircles/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "window.h"
-
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- Window window;
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/painting/concentriccircles/window.cpp b/examples/widgets/painting/concentriccircles/window.cpp
deleted file mode 100644
index 9f25c2fcde..0000000000
--- a/examples/widgets/painting/concentriccircles/window.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "circlewidget.h"
-#include "window.h"
-
-#include <QtWidgets>
-
-//! [0]
-Window::Window()
-{
- aliasedLabel = createLabel(tr("Aliased"));
- antialiasedLabel = createLabel(tr("Antialiased"));
- intLabel = createLabel(tr("Int"));
- floatLabel = createLabel(tr("Float"));
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(aliasedLabel, 0, 1);
- layout->addWidget(antialiasedLabel, 0, 2);
- layout->addWidget(intLabel, 1, 0);
- layout->addWidget(floatLabel, 2, 0);
-//! [0]
-
-//! [1]
- QTimer *timer = new QTimer(this);
-
- for (int i = 0; i < 2; ++i) {
- for (int j = 0; j < 2; ++j) {
- circleWidgets[i][j] = new CircleWidget;
- circleWidgets[i][j]->setAntialiased(j != 0);
- circleWidgets[i][j]->setFloatBased(i != 0);
-
- connect(timer, &QTimer::timeout,
- circleWidgets[i][j], &CircleWidget::nextAnimationFrame);
-
- layout->addWidget(circleWidgets[i][j], i + 1, j + 1);
- }
- }
-//! [1] //! [2]
- timer->start(100);
- setLayout(layout);
-
- setWindowTitle(tr("Concentric Circles"));
-}
-//! [2]
-
-//! [3]
-QLabel *Window::createLabel(const QString &text)
-{
- QLabel *label = new QLabel(text);
- label->setAlignment(Qt::AlignCenter);
- label->setMargin(2);
- label->setFrameStyle(QFrame::Box | QFrame::Sunken);
- return label;
-}
-//! [3]
diff --git a/examples/widgets/painting/concentriccircles/window.h b/examples/widgets/painting/concentriccircles/window.h
deleted file mode 100644
index a111ffbe58..0000000000
--- a/examples/widgets/painting/concentriccircles/window.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-QT_END_NAMESPACE
-class CircleWidget;
-
-//! [0]
-class Window : public QWidget
-{
- Q_OBJECT
-
-public:
- Window();
-
-private:
- QLabel *createLabel(const QString &text);
-
- QLabel *aliasedLabel;
- QLabel *antialiasedLabel;
- QLabel *intLabel;
- QLabel *floatLabel;
- CircleWidget *circleWidgets[2][2];
-};
-//! [0]
-
-#endif // WINDOW_H
diff --git a/examples/widgets/painting/deform/CMakeLists.txt b/examples/widgets/painting/deform/CMakeLists.txt
index 9a37035f8e..1038df03ad 100644
--- a/examples/widgets/painting/deform/CMakeLists.txt
+++ b/examples/widgets/painting/deform/CMakeLists.txt
@@ -1,24 +1,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(deform LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/deform")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(deform
- # remove files from ../shared
- #../shared/arthurstyle.cpp ../shared/arthurstyle.h
- #../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- #../shared/hoverpoints.cpp ../shared/hoverpoints.h
main.cpp
pathdeform.cpp pathdeform.h
)
@@ -28,18 +18,14 @@ set_target_properties(deform PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_include_directories(deform PUBLIC
- ../shared
-)
-
if(NOT TARGET painting_shared::painting_shared)
include(../shared/use_lib.cmake)
endif()
-target_link_libraries(deform PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(deform PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
painting_shared::painting_shared
)
@@ -103,19 +89,15 @@ qt_add_resources(deform "deform"
${deform_resource_files}
)
-# remove files from ../shared
-#if(QT_FEATURE_opengl)
- #target_sources(affine PUBLIC
- #../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h
- #)
-
- #target_link_libraries(affine PUBLIC
- #Qt::OpenGL
- #)
-#endif()
-
install(TARGETS deform
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET deform
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/painting/deform/main.cpp b/examples/widgets/painting/deform/main.cpp
index b81adc09b4..5ac5b4cc3f 100644
--- a/examples/widgets/painting/deform/main.cpp
+++ b/examples/widgets/painting/deform/main.cpp
@@ -7,8 +7,6 @@
int main(int argc, char **argv)
{
- Q_INIT_RESOURCE(deform);
-
QApplication app(argc, argv);
bool smallScreen = QApplication::arguments().contains("-small-screen");
diff --git a/examples/widgets/painting/deform/pathdeform.cpp b/examples/widgets/painting/deform/pathdeform.cpp
index fead0e3c13..f2c67c1587 100644
--- a/examples/widgets/painting/deform/pathdeform.cpp
+++ b/examples/widgets/painting/deform/pathdeform.cpp
@@ -61,13 +61,6 @@ void PathDeformControls::layoutForDesktop()
QPushButton *showSourceButton = new QPushButton(mainGroup);
showSourceButton->setText(tr("Show Source"));
-#if QT_CONFIG(opengl)
- QPushButton *enableOpenGLButton = new QPushButton(mainGroup);
- enableOpenGLButton->setText(tr("Use OpenGL"));
- enableOpenGLButton->setCheckable(true);
- enableOpenGLButton->setChecked(m_renderer->usesOpenGL());
-#endif
-
QPushButton *whatsThisButton = new QPushButton(mainGroup);
whatsThisButton->setText(tr("What's This?"));
whatsThisButton->setCheckable(true);
@@ -82,9 +75,6 @@ void PathDeformControls::layoutForDesktop()
mainGroupLayout->addWidget(textGroup);
mainGroupLayout->addWidget(animateButton);
mainGroupLayout->addStretch(1);
-#if QT_CONFIG(opengl)
- mainGroupLayout->addWidget(enableOpenGLButton);
-#endif
mainGroupLayout->addWidget(showSourceButton);
mainGroupLayout->addWidget(whatsThisButton);
@@ -108,9 +98,6 @@ void PathDeformControls::layoutForDesktop()
connect(deformSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setIntensity);
connect(fontSizeSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setFontSize);
connect(animateButton, &QAbstractButton::clicked, m_renderer, &PathDeformRenderer::setAnimated);
-#if QT_CONFIG(opengl)
- connect(enableOpenGLButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::enableOpenGL);
-#endif
connect(textInput, &QLineEdit::textChanged, m_renderer, &PathDeformRenderer::setText);
connect(m_renderer, &ArthurFrame::descriptionEnabledChanged,
@@ -151,13 +138,6 @@ void PathDeformControls::layoutForSmallScreen()
QPushButton *animateButton = new QPushButton(tr("Animated"), mainGroup);
animateButton->setCheckable(true);
-#if QT_CONFIG(opengl)
- QPushButton *enableOpenGLButton = new QPushButton(mainGroup);
- enableOpenGLButton->setText(tr("Use OpenGL"));
- enableOpenGLButton->setCheckable(mainGroup);
- enableOpenGLButton->setChecked(m_renderer->usesOpenGL());
-#endif
-
QPushButton *quitButton = new QPushButton(tr("Quit"), mainGroup);
QPushButton *okButton = new QPushButton(tr("OK"), mainGroup);
@@ -171,9 +151,6 @@ void PathDeformControls::layoutForSmallScreen()
mainGroupLayout->addWidget(fontSizeLabel, 2, 0, Qt::AlignRight);
mainGroupLayout->addWidget(fontSizeSlider, 2, 1);
mainGroupLayout->addWidget(animateButton, 3,0, 1,2);
-#if QT_CONFIG(opengl)
- mainGroupLayout->addWidget(enableOpenGLButton, 4,0, 1,2);
-#endif
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(mainGroup);
@@ -187,10 +164,6 @@ void PathDeformControls::layoutForSmallScreen()
connect(deformSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setIntensity);
connect(fontSizeSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setFontSize);
connect(animateButton, &QAbstractButton::clicked, m_renderer, &PathDeformRenderer::setAnimated);
-#if QT_CONFIG(opengl)
- connect(enableOpenGLButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::enableOpenGL);
-#endif
-
animateButton->animateClick();
deformSlider->setValue(80);
@@ -380,7 +353,6 @@ void PathDeformRenderer::setAnimated(bool animated)
void PathDeformRenderer::timerEvent(QTimerEvent *e)
{
-
if (e->timerId() == m_repaintTimer.timerId()) {
if (QLineF(QPointF(0,0), m_direction).length() > 1)
@@ -414,22 +386,9 @@ void PathDeformRenderer::timerEvent(QTimerEvent *e)
m_pos.setY(height() - m_radius);
}
-#if QT_CONFIG(opengl)
- if (usesOpenGL()) {
- update();
- } else
-#endif
- {
- QRect rectAfter = circle_bounds(m_pos, m_radius, m_fontSize);
- update(rectAfter | rectBefore);
- }
+ QRect rectAfter = circle_bounds(m_pos, m_radius, m_fontSize);
+ update(rectAfter | rectBefore);
}
-// else if (e->timerId() == m_fpsTimer.timerId()) {
-// printf("fps: %d\n", m_fpsCounter);
-// emit frameRate(m_fpsCounter);
-// m_fpsCounter = 0;
-
-// }
}
void PathDeformRenderer::mousePressEvent(QMouseEvent *e)
@@ -478,15 +437,8 @@ void PathDeformRenderer::mouseMoveEvent(QMouseEvent *e)
m_direction = (m_direction + dir) / 2;
}
m_pos = e->position().toPoint() + m_offset;
-#if QT_CONFIG(opengl)
- if (usesOpenGL()) {
- update();
- } else
-#endif
- {
- QRect rectAfter = circle_bounds(m_pos, m_radius, m_fontSize);
- update(rectBefore | rectAfter);
- }
+ QRect rectAfter = circle_bounds(m_pos, m_radius, m_fontSize);
+ update(rectBefore | rectAfter);
}
}
@@ -570,27 +522,13 @@ void PathDeformRenderer::setRadius(int radius)
qreal max = qMax(m_radius, (qreal)radius);
m_radius = radius;
generateLensPixmap();
- if (!m_animated || m_radius < max) {
-#if QT_CONFIG(opengl)
- if (usesOpenGL()){
- update();
- return;
- }
-#endif
+ if (!m_animated || m_radius < max)
update(circle_bounds(m_pos, max, m_fontSize));
- }
}
void PathDeformRenderer::setIntensity(int intensity)
{
m_intensity = intensity;
- if (!m_animated) {
-#if QT_CONFIG(opengl)
- if (usesOpenGL()) {
- update();
- return;
- }
-#endif
+ if (!m_animated)
update(circle_bounds(m_pos, m_radius, m_fontSize));
- }
}
diff --git a/examples/widgets/painting/fontsampler/CMakeLists.txt b/examples/widgets/painting/fontsampler/CMakeLists.txt
deleted file mode 100644
index 5ed4176dd9..0000000000
--- a/examples/widgets/painting/fontsampler/CMakeLists.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(fontsampler LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/fontsampler")
-
-find_package(Qt6
- REQUIRED COMPONENTS Core Gui Widgets
- OPTIONAL_COMPONENTS PrintSupport
-)
-
-qt_add_executable(fontsampler
- main.cpp
- mainwindow.cpp mainwindow.h
- mainwindowbase.ui
-)
-
-set_target_properties(fontsampler PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(fontsampler PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-if(TARGET Qt::PrintSupport)
- target_link_libraries(fontsampler PUBLIC
- Qt::PrintSupport
- )
-endif()
-
-install(TARGETS fontsampler
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/painting/fontsampler/fontsampler.pro b/examples/widgets/painting/fontsampler/fontsampler.pro
deleted file mode 100644
index 5d3461f4b8..0000000000
--- a/examples/widgets/painting/fontsampler/fontsampler.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-QT += widgets
-requires(qtConfig(combobox))
-qtHaveModule(printsupport): QT += printsupport
-
-FORMS = mainwindowbase.ui
-HEADERS = mainwindow.h
-SOURCES = main.cpp \
- mainwindow.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/painting/fontsampler
-INSTALLS += target
diff --git a/examples/widgets/painting/fontsampler/main.cpp b/examples/widgets/painting/fontsampler/main.cpp
deleted file mode 100644
index 7d7cf3e573..0000000000
--- a/examples/widgets/painting/fontsampler/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- MainWindow window;
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/painting/fontsampler/mainwindow.cpp b/examples/widgets/painting/fontsampler/mainwindow.cpp
deleted file mode 100644
index 1b1b816395..0000000000
--- a/examples/widgets/painting/fontsampler/mainwindow.cpp
+++ /dev/null
@@ -1,314 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#if defined(QT_PRINTSUPPORT_LIB)
-#include <QtPrintSupport/qtprintsupportglobal.h>
-#if QT_CONFIG(printdialog)
-#include <QPrinter>
-#include <QPrintDialog>
-#if QT_CONFIG(printpreviewdialog)
-#include <QPrintPreviewDialog>
-#endif
-#endif
-#endif
-
-#include "mainwindow.h"
-
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
-{
- setupUi(this);
-
- sampleSizes << 32 << 24 << 16 << 14 << 12 << 8 << 4 << 2 << 1;
- markedCount = 0;
- setupFontTree();
-
- connect(quitAction, &QAction::triggered,
- qApp, &QApplication::quit);
- connect(fontTree, &QTreeWidget::currentItemChanged,
- this, &MainWindow::showFont);
- connect(fontTree, &QTreeWidget::itemChanged,
- this, &MainWindow::updateStyles);
-
- fontTree->topLevelItem(0)->setSelected(true);
- showFont(fontTree->topLevelItem(0));
-}
-
-void MainWindow::setupFontTree()
-{
- fontTree->setColumnCount(1);
- fontTree->setHeaderLabels({ tr("Font") });
-
- const QStringList fontFamilies = QFontDatabase::families();
- for (const QString &family : fontFamilies) {
- const QStringList styles = QFontDatabase::styles(family);
- if (styles.isEmpty())
- continue;
-
- QTreeWidgetItem *familyItem = new QTreeWidgetItem(fontTree);
- familyItem->setText(0, family);
- familyItem->setCheckState(0, Qt::Unchecked);
- familyItem->setFlags(familyItem->flags() | Qt::ItemIsAutoTristate);
-
- for (const QString &style : styles) {
- QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem);
- styleItem->setText(0, style);
- styleItem->setCheckState(0, Qt::Unchecked);
- styleItem->setData(0, Qt::UserRole, QVariant(QFontDatabase::weight(family, style)));
- styleItem->setData(0, Qt::UserRole + 1, QVariant(QFontDatabase::italic(family, style)));
- }
- }
-}
-
-void MainWindow::on_clearAction_triggered()
-{
- const QList<QTreeWidgetItem *> items = fontTree->selectedItems();
- for (QTreeWidgetItem *item : items)
- item->setSelected(false);
- fontTree->currentItem()->setSelected(true);
-}
-
-void MainWindow::on_markAction_triggered()
-{
- markUnmarkFonts(Qt::Checked);
-}
-
-void MainWindow::on_unmarkAction_triggered()
-{
- markUnmarkFonts(Qt::Unchecked);
-}
-
-void MainWindow::markUnmarkFonts(Qt::CheckState state)
-{
- const QList<QTreeWidgetItem *> items = fontTree->selectedItems();
- for (QTreeWidgetItem *item : items) {
- if (item->checkState(0) != state)
- item->setCheckState(0, state);
- }
-}
-
-void MainWindow::showFont(QTreeWidgetItem *item)
-{
- if (!item)
- return;
-
- QString family;
- QString style;
- int weight;
- bool italic;
-
- if (item->parent()) {
- family = item->parent()->text(0);
- style = item->text(0);
- weight = item->data(0, Qt::UserRole).toInt();
- italic = item->data(0, Qt::UserRole + 1).toBool();
- } else {
- family = item->text(0);
- style = item->child(0)->text(0);
- weight = item->child(0)->data(0, Qt::UserRole).toInt();
- italic = item->child(0)->data(0, Qt::UserRole + 1).toBool();
- }
-
- QString oldText = textEdit->toPlainText().trimmed();
- bool modified = textEdit->document()->isModified();
- textEdit->clear();
- QFont font(family, 32, weight, italic);
- font.setStyleName(style);
- textEdit->document()->setDefaultFont(font);
-
- QTextCursor cursor = textEdit->textCursor();
- QTextBlockFormat blockFormat;
- blockFormat.setAlignment(Qt::AlignCenter);
- cursor.insertBlock(blockFormat);
-
- if (modified)
- cursor.insertText(QString(oldText));
- else
- cursor.insertText(QString("%1 %2").arg(family).arg(style));
-
- textEdit->document()->setModified(modified);
-}
-
-void MainWindow::updateStyles(QTreeWidgetItem *item, int column)
-{
- if (!item || column != 0)
- return;
-
- Qt::CheckState state = item->checkState(0);
- QTreeWidgetItem *parent = item->parent();
-
- if (parent) {
- // Only count style items.
- if (state == Qt::Checked)
- ++markedCount;
- else
- --markedCount;
- }
-
- printAction->setEnabled(markedCount > 0);
- printPreviewAction->setEnabled(markedCount > 0);
-}
-
-QMap<QString, StyleItems> MainWindow::currentPageMap()
-{
- QMap<QString, StyleItems> pageMap;
-
- for (int row = 0; row < fontTree->topLevelItemCount(); ++row) {
- QTreeWidgetItem *familyItem = fontTree->topLevelItem(row);
- QString family;
-
- if (familyItem->checkState(0) == Qt::Checked) {
- family = familyItem->text(0);
- pageMap[family] = StyleItems();
- }
-
- for (int childRow = 0; childRow < familyItem->childCount(); ++childRow) {
- QTreeWidgetItem *styleItem = familyItem->child(childRow);
- if (styleItem->checkState(0) == Qt::Checked)
- pageMap[family].append(styleItem);
- }
- }
-
- return pageMap;
-}
-
-void MainWindow::on_printAction_triggered()
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
- pageMap = currentPageMap();
-
- if (pageMap.count() == 0)
- return;
-
- QPrinter printer(QPrinter::HighResolution);
- QPrintDialog dialog(&printer, this);
- if (dialog.exec() != QDialog::Accepted)
- return;
-
- int from = printer.fromPage();
- int to = printer.toPage();
- if (from <= 0 && to <= 0)
- printer.setFromTo(1, pageMap.keys().count());
-
- printDocument(&printer);
-#endif
-}
-
-void MainWindow::printDocument(QPrinter *printer)
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
- printer->setFromTo(1, pageMap.count());
-
- QProgressDialog progress(tr("Preparing font samples..."), tr("&Cancel"),
- 0, pageMap.count(), this);
- progress.setWindowModality(Qt::ApplicationModal);
- progress.setWindowTitle(tr("Font Sampler"));
- progress.setMinimum(printer->fromPage() - 1);
- progress.setMaximum(printer->toPage());
-
- QPainter painter;
- painter.begin(printer);
- bool firstPage = true;
-
- for (int page = printer->fromPage(); page <= printer->toPage(); ++page) {
-
- if (!firstPage)
- printer->newPage();
-
- qApp->processEvents();
- if (progress.wasCanceled())
- break;
-
- printPage(page - 1, &painter, printer);
- progress.setValue(page);
- firstPage = false;
- }
-
- painter.end();
-#endif
-}
-
-void MainWindow::on_printPreviewAction_triggered()
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printpreviewdialog)
- pageMap = currentPageMap();
-
- if (pageMap.count() == 0)
- return;
-
- QPrinter printer(QPrinter::HighResolution);
- QPrintPreviewDialog preview(&printer, this);
- connect(&preview, &QPrintPreviewDialog::paintRequested,
- this, &MainWindow::printDocument);
- preview.exec();
-#endif
-}
-
-void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer)
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
- const QString family = std::next(pageMap.begin(), index).key();
- const StyleItems items = pageMap.value(family);
-
- // Find the dimensions of the text on each page.
- qreal width = 0.0;
- qreal height = 0.0;
- for (const QTreeWidgetItem *item : items) {
- QString style = item->text(0);
- int weight = item->data(0, Qt::UserRole).toInt();
- bool italic = item->data(0, Qt::UserRole + 1).toBool();
-
- // Calculate the maximum width and total height of the text.
- for (int size : qAsConst(sampleSizes)) {
- QFont font(family, size, weight, italic);
- font.setStyleName(style);
- font = QFont(font, painter->device());
- QFontMetricsF fontMetrics(font);
- QRectF rect = fontMetrics.boundingRect(
- QString("%1 %2").arg(family).arg(style));
- width = qMax(rect.width(), width);
- height += rect.height();
- }
- }
-
- qreal xScale = printer->pageRect(QPrinter::DevicePixel).width() / width;
- qreal yScale = printer->pageRect(QPrinter::DevicePixel).height() / height;
- qreal scale = qMin(xScale, yScale);
-
- qreal remainingHeight = printer->pageRect(QPrinter::DevicePixel).height()/scale - height;
- qreal spaceHeight = (remainingHeight / 4.0) / (items.count() + 1);
- qreal interLineHeight = (remainingHeight / 4.0) / (sampleSizes.count() * items.count());
-
- painter->save();
- painter->translate(printer->pageRect(QPrinter::DevicePixel).width() / 2.0, printer->pageRect(QPrinter::DevicePixel).height() / 2.0);
- painter->scale(scale, scale);
- painter->setBrush(QBrush(Qt::black));
-
- qreal x = -width / 2.0;
- qreal y = -height / 2.0 - remainingHeight / 4.0 + spaceHeight;
-
- for (const QTreeWidgetItem *item : items) {
- QString style = item->text(0);
- int weight = item->data(0, Qt::UserRole).toInt();
- bool italic = item->data(0, Qt::UserRole + 1).toBool();
-
- // Draw each line of text.
- for (int size : qAsConst(sampleSizes)) {
- QFont font(family, size, weight, italic);
- font.setStyleName(style);
- font = QFont(font, painter->device());
- QFontMetricsF fontMetrics(font);
- QRectF rect = fontMetrics.boundingRect(QString("%1 %2").arg(
- font.family()).arg(style));
- y += rect.height();
- painter->setFont(font);
- painter->drawText(QPointF(x, y), QString("%1 %2").arg(family).arg(style));
- y += interLineHeight;
- }
- y += spaceHeight;
- }
-
- painter->restore();
-#endif
-}
diff --git a/examples/widgets/painting/fontsampler/mainwindow.h b/examples/widgets/painting/fontsampler/mainwindow.h
deleted file mode 100644
index 131fb06312..0000000000
--- a/examples/widgets/painting/fontsampler/mainwindow.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include "ui_mainwindowbase.h"
-
-#if defined(QT_PRINTSUPPORT_LIB)
-#include <QtPrintSupport/qtprintsupportglobal.h>
-#endif
-
-#include <QList>
-#include <QMap>
-#include <QString>
-
-QT_BEGIN_NAMESPACE
-class QPrinter;
-class QTextEdit;
-class QTreeWidget;
-class QTreeWidgetItem;
-QT_END_NAMESPACE
-
-typedef QList<QTreeWidgetItem *> StyleItems;
-
-class MainWindow : public QMainWindow, private Ui::MainWindowBase
-{
- Q_OBJECT
-
-public:
- MainWindow(QWidget *parent = nullptr);
-
-public slots:
- void on_clearAction_triggered();
- void on_markAction_triggered();
- void on_unmarkAction_triggered();
- void on_printAction_triggered();
- void on_printPreviewAction_triggered();
- void printDocument(QPrinter *printer);
- void printPage(int index, QPainter *painter, QPrinter *printer);
- void showFont(QTreeWidgetItem *item);
- void updateStyles(QTreeWidgetItem *item, int column);
-
-private:
- QMap<QString, StyleItems> currentPageMap();
- void markUnmarkFonts(Qt::CheckState state);
- void setupFontTree();
-
- QList<int> sampleSizes;
- QMap<QString, StyleItems> pageMap;
- int markedCount;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/widgets/painting/fontsampler/mainwindowbase.ui b/examples/widgets/painting/fontsampler/mainwindowbase.ui
deleted file mode 100644
index 1a95ebd6d1..0000000000
--- a/examples/widgets/painting/fontsampler/mainwindowbase.ui
+++ /dev/null
@@ -1,142 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainWindowBase</class>
- <widget class="QMainWindow" name="MainWindowBase">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>345</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Font Sampler</string>
- </property>
- <widget class="QWidget" name="centralwidget">
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>9</number>
- </property>
- <item>
- <widget class="QTextEdit" name="textEdit"/>
- </item>
- </layout>
- </widget>
- <widget class="QMenuBar" name="menubar">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>18</height>
- </rect>
- </property>
- <widget class="QMenu" name="menu_Selection">
- <property name="title">
- <string>&amp;Selection</string>
- </property>
- <addaction name="markAction"/>
- <addaction name="unmarkAction"/>
- <addaction name="clearAction"/>
- </widget>
- <widget class="QMenu" name="menu_File">
- <property name="title">
- <string>&amp;File</string>
- </property>
- <addaction name="printPreviewAction"/>
- <addaction name="printAction"/>
- <addaction name="quitAction"/>
- </widget>
- <addaction name="menu_File"/>
- <addaction name="menu_Selection"/>
- </widget>
- <widget class="QStatusBar" name="statusbar"/>
- <widget class="QDockWidget" name="dockWidget">
- <property name="features">
- <set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
- </property>
- <property name="windowTitle">
- <string>Available Fonts</string>
- </property>
- <attribute name="dockWidgetArea">
- <number>1</number>
- </attribute>
- <widget class="QWidget" name="dockWidgetContents">
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>9</number>
- </property>
- <item>
- <widget class="QTreeWidget" name="fontTree">
- <property name="selectionMode">
- <enum>QAbstractItemView::ExtendedSelection</enum>
- </property>
- <column>
- <property name="text">
- <string notr="true">1</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- <action name="printAction">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>&amp;Print...</string>
- </property>
- <property name="shortcut">
- <string>Ctrl+P</string>
- </property>
- </action>
- <action name="quitAction">
- <property name="text">
- <string>E&amp;xit</string>
- </property>
- <property name="shortcut">
- <string>Ctrl+Q</string>
- </property>
- </action>
- <action name="markAction">
- <property name="text">
- <string>&amp;Mark</string>
- </property>
- <property name="shortcut">
- <string>Ctrl+M</string>
- </property>
- </action>
- <action name="unmarkAction">
- <property name="text">
- <string>&amp;Unmark</string>
- </property>
- <property name="shortcut">
- <string>Ctrl+U</string>
- </property>
- </action>
- <action name="clearAction">
- <property name="text">
- <string>&amp;Clear</string>
- </property>
- </action>
- <action name="printPreviewAction">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Print Preview...</string>
- </property>
- </action>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/widgets/painting/gradients/CMakeLists.txt b/examples/widgets/painting/gradients/CMakeLists.txt
index f45cee0a07..39cc44ed8f 100644
--- a/examples/widgets/painting/gradients/CMakeLists.txt
+++ b/examples/widgets/painting/gradients/CMakeLists.txt
@@ -1,24 +1,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(gradients LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/gradients")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(gradients
- # remove files from ../shared
- #../shared/arthurstyle.cpp ../shared/arthurstyle.h
- #../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- #../shared/hoverpoints.cpp ../shared/hoverpoints.h
gradients.cpp gradients.h
main.cpp
)
@@ -28,18 +18,14 @@ set_target_properties(gradients PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_include_directories(gradients PUBLIC
- ../shared
-)
-
if(NOT TARGET painting_shared::painting_shared)
include(../shared/use_lib.cmake)
endif()
-target_link_libraries(gradients PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(gradients PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
painting_shared::painting_shared
)
@@ -103,19 +89,15 @@ qt_add_resources(gradients "gradients"
${gradients_resource_files}
)
-# remove files from ../shared
-#if(QT_FEATURE_opengl)
- #target_sources(affine PUBLIC
- #../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h
- #)
-
- #target_link_libraries(affine PUBLIC
- #Qt::OpenGL
- #)
-#endif()
-
install(TARGETS gradients
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET gradients
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp
index dcedd250cf..5ed3d764d1 100644
--- a/examples/widgets/painting/gradients/gradients.cpp
+++ b/examples/widgets/painting/gradients/gradients.cpp
@@ -273,12 +273,6 @@ GradientWidget::GradientWidget(QWidget *parent)
QPushButton *showSourceButton = new QPushButton(mainGroup);
showSourceButton->setText(tr("Show Source"));
-#if QT_CONFIG(opengl)
- QPushButton *enableOpenGLButton = new QPushButton(mainGroup);
- enableOpenGLButton->setText(tr("Use OpenGL"));
- enableOpenGLButton->setCheckable(true);
- enableOpenGLButton->setChecked(m_renderer->usesOpenGL());
-#endif
QPushButton *whatsThisButton = new QPushButton(mainGroup);
whatsThisButton->setText(tr("What's This?"));
whatsThisButton->setCheckable(true);
@@ -292,9 +286,6 @@ GradientWidget::GradientWidget(QWidget *parent)
mainGroupLayout->addWidget(defaultsGroup);
mainGroupLayout->addStretch(1);
mainGroupLayout->addWidget(showSourceButton);
-#if QT_CONFIG(opengl)
- mainGroupLayout->addWidget(enableOpenGLButton);
-#endif
mainGroupLayout->addWidget(whatsThisButton);
QVBoxLayout *editorGroupLayout = new QVBoxLayout(editorGroup);
@@ -370,11 +361,6 @@ GradientWidget::GradientWidget(QWidget *parent)
connect(showSourceButton, &QPushButton::clicked,
m_renderer, &GradientRenderer::showSource);
-#if QT_CONFIG(opengl)
- connect(enableOpenGLButton, QOverload<bool>::of(&QPushButton::clicked),
- m_renderer, &ArthurFrame::enableOpenGL);
-#endif
-
connect(whatsThisButton, QOverload<bool>::of(&QPushButton::clicked),
m_renderer, &ArthurFrame::setDescriptionEnabled);
connect(whatsThisButton, QOverload<bool>::of(&QPushButton::clicked),
@@ -534,7 +520,7 @@ void GradientRenderer::paint(QPainter *p)
g = QConicalGradient(pts.at(0), angle);
}
- for (const auto &stop : qAsConst(m_stops))
+ for (const auto &stop : std::as_const(m_stops))
g.setColorAt(stop.first, stop.second);
g.setSpread(m_spread);
diff --git a/examples/widgets/painting/gradients/main.cpp b/examples/widgets/painting/gradients/main.cpp
index 7e61687f91..c1e2297512 100644
--- a/examples/widgets/painting/gradients/main.cpp
+++ b/examples/widgets/painting/gradients/main.cpp
@@ -7,11 +7,6 @@
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(gradients);
-#ifdef Q_OS_ANDROID
- qputenv("QT_SCALE_FACTOR", "2");
-#endif
-
QApplication app(argc, argv);
GradientWidget gradientWidget;
diff --git a/examples/widgets/painting/imagecomposition/CMakeLists.txt b/examples/widgets/painting/imagecomposition/CMakeLists.txt
index de53844afa..eea0c24173 100644
--- a/examples/widgets/painting/imagecomposition/CMakeLists.txt
+++ b/examples/widgets/painting/imagecomposition/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(imagecomposition LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/imagecomposition")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(imagecomposition
imagecomposer.cpp imagecomposer.h
main.cpp
@@ -24,10 +18,10 @@ set_target_properties(imagecomposition PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(imagecomposition PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(imagecomposition PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -44,7 +38,14 @@ qt_add_resources(imagecomposition "imagecomposition"
)
install(TARGETS imagecomposition
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET imagecomposition
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/painting/imagecomposition/main.cpp b/examples/widgets/painting/imagecomposition/main.cpp
index cd5468f088..a3cf65a344 100644
--- a/examples/widgets/painting/imagecomposition/main.cpp
+++ b/examples/widgets/painting/imagecomposition/main.cpp
@@ -8,8 +8,6 @@
//! [0]
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(imagecomposition);
-
QApplication app(argc, argv);
ImageComposer composer;
composer.show();
diff --git a/examples/widgets/painting/painterpaths/CMakeLists.txt b/examples/widgets/painting/painterpaths/CMakeLists.txt
index f1a2b31898..46f7948277 100644
--- a/examples/widgets/painting/painterpaths/CMakeLists.txt
+++ b/examples/widgets/painting/painterpaths/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(painterpaths LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/painterpaths")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(painterpaths
main.cpp
renderarea.cpp renderarea.h
@@ -25,20 +19,27 @@ set_target_properties(painterpaths PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(painterpaths PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(painterpaths PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
if(UNIX AND NOT APPLE AND NOT HAIKU AND NOT INTEGRITY AND NOT VXWORKS)
- target_link_libraries(painterpaths PUBLIC
+ target_link_libraries(painterpaths PRIVATE
m
)
endif()
install(TARGETS painterpaths
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET painterpaths
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/painting/painterpaths/window.cpp b/examples/widgets/painting/painterpaths/window.cpp
index 4fc3e8efd9..01b62d6988 100644
--- a/examples/widgets/painting/painterpaths/window.cpp
+++ b/examples/widgets/painting/painterpaths/window.cpp
@@ -156,7 +156,7 @@ Window::Window()
connect(penColorComboBox, &QComboBox::activated,
this, &Window::penColorChanged);
- for (RenderArea *area : qAsConst(renderAreas)) {
+ for (RenderArea *area : std::as_const(renderAreas)) {
connect(penWidthSpinBox, &QSpinBox::valueChanged,
area, &RenderArea::setPenWidth);
connect(rotationAngleSpinBox, &QSpinBox::valueChanged,
@@ -167,7 +167,7 @@ Window::Window()
QGridLayout *topLayout = new QGridLayout;
int i = 0;
- for (RenderArea *area : qAsConst(renderAreas)) {
+ for (RenderArea *area : std::as_const(renderAreas)) {
topLayout->addWidget(area, i / 3, i % 3);
++i;
}
@@ -204,7 +204,7 @@ void Window::fillRuleChanged()
{
Qt::FillRule rule = (Qt::FillRule)currentItemData(fillRuleComboBox).toInt();
- for (RenderArea *area : qAsConst(renderAreas))
+ for (RenderArea *area : std::as_const(renderAreas))
area->setFillRule(rule);
}
//! [19]
@@ -215,7 +215,7 @@ void Window::fillGradientChanged()
QColor color1 = qvariant_cast<QColor>(currentItemData(fillColor1ComboBox));
QColor color2 = qvariant_cast<QColor>(currentItemData(fillColor2ComboBox));
- for (RenderArea *area : qAsConst(renderAreas))
+ for (RenderArea *area : std::as_const(renderAreas))
area->setFillGradient(color1, color2);
}
//! [20]
@@ -225,7 +225,7 @@ void Window::penColorChanged()
{
QColor color = qvariant_cast<QColor>(currentItemData(penColorComboBox));
- for (RenderArea *area : qAsConst(renderAreas))
+ for (RenderArea *area : std::as_const(renderAreas))
area->setPenColor(color);
}
//! [21]
diff --git a/examples/widgets/painting/painting.pro b/examples/widgets/painting/painting.pro
index a9749a560d..1dfd660f77 100644
--- a/examples/widgets/painting/painting.pro
+++ b/examples/widgets/painting/painting.pro
@@ -1,6 +1,5 @@
TEMPLATE = subdirs
SUBDIRS = basicdrawing \
- concentriccircles \
affine \
composition \
deform \
@@ -8,8 +7,7 @@ SUBDIRS = basicdrawing \
pathstroke \
imagecomposition \
painterpaths \
- transformations \
- fontsampler
+ transformations
EXAMPLE_FILES = \
shared
diff --git a/examples/widgets/painting/pathstroke/CMakeLists.txt b/examples/widgets/painting/pathstroke/CMakeLists.txt
index 88e6a9285d..5c995617eb 100644
--- a/examples/widgets/painting/pathstroke/CMakeLists.txt
+++ b/examples/widgets/painting/pathstroke/CMakeLists.txt
@@ -1,24 +1,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(pathstroke LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/pathstroke")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(pathstroke
- # remove files from ../shared
- #../shared/arthurstyle.cpp ../shared/arthurstyle.h
- #../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- #../shared/hoverpoints.cpp ../shared/hoverpoints.h
main.cpp
pathstroke.cpp pathstroke.h
)
@@ -28,18 +18,14 @@ set_target_properties(pathstroke PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_include_directories(pathstroke PUBLIC
- ../shared
-)
-
if(NOT TARGET painting_shared::painting_shared)
include(../shared/use_lib.cmake)
endif()
-target_link_libraries(pathstroke PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(pathstroke PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
painting_shared::painting_shared
)
@@ -103,19 +89,15 @@ qt_add_resources(pathstroke "pathstroke"
${pathstroke_resource_files}
)
-# remove files from ../shared
-#if(QT_FEATURE_opengl)
- #target_sources(affine PUBLIC
- #../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h
- #)
-
- #target_link_libraries(affine PUBLIC
- #Qt::OpenGL
- #)
-#endif()
-
install(TARGETS pathstroke
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET pathstroke
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/painting/pathstroke/main.cpp b/examples/widgets/painting/pathstroke/main.cpp
index d7c64b3c64..4f991e8a0a 100644
--- a/examples/widgets/painting/pathstroke/main.cpp
+++ b/examples/widgets/painting/pathstroke/main.cpp
@@ -7,11 +7,6 @@
int main(int argc, char **argv)
{
- Q_INIT_RESOURCE(pathstroke);
-#ifdef Q_OS_ANDROID
- qputenv("QT_SCALE_FACTOR", "2");
-#endif
-
QApplication app(argc, argv);
bool smallScreen = QApplication::arguments().contains("-small-screen");
diff --git a/examples/widgets/painting/pathstroke/pathstroke.cpp b/examples/widgets/painting/pathstroke/pathstroke.cpp
index 9bec56233c..cd54a7a8aa 100644
--- a/examples/widgets/painting/pathstroke/pathstroke.cpp
+++ b/examples/widgets/painting/pathstroke/pathstroke.cpp
@@ -177,12 +177,6 @@ void PathStrokeControls::layoutForDesktop()
QPushButton *showSourceButton = new QPushButton(mainGroup);
showSourceButton->setText(tr("Show Source"));
-#if QT_CONFIG(opengl)
- QPushButton *enableOpenGLButton = new QPushButton(mainGroup);
- enableOpenGLButton->setText(tr("Use OpenGL"));
- enableOpenGLButton->setCheckable(true);
- enableOpenGLButton->setChecked(m_renderer->usesOpenGL());
-#endif
QPushButton *whatsThisButton = new QPushButton(mainGroup);
whatsThisButton->setText(tr("What's This?"));
whatsThisButton->setCheckable(true);
@@ -206,9 +200,6 @@ void PathStrokeControls::layoutForDesktop()
mainGroupLayout->addWidget(animated);
mainGroupLayout->addStretch(1);
mainGroupLayout->addWidget(showSourceButton);
-#if QT_CONFIG(opengl)
- mainGroupLayout->addWidget(enableOpenGLButton);
-#endif
mainGroupLayout->addWidget(whatsThisButton);
@@ -221,10 +212,6 @@ void PathStrokeControls::layoutForDesktop()
connect(showSourceButton, &QAbstractButton::clicked,
m_renderer, &ArthurFrame::showSource);
-#if QT_CONFIG(opengl)
- connect(enableOpenGLButton, &QAbstractButton::clicked,
- m_renderer, &ArthurFrame::enableOpenGL);
-#endif
connect(whatsThisButton, &QAbstractButton::clicked,
m_renderer, &ArthurFrame::setDescriptionEnabled);
connect(m_renderer, &ArthurFrame::descriptionEnabledChanged,
@@ -259,13 +246,6 @@ void PathStrokeControls::layoutForSmallScreens()
penWidth->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
penWidth->setRange(0, 500);
-#if QT_CONFIG(opengl)
- QPushButton *enableOpenGLButton = new QPushButton(this);
- enableOpenGLButton->setText(tr("Use OpenGL"));
- enableOpenGLButton->setCheckable(true);
- enableOpenGLButton->setChecked(m_renderer->usesOpenGL());
-#endif
-
// Layouts:
QHBoxLayout *penWidthLayout = new QHBoxLayout;
penWidthLayout->addWidget(penWidthLabel, 0, Qt::AlignRight);
@@ -274,9 +254,6 @@ void PathStrokeControls::layoutForSmallScreens()
QVBoxLayout *leftLayout = new QVBoxLayout;
leftLayout->addWidget(m_capGroup);
leftLayout->addWidget(m_joinGroup);
-#if QT_CONFIG(opengl)
- leftLayout->addWidget(enableOpenGLButton);
-#endif
leftLayout->addLayout(penWidthLayout);
QVBoxLayout *rightLayout = new QVBoxLayout;
@@ -297,10 +274,6 @@ void PathStrokeControls::layoutForSmallScreens()
mainLayout->addWidget(quitBtn, 2, 1, Qt::AlignHCenter | Qt::AlignTop);
mainLayout->addWidget(okBtn, 2, 2, Qt::AlignHCenter | Qt::AlignTop);
-#if QT_CONFIG(opengl)
- connect(enableOpenGLButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::enableOpenGL);
-#endif
-
connect(penWidth, &QAbstractSlider::valueChanged, m_renderer, &PathStrokeRenderer::setPenWidth);
connect(quitBtn, &QAbstractButton::clicked, this, &PathStrokeControls::emitQuitSignal);
connect(okBtn, &QAbstractButton::clicked, this, &PathStrokeControls::emitOkSignal);
@@ -341,7 +314,7 @@ PathStrokeWidget::PathStrokeWidget(bool smallScreen)
connect(m_renderer, &PathStrokeRenderer::clicked, this, &PathStrokeWidget::showControls);
connect(m_controls, &PathStrokeControls::okPressed, this, &PathStrokeWidget::hideControls);
- connect(m_controls, SIGNAL(quitPressed()), QApplication::instance(), SLOT(quit()));
+ connect(m_controls, &PathStrokeControls::quitPressed, QApplication::instance(), &QApplication::quit);
}
void PathStrokeWidget::showControls()
diff --git a/examples/widgets/painting/shared/CMakeLists.txt b/examples/widgets/painting/shared/CMakeLists.txt
index 48fca30029..5eaa3b42e1 100644
--- a/examples/widgets/painting/shared/CMakeLists.txt
+++ b/examples/widgets/painting/shared/CMakeLists.txt
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
add_library(painting_shared OBJECT)
add_library(painting_shared::painting_shared ALIAS painting_shared)
@@ -11,17 +11,7 @@ target_sources(painting_shared PRIVATE
${moc_files}
)
-target_link_libraries(painting_shared PUBLIC Qt::Widgets)
-target_include_directories(painting_shared PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
-
-## Scopes:
-#####################################################################
+set_target_properties(painting_shared PROPERTIES UNITY_BUILD OFF)
-if (TARGET Qt::OpenGL OR QT_FEATURE_opengles2)
- target_compile_definitions(painting_shared PRIVATE QT_OPENGL_SUPPORT)
- target_link_libraries(painting_shared PUBLIC
- Qt::OpenGL
- )
- qt6_wrap_cpp(moc_files_gl fbopaintdevice.h) # no automoc for OBJECT libs
- target_sources(painting_shared PRIVATE fbopaintdevice.cpp fbopaintdevice.h ${moc_files_gl})
-endif()
+target_link_libraries(painting_shared PUBLIC Qt6::Widgets)
+target_include_directories(painting_shared PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
diff --git a/examples/widgets/painting/shared/arthurwidgets.cpp b/examples/widgets/painting/shared/arthurwidgets.cpp
index 7f3e50f5e6..4ff435783b 100644
--- a/examples/widgets/painting/shared/arthurwidgets.cpp
+++ b/examples/widgets/painting/shared/arthurwidgets.cpp
@@ -14,11 +14,6 @@
#include <QBoxLayout>
#include <QRegularExpression>
#include <QOffscreenSurface>
-#include <QOpenGLContext>
-#if QT_CONFIG(opengl)
-#include <QtOpenGL/QOpenGLPaintDevice>
-#include <QtOpenGL/QOpenGLWindow>
-#endif
extern QPixmap cached(const QString &img);
@@ -34,61 +29,13 @@ ArthurFrame::ArthurFrame(QWidget *parent)
pt.end();
}
-
-#if QT_CONFIG(opengl)
-void ArthurFrame::enableOpenGL(bool use_opengl)
-{
- if (m_use_opengl == use_opengl)
- return;
-
- m_use_opengl = use_opengl;
-
- if (!m_glWindow && use_opengl) {
- createGlWindow();
- QApplication::postEvent(this, new QResizeEvent(size(), size()));
- }
-
- if (use_opengl) {
- m_glWidget->show();
- } else {
- if (m_glWidget)
- m_glWidget->hide();
- }
-
- update();
-}
-
-void ArthurFrame::createGlWindow()
-{
- Q_ASSERT(m_use_opengl);
-
- m_glWindow = new QOpenGLWindow();
- QSurfaceFormat f = QSurfaceFormat::defaultFormat();
- f.setSamples(4);
- f.setAlphaBufferSize(8);
- f.setStencilBufferSize(8);
- m_glWindow->setFormat(f);
- m_glWindow->setFlags(Qt::WindowTransparentForInput);
- m_glWindow->resize(width(), height());
- m_glWidget = QWidget::createWindowContainer(m_glWindow, this);
- // create() must be called after createWindowContainer() otherwise
- // an incorrect offsetting of the position will occur.
- m_glWindow->create();
-}
-#endif
-
-
void ArthurFrame::paintEvent(QPaintEvent *e)
{
static QImage *static_image = nullptr;
QPainter painter;
- if (preferImage()
-#if QT_CONFIG(opengl)
- && !m_use_opengl
-#endif
- ) {
+ if (preferImage()) {
if (!static_image || static_image->size() != size()) {
delete static_image;
static_image = new QImage(size(), QImage::Format_RGB32);
@@ -103,18 +50,7 @@ void ArthurFrame::paintEvent(QPaintEvent *e)
painter.fillRect(0, height() - o, o, o, bg);
painter.fillRect(width() - o, height() - o, o, o, bg);
} else {
-#if QT_CONFIG(opengl)
- if (m_use_opengl && m_glWindow->isValid()) {
- m_glWindow->makeCurrent();
-
- painter.begin(m_glWindow);
- painter.fillRect(QRectF(0, 0, m_glWindow->width(), m_glWindow->height()), palette().color(backgroundRole()));
- } else {
- painter.begin(this);
- }
-#else
painter.begin(this);
-#endif
}
painter.setClipRect(e->rect());
@@ -158,27 +94,15 @@ void ArthurFrame::paintEvent(QPaintEvent *e)
painter.setBrush(Qt::NoBrush);
painter.drawPath(clipPath);
- if (preferImage()
-#if QT_CONFIG(opengl)
- && !m_use_opengl
-#endif
- ) {
+ if (preferImage()) {
painter.end();
painter.begin(this);
painter.drawImage(e->rect(), *static_image, e->rect());
}
-#if QT_CONFIG(opengl)
- if (m_use_opengl)
- m_glWindow->update();
-#endif
}
void ArthurFrame::resizeEvent(QResizeEvent *e)
{
-#if QT_CONFIG(opengl)
- if (m_glWidget)
- m_glWidget->setGeometry(0, 0, e->size().width(), e->size().height());
-#endif
QWidget::resizeEvent(e);
}
diff --git a/examples/widgets/painting/shared/arthurwidgets.h b/examples/widgets/painting/shared/arthurwidgets.h
index bf50b24346..e508e811cb 100644
--- a/examples/widgets/painting/shared/arthurwidgets.h
+++ b/examples/widgets/painting/shared/arthurwidgets.h
@@ -9,7 +9,6 @@
#include <QPushButton>
#include <QGroupBox>
-QT_FORWARD_DECLARE_CLASS(QOpenGLWindow)
QT_FORWARD_DECLARE_CLASS(QTextDocument)
QT_FORWARD_DECLARE_CLASS(QTextEdit)
QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
@@ -30,20 +29,12 @@ public:
void loadSourceFile(const QString &fileName);
bool preferImage() const { return m_preferImage; }
-#if QT_CONFIG(opengl)
- QOpenGLWindow *glWindow() const { return m_glWindow; }
-#endif
public slots:
void setPreferImage(bool pi) { m_preferImage = pi; }
void setDescriptionEnabled(bool enabled);
void showSource();
-#if QT_CONFIG(opengl)
- void enableOpenGL(bool use_opengl);
- bool usesOpenGL() { return m_use_opengl; }
-#endif
-
signals:
void descriptionEnabledChanged(bool);
@@ -51,17 +42,11 @@ protected:
void paintEvent(QPaintEvent *) override;
void resizeEvent(QResizeEvent *) override;
-#if QT_CONFIG(opengl)
- virtual void createGlWindow();
- QOpenGLWindow *m_glWindow = nullptr;
- QWidget *m_glWidget = nullptr;
- bool m_use_opengl = false;
-#endif
QPixmap m_tile;
bool m_showDoc = false;
bool m_preferImage = false;
- QTextDocument *m_document = nullptr;;
+ QTextDocument *m_document = nullptr;
QString m_sourceFileName;
};
diff --git a/examples/widgets/painting/shared/fbopaintdevice.cpp b/examples/widgets/painting/shared/fbopaintdevice.cpp
deleted file mode 100644
index 305f4f2c2c..0000000000
--- a/examples/widgets/painting/shared/fbopaintdevice.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "fbopaintdevice.h"
-
-#include <QOffscreenSurface>
-#include <QOpenGLFunctions>
-
-QFboPaintDevice::QFboPaintDevice(const QSize &size, bool flipped, bool clearOnInit,
- QOpenGLFramebufferObject::Attachment attachment)
- : QOpenGLPaintDevice(size)
-{
- QOpenGLFramebufferObjectFormat format;
- format.setAttachment(attachment);
- format.setSamples(4);
- m_framebufferObject = new QOpenGLFramebufferObject(size, format);
- QOffscreenSurface *surface = new QOffscreenSurface();
- surface->create();
- m_surface = surface;
- setPaintFlipped(flipped);
- if (clearOnInit) {
- m_framebufferObject->bind();
-
- context()->functions()->glClearColor(0, 0, 0, 0);
- context()->functions()->glClear(GL_COLOR_BUFFER_BIT);
- }
-}
-
-QFboPaintDevice::~QFboPaintDevice()
-{
- delete m_framebufferObject;
- delete m_surface;
-}
-
-void QFboPaintDevice::ensureActiveTarget()
-{
- if (QOpenGLContext::currentContext() != context())
- context()->makeCurrent(m_surface);
-
- m_framebufferObject->bind();
-}
-
-GLuint QFboPaintDevice::takeTexture()
-{
- // We have multisamples so we can't just forward takeTexture().
- QOpenGLFramebufferObject resolvedFbo(m_framebufferObject->size(), m_framebufferObject->attachment());
- QOpenGLFramebufferObject::blitFramebuffer(&resolvedFbo, m_framebufferObject);
- return resolvedFbo.takeTexture();
-}
-
-QImage QFboPaintDevice::toImage() const
-{
- QOpenGLContext *currentContext = QOpenGLContext::currentContext();
- QSurface *currentSurface = currentContext ? currentContext->surface() : nullptr;
-
- context()->makeCurrent(m_surface);
-
- QImage image = m_framebufferObject->toImage(!paintFlipped());
-
- if (currentContext)
- currentContext->makeCurrent(currentSurface);
- else
- context()->doneCurrent();
-
- return image;
-}
diff --git a/examples/widgets/painting/shared/fbopaintdevice.h b/examples/widgets/painting/shared/fbopaintdevice.h
deleted file mode 100644
index a46166217b..0000000000
--- a/examples/widgets/painting/shared/fbopaintdevice.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef QFBOPAINTDEVICE_H
-#define QFBOPAINTDEVICE_H
-
-#ifndef QT_NO_OPENGL
-
-#include <QImage>
-#include <QOpenGLFramebufferObject>
-#include <QOpenGLPaintDevice>
-#include <QSurface>
-
-class QFboPaintDevice : public QOpenGLPaintDevice {
-public:
- QFboPaintDevice(const QSize &size, bool flipped = false, bool clearOnInit = true,
- QOpenGLFramebufferObject::Attachment = QOpenGLFramebufferObject::CombinedDepthStencil);
- ~QFboPaintDevice();
-
- // QOpenGLPaintDevice:
- void ensureActiveTarget() override;
-
- bool isValid() const { return m_framebufferObject->isValid(); }
- GLuint handle() const { return m_framebufferObject->handle(); }
- GLuint takeTexture();
- QImage toImage() const;
-
- bool bind() { return m_framebufferObject->bind(); }
- bool release() { return m_framebufferObject->release(); }
- QSize size() const { return m_framebufferObject->size(); }
-
- QOpenGLFramebufferObject* framebufferObject() { return m_framebufferObject; }
- const QOpenGLFramebufferObject* framebufferObject() const { return m_framebufferObject; }
-
- static bool isSupported() { return QOpenGLFramebufferObject::hasOpenGLFramebufferObjects(); }
-
-private:
- QOpenGLFramebufferObject *m_framebufferObject;
- QSurface *m_surface;
-};
-
-#endif // QT_NO_OPENGL
-
-#endif // QFBOPAINTDEVICE_H
diff --git a/examples/widgets/painting/shared/hoverpoints.cpp b/examples/widgets/painting/shared/hoverpoints.cpp
index 7d2bb81538..a917139613 100644
--- a/examples/widgets/painting/shared/hoverpoints.cpp
+++ b/examples/widgets/painting/shared/hoverpoints.cpp
@@ -6,10 +6,6 @@
#include <algorithm>
-#if QT_CONFIG(opengl)
-#include <QtOpenGL/QOpenGLWindow>
-#endif
-
HoverPoints::HoverPoints(QWidget *widget, PointShape shape)
: QObject(widget),
m_widget(widget),
@@ -131,6 +127,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
const int id = point.id();
switch (point.state()) {
case QEventPoint::Pressed:
+ case QEventPoint::Stationary:
{
// find the point, move it
const auto mappedPoints = m_fingerPointMapping.values();
@@ -155,7 +152,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
}
}
if (activePoint != -1) {
- m_fingerPointMapping.insert(point.id(), activePoint);
+ m_fingerPointMapping.insert(id, activePoint);
movePoint(activePoint, point.position());
}
}
@@ -163,9 +160,11 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
case QEventPoint::Released:
{
// move the point and release
- const auto it = m_fingerPointMapping.find(id);
- movePoint(it.value(), point.position());
- m_fingerPointMapping.erase(it);
+ const auto it = m_fingerPointMapping.constFind(id);
+ if (it != m_fingerPointMapping.constEnd()) {
+ movePoint(it.value(), point.position());
+ m_fingerPointMapping.erase(it);
+ }
}
break;
case QEventPoint::Updated:
@@ -230,17 +229,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event)
void HoverPoints::paintPoints()
{
QPainter p;
-#if QT_CONFIG(opengl)
- ArthurFrame *af = qobject_cast<ArthurFrame *>(m_widget);
- if (af && af->usesOpenGL() && af->glWindow()->isValid()) {
- af->glWindow()->makeCurrent();
- p.begin(af->glWindow());
- } else {
- p.begin(m_widget);
- }
-#else
p.begin(m_widget);
-#endif
p.setRenderHint(QPainter::Antialiasing);
@@ -268,7 +257,7 @@ void HoverPoints::paintPoints()
p.setPen(m_pointPen);
p.setBrush(m_pointBrush);
- for (const auto &point : qAsConst(m_points)) {
+ for (const auto &point : std::as_const(m_points)) {
QRectF bounds = pointBoundingRect(point);
if (m_shape == CircleShape)
p.drawEllipse(bounds);
diff --git a/examples/widgets/painting/shared/shared.pri b/examples/widgets/painting/shared/shared.pri
index 7e2b4df8cb..77881b03cc 100644
--- a/examples/widgets/painting/shared/shared.pri
+++ b/examples/widgets/painting/shared/shared.pri
@@ -1,11 +1,5 @@
INCLUDEPATH += $$PWD
-qtConfig(opengl) {
- QT += opengl
- SOURCES += $$PWD/fbopaintdevice.cpp
- HEADERS += $$PWD/fbopaintdevice.h
-}
-
SOURCES += \
$$PWD/arthurstyle.cpp\
$$PWD/arthurwidgets.cpp \
diff --git a/examples/widgets/painting/shared/use_lib.cmake b/examples/widgets/painting/shared/use_lib.cmake
index dc17fff3c0..84684a3444 100644
--- a/examples/widgets/painting/shared/use_lib.cmake
+++ b/examples/widgets/painting/shared/use_lib.cmake
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
# Include this file in your example project to use the library defined in this directory.
# This avoids find_package calls in a directory scope different from the directory scope of the
@@ -9,8 +9,4 @@ if(NOT TARGET Qt::Widgets)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
endif()
-if(NOT TARGET Qt::OpenGL)
- find_package(Qt6 OPTIONAL_COMPONENTS OpenGL)
-endif()
-
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}" painting_shared)
diff --git a/examples/widgets/painting/transformations/CMakeLists.txt b/examples/widgets/painting/transformations/CMakeLists.txt
index 26c2b1b21d..dfc35b2551 100644
--- a/examples/widgets/painting/transformations/CMakeLists.txt
+++ b/examples/widgets/painting/transformations/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(transformations LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/transformations")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(transformations
main.cpp
renderarea.cpp renderarea.h
@@ -25,14 +19,21 @@ set_target_properties(transformations PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(transformations PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(transformations PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS transformations
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET transformations
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/qnx/foreignwindows/collector.cpp b/examples/widgets/qnx/foreignwindows/collector.cpp
index 6717488dfa..8831aab3aa 100644
--- a/examples/widgets/qnx/foreignwindows/collector.cpp
+++ b/examples/widgets/qnx/foreignwindows/collector.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2018 QNX Software Systems. All rights reserved.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QDebug>
diff --git a/examples/widgets/qnx/foreignwindows/collector.h b/examples/widgets/qnx/foreignwindows/collector.h
index a6cd00f9a8..4ee93cbc51 100644
--- a/examples/widgets/qnx/foreignwindows/collector.h
+++ b/examples/widgets/qnx/foreignwindows/collector.h
@@ -1,5 +1,5 @@
// Copyright (C) 2018 QNX Software Systems. All rights reserved.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef COLLECTOR_H_
#define COLLECTOR_H_
diff --git a/examples/widgets/qnx/foreignwindows/main.cpp b/examples/widgets/qnx/foreignwindows/main.cpp
index e5cc0ea362..55dfc98f01 100644
--- a/examples/widgets/qnx/foreignwindows/main.cpp
+++ b/examples/widgets/qnx/foreignwindows/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2018 QNX Software Systems. All rights reserved.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/rhi/CMakeLists.txt b/examples/widgets/rhi/CMakeLists.txt
new file mode 100644
index 0000000000..6734a13c9e
--- /dev/null
+++ b/examples/widgets/rhi/CMakeLists.txt
@@ -0,0 +1,8 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+if(NOT TARGET Qt6::Widgets)
+ return()
+endif()
+qt_internal_add_example(simplerhiwidget)
+qt_internal_add_example(cuberhiwidget)
diff --git a/examples/widgets/rhi/cuberhiwidget/CMakeLists.txt b/examples/widgets/rhi/cuberhiwidget/CMakeLists.txt
new file mode 100644
index 0000000000..effa9a5a73
--- /dev/null
+++ b/examples/widgets/rhi/cuberhiwidget/CMakeLists.txt
@@ -0,0 +1,48 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(cuberhiwidget LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(cuberhiwidget
+ examplewidget.cpp examplewidget.h cube.h
+ main.cpp
+)
+
+set_target_properties(cuberhiwidget PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+# needs GuiPrivate to be able to include <rhi/qrhi.h>
+target_link_libraries(cuberhiwidget PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::GuiPrivate
+ Qt6::Widgets
+)
+
+qt_add_resources(cuberhiwidget "cuberhiwidget"
+ PREFIX
+ "/"
+ FILES
+ "shader_assets/texture.vert.qsb"
+ "shader_assets/texture.frag.qsb"
+)
+
+install(TARGETS cuberhiwidget
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET cuberhiwidget
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/rhi/cuberhiwidget/cube.h b/examples/widgets/rhi/cuberhiwidget/cube.h
new file mode 100644
index 0000000000..9d55eede92
--- /dev/null
+++ b/examples/widgets/rhi/cuberhiwidget/cube.h
@@ -0,0 +1,139 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef CUBE_H
+#define CUBE_H
+
+// clang-format off
+static const float cube[] = {
+ -1.0f, -1.0f, -1.0f, // -X
+ -1.0f, -1.0f, 1.0f,
+ -1.0f, 1.0f, 1.0f,
+ -1.0f, 1.0f, 1.0f,
+ -1.0f, 1.0f, -1.0f,
+ -1.0f, -1.0f, -1.0f,
+
+ -1.0f, -1.0f, -1.0f, // -Z
+ 1.0f, 1.0f, -1.0f,
+ 1.0f, -1.0f, -1.0f,
+ -1.0f, -1.0f, -1.0f,
+ -1.0f, 1.0f, -1.0f,
+ 1.0f, 1.0f, -1.0f,
+
+ -1.0f, -1.0f, -1.0f, // -Y
+ 1.0f, -1.0f, -1.0f,
+ 1.0f, -1.0f, 1.0f,
+ -1.0f, -1.0f, -1.0f,
+ 1.0f, -1.0f, 1.0f,
+ -1.0f, -1.0f, 1.0f,
+
+ -1.0f, 1.0f, -1.0f, // +Y
+ -1.0f, 1.0f, 1.0f,
+ 1.0f, 1.0f, 1.0f,
+ -1.0f, 1.0f, -1.0f,
+ 1.0f, 1.0f, 1.0f,
+ 1.0f, 1.0f, -1.0f,
+
+ 1.0f, 1.0f, -1.0f, // +X
+ 1.0f, 1.0f, 1.0f,
+ 1.0f, -1.0f, 1.0f,
+ 1.0f, -1.0f, 1.0f,
+ 1.0f, -1.0f, -1.0f,
+ 1.0f, 1.0f, -1.0f,
+
+ -1.0f, 1.0f, 1.0f, // +Z
+ -1.0f, -1.0f, 1.0f,
+ 1.0f, 1.0f, 1.0f,
+ -1.0f, -1.0f, 1.0f,
+ 1.0f, -1.0f, 1.0f,
+ 1.0f, 1.0f, 1.0f,
+
+ // UVs
+ 0.0f, 1.0f, // -X
+ 1.0f, 1.0f,
+ 1.0f, 0.0f,
+ 1.0f, 0.0f,
+ 0.0f, 0.0f,
+ 0.0f, 1.0f,
+
+ 1.0f, 1.0f, // -Z
+ 0.0f, 0.0f,
+ 0.0f, 1.0f,
+ 1.0f, 1.0f,
+ 1.0f, 0.0f,
+ 0.0f, 0.0f,
+
+ 1.0f, 0.0f, // -Y
+ 1.0f, 1.0f,
+ 0.0f, 1.0f,
+ 1.0f, 0.0f,
+ 0.0f, 1.0f,
+ 0.0f, 0.0f,
+
+ 1.0f, 0.0f, // +Y
+ 0.0f, 0.0f,
+ 0.0f, 1.0f,
+ 1.0f, 0.0f,
+ 0.0f, 1.0f,
+ 1.0f, 1.0f,
+
+ 1.0f, 0.0f, // +X
+ 0.0f, 0.0f,
+ 0.0f, 1.0f,
+ 0.0f, 1.0f,
+ 1.0f, 1.0f,
+ 1.0f, 0.0f,
+
+ 0.0f, 0.0f, // +Z
+ 0.0f, 1.0f,
+ 1.0f, 0.0f,
+ 0.0f, 1.0f,
+ 1.0f, 1.0f,
+ 1.0f, 0.0f,
+
+ // normals
+ -1.0, 0.0, 0.0, // -X
+ -1.0, 0.0, 0.0,
+ -1.0, 0.0, 0.0,
+ -1.0, 0.0, 0.0,
+ -1.0, 0.0, 0.0,
+ -1.0, 0.0, 0.0,
+
+ 0.0, 0.0, -1.0, // -Z
+ 0.0, 0.0, -1.0,
+ 0.0, 0.0, -1.0,
+ 0.0, 0.0, -1.0,
+ 0.0, 0.0, -1.0,
+ 0.0, 0.0, -1.0,
+
+ 0.0, -1.0, 0.0, // -Y
+ 0.0, -1.0, 0.0,
+ 0.0, -1.0, 0.0,
+ 0.0, -1.0, 0.0,
+ 0.0, -1.0, 0.0,
+ 0.0, -1.0, 0.0,
+
+ 0.0, 1.0, 0.0, // +Y
+ 0.0, 1.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.0, 1.0, 0.0,
+
+ 1.0, 0.0, 0.0, // +X
+ 1.0, 0.0, 0.0,
+ 1.0, 0.0, 0.0,
+ 1.0, 0.0, 0.0,
+ 1.0, 0.0, 0.0,
+ 1.0, 0.0, 0.0,
+
+ 0.0, 0.0, 1.0, // +Z
+ 0.0, 0.0, 1.0,
+ 0.0, 0.0, 1.0,
+ 0.0, 0.0, 1.0,
+ 0.0, 0.0, 1.0,
+ 0.0, 0.0, 1.0
+};
+// clang-format on
+
+#endif
diff --git a/examples/widgets/rhi/cuberhiwidget/cuberhiwidget.pro b/examples/widgets/rhi/cuberhiwidget/cuberhiwidget.pro
new file mode 100644
index 0000000000..94abd29e08
--- /dev/null
+++ b/examples/widgets/rhi/cuberhiwidget/cuberhiwidget.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+
+# needs gui-private to be able to include <rhi/qrhi.h>
+QT += gui-private widgets
+
+HEADERS += examplewidget.h
+SOURCES += examplewidget.cpp main.cpp
+
+RESOURCES += cuberhiwidget.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/widgets/rhi/cuberhiwidget
+INSTALLS += target
diff --git a/examples/widgets/rhi/cuberhiwidget/cuberhiwidget.qrc b/examples/widgets/rhi/cuberhiwidget/cuberhiwidget.qrc
new file mode 100644
index 0000000000..33ca81dbde
--- /dev/null
+++ b/examples/widgets/rhi/cuberhiwidget/cuberhiwidget.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/">
+ <file>shader_assets/texture.vert.qsb</file>
+ <file>shader_assets/texture.frag.qsb</file>
+</qresource>
+</RCC>
diff --git a/examples/widgets/rhi/cuberhiwidget/examplewidget.cpp b/examples/widgets/rhi/cuberhiwidget/examplewidget.cpp
new file mode 100644
index 0000000000..fe39d904dd
--- /dev/null
+++ b/examples/widgets/rhi/cuberhiwidget/examplewidget.cpp
@@ -0,0 +1,172 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "examplewidget.h"
+#include "cube.h"
+#include <QFile>
+#include <QPainter>
+
+static const QSize CUBE_TEX_SIZE(512, 512);
+
+ExampleRhiWidget::ExampleRhiWidget(QWidget *parent)
+ : QRhiWidget(parent)
+{
+}
+
+//![init-1]
+void ExampleRhiWidget::initialize(QRhiCommandBuffer *)
+{
+ if (m_rhi != rhi()) {
+ m_rhi = rhi();
+ scene = {};
+ emit rhiChanged(QString::fromUtf8(m_rhi->backendName()));
+ }
+ if (m_pixelSize != renderTarget()->pixelSize()) {
+ m_pixelSize = renderTarget()->pixelSize();
+ emit resized();
+ }
+ if (m_sampleCount != renderTarget()->sampleCount()) {
+ m_sampleCount = renderTarget()->sampleCount();
+ scene = {};
+ }
+//![init-1]
+
+//![init-2]
+ if (!scene.vbuf) {
+ initScene();
+ updateCubeTexture();
+ }
+
+ scene.mvp = m_rhi->clipSpaceCorrMatrix();
+ scene.mvp.perspective(45.0f, m_pixelSize.width() / (float) m_pixelSize.height(), 0.01f, 1000.0f);
+ scene.mvp.translate(0, 0, -4);
+ updateMvp();
+}
+//![init-2]
+
+//![rotation-update]
+void ExampleRhiWidget::updateMvp()
+{
+ QMatrix4x4 mvp = scene.mvp * QMatrix4x4(QQuaternion::fromEulerAngles(QVector3D(30, itemData.cubeRotation, 0)).toRotationMatrix());
+ if (!scene.resourceUpdates)
+ scene.resourceUpdates = m_rhi->nextResourceUpdateBatch();
+ scene.resourceUpdates->updateDynamicBuffer(scene.ubuf.get(), 0, 64, mvp.constData());
+}
+//![rotation-update]
+
+//![texture-update]
+void ExampleRhiWidget::updateCubeTexture()
+{
+ QImage image(CUBE_TEX_SIZE, QImage::Format_RGBA8888);
+ const QRect r(QPoint(0, 0), CUBE_TEX_SIZE);
+ QPainter p(&image);
+ p.fillRect(r, QGradient::DeepBlue);
+ QFont font;
+ font.setPointSize(24);
+ p.setFont(font);
+ p.drawText(r, itemData.cubeText);
+ p.end();
+
+ if (!scene.resourceUpdates)
+ scene.resourceUpdates = m_rhi->nextResourceUpdateBatch();
+ scene.resourceUpdates->uploadTexture(scene.cubeTex.get(), image);
+}
+//![texture-update]
+
+static QShader getShader(const QString &name)
+{
+ QFile f(name);
+ return f.open(QIODevice::ReadOnly) ? QShader::fromSerialized(f.readAll()) : QShader();
+}
+
+void ExampleRhiWidget::initScene()
+{
+//![setup-scene]
+ scene.vbuf.reset(m_rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(cube)));
+ scene.vbuf->create();
+
+ scene.resourceUpdates = m_rhi->nextResourceUpdateBatch();
+ scene.resourceUpdates->uploadStaticBuffer(scene.vbuf.get(), cube);
+
+ scene.ubuf.reset(m_rhi->newBuffer(QRhiBuffer::Dynamic, QRhiBuffer::UniformBuffer, 64));
+ scene.ubuf->create();
+
+ scene.cubeTex.reset(m_rhi->newTexture(QRhiTexture::RGBA8, CUBE_TEX_SIZE));
+ scene.cubeTex->create();
+
+ scene.sampler.reset(m_rhi->newSampler(QRhiSampler::Linear, QRhiSampler::Linear, QRhiSampler::None,
+ QRhiSampler::ClampToEdge, QRhiSampler::ClampToEdge));
+ scene.sampler->create();
+
+ scene.srb.reset(m_rhi->newShaderResourceBindings());
+ scene.srb->setBindings({
+ QRhiShaderResourceBinding::uniformBuffer(0, QRhiShaderResourceBinding::VertexStage, scene.ubuf.get()),
+ QRhiShaderResourceBinding::sampledTexture(1, QRhiShaderResourceBinding::FragmentStage, scene.cubeTex.get(), scene.sampler.get())
+ });
+ scene.srb->create();
+
+ scene.ps.reset(m_rhi->newGraphicsPipeline());
+ scene.ps->setDepthTest(true);
+ scene.ps->setDepthWrite(true);
+ scene.ps->setCullMode(QRhiGraphicsPipeline::Back);
+ scene.ps->setShaderStages({
+ { QRhiShaderStage::Vertex, getShader(QLatin1String(":/shader_assets/texture.vert.qsb")) },
+ { QRhiShaderStage::Fragment, getShader(QLatin1String(":/shader_assets/texture.frag.qsb")) }
+ });
+ QRhiVertexInputLayout inputLayout;
+ // The cube is provided as non-interleaved sets of positions, UVs, normals.
+ // Normals are not interesting here, only need the positions and UVs.
+ inputLayout.setBindings({
+ { 3 * sizeof(float) },
+ { 2 * sizeof(float) }
+ });
+ inputLayout.setAttributes({
+ { 0, 0, QRhiVertexInputAttribute::Float3, 0 },
+ { 1, 1, QRhiVertexInputAttribute::Float2, 0 }
+ });
+ scene.ps->setSampleCount(m_sampleCount);
+ scene.ps->setVertexInputLayout(inputLayout);
+ scene.ps->setShaderResourceBindings(scene.srb.get());
+ scene.ps->setRenderPassDescriptor(renderTarget()->renderPassDescriptor());
+ scene.ps->create();
+//![setup-scene]
+}
+
+//![render]
+void ExampleRhiWidget::render(QRhiCommandBuffer *cb)
+{
+ if (itemData.cubeRotationDirty) {
+ itemData.cubeRotationDirty = false;
+ updateMvp();
+ }
+
+ if (itemData.cubeTextDirty) {
+ itemData.cubeTextDirty = false;
+ updateCubeTexture();
+ }
+
+ QRhiResourceUpdateBatch *resourceUpdates = scene.resourceUpdates;
+ if (resourceUpdates)
+ scene.resourceUpdates = nullptr;
+
+ const QColor clearColor = QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f);
+ cb->beginPass(renderTarget(), clearColor, { 1.0f, 0 }, resourceUpdates);
+
+ cb->setGraphicsPipeline(scene.ps.get());
+ cb->setViewport(QRhiViewport(0, 0, m_pixelSize.width(), m_pixelSize.height()));
+ cb->setShaderResources();
+ const QRhiCommandBuffer::VertexInput vbufBindings[] = {
+ { scene.vbuf.get(), 0 },
+ { scene.vbuf.get(), quint32(36 * 3 * sizeof(float)) }
+ };
+ cb->setVertexInput(0, 2, vbufBindings);
+ cb->draw(36);
+
+ cb->endPass();
+}
+//![render]
+
+void ExampleRhiWidget::releaseResources()
+{
+ scene = {}; // a subsequent initialize() will recreate everything
+}
diff --git a/examples/widgets/rhi/cuberhiwidget/examplewidget.h b/examples/widgets/rhi/cuberhiwidget/examplewidget.h
new file mode 100644
index 0000000000..9cc554b3fb
--- /dev/null
+++ b/examples/widgets/rhi/cuberhiwidget/examplewidget.h
@@ -0,0 +1,72 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef EXAMPLEWIDGET_H
+#define EXAMPLEWIDGET_H
+
+#include <QRhiWidget>
+#include <rhi/qrhi.h>
+
+class ExampleRhiWidget : public QRhiWidget
+{
+ Q_OBJECT
+
+public:
+ ExampleRhiWidget(QWidget *parent = nullptr);
+
+ void initialize(QRhiCommandBuffer *cb) override;
+ void render(QRhiCommandBuffer *cb) override;
+ void releaseResources() override;
+//![data-setters]
+ void setCubeTextureText(const QString &s)
+ {
+ if (itemData.cubeText == s)
+ return;
+ itemData.cubeText = s;
+ itemData.cubeTextDirty = true;
+ update();
+ }
+
+ void setCubeRotation(float r)
+ {
+ if (itemData.cubeRotation == r)
+ return;
+ itemData.cubeRotation = r;
+ itemData.cubeRotationDirty = true;
+ update();
+ }
+//![data-setters]
+
+signals:
+ void resized();
+ void rhiChanged(const QString &apiName);
+
+private:
+ QRhi *m_rhi = nullptr;
+ int m_sampleCount = 1;
+ QSize m_pixelSize;
+
+ struct {
+ QRhiResourceUpdateBatch *resourceUpdates = nullptr;
+ std::unique_ptr<QRhiBuffer> vbuf;
+ std::unique_ptr<QRhiBuffer> ubuf;
+ std::unique_ptr<QRhiShaderResourceBindings> srb;
+ std::unique_ptr<QRhiGraphicsPipeline> ps;
+ std::unique_ptr<QRhiSampler> sampler;
+ std::unique_ptr<QRhiTexture> cubeTex;
+ QMatrix4x4 mvp;
+ } scene;
+
+ struct {
+ QString cubeText;
+ bool cubeTextDirty = false;
+ float cubeRotation = 0.0f;
+ bool cubeRotationDirty = false;
+ } itemData;
+
+ void initScene();
+ void updateMvp();
+ void updateCubeTexture();
+};
+
+#endif
diff --git a/examples/widgets/rhi/cuberhiwidget/main.cpp b/examples/widgets/rhi/cuberhiwidget/main.cpp
new file mode 100644
index 0000000000..95a29feee5
--- /dev/null
+++ b/examples/widgets/rhi/cuberhiwidget/main.cpp
@@ -0,0 +1,166 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QApplication>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QSlider>
+#include <QTextEdit>
+#include <QPushButton>
+#include <QLabel>
+#include <QCheckBox>
+#include <QFileDialog>
+#include <QFontInfo>
+#include <QMouseEvent>
+#include <QDrag>
+#include <QMimeData>
+#include "examplewidget.h"
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+
+ ExampleRhiWidget *rhiWidget = new ExampleRhiWidget;
+ QLabel *overlayLabel = new QLabel(rhiWidget);
+ overlayLabel->setText(QObject::tr("This is a\nsemi-transparent\n overlay widget\n"
+ "placed on top of\nthe QRhiWidget."));
+ overlayLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
+ overlayLabel->setAutoFillBackground(true);
+ QPalette semiTransparent(QColor(255, 0, 0, 64));
+ semiTransparent.setBrush(QPalette::Text, Qt::white);
+ semiTransparent.setBrush(QPalette::WindowText, Qt::white);
+ overlayLabel->setPalette(semiTransparent);
+ QFont f = overlayLabel->font();
+ f.setPixelSize(QFontInfo(f).pixelSize() * 2);
+ f.setWeight(QFont::Bold);
+ overlayLabel->setFont(f);
+ overlayLabel->resize(320, 320);
+ overlayLabel->hide();
+ QObject::connect(rhiWidget, &ExampleRhiWidget::resized, rhiWidget, [rhiWidget, overlayLabel] {
+ const int w = overlayLabel->width();
+ const int h = overlayLabel->height();
+ overlayLabel->setGeometry(rhiWidget->width() / 2 - w / 2, rhiWidget->height() / 2 - h / 2, w, h);
+ });
+
+ QTextEdit *edit = new QTextEdit(QObject::tr("QRhiWidget!<br><br>"
+ "The cube is textured with QPainter-generated content.<br><br>"
+ "Regular, non-native widgets on top work just fine."));
+ QObject::connect(edit, &QTextEdit::textChanged, edit, [edit, rhiWidget] {
+ rhiWidget->setCubeTextureText(edit->toPlainText());
+ });
+ edit->setMaximumHeight(100);
+ layout->addWidget(edit);
+
+ QSlider *slider = new QSlider(Qt::Horizontal);
+ slider->setMinimum(0);
+ slider->setMaximum(360);
+ QObject::connect(slider, &QSlider::valueChanged, slider, [slider, rhiWidget] {
+ rhiWidget->setCubeRotation(slider->value());
+ });
+
+ QHBoxLayout *sliderLayout = new QHBoxLayout;
+ sliderLayout->addWidget(new QLabel(QObject::tr("Cube rotation")));
+ sliderLayout->addWidget(slider);
+ layout->addLayout(sliderLayout);
+
+ QHBoxLayout *btnLayout = new QHBoxLayout;
+
+ QLabel *apiLabel = new QLabel;
+ btnLayout->addWidget(apiLabel);
+ QObject::connect(rhiWidget, &ExampleRhiWidget::rhiChanged, rhiWidget, [apiLabel](const QString &apiName) {
+ apiLabel->setText(QObject::tr("Using QRhi on ") + apiName);
+ });
+
+ QPushButton *btnMakeWindow = new QPushButton(QObject::tr("Make top-level window"));
+ QObject::connect(btnMakeWindow, &QPushButton::clicked, btnMakeWindow, [rhiWidget, btnMakeWindow, layout] {
+ if (rhiWidget->parentWidget()) {
+ rhiWidget->setParent(nullptr);
+ rhiWidget->setAttribute(Qt::WA_DeleteOnClose, true);
+ rhiWidget->show();
+ btnMakeWindow->setText(QObject::tr("Make child widget"));
+ } else {
+ rhiWidget->setAttribute(Qt::WA_DeleteOnClose, false);
+ layout->addWidget(rhiWidget);
+ btnMakeWindow->setText(QObject::tr("Make top-level window"));
+ }
+ });
+ btnLayout->addWidget(btnMakeWindow);
+
+ QPushButton *btn = new QPushButton(QObject::tr("Grab to image"));
+ QObject::connect(btn, &QPushButton::clicked, btn, [rhiWidget] {
+ QImage image = rhiWidget->grabFramebuffer();
+ qDebug() << "Got image" << image;
+ if (!image.isNull()) {
+ QFileDialog fd(rhiWidget->parentWidget());
+ fd.setAcceptMode(QFileDialog::AcceptSave);
+ fd.setDefaultSuffix("png");
+ fd.selectFile("test.png");
+ if (fd.exec() == QDialog::Accepted)
+ image.save(fd.selectedFiles().first());
+ }
+ });
+ btnLayout->addWidget(btn);
+
+ QCheckBox *cbMsaa = new QCheckBox(QObject::tr("Use 4x MSAA"));
+ QObject::connect(cbMsaa, &QCheckBox::stateChanged, cbMsaa, [cbMsaa, rhiWidget] {
+ if (cbMsaa->isChecked())
+ rhiWidget->setSampleCount(4);
+ else
+ rhiWidget->setSampleCount(1);
+ });
+ btnLayout->addWidget(cbMsaa);
+
+ QCheckBox *cbOvberlay = new QCheckBox(QObject::tr("Show overlay widget"));
+ QObject::connect(cbOvberlay, &QCheckBox::stateChanged, cbOvberlay, [cbOvberlay, overlayLabel] {
+ if (cbOvberlay->isChecked())
+ overlayLabel->setVisible(true);
+ else
+ overlayLabel->setVisible(false);
+ });
+ btnLayout->addWidget(cbOvberlay);
+
+ QCheckBox *cbFlip = new QCheckBox(QObject::tr("Flip"));
+ QObject::connect(cbFlip, &QCheckBox::stateChanged, cbOvberlay, [cbFlip, rhiWidget] {
+ rhiWidget->setMirrorVertically(cbFlip->isChecked());
+ });
+ btnLayout->addWidget(cbFlip);
+
+ QCheckBox *cbFixedSize = new QCheckBox(QObject::tr("Use fixed color buffer size"));
+ btnLayout->addWidget(cbFixedSize);
+ QSlider *fixedSizeSlider = new QSlider(Qt::Horizontal);
+ fixedSizeSlider->setMinimum(16);
+ fixedSizeSlider->setMaximum(512);
+ btnLayout->addWidget(fixedSizeSlider);
+
+ QObject::connect(cbFixedSize, &QCheckBox::stateChanged, cbFixedSize, [cbFixedSize, fixedSizeSlider, rhiWidget] {
+ if (cbFixedSize->isChecked())
+ rhiWidget->setFixedColorBufferSize(QSize(fixedSizeSlider->value(), fixedSizeSlider->value()));
+ else
+ rhiWidget->setFixedColorBufferSize(QSize());
+ });
+ QObject::connect(fixedSizeSlider, &QSlider::valueChanged, fixedSizeSlider, [fixedSizeSlider, cbFixedSize, rhiWidget] {
+ if (cbFixedSize->isChecked())
+ rhiWidget->setFixedColorBufferSize(QSize(fixedSizeSlider->value(), fixedSizeSlider->value()));
+ });
+
+ // Exit when the detached window is closed; there is not much we can do
+ // with the controls in the main window then.
+ QObject::connect(rhiWidget, &QObject::destroyed, rhiWidget, [rhiWidget] {
+ if (!rhiWidget->parentWidget())
+ qGuiApp->quit();
+ });
+
+ layout->addLayout(btnLayout);
+ layout->addWidget(rhiWidget);
+
+ rhiWidget->setCubeTextureText(edit->toPlainText());
+
+ QWidget w;
+ w.setLayout(layout);
+ w.resize(1280, 720);
+ w.show();
+
+ return app.exec();
+}
diff --git a/examples/widgets/rhi/cuberhiwidget/shader_assets/texture.frag.qsb b/examples/widgets/rhi/cuberhiwidget/shader_assets/texture.frag.qsb
new file mode 100644
index 0000000000..dc440d8067
--- /dev/null
+++ b/examples/widgets/rhi/cuberhiwidget/shader_assets/texture.frag.qsb
Binary files differ
diff --git a/examples/widgets/rhi/cuberhiwidget/shader_assets/texture.vert.qsb b/examples/widgets/rhi/cuberhiwidget/shader_assets/texture.vert.qsb
new file mode 100644
index 0000000000..84aed7fee2
--- /dev/null
+++ b/examples/widgets/rhi/cuberhiwidget/shader_assets/texture.vert.qsb
Binary files differ
diff --git a/examples/widgets/rhi/cuberhiwidget/shaders/texture.frag b/examples/widgets/rhi/cuberhiwidget/shaders/texture.frag
new file mode 100644
index 0000000000..9a14dc6eeb
--- /dev/null
+++ b/examples/widgets/rhi/cuberhiwidget/shaders/texture.frag
@@ -0,0 +1,12 @@
+#version 440
+
+layout(location = 0) in vec2 v_texcoord;
+layout(location = 0) out vec4 fragColor;
+
+layout(binding = 1) uniform sampler2D tex;
+
+void main()
+{
+ vec4 c = texture(tex, v_texcoord);
+ fragColor = vec4(c.rgb * c.a, c.a);
+}
diff --git a/examples/widgets/rhi/cuberhiwidget/shaders/texture.vert b/examples/widgets/rhi/cuberhiwidget/shaders/texture.vert
new file mode 100644
index 0000000000..a58a932abc
--- /dev/null
+++ b/examples/widgets/rhi/cuberhiwidget/shaders/texture.vert
@@ -0,0 +1,15 @@
+#version 440
+
+layout(location = 0) in vec4 position;
+layout(location = 1) in vec2 texcoord;
+layout(location = 0) out vec2 v_texcoord;
+
+layout(std140, binding = 0) uniform buf {
+ mat4 mvp;
+};
+
+void main()
+{
+ v_texcoord = vec2(texcoord.x, texcoord.y);
+ gl_Position = mvp * position;
+}
diff --git a/examples/widgets/rhi/rhi.pro b/examples/widgets/rhi/rhi.pro
new file mode 100644
index 0000000000..9248e5e0e3
--- /dev/null
+++ b/examples/widgets/rhi/rhi.pro
@@ -0,0 +1,4 @@
+requires(qtHaveModule(widgets))
+TEMPLATE = subdirs
+SUBDIRS = simplerhiwidget \
+ cuberhiwidget
diff --git a/examples/widgets/rhi/simplerhiwidget/CMakeLists.txt b/examples/widgets/rhi/simplerhiwidget/CMakeLists.txt
new file mode 100644
index 0000000000..cf471f1f8a
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/CMakeLists.txt
@@ -0,0 +1,48 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(simplerhiwidget LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(simplerhiwidget
+ examplewidget.cpp examplewidget.h
+ main.cpp
+)
+
+set_target_properties(simplerhiwidget PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+# needs GuiPrivate to be able to include <rhi/qrhi.h>
+target_link_libraries(simplerhiwidget PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::GuiPrivate
+ Qt6::Widgets
+)
+
+qt_add_resources(simplerhiwidget "simplerhiwidget"
+ PREFIX
+ "/"
+ FILES
+ "shader_assets/color.vert.qsb"
+ "shader_assets/color.frag.qsb"
+)
+
+install(TARGETS simplerhiwidget
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET simplerhiwidget
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/rhi/simplerhiwidget/examplewidget.cpp b/examples/widgets/rhi/simplerhiwidget/examplewidget.cpp
new file mode 100644
index 0000000000..7de33059a3
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/examplewidget.cpp
@@ -0,0 +1,102 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "examplewidget.h"
+#include <QFile>
+
+static float vertexData[] = {
+ 0.0f, 0.5f, 1.0f, 0.0f, 0.0f,
+ -0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
+ 0.5f, -0.5f, 0.0f, 0.0f, 1.0f,
+};
+
+//![get-shader]
+static QShader getShader(const QString &name)
+{
+ QFile f(name);
+ return f.open(QIODevice::ReadOnly) ? QShader::fromSerialized(f.readAll()) : QShader();
+}
+//![get-shader]
+
+//![init-1]
+void ExampleRhiWidget::initialize(QRhiCommandBuffer *cb)
+{
+ if (m_rhi != rhi()) {
+ m_pipeline.reset();
+ m_rhi = rhi();
+ }
+//![init-1]
+//![init-pipeline]
+ if (!m_pipeline) {
+ m_vbuf.reset(m_rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(vertexData)));
+ m_vbuf->create();
+
+ m_ubuf.reset(m_rhi->newBuffer(QRhiBuffer::Dynamic, QRhiBuffer::UniformBuffer, 64));
+ m_ubuf->create();
+
+ m_srb.reset(m_rhi->newShaderResourceBindings());
+ m_srb->setBindings({
+ QRhiShaderResourceBinding::uniformBuffer(0, QRhiShaderResourceBinding::VertexStage, m_ubuf.get()),
+ });
+ m_srb->create();
+
+ m_pipeline.reset(m_rhi->newGraphicsPipeline());
+ m_pipeline->setShaderStages({
+ { QRhiShaderStage::Vertex, getShader(QLatin1String(":/shader_assets/color.vert.qsb")) },
+ { QRhiShaderStage::Fragment, getShader(QLatin1String(":/shader_assets/color.frag.qsb")) }
+ });
+ QRhiVertexInputLayout inputLayout;
+ inputLayout.setBindings({
+ { 5 * sizeof(float) }
+ });
+ inputLayout.setAttributes({
+ { 0, 0, QRhiVertexInputAttribute::Float2, 0 },
+ { 0, 1, QRhiVertexInputAttribute::Float3, 2 * sizeof(float) }
+ });
+ m_pipeline->setVertexInputLayout(inputLayout);
+ m_pipeline->setShaderResourceBindings(m_srb.get());
+ m_pipeline->setRenderPassDescriptor(renderTarget()->renderPassDescriptor());
+ m_pipeline->create();
+
+ QRhiResourceUpdateBatch *resourceUpdates = m_rhi->nextResourceUpdateBatch();
+ resourceUpdates->uploadStaticBuffer(m_vbuf.get(), vertexData);
+ cb->resourceUpdate(resourceUpdates);
+ }
+//![init-pipeline]
+
+//![init-matrix]
+ const QSize outputSize = renderTarget()->pixelSize();
+ m_viewProjection = m_rhi->clipSpaceCorrMatrix();
+ m_viewProjection.perspective(45.0f, outputSize.width() / (float) outputSize.height(), 0.01f, 1000.0f);
+ m_viewProjection.translate(0, 0, -4);
+}
+//![init-matrix]
+
+//![render-1]
+void ExampleRhiWidget::render(QRhiCommandBuffer *cb)
+{
+ QRhiResourceUpdateBatch *resourceUpdates = m_rhi->nextResourceUpdateBatch();
+ m_rotation += 1.0f;
+ QMatrix4x4 modelViewProjection = m_viewProjection;
+ modelViewProjection.rotate(m_rotation, 0, 1, 0);
+ resourceUpdates->updateDynamicBuffer(m_ubuf.get(), 0, 64, modelViewProjection.constData());
+//![render-1]
+//![render-pass]
+ const QColor clearColor = QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f);
+ cb->beginPass(renderTarget(), clearColor, { 1.0f, 0 }, resourceUpdates);
+
+ cb->setGraphicsPipeline(m_pipeline.get());
+ const QSize outputSize = renderTarget()->pixelSize();
+ cb->setViewport(QRhiViewport(0, 0, outputSize.width(), outputSize.height()));
+ cb->setShaderResources();
+ const QRhiCommandBuffer::VertexInput vbufBinding(m_vbuf.get(), 0);
+ cb->setVertexInput(0, 1, &vbufBinding);
+ cb->draw(3);
+
+ cb->endPass();
+//![render-pass]
+
+//![render-2]
+ update();
+}
+//![render-2]
diff --git a/examples/widgets/rhi/simplerhiwidget/examplewidget.h b/examples/widgets/rhi/simplerhiwidget/examplewidget.h
new file mode 100644
index 0000000000..efd3b90d91
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/examplewidget.h
@@ -0,0 +1,30 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef EXAMPLEWIDGET_H
+#define EXAMPLEWIDGET_H
+
+//![0]
+#include <QRhiWidget>
+#include <rhi/qrhi.h>
+
+class ExampleRhiWidget : public QRhiWidget
+{
+public:
+ ExampleRhiWidget(QWidget *parent = nullptr) : QRhiWidget(parent) { }
+
+ void initialize(QRhiCommandBuffer *cb) override;
+ void render(QRhiCommandBuffer *cb) override;
+
+private:
+ QRhi *m_rhi = nullptr;
+ std::unique_ptr<QRhiBuffer> m_vbuf;
+ std::unique_ptr<QRhiBuffer> m_ubuf;
+ std::unique_ptr<QRhiShaderResourceBindings> m_srb;
+ std::unique_ptr<QRhiGraphicsPipeline> m_pipeline;
+ QMatrix4x4 m_viewProjection;
+ float m_rotation = 0.0f;
+};
+//![0]
+
+#endif
diff --git a/examples/widgets/rhi/simplerhiwidget/main.cpp b/examples/widgets/rhi/simplerhiwidget/main.cpp
new file mode 100644
index 0000000000..b9cf848125
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/main.cpp
@@ -0,0 +1,26 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QApplication>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include "examplewidget.h"
+
+//![0]
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ ExampleRhiWidget *rhiWidget = new ExampleRhiWidget;
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(rhiWidget);
+
+ QWidget w;
+ w.setLayout(layout);
+ w.resize(1280, 720);
+ w.show();
+
+ return app.exec();
+}
+//![0]
diff --git a/examples/widgets/rhi/simplerhiwidget/shader_assets/color.frag.qsb b/examples/widgets/rhi/simplerhiwidget/shader_assets/color.frag.qsb
new file mode 100644
index 0000000000..32bd2d5953
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/shader_assets/color.frag.qsb
Binary files differ
diff --git a/examples/widgets/rhi/simplerhiwidget/shader_assets/color.vert.qsb b/examples/widgets/rhi/simplerhiwidget/shader_assets/color.vert.qsb
new file mode 100644
index 0000000000..bf97035d7e
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/shader_assets/color.vert.qsb
Binary files differ
diff --git a/examples/widgets/rhi/simplerhiwidget/shaders/color.frag b/examples/widgets/rhi/simplerhiwidget/shaders/color.frag
new file mode 100644
index 0000000000..375587662f
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/shaders/color.frag
@@ -0,0 +1,10 @@
+#version 440
+
+layout(location = 0) in vec3 v_color;
+
+layout(location = 0) out vec4 fragColor;
+
+void main()
+{
+ fragColor = vec4(v_color, 1.0);
+}
diff --git a/examples/widgets/rhi/simplerhiwidget/shaders/color.vert b/examples/widgets/rhi/simplerhiwidget/shaders/color.vert
new file mode 100644
index 0000000000..e876f290e7
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/shaders/color.vert
@@ -0,0 +1,16 @@
+#version 440
+
+layout(location = 0) in vec4 position;
+layout(location = 1) in vec3 color;
+
+layout(location = 0) out vec3 v_color;
+
+layout(std140, binding = 0) uniform buf {
+ mat4 mvp;
+};
+
+void main()
+{
+ v_color = color;
+ gl_Position = mvp * position;
+}
diff --git a/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.pro b/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.pro
new file mode 100644
index 0000000000..2477d7f368
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+
+# needs gui-private to be able to include <rhi/qrhi.h>
+QT += gui-private widgets
+
+HEADERS += examplewidget.h
+SOURCES += examplewidget.cpp main.cpp
+
+RESOURCES += simplerhiwidget.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/widgets/rhi/simplerhiwidget
+INSTALLS += target
diff --git a/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.qrc b/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.qrc
new file mode 100644
index 0000000000..ddc6dfbe5a
--- /dev/null
+++ b/examples/widgets/rhi/simplerhiwidget/simplerhiwidget.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/">
+ <file>shader_assets/color.vert.qsb</file>
+ <file>shader_assets/color.frag.qsb</file>
+</qresource>
+</RCC>
diff --git a/examples/widgets/richtext/CMakeLists.txt b/examples/widgets/richtext/CMakeLists.txt
index ea4165b764..d62e88b3e8 100644
--- a/examples/widgets/richtext/CMakeLists.txt
+++ b/examples/widgets/richtext/CMakeLists.txt
@@ -1,7 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-qt_internal_add_example(calendar)
qt_internal_add_example(orderform)
qt_internal_add_example(syntaxhighlighter)
-qt_internal_add_example(textedit)
diff --git a/examples/widgets/richtext/calendar/CMakeLists.txt b/examples/widgets/richtext/calendar/CMakeLists.txt
deleted file mode 100644
index a66f002e3c..0000000000
--- a/examples/widgets/richtext/calendar/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(calendar LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/richtext/calendar")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(calendar
- main.cpp
- mainwindow.cpp mainwindow.h
-)
-
-set_target_properties(calendar PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(calendar PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS calendar
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/richtext/calendar/calendar.pro b/examples/widgets/richtext/calendar/calendar.pro
deleted file mode 100644
index 199c1dbb8d..0000000000
--- a/examples/widgets/richtext/calendar/calendar.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT += widgets
-requires(qtConfig(combobox))
-
-HEADERS = mainwindow.h
-SOURCES = main.cpp \
- mainwindow.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/richtext/calendar
-INSTALLS += target
diff --git a/examples/widgets/richtext/calendar/main.cpp b/examples/widgets/richtext/calendar/main.cpp
deleted file mode 100644
index 5641ae527a..0000000000
--- a/examples/widgets/richtext/calendar/main.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- MainWindow window;
- window.resize(640, 256);
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/richtext/calendar/mainwindow.cpp b/examples/widgets/richtext/calendar/mainwindow.cpp
deleted file mode 100644
index 0b44c96d46..0000000000
--- a/examples/widgets/richtext/calendar/mainwindow.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-
-#include <QtWidgets>
-
-//! [0]
-MainWindow::MainWindow()
-{
- selectedDate = QDate::currentDate();
- fontSize = 10;
-
- QWidget *centralWidget = new QWidget;
-//! [0]
-
-//! [1]
- QLabel *dateLabel = new QLabel(tr("Date:"));
- QComboBox *monthCombo = new QComboBox;
-
- for (int month = 1; month <= 12; ++month)
- monthCombo->addItem(QLocale::system().monthName(month));
-
- QDateTimeEdit *yearEdit = new QDateTimeEdit;
- yearEdit->setDisplayFormat("yyyy");
- yearEdit->setDateRange(QDate(1753, 1, 1), QDate(8000, 1, 1));
-//! [1]
-
- monthCombo->setCurrentIndex(selectedDate.month() - 1);
- yearEdit->setDate(selectedDate);
-
-//! [2]
- QLabel *fontSizeLabel = new QLabel(tr("Font size:"));
- QSpinBox *fontSizeSpinBox = new QSpinBox;
- fontSizeSpinBox->setRange(1, 64);
-
- editor = new QTextBrowser;
- insertCalendar();
-//! [2]
-
-//! [3]
- connect(monthCombo, &QComboBox::activated,
- this, &MainWindow::setMonth);
- connect(yearEdit, &QDateTimeEdit::dateChanged,
- this, &MainWindow::setYear);
- connect(fontSizeSpinBox, &QSpinBox::valueChanged,
- this, &MainWindow::setFontSize);
-//! [3]
-
- fontSizeSpinBox->setValue(10);
-
-//! [4]
- QHBoxLayout *controlsLayout = new QHBoxLayout;
- controlsLayout->addWidget(dateLabel);
- controlsLayout->addWidget(monthCombo);
- controlsLayout->addWidget(yearEdit);
- controlsLayout->addSpacing(24);
- controlsLayout->addWidget(fontSizeLabel);
- controlsLayout->addWidget(fontSizeSpinBox);
- controlsLayout->addStretch(1);
-
- QVBoxLayout *centralLayout = new QVBoxLayout;
- centralLayout->addLayout(controlsLayout);
- centralLayout->addWidget(editor, 1);
- centralWidget->setLayout(centralLayout);
-
- setCentralWidget(centralWidget);
-//! [4]
-}
-
-//! [5]
-void MainWindow::insertCalendar()
-{
- editor->clear();
- QTextCursor cursor = editor->textCursor();
- cursor.beginEditBlock();
-
- QDate date(selectedDate.year(), selectedDate.month(), 1);
-//! [5]
-
-//! [6]
- QTextTableFormat tableFormat;
- tableFormat.setAlignment(Qt::AlignHCenter);
- tableFormat.setBackground(QColor("#e0e0e0"));
- tableFormat.setCellPadding(2);
- tableFormat.setCellSpacing(4);
-//! [6] //! [7]
- QList<QTextLength> constraints;
- constraints << QTextLength(QTextLength::PercentageLength, 14)
- << QTextLength(QTextLength::PercentageLength, 14)
- << QTextLength(QTextLength::PercentageLength, 14)
- << QTextLength(QTextLength::PercentageLength, 14)
- << QTextLength(QTextLength::PercentageLength, 14)
- << QTextLength(QTextLength::PercentageLength, 14)
- << QTextLength(QTextLength::PercentageLength, 14);
- tableFormat.setColumnWidthConstraints(constraints);
-//! [7]
-
-//! [8]
- QTextTable *table = cursor.insertTable(1, 7, tableFormat);
-//! [8]
-
-//! [9]
- QTextFrame *frame = cursor.currentFrame();
- QTextFrameFormat frameFormat = frame->frameFormat();
- frameFormat.setBorder(1);
- frame->setFrameFormat(frameFormat);
-//! [9]
-
-//! [10]
- QTextCharFormat format = cursor.charFormat();
- format.setFontPointSize(fontSize);
-
- QTextCharFormat boldFormat = format;
- boldFormat.setFontWeight(QFont::Bold);
-
- QTextCharFormat highlightedFormat = boldFormat;
- highlightedFormat.setBackground(Qt::yellow);
-//! [10]
-
-//! [11]
- for (int weekDay = 1; weekDay <= 7; ++weekDay) {
- QTextTableCell cell = table->cellAt(0, weekDay-1);
-//! [11] //! [12]
- QTextCursor cellCursor = cell.firstCursorPosition();
- cellCursor.insertText(QLocale::system().dayName(weekDay), boldFormat);
- }
-//! [12]
-
-//! [13]
- table->insertRows(table->rows(), 1);
-//! [13]
-
- while (date.month() == selectedDate.month()) {
- int weekDay = date.dayOfWeek();
- QTextTableCell cell = table->cellAt(table->rows()-1, weekDay-1);
- QTextCursor cellCursor = cell.firstCursorPosition();
-
- if (date == QDate::currentDate())
- cellCursor.insertText(QString("%1").arg(date.day()), highlightedFormat);
- else
- cellCursor.insertText(QString("%1").arg(date.day()), format);
-
- date = date.addDays(1);
- if (weekDay == 7 && date.month() == selectedDate.month())
- table->insertRows(table->rows(), 1);
- }
-
- cursor.endEditBlock();
-//! [14]
- setWindowTitle(tr("Calendar for %1 %2"
- ).arg(QLocale::system().monthName(selectedDate.month())
- ).arg(selectedDate.year()));
-}
-//! [14]
-
-//! [15]
-void MainWindow::setFontSize(int size)
-{
- fontSize = size;
- insertCalendar();
-}
-//! [15]
-
-//! [16]
-void MainWindow::setMonth(int month)
-{
- selectedDate = QDate(selectedDate.year(), month + 1, selectedDate.day());
- insertCalendar();
-}
-//! [16]
-
-//! [17]
-void MainWindow::setYear(QDate date)
-{
- selectedDate = QDate(date.year(), selectedDate.month(), selectedDate.day());
- insertCalendar();
-}
-//! [17]
diff --git a/examples/widgets/richtext/calendar/mainwindow.h b/examples/widgets/richtext/calendar/mainwindow.h
deleted file mode 100644
index 76632820d6..0000000000
--- a/examples/widgets/richtext/calendar/mainwindow.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QDate>
-#include <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QTextBrowser;
-QT_END_NAMESPACE
-
-//! [0]
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
-public slots:
- void setFontSize(int size);
- void setMonth(int month);
- void setYear(QDate date);
-
-private:
- void insertCalendar();
-
- int fontSize;
- QDate selectedDate;
- QTextBrowser *editor;
-};
-//! [0]
-
-#endif // MAINWINDOW_H
diff --git a/examples/widgets/richtext/orderform/CMakeLists.txt b/examples/widgets/richtext/orderform/CMakeLists.txt
index c47b93eac9..eacf41fd1f 100644
--- a/examples/widgets/richtext/orderform/CMakeLists.txt
+++ b/examples/widgets/richtext/orderform/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(orderform LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/richtext/orderform")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(orderform
detailsdialog.cpp detailsdialog.h
main.cpp
@@ -25,20 +19,25 @@ set_target_properties(orderform PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(orderform PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(orderform PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
-if(TARGET Qt::PrintSupport)
- target_link_libraries(orderform PUBLIC
- Qt::PrintSupport
- )
+if(TARGET Qt6::PrintSupport)
+ target_link_libraries(orderform PRIVATE Qt6::PrintSupport)
endif()
install(TARGETS orderform
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET orderform
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/richtext/richtext.pro b/examples/widgets/richtext/richtext.pro
index 499733ecec..0d7f6c942a 100644
--- a/examples/widgets/richtext/richtext.pro
+++ b/examples/widgets/richtext/richtext.pro
@@ -1,5 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS = calendar \
- orderform \
- syntaxhighlighter \
- textedit
+SUBDIRS = orderform \
+ syntaxhighlighter
diff --git a/examples/widgets/richtext/syntaxhighlighter/CMakeLists.txt b/examples/widgets/richtext/syntaxhighlighter/CMakeLists.txt
index 56c1991994..13fd37ba1b 100644
--- a/examples/widgets/richtext/syntaxhighlighter/CMakeLists.txt
+++ b/examples/widgets/richtext/syntaxhighlighter/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(syntaxhighlighter LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/richtext/syntaxhighlighter")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(syntaxhighlighter
highlighter.cpp highlighter.h
main.cpp
@@ -25,14 +19,21 @@ set_target_properties(syntaxhighlighter PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(syntaxhighlighter PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(syntaxhighlighter PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS syntaxhighlighter
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET syntaxhighlighter
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/richtext/syntaxhighlighter/highlighter.cpp b/examples/widgets/richtext/syntaxhighlighter/highlighter.cpp
index 11e203c333..d78de20a7d 100644
--- a/examples/widgets/richtext/syntaxhighlighter/highlighter.cpp
+++ b/examples/widgets/richtext/syntaxhighlighter/highlighter.cpp
@@ -72,7 +72,7 @@ Highlighter::Highlighter(QTextDocument *parent)
//! [7]
void Highlighter::highlightBlock(const QString &text)
{
- for (const HighlightingRule &rule : qAsConst(highlightingRules)) {
+ for (const HighlightingRule &rule : std::as_const(highlightingRules)) {
QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
while (matchIterator.hasNext()) {
QRegularExpressionMatch match = matchIterator.next();
diff --git a/examples/widgets/richtext/textedit/CMakeLists.txt b/examples/widgets/richtext/textedit/CMakeLists.txt
deleted file mode 100644
index 504fe69233..0000000000
--- a/examples/widgets/richtext/textedit/CMakeLists.txt
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(textedit LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/richtext/textedit")
-
-find_package(Qt6
- REQUIRED COMPONENTS Core Gui Widgets
- OPTIONAL_COMPONENTS PrintSupport
-)
-
-qt_add_executable(textedit
- main.cpp
- textedit.cpp textedit.h
-)
-
-set_target_properties(textedit PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(textedit PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-if (TARGET Qt::PrintSupport)
- target_link_libraries(textedit PUBLIC Qt::PrintSupport)
-endif()
-
-# Resources:
-set(textedit_resource_files
- "example.html"
- "images/logo32.png"
- "images/mac/checkbox-checked.png"
- "images/mac/checkbox.png"
- "images/mac/editcopy.png"
- "images/mac/editcut.png"
- "images/mac/editpaste.png"
- "images/mac/editredo.png"
- "images/mac/editundo.png"
- "images/mac/exportpdf.png"
- "images/mac/filenew.png"
- "images/mac/fileopen.png"
- "images/mac/fileprint.png"
- "images/mac/filesave.png"
- "images/mac/format-indent-less.png"
- "images/mac/format-indent-more.png"
- "images/mac/textbold.png"
- "images/mac/textcenter.png"
- "images/mac/textitalic.png"
- "images/mac/textjustify.png"
- "images/mac/textleft.png"
- "images/mac/textright.png"
- "images/mac/textunder.png"
- "images/mac/textundercolor.png"
- "images/mac/zoomin.png"
- "images/mac/zoomout.png"
- "images/win/checkbox-checked.png"
- "images/win/checkbox.png"
- "images/win/editcopy.png"
- "images/win/editcut.png"
- "images/win/editpaste.png"
- "images/win/editredo.png"
- "images/win/editundo.png"
- "images/win/exportpdf.png"
- "images/win/filenew.png"
- "images/win/fileopen.png"
- "images/win/fileprint.png"
- "images/win/filesave.png"
- "images/win/format-indent-less.png"
- "images/win/format-indent-more.png"
- "images/win/textbold.png"
- "images/win/textcenter.png"
- "images/win/textitalic.png"
- "images/win/textjustify.png"
- "images/win/textleft.png"
- "images/win/textright.png"
- "images/win/textunder.png"
- "images/win/textundercolor.png"
- "images/win/zoomin.png"
- "images/win/zoomout.png"
-)
-
-qt_add_resources(textedit "textedit"
- PREFIX
- "/"
- FILES
- ${textedit_resource_files}
-)
-
-if(TARGET Qt::PrintSupport)
- target_link_libraries(textedit PUBLIC
- Qt::PrintSupport
- )
-endif()
-
-install(TARGETS textedit
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/richtext/textedit/example.html b/examples/widgets/richtext/textedit/example.html
deleted file mode 100644
index ebae3362e9..0000000000
--- a/examples/widgets/richtext/textedit/example.html
+++ /dev/null
@@ -1,84 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
-<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><title>QTextEdit Example</title><style type="text/css">
-p, li { white-space: pre-wrap; }
-hr { height: 1px; border-width: 0; }
-</style></head><body style=" font-family:'Helvetica'; font-size:9pt; font-weight:400; font-style:normal;">
-<h1 align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:20pt; font-weight:600;">QTextEdit</span></h1>
-<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">The QTextEdit widget is an advanced editor that supports formatted rich text. It can be used to display HTML and other rich document formats. Internally, QTextEdit uses the QTextDocument class to describe both the high-level structure of each document and the low-level formatting of paragraphs.</span></p>
-<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">If you are viewing this document in the <span style=" font-style:italic;">textedit</span> example, you can edit this document to explore Qt's rich text editing features. We have included some comments in each of the following sections to encourage you to experiment. </p>
-<h2 style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:18pt; font-weight:600;"><span style=" font-size:16pt;">Font and Paragraph Styles</span></h2>
-<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">QTextEdit supports </span><span style=" font-size:11pt; font-weight:600;">bold</span><span style=" font-size:11pt;">, </span><span style=" font-size:11pt; font-style:italic;">italic</span><span style=" font-size:11pt;">, and </span><span style=" font-size:11pt; text-decoration: underline;">underlined</span><span style=" font-size:11pt;"> font styles, and can display </span><span style=" font-size:11pt; font-weight:600; color:#00007f;">multicolored</span><span style=" font-size:11pt;"> </span><span style=" font-size:11pt; font-weight:600; color:#aa0000;">text</span><span style=" font-size:11pt;">. Font families such as </span><span style=" font-family:'Times New Roman'; font-size:11pt; font-weight:600;">Times New Roman</span><span style=" font-size:11pt;"> and </span><span style=" font-family:'Courier'; font-size:11pt; font-weight:600;">Courier</span><span style=" font-size:11pt;"> can also be used directly. </span><span style=" font-size:11pt; font-style:italic;">If you place the cursor in a region of styled text, the controls in the tool bars will change to reflect the current style.</span></p>
-<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Paragraphs can be formatted so that the text is left-aligned, right-aligned, centered, or fully justified.</p>
-<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-style:italic;">Try changing the alignment of some text and resize the editor to see how the text layout changes.</span> </p>
-<h2 align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600;">Lists</span></h2>
-<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">Different kinds of lists can be included in rich text documents. Standard bullet lists can be nested, using different symbols for each level of the list: </span></p>
-<ul style="-qt-list-indent: 1;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Disc symbols are typically used for top-level list items. </li></ul>
-<ul type=circle style="-qt-list-indent: 2;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Circle symbols can be used to distinguish between items in lower-level lists.</li></ul>
-<ul type=square style="-qt-list-indent: 3;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Square symbols provide a reasonable alternative to discs and circles. </li></ul>
-<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Ordered lists can be created that can be used for tables of contents. Different characters can be used to enumerate items, and we can use both Roman and Arabic numerals in the same list structure: </p>
-<ol style="-qt-list-indent: 1;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Introduction</li>
-<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Tools </li></ol>
-<ol type=a style="-qt-list-indent: 2;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Assistant</li>
-<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Designer</li>
-<ol type=A style="-qt-list-indent: 3;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Form Editor</li>
-<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Component Architecture</li></ol>
-<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Linguist</li></ol>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">The list will automatically be renumbered if you add or remove items. <span style=" font-style:italic;">Try adding new sections to the above list or removing existing item to see the numbers change.</span> </p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
-<h2 style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Images</span></h2>
-<p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">Inline images are treated like ordinary ranges of characters in the text editor, so they flow with the surrounding text. Images can also be selected in the same way as text, making it easy to cut, copy, and paste them. </span></p>
-<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><img src=":/images/logo32.png" /><span style=" font-style:italic;"> Try to select this image by clicking and dragging over it with the mouse, or use the text cursor to select it by holding down Shift and using the arrow keys. You can then cut or copy it, and paste it into different parts of this document.</span></p>
-<h2 align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600;">Horizontal Rule</span></h2>
-<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Here is an example:</p>
-<hr width="50%" style=" background-color:green;"/>
-<h2 align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Tables</span></h2>
-<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">QTextEdit can arrange and format tables, supporting features such as row and column spans, text formatting within cells, and size constraints for columns. </span></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
-<table border="1" align="center" width="90%" cellspacing="0" cellpadding="4">
-<tr>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> </p></td>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Development Tools </span></p></td>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Programming Techniques </span></p></td>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Graphical User Interfaces </span></p></td></tr>
-<tr>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">9:00 - 11:00 </span></p></td>
-<td colspan="3">
-<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Introduction to <span style=" font-style:italic;">Qt </span></p></td></tr>
-<tr>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">11:00 - 13:00 </span></p></td>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Using <span style=" font-style:italic;">qmake</span> </p></td>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Object-oriented Programming </p></td>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Layouts in <span style=" font-style:italic;">Qt</span> </p></td></tr>
-<tr>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">13:00 - 15:00 </span></p></td>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Qt Designer</span> Tutorial </p></td>
-<td rowspan="2">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Extreme Programming </p></td>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Writing Custom Styles </p></td></tr>
-<tr>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">15:00 - 17:00 </span></p></td>
-<td>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Qt Linguist</span> and Internationalization </p></td>
-<td></td></tr></table>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
-<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt; font-style:italic;">Try adding text to the cells in the table and experiment with the alignment of the paragraphs.</p>
-<h2 style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Hyperlinks</span></h2>
-<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">QTextEdit is designed to support hyperlinks between documents, and this feature is used extensively in </span><span style=" font-size:11pt; font-style:italic;">Qt Assistant</span><span style=" font-size:11pt;">. Hyperlinks are automatically created when an HTML file is imported into an editor. Since the rich text framework supports hyperlinks natively, they can also be created programmatically.</span></p>
-<h2 style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Undo and Redo</span></h2>
-<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Full support for undo and redo operations is built into QTextEdit and the underlying rich text framework. Operations on a document can be packaged together to make editing a more comfortable experience for the user.</p>
-<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-style:italic;">Try making changes to this document and press Ctrl+Z to undo them. You can always recover the original contents of the document.</span> </p></body></html>
diff --git a/examples/widgets/richtext/textedit/example.md b/examples/widgets/richtext/textedit/example.md
deleted file mode 100644
index 15f3c3cacf..0000000000
--- a/examples/widgets/richtext/textedit/example.md
+++ /dev/null
@@ -1,104 +0,0 @@
-# QTextEdit
-
-The QTextEdit widget is an advanced editor that supports formatted rich text.
-It can be used to display HTML and other rich document formats. Internally,
-QTextEdit uses the QTextDocument class to describe both the high-level
-structure of each document and the low-level formatting of paragraphs.
-
-If you are viewing this document in the textedit example, you can edit this
-document to explore Qt's rich text editing features. We have included some
-comments in each of the following sections to encourage you to experiment.
-
-## Font and Paragraph Styles
-
-QTextEdit supports **bold**, *italic*, _underline_ &amp; ~~strikethrough~~ font
-styles, and can display
-<span style="font-size:10pt; font-weight:600; color:#00007f;"> multicolored</span>
-text. Font families such as
-<span style="font-family:Times New Roman">Times New Roman</span> and
-<span style="font-family:Courier">Courier</span>
-can also be used directly. *If you place the cursor in a region of styled text,
-the controls in the tool bars will change to reflect the current style.*
-
-Paragraphs can be formatted so that the text is left-aligned, right-aligned,
-centered, or fully justified.
-
-*Try changing the alignment of some text and resize the editor to see how the
-text layout changes.*
-
-## Lists
-
-Different kinds of lists can be included in rich text documents. Standard
-bullet lists can be nested, using different symbols for each level of the list:
-
-- Disc symbols are typically used for top-level list items.
- * Circle symbols can be used to distinguish between items in lower-level
- lists.
- + Square symbols provide a reasonable alternative to discs and circles.
-
-Ordered lists can be created that can be used for tables of contents. Different
-characters can be used to enumerate items, and we can use both Roman and Arabic
-numerals in the same list structure:
-
-1. Introduction
-2. Qt Tools
- 1) Qt Assistant
- 2) Qt Designer
- 1. Form Editor
- 2. Component Architecture
- 3) Qt Linguist
-
-The list will automatically be renumbered if you add or remove items. *Try
-adding new sections to the above list or removing existing item to see the
-numbers change.*
-
-Task lists can be used to track progress on projects:
-
-- [ ] This is not yet done
-- This is just a bullet point
-- [x] This is done
-
-## Images
-
-Inline images are treated like ordinary ranges of characters in the text
-editor, so they flow with the surrounding text. Images can also be selected in
-the same way as text, making it easy to cut, copy, and paste them.
-
-![logo](images/logo32.png "logo") *Try to select this image by clicking and
-dragging over it with the mouse, or use the text cursor to select it by holding
-down Shift and using the arrow keys. You can then cut or copy it, and paste it
-into different parts of this document.*
-
-## Tables
-
-QTextEdit can arrange and format tables, supporting features such as row and
-column spans, text formatting within cells, and size constraints for columns.
-
-| | Development Tools | Programming Techniques | Graphical User Interfaces |
-| ------------: | ----------------- | ---------------------- | ------------------------- |
-| 9:00 - 11:00 | Introduction to Qt |||
-| 11:00 - 13:00 | Using qmake | Object-oriented Programming | Layouts in Qt |
-| 13:00 - 15:00 | Qt Designer Tutorial | Extreme Programming | Writing Custom Styles |
-| 15:00 - 17:00 | Qt Linguist and Internationalization | &nbsp; | &nbsp; |
-
-*Try adding text to the cells in the table and experiment with the alignment of
-the paragraphs.*
-
-## Hyperlinks
-
-QTextEdit is designed to support hyperlinks between documents, and this feature
-is used extensively in
-[Qt Assistant](http://doc.qt.io/qt-5/qtassistant-index.html). Hyperlinks are
-automatically created when an HTML file is imported into an editor. Since the
-rich text framework supports hyperlinks natively, they can also be created
-programmatically.
-
-## Undo and Redo
-
-Full support for undo and redo operations is built into QTextEdit and the
-underlying rich text framework. Operations on a document can be packaged
-together to make editing a more comfortable experience for the user.
-
-*Try making changes to this document and press `Ctrl+Z` to undo them. You can
-always recover the original contents of the document.*
-
diff --git a/examples/widgets/richtext/textedit/images/logo32.png b/examples/widgets/richtext/textedit/images/logo32.png
deleted file mode 100644
index 5f91e9873b..0000000000
--- a/examples/widgets/richtext/textedit/images/logo32.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/checkbox-checked.png b/examples/widgets/richtext/textedit/images/mac/checkbox-checked.png
deleted file mode 100644
index a072d7fb5c..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/checkbox-checked.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/checkbox.png b/examples/widgets/richtext/textedit/images/mac/checkbox.png
deleted file mode 100644
index 4064909712..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/checkbox.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/editcopy.png b/examples/widgets/richtext/textedit/images/mac/editcopy.png
deleted file mode 100644
index f551364464..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/editcopy.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/editcut.png b/examples/widgets/richtext/textedit/images/mac/editcut.png
deleted file mode 100644
index a784fd5709..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/editcut.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/editpaste.png b/examples/widgets/richtext/textedit/images/mac/editpaste.png
deleted file mode 100644
index 64c0b2d6ab..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/editpaste.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/editredo.png b/examples/widgets/richtext/textedit/images/mac/editredo.png
deleted file mode 100644
index 8875bf246c..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/editredo.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/editundo.png b/examples/widgets/richtext/textedit/images/mac/editundo.png
deleted file mode 100644
index a3bd5e0bf2..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/editundo.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/exportpdf.png b/examples/widgets/richtext/textedit/images/mac/exportpdf.png
deleted file mode 100644
index 9e199407af..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/exportpdf.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/filenew.png b/examples/widgets/richtext/textedit/images/mac/filenew.png
deleted file mode 100644
index d3882c7b3f..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/filenew.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/fileopen.png b/examples/widgets/richtext/textedit/images/mac/fileopen.png
deleted file mode 100644
index fc06c5ec63..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/fileopen.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/fileprint.png b/examples/widgets/richtext/textedit/images/mac/fileprint.png
deleted file mode 100644
index 10ca56c82a..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/fileprint.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/filesave.png b/examples/widgets/richtext/textedit/images/mac/filesave.png
deleted file mode 100644
index e65a29d5f1..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/filesave.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/format-indent-less.png b/examples/widgets/richtext/textedit/images/mac/format-indent-less.png
deleted file mode 100644
index e38074e78b..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/format-indent-less.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/format-indent-more.png b/examples/widgets/richtext/textedit/images/mac/format-indent-more.png
deleted file mode 100644
index 1bdeabd354..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/format-indent-more.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/textbold.png b/examples/widgets/richtext/textedit/images/mac/textbold.png
deleted file mode 100644
index 38400bd1f6..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/textbold.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/textcenter.png b/examples/widgets/richtext/textedit/images/mac/textcenter.png
deleted file mode 100644
index 2ef5b2ee6f..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/textcenter.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/textitalic.png b/examples/widgets/richtext/textedit/images/mac/textitalic.png
deleted file mode 100644
index 0170ee26a6..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/textitalic.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/textjustify.png b/examples/widgets/richtext/textedit/images/mac/textjustify.png
deleted file mode 100644
index 39cd6c1a9d..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/textjustify.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/textleft.png b/examples/widgets/richtext/textedit/images/mac/textleft.png
deleted file mode 100644
index 83a66d5535..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/textleft.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/textright.png b/examples/widgets/richtext/textedit/images/mac/textright.png
deleted file mode 100644
index e7c04645cf..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/textright.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/textunder.png b/examples/widgets/richtext/textedit/images/mac/textunder.png
deleted file mode 100644
index 968bac5e90..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/textunder.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/textundercolor.png b/examples/widgets/richtext/textedit/images/mac/textundercolor.png
deleted file mode 100644
index 30e24e61c3..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/textundercolor.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/zoomin.png b/examples/widgets/richtext/textedit/images/mac/zoomin.png
deleted file mode 100644
index d46f5aff0d..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/zoomin.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/mac/zoomout.png b/examples/widgets/richtext/textedit/images/mac/zoomout.png
deleted file mode 100644
index 46326566d1..0000000000
--- a/examples/widgets/richtext/textedit/images/mac/zoomout.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/checkbox-checked.png b/examples/widgets/richtext/textedit/images/win/checkbox-checked.png
deleted file mode 100644
index a072d7fb5c..0000000000
--- a/examples/widgets/richtext/textedit/images/win/checkbox-checked.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/checkbox.png b/examples/widgets/richtext/textedit/images/win/checkbox.png
deleted file mode 100644
index 4064909712..0000000000
--- a/examples/widgets/richtext/textedit/images/win/checkbox.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/editcopy.png b/examples/widgets/richtext/textedit/images/win/editcopy.png
deleted file mode 100644
index 1121b47d8b..0000000000
--- a/examples/widgets/richtext/textedit/images/win/editcopy.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/editcut.png b/examples/widgets/richtext/textedit/images/win/editcut.png
deleted file mode 100644
index 38e55f7420..0000000000
--- a/examples/widgets/richtext/textedit/images/win/editcut.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/editpaste.png b/examples/widgets/richtext/textedit/images/win/editpaste.png
deleted file mode 100644
index ffab15aaf8..0000000000
--- a/examples/widgets/richtext/textedit/images/win/editpaste.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/editredo.png b/examples/widgets/richtext/textedit/images/win/editredo.png
deleted file mode 100644
index 9d679fe6fc..0000000000
--- a/examples/widgets/richtext/textedit/images/win/editredo.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/editundo.png b/examples/widgets/richtext/textedit/images/win/editundo.png
deleted file mode 100644
index eee23d24a3..0000000000
--- a/examples/widgets/richtext/textedit/images/win/editundo.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/exportpdf.png b/examples/widgets/richtext/textedit/images/win/exportpdf.png
deleted file mode 100644
index ebb44e6b88..0000000000
--- a/examples/widgets/richtext/textedit/images/win/exportpdf.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/filenew.png b/examples/widgets/richtext/textedit/images/win/filenew.png
deleted file mode 100644
index af5d122141..0000000000
--- a/examples/widgets/richtext/textedit/images/win/filenew.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/fileopen.png b/examples/widgets/richtext/textedit/images/win/fileopen.png
deleted file mode 100644
index fc6f17e977..0000000000
--- a/examples/widgets/richtext/textedit/images/win/fileopen.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/fileprint.png b/examples/widgets/richtext/textedit/images/win/fileprint.png
deleted file mode 100644
index ba7c02dc18..0000000000
--- a/examples/widgets/richtext/textedit/images/win/fileprint.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/filesave.png b/examples/widgets/richtext/textedit/images/win/filesave.png
deleted file mode 100644
index 8feec99bee..0000000000
--- a/examples/widgets/richtext/textedit/images/win/filesave.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/format-indent-less.png b/examples/widgets/richtext/textedit/images/win/format-indent-less.png
deleted file mode 100644
index e38074e78b..0000000000
--- a/examples/widgets/richtext/textedit/images/win/format-indent-less.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/format-indent-more.png b/examples/widgets/richtext/textedit/images/win/format-indent-more.png
deleted file mode 100644
index 1bdeabd354..0000000000
--- a/examples/widgets/richtext/textedit/images/win/format-indent-more.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/textbold.png b/examples/widgets/richtext/textedit/images/win/textbold.png
deleted file mode 100644
index 9cbc7138b9..0000000000
--- a/examples/widgets/richtext/textedit/images/win/textbold.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/textcenter.png b/examples/widgets/richtext/textedit/images/win/textcenter.png
deleted file mode 100644
index 11efb4b852..0000000000
--- a/examples/widgets/richtext/textedit/images/win/textcenter.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/textitalic.png b/examples/widgets/richtext/textedit/images/win/textitalic.png
deleted file mode 100644
index b30ce14c14..0000000000
--- a/examples/widgets/richtext/textedit/images/win/textitalic.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/textjustify.png b/examples/widgets/richtext/textedit/images/win/textjustify.png
deleted file mode 100644
index 9de0c88085..0000000000
--- a/examples/widgets/richtext/textedit/images/win/textjustify.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/textleft.png b/examples/widgets/richtext/textedit/images/win/textleft.png
deleted file mode 100644
index 16f80bc325..0000000000
--- a/examples/widgets/richtext/textedit/images/win/textleft.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/textright.png b/examples/widgets/richtext/textedit/images/win/textright.png
deleted file mode 100644
index 16872df62a..0000000000
--- a/examples/widgets/richtext/textedit/images/win/textright.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/textunder.png b/examples/widgets/richtext/textedit/images/win/textunder.png
deleted file mode 100644
index c72eff53fb..0000000000
--- a/examples/widgets/richtext/textedit/images/win/textunder.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/textundercolor.png b/examples/widgets/richtext/textedit/images/win/textundercolor.png
deleted file mode 100644
index 30e24e61c3..0000000000
--- a/examples/widgets/richtext/textedit/images/win/textundercolor.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/zoomin.png b/examples/widgets/richtext/textedit/images/win/zoomin.png
deleted file mode 100644
index 2e586fc7bf..0000000000
--- a/examples/widgets/richtext/textedit/images/win/zoomin.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/zoomout.png b/examples/widgets/richtext/textedit/images/win/zoomout.png
deleted file mode 100644
index a736d39343..0000000000
--- a/examples/widgets/richtext/textedit/images/win/zoomout.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/richtext/textedit/main.cpp b/examples/widgets/richtext/textedit/main.cpp
deleted file mode 100644
index 076d5df8ae..0000000000
--- a/examples/widgets/richtext/textedit/main.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "textedit.h"
-
-#include <QApplication>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-#include <QScreen>
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(textedit);
-
- QApplication a(argc, argv);
- QCoreApplication::setOrganizationName("QtProject");
- QCoreApplication::setApplicationName("Rich Text");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription(QCoreApplication::applicationName());
- parser.addHelpOption();
- parser.addVersionOption();
- parser.addPositionalArgument("file", "The file to open.");
- parser.process(a);
-
- TextEdit mw;
-
- const QRect availableGeometry = mw.screen()->availableGeometry();
- mw.resize(availableGeometry.width() / 2, (availableGeometry.height() * 2) / 3);
- mw.move((availableGeometry.width() - mw.width()) / 2,
- (availableGeometry.height() - mw.height()) / 2);
-
- if (!mw.load(parser.positionalArguments().value(0, QLatin1String(":/example.html"))))
- mw.fileNew();
-
- mw.show();
- return a.exec();
-}
diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp
deleted file mode 100644
index 5a4d62c646..0000000000
--- a/examples/widgets/richtext/textedit/textedit.cpp
+++ /dev/null
@@ -1,851 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "textedit.h"
-
-#include <QActionGroup>
-#include <QApplication>
-#include <QClipboard>
-#include <QColorDialog>
-#include <QComboBox>
-#include <QFontComboBox>
-#include <QFile>
-#include <QFileDialog>
-#include <QFileInfo>
-#include <QFontDatabase>
-#include <QMenu>
-#include <QMenuBar>
-#include <QTextEdit>
-#include <QStatusBar>
-#include <QToolBar>
-#include <QTextCursor>
-#include <QTextDocumentWriter>
-#include <QTextList>
-#include <QtDebug>
-#include <QCloseEvent>
-#include <QMessageBox>
-#include <QMimeData>
-#include <QMimeDatabase>
-#include <QStringDecoder>
-#if defined(QT_PRINTSUPPORT_LIB)
-#include <QtPrintSupport/qtprintsupportglobal.h>
-#if QT_CONFIG(printer)
-#if QT_CONFIG(printdialog)
-#include <QPrintDialog>
-#endif
-#include <QPrinter>
-#if QT_CONFIG(printpreviewdialog)
-#include <QPrintPreviewDialog>
-#endif
-#endif
-#endif
-
-#ifdef Q_OS_MAC
-const QString rsrcPath = ":/images/mac";
-#else
-const QString rsrcPath = ":/images/win";
-#endif
-
-TextEdit::TextEdit(QWidget *parent)
- : QMainWindow(parent)
-{
-#ifdef Q_OS_MACOS
- setUnifiedTitleAndToolBarOnMac(true);
-#endif
- setWindowTitle(QCoreApplication::applicationName());
-
- textEdit = new QTextEdit(this);
- connect(textEdit, &QTextEdit::currentCharFormatChanged,
- this, &TextEdit::currentCharFormatChanged);
- connect(textEdit, &QTextEdit::cursorPositionChanged,
- this, &TextEdit::cursorPositionChanged);
- setCentralWidget(textEdit);
-
- setToolButtonStyle(Qt::ToolButtonFollowStyle);
- setupFileActions();
- setupEditActions();
- setupTextActions();
-
- {
- QMenu *helpMenu = menuBar()->addMenu(tr("Help"));
- helpMenu->addAction(tr("About"), this, &TextEdit::about);
- helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
- }
-
- QFont textFont("Helvetica");
- textFont.setStyleHint(QFont::SansSerif);
- textEdit->setFont(textFont);
- fontChanged(textEdit->font());
- colorChanged(textEdit->textColor());
- alignmentChanged(textEdit->alignment());
-
- auto *document = textEdit->document();
- connect(document, &QTextDocument::modificationChanged,
- actionSave, &QAction::setEnabled);
- connect(document, &QTextDocument::modificationChanged,
- this, &QWidget::setWindowModified);
- connect(document, &QTextDocument::undoAvailable,
- actionUndo, &QAction::setEnabled);
- connect(document, &QTextDocument::redoAvailable,
- actionRedo, &QAction::setEnabled);
-
- setWindowModified(document->isModified());
- actionSave->setEnabled(document->isModified());
- actionUndo->setEnabled(document->isUndoAvailable());
- actionRedo->setEnabled(document->isRedoAvailable());
-
-#ifndef QT_NO_CLIPBOARD
- actionCut->setEnabled(false);
- connect(textEdit, &QTextEdit::copyAvailable, actionCut, &QAction::setEnabled);
- actionCopy->setEnabled(false);
- connect(textEdit, &QTextEdit::copyAvailable, actionCopy, &QAction::setEnabled);
-
- connect(QGuiApplication::clipboard(), &QClipboard::dataChanged,
- this, &TextEdit::clipboardDataChanged);
-#endif
-
- textEdit->setFocus();
- setCurrentFileName(QString());
-
-#ifdef Q_OS_MACOS
- // Use dark text on light background on macOS, also in dark mode.
- QPalette pal = textEdit->palette();
- pal.setColor(QPalette::Base, QColor(Qt::white));
- pal.setColor(QPalette::Text, QColor(Qt::black));
- textEdit->setPalette(pal);
-#endif
-}
-
-void TextEdit::closeEvent(QCloseEvent *e)
-{
- if (maybeSave())
- e->accept();
- else
- e->ignore();
-}
-
-void TextEdit::setupFileActions()
-{
- QToolBar *tb = addToolBar(tr("File Actions"));
- QMenu *menu = menuBar()->addMenu(tr("&File"));
-
- const QIcon newIcon = QIcon::fromTheme("document-new", QIcon(rsrcPath + "/filenew.png"));
- QAction *a = menu->addAction(newIcon, tr("&New"), this, &TextEdit::fileNew);
- tb->addAction(a);
- a->setPriority(QAction::LowPriority);
- a->setShortcut(QKeySequence::New);
-
- const QIcon openIcon = QIcon::fromTheme("document-open", QIcon(rsrcPath + "/fileopen.png"));
- a = menu->addAction(openIcon, tr("&Open..."), this, &TextEdit::fileOpen);
- a->setShortcut(QKeySequence::Open);
- tb->addAction(a);
-
- menu->addSeparator();
-
- const QIcon saveIcon = QIcon::fromTheme("document-save", QIcon(rsrcPath + "/filesave.png"));
- actionSave = menu->addAction(saveIcon, tr("&Save"), this, &TextEdit::fileSave);
- actionSave->setShortcut(QKeySequence::Save);
- actionSave->setEnabled(false);
- tb->addAction(actionSave);
-
- a = menu->addAction(tr("Save &As..."), this, &TextEdit::fileSaveAs);
- a->setPriority(QAction::LowPriority);
- menu->addSeparator();
-
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
- const QIcon printIcon = QIcon::fromTheme("document-print", QIcon(rsrcPath + "/fileprint.png"));
- a = menu->addAction(printIcon, tr("&Print..."), this, &TextEdit::filePrint);
- a->setPriority(QAction::LowPriority);
- a->setShortcut(QKeySequence::Print);
- tb->addAction(a);
-
- const QIcon filePrintIcon = QIcon::fromTheme("fileprint", QIcon(rsrcPath + "/fileprint.png"));
- menu->addAction(filePrintIcon, tr("Print Preview..."), this, &TextEdit::filePrintPreview);
-
- const QIcon exportPdfIcon = QIcon::fromTheme("exportpdf", QIcon(rsrcPath + "/exportpdf.png"));
- a = menu->addAction(exportPdfIcon, tr("&Export PDF..."), this, &TextEdit::filePrintPdf);
- a->setPriority(QAction::LowPriority);
- a->setShortcut(Qt::CTRL | Qt::Key_D);
- tb->addAction(a);
-
- menu->addSeparator();
-#endif
-
- a = menu->addAction(tr("&Quit"), this, &QWidget::close);
- a->setShortcut(Qt::CTRL | Qt::Key_Q);
-}
-
-void TextEdit::setupEditActions()
-{
- QToolBar *tb = addToolBar(tr("Edit Actions"));
- QMenu *menu = menuBar()->addMenu(tr("&Edit"));
-
- const QIcon undoIcon = QIcon::fromTheme("edit-undo", QIcon(rsrcPath + "/editundo.png"));
- actionUndo = menu->addAction(undoIcon, tr("&Undo"), textEdit, &QTextEdit::undo);
- actionUndo->setShortcut(QKeySequence::Undo);
- tb->addAction(actionUndo);
-
- const QIcon redoIcon = QIcon::fromTheme("edit-redo", QIcon(rsrcPath + "/editredo.png"));
- actionRedo = menu->addAction(redoIcon, tr("&Redo"), textEdit, &QTextEdit::redo);
- actionRedo->setPriority(QAction::LowPriority);
- actionRedo->setShortcut(QKeySequence::Redo);
- tb->addAction(actionRedo);
- menu->addSeparator();
-
-#ifndef QT_NO_CLIPBOARD
- const QIcon cutIcon = QIcon::fromTheme("edit-cut", QIcon(rsrcPath + "/editcut.png"));
- actionCut = menu->addAction(cutIcon, tr("Cu&t"), textEdit, &QTextEdit::cut);
- actionCut->setPriority(QAction::LowPriority);
- actionCut->setShortcut(QKeySequence::Cut);
- tb->addAction(actionCut);
-
- const QIcon copyIcon = QIcon::fromTheme("edit-copy", QIcon(rsrcPath + "/editcopy.png"));
- actionCopy = menu->addAction(copyIcon, tr("&Copy"), textEdit, &QTextEdit::copy);
- actionCopy->setPriority(QAction::LowPriority);
- actionCopy->setShortcut(QKeySequence::Copy);
- tb->addAction(actionCopy);
-
- const QIcon pasteIcon = QIcon::fromTheme("edit-paste", QIcon(rsrcPath + "/editpaste.png"));
- actionPaste = menu->addAction(pasteIcon, tr("&Paste"), textEdit, &QTextEdit::paste);
- actionPaste->setPriority(QAction::LowPriority);
- actionPaste->setShortcut(QKeySequence::Paste);
- tb->addAction(actionPaste);
- if (const QMimeData *md = QGuiApplication::clipboard()->mimeData())
- actionPaste->setEnabled(md->hasText());
-#endif
-}
-
-void TextEdit::setupTextActions()
-{
- QToolBar *tb = addToolBar(tr("Format Actions"));
- QMenu *menu = menuBar()->addMenu(tr("F&ormat"));
-
- const QIcon boldIcon = QIcon::fromTheme("format-text-bold", QIcon(rsrcPath + "/textbold.png"));
- actionTextBold = menu->addAction(boldIcon, tr("&Bold"), this, &TextEdit::textBold);
- actionTextBold->setShortcut(Qt::CTRL | Qt::Key_B);
- actionTextBold->setPriority(QAction::LowPriority);
- QFont bold;
- bold.setBold(true);
- actionTextBold->setFont(bold);
- tb->addAction(actionTextBold);
- actionTextBold->setCheckable(true);
-
- const QIcon italicIcon = QIcon::fromTheme("format-text-italic", QIcon(rsrcPath + "/textitalic.png"));
- actionTextItalic = menu->addAction(italicIcon, tr("&Italic"), this, &TextEdit::textItalic);
- actionTextItalic->setPriority(QAction::LowPriority);
- actionTextItalic->setShortcut(Qt::CTRL | Qt::Key_I);
- QFont italic;
- italic.setItalic(true);
- actionTextItalic->setFont(italic);
- tb->addAction(actionTextItalic);
- actionTextItalic->setCheckable(true);
-
- const QIcon underlineIcon = QIcon::fromTheme("format-text-underline", QIcon(rsrcPath + "/textunder.png"));
- actionTextUnderline = menu->addAction(underlineIcon, tr("&Underline"), this, &TextEdit::textUnderline);
- actionTextUnderline->setShortcut(Qt::CTRL | Qt::Key_U);
- actionTextUnderline->setPriority(QAction::LowPriority);
- QFont underline;
- underline.setUnderline(true);
- actionTextUnderline->setFont(underline);
- tb->addAction(actionTextUnderline);
- actionTextUnderline->setCheckable(true);
-
- menu->addSeparator();
-
- const QIcon leftIcon = QIcon::fromTheme("format-justify-left", QIcon(rsrcPath + "/textleft.png"));
- actionAlignLeft = new QAction(leftIcon, tr("&Left"), this);
- actionAlignLeft->setShortcut(Qt::CTRL | Qt::Key_L);
- actionAlignLeft->setCheckable(true);
- actionAlignLeft->setPriority(QAction::LowPriority);
- const QIcon centerIcon = QIcon::fromTheme("format-justify-center", QIcon(rsrcPath + "/textcenter.png"));
- actionAlignCenter = new QAction(centerIcon, tr("C&enter"), this);
- actionAlignCenter->setShortcut(Qt::CTRL | Qt::Key_E);
- actionAlignCenter->setCheckable(true);
- actionAlignCenter->setPriority(QAction::LowPriority);
- const QIcon rightIcon = QIcon::fromTheme("format-justify-right", QIcon(rsrcPath + "/textright.png"));
- actionAlignRight = new QAction(rightIcon, tr("&Right"), this);
- actionAlignRight->setShortcut(Qt::CTRL | Qt::Key_R);
- actionAlignRight->setCheckable(true);
- actionAlignRight->setPriority(QAction::LowPriority);
- const QIcon fillIcon = QIcon::fromTheme("format-justify-fill", QIcon(rsrcPath + "/textjustify.png"));
- actionAlignJustify = new QAction(fillIcon, tr("&Justify"), this);
- actionAlignJustify->setShortcut(Qt::CTRL | Qt::Key_J);
- actionAlignJustify->setCheckable(true);
- actionAlignJustify->setPriority(QAction::LowPriority);
- const QIcon indentMoreIcon = QIcon::fromTheme("format-indent-more", QIcon(rsrcPath + "/format-indent-more.png"));
- actionIndentMore = menu->addAction(indentMoreIcon, tr("&Indent"), this, &TextEdit::indent);
- actionIndentMore->setShortcut(Qt::CTRL | Qt::Key_BracketRight);
- actionIndentMore->setPriority(QAction::LowPriority);
- const QIcon indentLessIcon = QIcon::fromTheme("format-indent-less", QIcon(rsrcPath + "/format-indent-less.png"));
- actionIndentLess = menu->addAction(indentLessIcon, tr("&Unindent"), this, &TextEdit::unindent);
- actionIndentLess->setShortcut(Qt::CTRL | Qt::Key_BracketLeft);
- actionIndentLess->setPriority(QAction::LowPriority);
-
- // Make sure the alignLeft is always left of the alignRight
- QActionGroup *alignGroup = new QActionGroup(this);
- connect(alignGroup, &QActionGroup::triggered, this, &TextEdit::textAlign);
-
- if (QGuiApplication::isLeftToRight()) {
- alignGroup->addAction(actionAlignLeft);
- alignGroup->addAction(actionAlignCenter);
- alignGroup->addAction(actionAlignRight);
- } else {
- alignGroup->addAction(actionAlignRight);
- alignGroup->addAction(actionAlignCenter);
- alignGroup->addAction(actionAlignLeft);
- }
- alignGroup->addAction(actionAlignJustify);
-
- tb->addActions(alignGroup->actions());
- menu->addActions(alignGroup->actions());
- tb->addAction(actionIndentMore);
- tb->addAction(actionIndentLess);
- menu->addAction(actionIndentMore);
- menu->addAction(actionIndentLess);
-
- menu->addSeparator();
-
- QPixmap pix(16, 16);
- pix.fill(Qt::black);
- actionTextColor = menu->addAction(pix, tr("&Color..."), this, &TextEdit::textColor);
- tb->addAction(actionTextColor);
-
- const QIcon underlineColorIcon(rsrcPath + "/textundercolor.png");
- actionUnderlineColor = menu->addAction(underlineColorIcon, tr("Underline color..."), this, &TextEdit::underlineColor);
- tb->addAction(actionUnderlineColor);
-
- menu->addSeparator();
-
- const QIcon checkboxIcon = QIcon::fromTheme("status-checkbox-checked", QIcon(rsrcPath + "/checkbox-checked.png"));
- actionToggleCheckState = menu->addAction(checkboxIcon, tr("Chec&ked"), this, &TextEdit::setChecked);
- actionToggleCheckState->setShortcut(Qt::CTRL | Qt::Key_K);
- actionToggleCheckState->setCheckable(true);
- actionToggleCheckState->setPriority(QAction::LowPriority);
- tb->addAction(actionToggleCheckState);
-
- tb = addToolBar(tr("Format Actions"));
- tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
- addToolBarBreak(Qt::TopToolBarArea);
- addToolBar(tb);
-
- comboStyle = new QComboBox(tb);
- tb->addWidget(comboStyle);
- comboStyle->addItems({"Standard",
- "Bullet List (Disc)",
- "Bullet List (Circle)",
- "Bullet List (Square)",
- "Task List (Unchecked)",
- "Task List (Checked)",
- "Ordered List (Decimal)",
- "Ordered List (Alpha lower)",
- "Ordered List (Alpha upper)",
- "Ordered List (Roman lower)",
- "Ordered List (Roman upper)",
- "Heading 1",
- "Heading 2",
- "Heading 3",
- "Heading 4",
- "Heading 5",
- "Heading 6"}),
-
- connect(comboStyle, &QComboBox::activated, this, &TextEdit::textStyle);
-
- comboFont = new QFontComboBox(tb);
- tb->addWidget(comboFont);
- connect(comboFont, &QComboBox::textActivated, this, &TextEdit::textFamily);
-
- comboSize = new QComboBox(tb);
- comboSize->setObjectName("comboSize");
- tb->addWidget(comboSize);
- comboSize->setEditable(true);
-
- const QList<int> standardSizes = QFontDatabase::standardSizes();
- for (int size : standardSizes)
- comboSize->addItem(QString::number(size));
- comboSize->setCurrentIndex(standardSizes.indexOf(QApplication::font().pointSize()));
-
- connect(comboSize, &QComboBox::textActivated, this, &TextEdit::textSize);
-}
-
-bool TextEdit::load(const QString &f)
-{
- if (!QFile::exists(f))
- return false;
- QFile file(f);
- if (!file.open(QFile::ReadOnly))
- return false;
-
- QByteArray data = file.readAll();
- QMimeDatabase db;
- const QString &mimeTypeName = db.mimeTypeForFileNameAndData(f, data).name();
- if (mimeTypeName == u"text/html") {
- auto encoding = QStringDecoder::encodingForHtml(data);
- QString str = QStringDecoder(encoding ? *encoding : QStringDecoder::Utf8)(data);
- QUrl fileUrl = f.startsWith(u':') ? QUrl(f) : QUrl::fromLocalFile(f);
- textEdit->document()->setBaseUrl(fileUrl.adjusted(QUrl::RemoveFilename));
- textEdit->setHtml(str);
-#if QT_CONFIG(textmarkdownreader)
- } else if (mimeTypeName == u"text/markdown") {
- textEdit->setMarkdown(QString::fromUtf8(data));
-#endif
- } else {
- textEdit->setPlainText(QString::fromUtf8(data));
- }
-
- setCurrentFileName(f);
- return true;
-}
-
-bool TextEdit::maybeSave()
-{
- if (!textEdit->document()->isModified())
- return true;
-
- const QMessageBox::StandardButton ret =
- QMessageBox::warning(this, QCoreApplication::applicationName(),
- tr("The document has been modified.\n"
- "Do you want to save your changes?"),
- QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
- if (ret == QMessageBox::Save)
- return fileSave();
- if (ret == QMessageBox::Cancel)
- return false;
- return true;
-}
-
-void TextEdit::setCurrentFileName(const QString &fileName)
-{
- this->fileName = fileName;
- textEdit->document()->setModified(false);
-
- QString shownName;
- if (fileName.isEmpty())
- shownName = "untitled.txt";
- else
- shownName = QFileInfo(fileName).fileName();
-
- setWindowTitle(tr("%1[*] - %2").arg(shownName, QCoreApplication::applicationName()));
- setWindowModified(false);
-}
-
-void TextEdit::fileNew()
-{
- if (maybeSave()) {
- textEdit->clear();
- setCurrentFileName({});
- }
-}
-
-void TextEdit::fileOpen()
-{
- QFileDialog fileDialog(this, tr("Open File..."));
- fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
- fileDialog.setFileMode(QFileDialog::ExistingFile);
- fileDialog.setMimeTypeFilters({
-#if QT_CONFIG(texthtmlparser)
- "text/html",
-#endif
-#if QT_CONFIG(textmarkdownreader)
-
- "text/markdown",
-#endif
- "text/plain"});
- if (fileDialog.exec() != QDialog::Accepted)
- return;
- const QString fn = fileDialog.selectedFiles().constFirst();
- if (load(fn))
- statusBar()->showMessage(tr("Opened \"%1\"").arg(QDir::toNativeSeparators(fn)));
- else
- statusBar()->showMessage(tr("Could not open \"%1\"").arg(QDir::toNativeSeparators(fn)));
-}
-
-bool TextEdit::fileSave()
-{
- if (fileName.isEmpty() || fileName.startsWith(u":/"))
- return fileSaveAs();
-
- QTextDocumentWriter writer(fileName);
- bool success = writer.write(textEdit->document());
- if (success) {
- textEdit->document()->setModified(false);
- statusBar()->showMessage(tr("Wrote \"%1\"").arg(QDir::toNativeSeparators(fileName)));
- } else {
- statusBar()->showMessage(tr("Could not write to file \"%1\"")
- .arg(QDir::toNativeSeparators(fileName)));
- }
- return success;
-}
-
-bool TextEdit::fileSaveAs()
-{
- QFileDialog fileDialog(this, tr("Save as..."));
- fileDialog.setAcceptMode(QFileDialog::AcceptSave);
- QStringList mimeTypes{"text/plain",
-#if QT_CONFIG(textodfwriter)
- "application/vnd.oasis.opendocument.text",
-#endif
-#if QT_CONFIG(textmarkdownwriter)
- "text/markdown",
-#endif
- "text/html"};
- fileDialog.setMimeTypeFilters(mimeTypes);
-#if QT_CONFIG(textodfwriter)
- fileDialog.setDefaultSuffix("odt");
-#endif
- if (fileDialog.exec() != QDialog::Accepted)
- return false;
- const QString fn = fileDialog.selectedFiles().constFirst();
- setCurrentFileName(fn);
- return fileSave();
-}
-
-void TextEdit::filePrint()
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
- QPrinter printer(QPrinter::HighResolution);
- QPrintDialog dlg(&printer, this);
- if (textEdit->textCursor().hasSelection())
- dlg.setOption(QAbstractPrintDialog::PrintSelection);
- dlg.setWindowTitle(tr("Print Document"));
- if (dlg.exec() == QDialog::Accepted)
- textEdit->print(&printer);
-#endif
-}
-
-void TextEdit::filePrintPreview()
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printpreviewdialog)
- QPrinter printer(QPrinter::HighResolution);
- QPrintPreviewDialog preview(&printer, this);
- connect(&preview, &QPrintPreviewDialog::paintRequested, textEdit, &QTextEdit::print);
- preview.exec();
-#endif
-}
-
-void TextEdit::filePrintPdf()
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
-//! [0]
- QFileDialog fileDialog(this, tr("Export PDF"));
- fileDialog.setAcceptMode(QFileDialog::AcceptSave);
- fileDialog.setMimeTypeFilters(QStringList("application/pdf"));
- fileDialog.setDefaultSuffix("pdf");
- if (fileDialog.exec() != QDialog::Accepted)
- return;
- QString pdfFileName = fileDialog.selectedFiles().constFirst();
- QPrinter printer(QPrinter::HighResolution);
- printer.setOutputFormat(QPrinter::PdfFormat);
- printer.setOutputFileName(pdfFileName);
- textEdit->document()->print(&printer);
- statusBar()->showMessage(tr("Exported \"%1\"")
- .arg(QDir::toNativeSeparators(pdfFileName)));
-//! [0]
-#endif
-}
-
-void TextEdit::textBold()
-{
- QTextCharFormat fmt;
- fmt.setFontWeight(actionTextBold->isChecked() ? QFont::Bold : QFont::Normal);
- mergeFormatOnWordOrSelection(fmt);
-}
-
-void TextEdit::textUnderline()
-{
- QTextCharFormat fmt;
- fmt.setFontUnderline(actionTextUnderline->isChecked());
- mergeFormatOnWordOrSelection(fmt);
-}
-
-void TextEdit::textItalic()
-{
- QTextCharFormat fmt;
- fmt.setFontItalic(actionTextItalic->isChecked());
- mergeFormatOnWordOrSelection(fmt);
-}
-
-void TextEdit::textFamily(const QString &f)
-{
- QTextCharFormat fmt;
- fmt.setFontFamilies({f});
- mergeFormatOnWordOrSelection(fmt);
-}
-
-void TextEdit::textSize(const QString &p)
-{
- qreal pointSize = p.toFloat();
- if (pointSize > 0) {
- QTextCharFormat fmt;
- fmt.setFontPointSize(pointSize);
- mergeFormatOnWordOrSelection(fmt);
- }
-}
-
-void TextEdit::textStyle(int styleIndex)
-{
- QTextCursor cursor = textEdit->textCursor();
- QTextListFormat::Style style = QTextListFormat::ListStyleUndefined;
- QTextBlockFormat::MarkerType marker = QTextBlockFormat::MarkerType::NoMarker;
-
- switch (styleIndex) {
- case 1:
- style = QTextListFormat::ListDisc;
- break;
- case 2:
- style = QTextListFormat::ListCircle;
- break;
- case 3:
- style = QTextListFormat::ListSquare;
- break;
- case 4:
- if (cursor.currentList())
- style = cursor.currentList()->format().style();
- else
- style = QTextListFormat::ListDisc;
- marker = QTextBlockFormat::MarkerType::Unchecked;
- break;
- case 5:
- if (cursor.currentList())
- style = cursor.currentList()->format().style();
- else
- style = QTextListFormat::ListDisc;
- marker = QTextBlockFormat::MarkerType::Checked;
- break;
- case 6:
- style = QTextListFormat::ListDecimal;
- break;
- case 7:
- style = QTextListFormat::ListLowerAlpha;
- break;
- case 8:
- style = QTextListFormat::ListUpperAlpha;
- break;
- case 9:
- style = QTextListFormat::ListLowerRoman;
- break;
- case 10:
- style = QTextListFormat::ListUpperRoman;
- break;
- default:
- break;
- }
-
- cursor.beginEditBlock();
-
- QTextBlockFormat blockFmt = cursor.blockFormat();
-
- if (style == QTextListFormat::ListStyleUndefined) {
- blockFmt.setObjectIndex(-1);
- int headingLevel = styleIndex >= 11 ? styleIndex - 11 + 1 : 0; // H1 to H6, or Standard
- blockFmt.setHeadingLevel(headingLevel);
- cursor.setBlockFormat(blockFmt);
-
- int sizeAdjustment = headingLevel ? 4 - headingLevel : 0; // H1 to H6: +3 to -2
- QTextCharFormat fmt;
- fmt.setFontWeight(headingLevel ? QFont::Bold : QFont::Normal);
- fmt.setProperty(QTextFormat::FontSizeAdjustment, sizeAdjustment);
- cursor.select(QTextCursor::LineUnderCursor);
- cursor.mergeCharFormat(fmt);
- textEdit->mergeCurrentCharFormat(fmt);
- } else {
- blockFmt.setMarker(marker);
- cursor.setBlockFormat(blockFmt);
- QTextListFormat listFmt;
- if (cursor.currentList()) {
- listFmt = cursor.currentList()->format();
- } else {
- listFmt.setIndent(blockFmt.indent() + 1);
- blockFmt.setIndent(0);
- cursor.setBlockFormat(blockFmt);
- }
- listFmt.setStyle(style);
- cursor.createList(listFmt);
- }
-
- cursor.endEditBlock();
-}
-
-void TextEdit::textColor()
-{
- QColor col = QColorDialog::getColor(textEdit->textColor(), this);
- if (!col.isValid())
- return;
- QTextCharFormat fmt;
- fmt.setForeground(col);
- mergeFormatOnWordOrSelection(fmt);
- colorChanged(col);
-}
-
-void TextEdit::underlineColor()
-{
- QColor col = QColorDialog::getColor(Qt::black, this);
- if (!col.isValid())
- return;
- QTextCharFormat fmt;
- fmt.setUnderlineColor(col);
- mergeFormatOnWordOrSelection(fmt);
- colorChanged(col);
-}
-
-void TextEdit::textAlign(QAction *a)
-{
- if (a == actionAlignLeft)
- textEdit->setAlignment(Qt::AlignLeft | Qt::AlignAbsolute);
- else if (a == actionAlignCenter)
- textEdit->setAlignment(Qt::AlignHCenter);
- else if (a == actionAlignRight)
- textEdit->setAlignment(Qt::AlignRight | Qt::AlignAbsolute);
- else if (a == actionAlignJustify)
- textEdit->setAlignment(Qt::AlignJustify);
-}
-
-void TextEdit::setChecked(bool checked)
-{
- textStyle(checked ? 5 : 4);
-}
-
-void TextEdit::indent()
-{
- modifyIndentation(1);
-}
-
-void TextEdit::unindent()
-{
- modifyIndentation(-1);
-}
-
-void TextEdit::modifyIndentation(int amount)
-{
- QTextCursor cursor = textEdit->textCursor();
- cursor.beginEditBlock();
- if (cursor.currentList()) {
- QTextListFormat listFmt = cursor.currentList()->format();
- // See whether the line above is the list we want to move this item into,
- // or whether we need a new list.
- QTextCursor above(cursor);
- above.movePosition(QTextCursor::Up);
- if (above.currentList() && listFmt.indent() + amount == above.currentList()->format().indent()) {
- above.currentList()->add(cursor.block());
- } else {
- listFmt.setIndent(listFmt.indent() + amount);
- cursor.createList(listFmt);
- }
- } else {
- QTextBlockFormat blockFmt = cursor.blockFormat();
- blockFmt.setIndent(blockFmt.indent() + amount);
- cursor.setBlockFormat(blockFmt);
- }
- cursor.endEditBlock();
-}
-
-void TextEdit::currentCharFormatChanged(const QTextCharFormat &format)
-{
- fontChanged(format.font());
- colorChanged(format.foreground().color());
-}
-
-void TextEdit::cursorPositionChanged()
-{
- alignmentChanged(textEdit->alignment());
- QTextList *list = textEdit->textCursor().currentList();
- if (list) {
- switch (list->format().style()) {
- case QTextListFormat::ListDisc:
- comboStyle->setCurrentIndex(1);
- break;
- case QTextListFormat::ListCircle:
- comboStyle->setCurrentIndex(2);
- break;
- case QTextListFormat::ListSquare:
- comboStyle->setCurrentIndex(3);
- break;
- case QTextListFormat::ListDecimal:
- comboStyle->setCurrentIndex(6);
- break;
- case QTextListFormat::ListLowerAlpha:
- comboStyle->setCurrentIndex(7);
- break;
- case QTextListFormat::ListUpperAlpha:
- comboStyle->setCurrentIndex(8);
- break;
- case QTextListFormat::ListLowerRoman:
- comboStyle->setCurrentIndex(9);
- break;
- case QTextListFormat::ListUpperRoman:
- comboStyle->setCurrentIndex(10);
- break;
- default:
- comboStyle->setCurrentIndex(-1);
- break;
- }
- switch (textEdit->textCursor().block().blockFormat().marker()) {
- case QTextBlockFormat::MarkerType::NoMarker:
- actionToggleCheckState->setChecked(false);
- break;
- case QTextBlockFormat::MarkerType::Unchecked:
- comboStyle->setCurrentIndex(4);
- actionToggleCheckState->setChecked(false);
- break;
- case QTextBlockFormat::MarkerType::Checked:
- comboStyle->setCurrentIndex(5);
- actionToggleCheckState->setChecked(true);
- break;
- }
- } else {
- int headingLevel = textEdit->textCursor().blockFormat().headingLevel();
- comboStyle->setCurrentIndex(headingLevel ? headingLevel + 10 : 0);
- }
-}
-
-void TextEdit::clipboardDataChanged()
-{
-#ifndef QT_NO_CLIPBOARD
- if (const QMimeData *md = QGuiApplication::clipboard()->mimeData())
- actionPaste->setEnabled(md->hasText());
-#endif
-}
-
-void TextEdit::about()
-{
- QMessageBox::about(this, tr("About"), tr("This example demonstrates Qt's "
- "rich text editing facilities in action, providing an example "
- "document for you to experiment with."));
-}
-
-void TextEdit::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
-{
- QTextCursor cursor = textEdit->textCursor();
- if (!cursor.hasSelection())
- cursor.select(QTextCursor::WordUnderCursor);
- cursor.mergeCharFormat(format);
- textEdit->mergeCurrentCharFormat(format);
-}
-
-void TextEdit::fontChanged(const QFont &f)
-{
- comboFont->setCurrentIndex(comboFont->findText(QFontInfo(f).family()));
- comboSize->setCurrentIndex(comboSize->findText(QString::number(f.pointSize())));
- actionTextBold->setChecked(f.bold());
- actionTextItalic->setChecked(f.italic());
- actionTextUnderline->setChecked(f.underline());
-}
-
-void TextEdit::colorChanged(const QColor &c)
-{
- QPixmap pix(16, 16);
- pix.fill(c);
- actionTextColor->setIcon(pix);
-}
-
-void TextEdit::alignmentChanged(Qt::Alignment a)
-{
- if (a.testFlag(Qt::AlignLeft))
- actionAlignLeft->setChecked(true);
- else if (a.testFlag(Qt::AlignHCenter))
- actionAlignCenter->setChecked(true);
- else if (a.testFlag(Qt::AlignRight))
- actionAlignRight->setChecked(true);
- else if (a.testFlag(Qt::AlignJustify))
- actionAlignJustify->setChecked(true);
-}
-
diff --git a/examples/widgets/richtext/textedit/textedit.h b/examples/widgets/richtext/textedit/textedit.h
deleted file mode 100644
index 2184863edc..0000000000
--- a/examples/widgets/richtext/textedit/textedit.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef TEXTEDIT_H
-#define TEXTEDIT_H
-
-#include <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QComboBox;
-class QFontComboBox;
-class QTextEdit;
-class QTextCharFormat;
-class QMenu;
-class QPrinter;
-QT_END_NAMESPACE
-
-class TextEdit : public QMainWindow
-{
- Q_OBJECT
-
-public:
- TextEdit(QWidget *parent = nullptr);
-
- bool load(const QString &f);
-
-public slots:
- void fileNew();
-
-protected:
- void closeEvent(QCloseEvent *e) override;
-
-private slots:
- void fileOpen();
- bool fileSave();
- bool fileSaveAs();
- void filePrint();
- void filePrintPreview();
- void filePrintPdf();
-
- void textBold();
- void textUnderline();
- void textItalic();
- void textFamily(const QString &f);
- void textSize(const QString &p);
- void textStyle(int styleIndex);
- void textColor();
- void underlineColor();
- void textAlign(QAction *a);
- void setChecked(bool checked);
- void indent();
- void unindent();
-
- void currentCharFormatChanged(const QTextCharFormat &format);
- void cursorPositionChanged();
-
- void clipboardDataChanged();
- void about();
-
-private:
- void setupFileActions();
- void setupEditActions();
- void setupTextActions();
- bool maybeSave();
- void setCurrentFileName(const QString &fileName);
- void modifyIndentation(int amount);
-
- void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
- void fontChanged(const QFont &f);
- void colorChanged(const QColor &c);
- void alignmentChanged(Qt::Alignment a);
-
- QAction *actionSave;
- QAction *actionTextBold;
- QAction *actionTextUnderline;
- QAction *actionTextItalic;
- QAction *actionTextColor;
- QAction *actionUnderlineColor;
- QAction *actionAlignLeft;
- QAction *actionAlignCenter;
- QAction *actionAlignRight;
- QAction *actionAlignJustify;
- QAction *actionIndentLess;
- QAction *actionIndentMore;
- QAction *actionToggleCheckState;
- QAction *actionUndo;
- QAction *actionRedo;
-#ifndef QT_NO_CLIPBOARD
- QAction *actionCut;
- QAction *actionCopy;
- QAction *actionPaste;
-#endif
-
- QComboBox *comboStyle;
- QFontComboBox *comboFont;
- QComboBox *comboSize;
-
- QString fileName;
- QTextEdit *textEdit;
-};
-
-#endif // TEXTEDIT_H
diff --git a/examples/widgets/richtext/textedit/textedit.pro b/examples/widgets/richtext/textedit/textedit.pro
deleted file mode 100644
index b7a2155b0b..0000000000
--- a/examples/widgets/richtext/textedit/textedit.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-QT += widgets
-requires(qtConfig(filedialog))
-qtHaveModule(printsupport): QT += printsupport
-
-TEMPLATE = app
-TARGET = textedit
-
-HEADERS = textedit.h
-SOURCES = textedit.cpp \
- main.cpp
-
-RESOURCES += textedit.qrc
-build_all:!build_pass {
- CONFIG -= build_all
- CONFIG += release
-}
-
-EXAMPLE_FILES = textedit.qdoc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/richtext/textedit
-INSTALLS += target
diff --git a/examples/widgets/richtext/textedit/textedit.qdoc b/examples/widgets/richtext/textedit/textedit.qdoc
deleted file mode 100644
index 938fad36c8..0000000000
--- a/examples/widgets/richtext/textedit/textedit.qdoc
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*! \page textedit-example.html
-
- \ingroup examples
- \title Text Edit Example
-
- \brief This example displays a text editor with the user interface written
- in pure C++.
-
- A similar example which uses Qt Designer to produce the user
- interface is in the \l {Qt Designer Manual}.
-
-
- See \c{$QTDIR/examples/textedit} for the source code.
-
-*/
-
-
diff --git a/examples/widgets/richtext/textedit/textedit.qrc b/examples/widgets/richtext/textedit/textedit.qrc
deleted file mode 100644
index a30d50fdbf..0000000000
--- a/examples/widgets/richtext/textedit/textedit.qrc
+++ /dev/null
@@ -1,54 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/">
- <file>images/logo32.png</file>
- <file>images/mac/checkbox.png</file>
- <file>images/mac/checkbox-checked.png</file>
- <file>images/mac/editcopy.png</file>
- <file>images/mac/editcut.png</file>
- <file>images/mac/editpaste.png</file>
- <file>images/mac/editredo.png</file>
- <file>images/mac/editundo.png</file>
- <file>images/mac/exportpdf.png</file>
- <file>images/mac/filenew.png</file>
- <file>images/mac/fileopen.png</file>
- <file>images/mac/fileprint.png</file>
- <file>images/mac/filesave.png</file>
- <file>images/mac/format-indent-less.png</file>
- <file>images/mac/format-indent-more.png</file>
- <file>images/mac/textbold.png</file>
- <file>images/mac/textcenter.png</file>
- <file>images/mac/textitalic.png</file>
- <file>images/mac/textjustify.png</file>
- <file>images/mac/textleft.png</file>
- <file>images/mac/textright.png</file>
- <file>images/mac/textunder.png</file>
- <file>images/mac/textundercolor.png</file>
- <file>images/mac/zoomin.png</file>
- <file>images/mac/zoomout.png</file>
- <file>images/win/checkbox.png</file>
- <file>images/win/checkbox-checked.png</file>
- <file>images/win/editcopy.png</file>
- <file>images/win/editcut.png</file>
- <file>images/win/editpaste.png</file>
- <file>images/win/editredo.png</file>
- <file>images/win/editundo.png</file>
- <file>images/win/exportpdf.png</file>
- <file>images/win/filenew.png</file>
- <file>images/win/fileopen.png</file>
- <file>images/win/fileprint.png</file>
- <file>images/win/filesave.png</file>
- <file>images/win/format-indent-less.png</file>
- <file>images/win/format-indent-more.png</file>
- <file>images/win/textbold.png</file>
- <file>images/win/textcenter.png</file>
- <file>images/win/textitalic.png</file>
- <file>images/win/textjustify.png</file>
- <file>images/win/textleft.png</file>
- <file>images/win/textright.png</file>
- <file>images/win/textunder.png</file>
- <file>images/win/textundercolor.png</file>
- <file>images/win/zoomin.png</file>
- <file>images/win/zoomout.png</file>
- <file>example.html</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/scroller/CMakeLists.txt b/examples/widgets/scroller/CMakeLists.txt
deleted file mode 100644
index fb9ebc2848..0000000000
--- a/examples/widgets/scroller/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-qt_internal_add_example(graphicsview)
diff --git a/examples/widgets/scroller/graphicsview/CMakeLists.txt b/examples/widgets/scroller/graphicsview/CMakeLists.txt
deleted file mode 100644
index 92d27394a4..0000000000
--- a/examples/widgets/scroller/graphicsview/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(graphicsview LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/scroller/graphicsview")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(graphicsview
- main.cpp
-)
-
-set_target_properties(graphicsview PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(graphicsview PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS graphicsview
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/scroller/graphicsview/graphicsview.pro b/examples/widgets/scroller/graphicsview/graphicsview.pro
deleted file mode 100644
index 39bdb2bc2c..0000000000
--- a/examples/widgets/scroller/graphicsview/graphicsview.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-QT += widgets
-
-TEMPLATE = app
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/scroller/graphicsview
-INSTALLS += target
diff --git a/examples/widgets/scroller/graphicsview/main.cpp b/examples/widgets/scroller/graphicsview/main.cpp
deleted file mode 100644
index b8df2b1b2e..0000000000
--- a/examples/widgets/scroller/graphicsview/main.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtCore>
-#include <QtWidgets>
-
-#define NUM_ITEMS 100
-#define NUM_LISTS 10
-
-/*!
- \class RectObject
- Note that it needs to be a QGraphicsObject or else the gestures will not work correctly.
-*/
-class RectObject : public QGraphicsObject
-{
- Q_OBJECT
-
-public:
-
- RectObject(const QString &text, qreal x, qreal y, qreal width, qreal height, QBrush brush, QGraphicsItem *parent = nullptr)
- : QGraphicsObject(parent)
- , m_text(text)
- , m_rect(x, y, width, height)
- , m_pen(brush.color().lighter(), 3.0)
- , m_brush(brush)
- {
- setFlag(QGraphicsItem::ItemClipsToShape, true);
- }
-
- QRectF boundingRect() const override
- {
- // here we only want the size of the children and not the size of the children of the children...
- qreal halfpw = m_pen.widthF() / 2;
- QRectF rect = m_rect;
- if (halfpw > 0.0)
- rect.adjust(-halfpw, -halfpw, halfpw, halfpw);
-
- return rect;
- }
-
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
- {
- Q_UNUSED(option);
- Q_UNUSED(widget);
- painter->setPen(m_pen);
- painter->setBrush(m_brush);
- painter->drawRect(m_rect);
-
- painter->setPen(Qt::black);
- QFont f;
- f.setPixelSize(m_rect.height());
- painter->setFont(f);
- painter->drawText(m_rect, Qt::AlignCenter, m_text);
- }
-
- QString m_text;
- QRectF m_rect;
- QPen m_pen;
- QBrush m_brush;
-};
-
-class ViewObject : public QGraphicsObject
-{
- Q_OBJECT
-public:
- ViewObject(QGraphicsObject *parent)
- : QGraphicsObject(parent)
- { }
-
- QRectF boundingRect() const override
- {
- QRectF rect;
- const auto items = childItems();
- for (const QGraphicsItem *item : items)
- rect |= item->boundingRect().translated(item->pos());
- return rect;
- }
-
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override
- { }
-};
-
-class ListObject : public QGraphicsObject
-{
- Q_OBJECT
-
-public:
- ListObject(const QSizeF &size, bool useTouch)
- {
- m_size = size;
- setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
- // grab gesture via Touch or Mouse events
- QScroller::grabGesture(this, useTouch ? QScroller::TouchGesture : QScroller::LeftMouseButtonGesture);
-
- // this needs to be QGraphicsOBJECT - otherwise gesture recognition
- // will not work for the parent of the viewport (in this case the
- // list)
- m_viewport = new ViewObject(this);
-
- }
-
- QGraphicsObject *viewport() const
- {
- return m_viewport;
- }
-
- bool event(QEvent *e) override
- {
- switch (e->type()) {
-// ![2]
- case QEvent::ScrollPrepare: {
- QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e);
- se->setViewportSize(m_size);
- QRectF br = m_viewport->boundingRect();
- se->setContentPosRange(QRectF(0, 0,
- qMax(qreal(0), br.width() - m_size.width()),
- qMax(qreal(0), br.height() - m_size.height())));
- se->setContentPos(-m_viewport->pos());
- se->accept();
- return true;
- }
-// ![1]
-// ![2]
- case QEvent::Scroll: {
- QScrollEvent *se = static_cast<QScrollEvent *>(e);
- m_viewport->setPos(-se->contentPos() - se->overshootDistance());
- return true;
- }
-// ![2]
- default:
- break;
- }
- return QGraphicsObject::event(e);
- }
-
- bool sceneEvent(QEvent *e) override
- {
- switch (e->type()) {
- case QEvent::TouchBegin: {
- // We need to return true for the TouchBegin here in the
- // top-most graphics object - otherwise gestures in our parent
- // objects will NOT work at all (the accept() flag is already
- // set due to our setAcceptTouchEvents(true) call in the c'tor
- return true;
-
- }
- case QEvent::GraphicsSceneMousePress: {
- // We need to return true for the MousePress here in the
- // top-most graphics object - otherwise gestures in our parent
- // objects will NOT work at all (the accept() flag is already
- // set to true by Qt)
- return true;
-
- }
- default:
- break;
- }
- return QGraphicsObject::sceneEvent(e);
- }
-
- QRectF boundingRect() const override
- {
- return QRectF(0, 0, m_size.width() + 3, m_size.height());
- }
-
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
- {
- Q_UNUSED(option);
- Q_UNUSED(widget);
- painter->setPen(QPen(QColor(100, 100, 100), 3.0));
- painter->drawRect(QRectF(1.5, 1.5, m_size.width() - 3, m_size.height() - 3));
- }
-
- QSizeF m_size;
- ViewObject *m_viewport;
-};
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow(bool useTouch)
- {
- m_scene = new QGraphicsScene();
-
- // -- make the main list
- ListObject *mainList = new ListObject(QSizeF(780, 400), useTouch);
- mainList->setObjectName(QLatin1String("MainList"));
- m_scene->addItem(mainList);
-// ![3]
- for (int i=0; i<NUM_LISTS; i++) {
- ListObject *childList = new ListObject(QSizeF(mainList->m_size.width()/3, mainList->m_size.height()), useTouch);
- childList->setObjectName(QString("ChildList %1").arg(i));
- fillList(childList);
- childList->setParentItem(mainList->viewport());
- childList->setPos(i*mainList->m_size.width()/3, 0);
- }
- mainList->viewport()->setPos(0, 0);
-
-
- /*
- list1->setTransformOriginPoint(200, 200);
- list1->setRotation(135);
- list1->setPos(20 + 200 * .41, 20 + 200 * .41);
- */
-// ![3]
-
- m_view = new QGraphicsView(m_scene);
- setCentralWidget(m_view);
- setWindowTitle(tr("Gesture example"));
- m_scene->setSceneRect(0, 0, m_view->viewport()->width(), m_view->viewport()->height());
- }
-
- /**
- * Fills the list object \a list with RectObjects.
- */
- void fillList(ListObject *list)
- {
- qreal h = list->m_size.height() / 10;
- for (int i=0; i<NUM_ITEMS; i++) {
- QColor color = QColor(255*i/NUM_ITEMS, 255*(NUM_ITEMS-i)/NUM_ITEMS, 127*(i%2)+64*(i/2%2));
- QString text = QLatin1String("Item #") + QString::number(i);
- QGraphicsItem *rect = new RectObject(text, 0, 0, list->m_size.width() - 6, h - 3, QBrush(color), list->viewport());
- rect->setPos(3, h*i+3);
- }
- list->viewport()->setPos(0, 0);
- }
-
-
-protected:
- void resizeEvent(QResizeEvent *e) override
- {
- // resize the scene according to our own size to prevent scrolling
- m_scene->setSceneRect(0, 0, m_view->viewport()->width(), m_view->viewport()->height());
- QMainWindow::resizeEvent(e);
- }
-
- QGraphicsScene *m_scene;
- QGraphicsView *m_view;
-};
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
- bool touch = (a.arguments().contains(QLatin1String("--touch")));
- MainWindow mw(touch);
- mw.show();
-#ifdef Q_OS_MAC
- mw.raise();
-#endif
- return a.exec();
-}
-
-#include "main.moc"
diff --git a/examples/widgets/scroller/scroller.pro b/examples/widgets/scroller/scroller.pro
deleted file mode 100644
index bac3f26554..0000000000
--- a/examples/widgets/scroller/scroller.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += graphicsview
diff --git a/examples/widgets/tools/CMakeLists.txt b/examples/widgets/tools/CMakeLists.txt
index ded4db7bba..a5ec5c4a3e 100644
--- a/examples/widgets/tools/CMakeLists.txt
+++ b/examples/widgets/tools/CMakeLists.txt
@@ -1,22 +1,8 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
qt_internal_add_example(completer)
qt_internal_add_example(customcompleter)
-if(QT_FEATURE_translation)
- qt_internal_add_example(i18n)
-endif()
qt_internal_add_example(regularexpression)
-qt_internal_add_example(settingseditor)
-qt_internal_add_example(styleplugin)
qt_internal_add_example(treemodelcompleter)
-qt_internal_add_example(undo)
qt_internal_add_example(undoframework)
-
-if(QT_FEATURE_library)
- qt_internal_add_example(echoplugin)
-
- if(QT_FEATURE_inputdialog)
- qt_internal_add_example(plugandpaint)
- endif()
-endif()
diff --git a/examples/widgets/tools/completer/CMakeLists.txt b/examples/widgets/tools/completer/CMakeLists.txt
index fe805ed943..a4ad8055b9 100644
--- a/examples/widgets/tools/completer/CMakeLists.txt
+++ b/examples/widgets/tools/completer/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(completer LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/completer")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(completer
fsmodel.cpp fsmodel.h
main.cpp
@@ -25,10 +19,10 @@ set_target_properties(completer PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(completer PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(completer PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -45,7 +39,14 @@ qt_add_resources(completer "completer"
)
install(TARGETS completer
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET completer
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tools/completer/main.cpp b/examples/widgets/tools/completer/main.cpp
index 4ea6bc1ac9..060dfe5bd8 100644
--- a/examples/widgets/tools/completer/main.cpp
+++ b/examples/widgets/tools/completer/main.cpp
@@ -7,8 +7,6 @@
//! [0]
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(completer);
-
QApplication app(argc, argv);
MainWindow window;
window.show();
diff --git a/examples/widgets/tools/customcompleter/CMakeLists.txt b/examples/widgets/tools/customcompleter/CMakeLists.txt
index 82a3df1fa3..8340f2cfdf 100644
--- a/examples/widgets/tools/customcompleter/CMakeLists.txt
+++ b/examples/widgets/tools/customcompleter/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(customcompleter LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/customcompleter")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(customcompleter
main.cpp
mainwindow.cpp mainwindow.h
@@ -25,10 +19,10 @@ set_target_properties(customcompleter PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(customcompleter PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(customcompleter PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -44,7 +38,14 @@ qt_add_resources(customcompleter "customcompleter"
)
install(TARGETS customcompleter
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET customcompleter
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tools/customcompleter/main.cpp b/examples/widgets/tools/customcompleter/main.cpp
index 13e8544b90..060dfe5bd8 100644
--- a/examples/widgets/tools/customcompleter/main.cpp
+++ b/examples/widgets/tools/customcompleter/main.cpp
@@ -7,8 +7,6 @@
//! [0]
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(customcompleter);
-
QApplication app(argc, argv);
MainWindow window;
window.show();
diff --git a/examples/widgets/tools/echoplugin/CMakeLists.txt b/examples/widgets/tools/echoplugin/CMakeLists.txt
deleted file mode 100644
index f4b97aa357..0000000000
--- a/examples/widgets/tools/echoplugin/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(plugandpaint LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/echoplugin")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-add_subdirectory(plugin)
-add_subdirectory(echowindow)
diff --git a/examples/widgets/tools/echoplugin/echoplugin.pro b/examples/widgets/tools/echoplugin/echoplugin.pro
deleted file mode 100644
index 1e3d625b2f..0000000000
--- a/examples/widgets/tools/echoplugin/echoplugin.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-#! [0]
-TEMPLATE = subdirs
-SUBDIRS = echowindow \
- plugin
-#! [0]
diff --git a/examples/widgets/tools/echoplugin/echowindow/CMakeLists.txt b/examples/widgets/tools/echoplugin/echowindow/CMakeLists.txt
deleted file mode 100644
index d238b5c1c0..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-qt_add_executable(echopluginwindow
- echointerface.h
- echowindow.cpp echowindow.h
- main.cpp
-)
-
-set_target_properties(echopluginwindow PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(echopluginwindow PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-if(NOT QT6_IS_SHARED_LIBS_BUILD)
- target_link_libraries(echopluginwindow PRIVATE
- echoplugin
- )
-endif()
-
-install(TARGETS echopluginwindow
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/echoplugin/echowindow/echointerface.h b/examples/widgets/tools/echoplugin/echowindow/echointerface.h
deleted file mode 100644
index c36578fd21..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/echointerface.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef ECHOINTERFACE_H
-#define ECHOINTERFACE_H
-
-#include <QObject>
-#include <QString>
-
-//! [0]
-class EchoInterface
-{
-public:
- virtual ~EchoInterface() = default;
- virtual QString echo(const QString &message) = 0;
-};
-
-
-QT_BEGIN_NAMESPACE
-
-#define EchoInterface_iid "org.qt-project.Qt.Examples.EchoInterface"
-
-Q_DECLARE_INTERFACE(EchoInterface, EchoInterface_iid)
-QT_END_NAMESPACE
-
-//! [0]
-#endif
diff --git a/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp b/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp
deleted file mode 100644
index 718c412c33..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "echowindow.h"
-
-#include <QCoreApplication>
-#include <QDir>
-#include <QLabel>
-#include <QLayout>
-#include <QLineEdit>
-#include <QMessageBox>
-#include <QPluginLoader>
-#include <QPushButton>
-
-//! [0]
-EchoWindow::EchoWindow()
-{
- createGUI();
- setLayout(layout);
- setWindowTitle("Echo Plugin Example");
-
- if (!loadPlugin()) {
- QMessageBox::information(this, "Error", "Could not load the plugin");
- lineEdit->setEnabled(false);
- button->setEnabled(false);
- }
-}
-//! [0]
-
-//! [1]
-void EchoWindow::sendEcho()
-{
- QString text = echoInterface->echo(lineEdit->text());
- label->setText(text);
-}
-//! [1]
-
-//! [2]
-void EchoWindow::createGUI()
-{
- lineEdit = new QLineEdit;
- label = new QLabel;
- label->setFrameStyle(QFrame::Box | QFrame::Plain);
- button = new QPushButton(tr("Send Message"));
-
- connect(lineEdit, &QLineEdit::editingFinished,
- this, &EchoWindow::sendEcho);
- connect(button, &QPushButton::clicked,
- this, &EchoWindow::sendEcho);
-
- layout = new QGridLayout;
- layout->addWidget(new QLabel(tr("Message:")), 0, 0);
- layout->addWidget(lineEdit, 0, 1);
- layout->addWidget(new QLabel(tr("Answer:")), 1, 0);
- layout->addWidget(label, 1, 1);
- layout->addWidget(button, 2, 1, Qt::AlignRight);
- layout->setSizeConstraint(QLayout::SetFixedSize);
-}
-//! [2]
-
-//! [3]
-bool EchoWindow::loadPlugin()
-{
- QDir pluginsDir(QCoreApplication::applicationDirPath());
-#if defined(Q_OS_WIN)
- if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
- pluginsDir.cdUp();
-#elif defined(Q_OS_MAC)
- if (pluginsDir.dirName() == "MacOS") {
- pluginsDir.cdUp();
- pluginsDir.cdUp();
- pluginsDir.cdUp();
- }
-#endif
- pluginsDir.cd("plugins");
- const QStringList entries = pluginsDir.entryList(QDir::Files);
- for (const QString &fileName : entries) {
- QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
- QObject *plugin = pluginLoader.instance();
- if (plugin) {
- echoInterface = qobject_cast<EchoInterface *>(plugin);
- if (echoInterface)
- return true;
- pluginLoader.unload();
- }
- }
-
- return false;
-}
-//! [3]
diff --git a/examples/widgets/tools/echoplugin/echowindow/echowindow.h b/examples/widgets/tools/echoplugin/echowindow/echowindow.h
deleted file mode 100644
index 25d08162a9..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/echowindow.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef ECHODIALOG_H
-#define ECHODIALOG_H
-
-#include <QWidget>
-
-#include "echointerface.h"
-
-QT_BEGIN_NAMESPACE
-class QString;
-class QLineEdit;
-class QLabel;
-class QPushButton;
-class QGridLayout;
-QT_END_NAMESPACE
-
-//! [0]
-class EchoWindow : public QWidget
-{
- Q_OBJECT
-
-public:
- EchoWindow();
-
-private slots:
- void sendEcho();
-
-private:
- void createGUI();
- bool loadPlugin();
-
- EchoInterface *echoInterface;
- QLineEdit *lineEdit;
- QLabel *label;
- QPushButton *button;
- QGridLayout *layout;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/tools/echoplugin/echowindow/echowindow.pro b/examples/widgets/tools/echoplugin/echowindow/echowindow.pro
deleted file mode 100644
index 092258dd30..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/echowindow.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-QT += widgets
-
-HEADERS = echowindow.h \
- echointerface.h
-SOURCES = echowindow.cpp \
- main.cpp
-
-TARGET = echoplugin
-QMAKE_PROJECT_NAME = echopluginwindow
-win32 {
- CONFIG(debug, release|debug):DESTDIR = ../debug/
- CONFIG(release, release|debug):DESTDIR = ../release/
-} else {
- DESTDIR = ../
-}
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/echoplugin
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
diff --git a/examples/widgets/tools/echoplugin/echowindow/main.cpp b/examples/widgets/tools/echoplugin/echowindow/main.cpp
deleted file mode 100644
index c48af33773..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/main.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "echowindow.h"
-#include "echointerface.h"
-
-//! [0]
-int main(int argv, char *args[])
-{
- QApplication app(argv, args);
-
- EchoWindow window;
- window.show();
-
- return app.exec();
-}
-//! [0]
diff --git a/examples/widgets/tools/echoplugin/plugin/CMakeLists.txt b/examples/widgets/tools/echoplugin/plugin/CMakeLists.txt
deleted file mode 100644
index f4ee5f87e7..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/CMakeLists.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-qt_add_plugin(echoplugin
- CLASS_NAME EchoPlugin
- echoplugin.cpp echoplugin.h
-)
-
-set_target_properties(echoplugin PROPERTIES
- LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/echowindow"
-)
-
-target_include_directories(echoplugin PUBLIC
- ../echowindow
-)
-
-target_link_libraries(echoplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS echoplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/echoplugin/plugin/echoplugin.cpp b/examples/widgets/tools/echoplugin/plugin/echoplugin.cpp
deleted file mode 100644
index 55ccedb39e..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/echoplugin.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "echoplugin.h"
-
-//! [0]
-QString EchoPlugin::echo(const QString &message)
-{
- return message;
-}
-//! [0]
diff --git a/examples/widgets/tools/echoplugin/plugin/echoplugin.h b/examples/widgets/tools/echoplugin/plugin/echoplugin.h
deleted file mode 100644
index 13e630da03..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/echoplugin.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef ECHOPLUGIN_H
-#define ECHOPLUGIN_H
-
-#include <QObject>
-#include <QtPlugin>
-#include "echointerface.h"
-
-//! [0]
-class EchoPlugin : public QObject, EchoInterface
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.EchoInterface" FILE "echoplugin.json")
- Q_INTERFACES(EchoInterface)
-
-public:
- QString echo(const QString &message) override;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/tools/echoplugin/plugin/echoplugin.json b/examples/widgets/tools/echoplugin/plugin/echoplugin.json
deleted file mode 100644
index 0967ef424b..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/echoplugin.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
diff --git a/examples/widgets/tools/echoplugin/plugin/plugin.pro b/examples/widgets/tools/echoplugin/plugin/plugin.pro
deleted file mode 100644
index a4b54b18f6..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/plugin.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-#! [0]
-TEMPLATE = lib
-CONFIG += plugin
-QT += widgets
-INCLUDEPATH += ../echowindow
-HEADERS = echoplugin.h
-SOURCES = echoplugin.cpp
-TARGET = $$qtLibraryTarget(echoplugin)
-DESTDIR = ../plugins
-#! [0]
-
-EXAMPLE_FILES = echoplugin.json
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/echoplugin/plugins
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
diff --git a/examples/widgets/tools/i18n/CMakeLists.txt b/examples/widgets/tools/i18n/CMakeLists.txt
deleted file mode 100644
index 175f9934d7..0000000000
--- a/examples/widgets/tools/i18n/CMakeLists.txt
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(i18n LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/i18n")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(i18n
- languagechooser.cpp languagechooser.h
- main.cpp
- mainwindow.cpp mainwindow.h
-)
-
-set_target_properties(i18n PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(i18n PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(i18n_resource_files
- "translations/i18n_ar.qm"
- "translations/i18n_cs.qm"
- "translations/i18n_de.qm"
- "translations/i18n_el.qm"
- "translations/i18n_en.qm"
- "translations/i18n_eo.qm"
- "translations/i18n_fr.qm"
- "translations/i18n_it.qm"
- "translations/i18n_jp.qm"
- "translations/i18n_ko.qm"
- "translations/i18n_no.qm"
- "translations/i18n_ru.qm"
- "translations/i18n_sv.qm"
- "translations/i18n_zh.qm"
-)
-
-qt_add_resources(i18n "i18n"
- PREFIX
- "/"
- FILES
- ${i18n_resource_files}
-)
-
-install(TARGETS i18n
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/i18n/i18n.pro b/examples/widgets/tools/i18n/i18n.pro
deleted file mode 100644
index a4d5e418ea..0000000000
--- a/examples/widgets/tools/i18n/i18n.pro
+++ /dev/null
@@ -1,27 +0,0 @@
-QT += widgets
-requires(qtConfig(listwidget))
-
-HEADERS = languagechooser.h \
- mainwindow.h
-SOURCES = languagechooser.cpp \
- main.cpp \
- mainwindow.cpp
-RESOURCES += i18n.qrc
-TRANSLATIONS += translations/i18n_ar.ts \
- translations/i18n_cs.ts \
- translations/i18n_de.ts \
- translations/i18n_el.ts \
- translations/i18n_en.ts \
- translations/i18n_eo.ts \
- translations/i18n_fr.ts \
- translations/i18n_it.ts \
- translations/i18n_jp.ts \
- translations/i18n_ko.ts \
- translations/i18n_no.ts \
- translations/i18n_ru.ts \
- translations/i18n_sv.ts \
- translations/i18n_zh.ts
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/i18n
-INSTALLS += target
diff --git a/examples/widgets/tools/i18n/i18n.qrc b/examples/widgets/tools/i18n/i18n.qrc
deleted file mode 100644
index 16a89f140b..0000000000
--- a/examples/widgets/tools/i18n/i18n.qrc
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>translations/i18n_ar.qm</file>
- <file>translations/i18n_cs.qm</file>
- <file>translations/i18n_de.qm</file>
- <file>translations/i18n_el.qm</file>
- <file>translations/i18n_en.qm</file>
- <file>translations/i18n_eo.qm</file>
- <file>translations/i18n_fr.qm</file>
- <file>translations/i18n_it.qm</file>
- <file>translations/i18n_jp.qm</file>
- <file>translations/i18n_ko.qm</file>
- <file>translations/i18n_no.qm</file>
- <file>translations/i18n_ru.qm</file>
- <file>translations/i18n_sv.qm</file>
- <file>translations/i18n_zh.qm</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/tools/i18n/languagechooser.cpp b/examples/widgets/tools/i18n/languagechooser.cpp
deleted file mode 100644
index 936c755e71..0000000000
--- a/examples/widgets/tools/i18n/languagechooser.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "languagechooser.h"
-#include "mainwindow.h"
-
-#include <QCoreApplication>
-#include <QCheckBox>
-#include <QDialogButtonBox>
-#include <QDir>
-#include <QGridLayout>
-#include <QGroupBox>
-#include <QPushButton>
-#include <QTranslator>
-
-LanguageChooser::LanguageChooser(const QString &defaultLang, QWidget *parent)
- : QDialog(parent, Qt::WindowStaysOnTopHint)
-{
- groupBox = new QGroupBox("Languages");
-
- QGridLayout *groupBoxLayout = new QGridLayout;
-
- const QStringList qmFiles = findQmFiles();
- for (int i = 0; i < qmFiles.size(); ++i) {
- const QString &qmlFile = qmFiles.at(i);
- QCheckBox *checkBox = new QCheckBox(languageName(qmlFile));
- qmFileForCheckBoxMap.insert(checkBox, qmlFile);
- connect(checkBox, &QCheckBox::toggled,
- this, &LanguageChooser::checkBoxToggled);
- if (languageMatch(defaultLang, qmlFile))
- checkBox->setCheckState(Qt::Checked);
- groupBoxLayout->addWidget(checkBox, i / 2, i % 2);
- }
- groupBox->setLayout(groupBoxLayout);
-
- buttonBox = new QDialogButtonBox;
- showAllButton = buttonBox->addButton("Show All",
- QDialogButtonBox::ActionRole);
- hideAllButton = buttonBox->addButton("Hide All",
- QDialogButtonBox::ActionRole);
-
- connect(showAllButton, &QAbstractButton::clicked, this, &LanguageChooser::showAll);
- connect(hideAllButton, &QAbstractButton::clicked, this, &LanguageChooser::hideAll);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(groupBox);
- mainLayout->addWidget(buttonBox);
- setLayout(mainLayout);
-
- setWindowTitle("I18N");
-}
-
-bool LanguageChooser::languageMatch(QStringView lang, QStringView qmFile)
-{
- //qmFile: i18n_xx.qm
- const QStringView prefix{ u"i18n_" };
- const int langTokenLength = 2; /*FIXME: is checking two chars enough?*/
- return qmFile.mid(qmFile.indexOf(prefix) + prefix.length(), langTokenLength) == lang.left(langTokenLength);
-}
-
-bool LanguageChooser::eventFilter(QObject *object, QEvent *event)
-{
- if (event->type() == QEvent::Close) {
- MainWindow *window = qobject_cast<MainWindow *>(object);
- if (window) {
- QCheckBox *checkBox = mainWindowForCheckBoxMap.key(window);
- if (checkBox)
- checkBox->setChecked(false);
- }
- }
- return QDialog::eventFilter(object, event);
-}
-
-void LanguageChooser::closeEvent(QCloseEvent * /* event */)
-{
- QCoreApplication::quit();
-}
-
-void LanguageChooser::checkBoxToggled()
-{
- QCheckBox *checkBox = qobject_cast<QCheckBox *>(sender());
- MainWindow *window = mainWindowForCheckBoxMap.value(checkBox);
- if (!window) {
- QTranslator translator;
- const QString qmlFile = qmFileForCheckBoxMap.value(checkBox);
- if (translator.load(qmlFile))
- QCoreApplication::installTranslator(&translator);
- else
- qWarning("Unable to load %s", qPrintable(QDir::toNativeSeparators(qmlFile)));
-
- window = new MainWindow;
- window->setPalette(colorForLanguage(checkBox->text()));
-
- window->installEventFilter(this);
- mainWindowForCheckBoxMap.insert(checkBox, window);
- }
- window->setVisible(checkBox->isChecked());
-}
-
-void LanguageChooser::showAll()
-{
- for (auto it = qmFileForCheckBoxMap.keyBegin(); it != qmFileForCheckBoxMap.keyEnd(); ++it)
- (*it)->setChecked(true);
-}
-
-void LanguageChooser::hideAll()
-{
- for (auto it = qmFileForCheckBoxMap.keyBegin(); it != qmFileForCheckBoxMap.keyEnd(); ++it)
- (*it)->setChecked(false);
-}
-
-QStringList LanguageChooser::findQmFiles()
-{
- QDir dir(":/translations");
- QStringList fileNames = dir.entryList(QStringList("*.qm"), QDir::Files,
- QDir::Name);
- for (QString &fileName : fileNames)
- fileName = dir.filePath(fileName);
- return fileNames;
-}
-
-QString LanguageChooser::languageName(const QString &qmFile)
-{
- QTranslator translator;
- if (!translator.load(qmFile)) {
- qWarning("Unable to load %s", qPrintable(QDir::toNativeSeparators(qmFile)));
- return {};
- }
- return translator.translate("MainWindow", "English");
-}
-
-QColor LanguageChooser::colorForLanguage(const QString &language)
-{
- size_t hashValue = qHash(language);
- int red = 156 + (hashValue & 0x3F);
- int green = 156 + ((hashValue >> 6) & 0x3F);
- int blue = 156 + ((hashValue >> 12) & 0x3F);
- return QColor(red, green, blue);
-}
diff --git a/examples/widgets/tools/i18n/languagechooser.h b/examples/widgets/tools/i18n/languagechooser.h
deleted file mode 100644
index b7b029bb0a..0000000000
--- a/examples/widgets/tools/i18n/languagechooser.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef LANGUAGECHOOSER_H
-#define LANGUAGECHOOSER_H
-
-#include <QDialog>
-#include <QHash>
-#include <QStringList>
-
-QT_BEGIN_NAMESPACE
-class QAbstractButton;
-class QCheckBox;
-class QDialogButtonBox;
-class QGroupBox;
-QT_END_NAMESPACE
-class MainWindow;
-
-class LanguageChooser : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit LanguageChooser(const QString &defaultLang = QString(), QWidget *parent = nullptr);
-
-protected:
- bool eventFilter(QObject *object, QEvent *event) override;
- void closeEvent(QCloseEvent *event) override;
-
-private slots:
- void checkBoxToggled();
- void showAll();
- void hideAll();
-
-private:
- static QStringList findQmFiles();
- static QString languageName(const QString &qmFile);
- static QColor colorForLanguage(const QString &language);
- static bool languageMatch(QStringView lang, QStringView qmFile);
-
- QGroupBox *groupBox;
- QDialogButtonBox *buttonBox;
- QAbstractButton *showAllButton;
- QAbstractButton *hideAllButton;
- QHash<QCheckBox *, QString> qmFileForCheckBoxMap;
- QHash<QCheckBox *, MainWindow *> mainWindowForCheckBoxMap;
-};
-
-#endif
diff --git a/examples/widgets/tools/i18n/main.cpp b/examples/widgets/tools/i18n/main.cpp
deleted file mode 100644
index c7133bd682..0000000000
--- a/examples/widgets/tools/i18n/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-#include <QLocale>
-#include "languagechooser.h"
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(i18n);
-
- QApplication app(argc, argv);
- LanguageChooser chooser(QLocale::system().name());
- chooser.show();
- return app.exec();
-}
diff --git a/examples/widgets/tools/i18n/mainwindow.cpp b/examples/widgets/tools/i18n/mainwindow.cpp
deleted file mode 100644
index e8feb06aa5..0000000000
--- a/examples/widgets/tools/i18n/mainwindow.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-
-#include <QAction>
-#include <QCoreApplication>
-#include <QGroupBox>
-#include <QListWidget>
-#include <QMenuBar>
-#include <QRadioButton>
-#include <QStatusBar>
-#include <QVBoxLayout>
-
-static const char * const listEntries[] = {
- QT_TRANSLATE_NOOP("MainWindow", "First"),
- QT_TRANSLATE_NOOP("MainWindow", "Second"),
- QT_TRANSLATE_NOOP("MainWindow", "Third"),
- nullptr
-};
-
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
-{
- centralWidget = new QWidget;
- setCentralWidget(centralWidget);
-
- createGroupBox();
-
- listWidget = new QListWidget;
- for (const char *entry : listEntries)
- listWidget->addItem(tr(entry));
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(groupBox);
- mainLayout->addWidget(listWidget);
- centralWidget->setLayout(mainLayout);
-
- exitAction = new QAction(tr("E&xit"), this);
- connect(exitAction, &QAction::triggered, qApp, QCoreApplication::quit);
-
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->setPalette(QPalette(Qt::red));
- fileMenu->addAction(exitAction);
-
- setWindowTitle(tr("Language: %1").arg(tr("English")));
- statusBar()->showMessage(tr("Internationalization Example"));
-
- if (tr("LTR") == "RTL")
- setLayoutDirection(Qt::RightToLeft);
-}
-
-void MainWindow::createGroupBox()
-{
- groupBox = new QGroupBox(tr("View"));
- perspectiveRadioButton = new QRadioButton(tr("Perspective"));
- isometricRadioButton = new QRadioButton(tr("Isometric"));
- obliqueRadioButton = new QRadioButton(tr("Oblique"));
- perspectiveRadioButton->setChecked(true);
-
- QVBoxLayout *groupBoxLayout = new QVBoxLayout;
- groupBoxLayout->addWidget(perspectiveRadioButton);
- groupBoxLayout->addWidget(isometricRadioButton);
- groupBoxLayout->addWidget(obliqueRadioButton);
- groupBox->setLayout(groupBoxLayout);
-}
diff --git a/examples/widgets/tools/i18n/mainwindow.h b/examples/widgets/tools/i18n/mainwindow.h
deleted file mode 100644
index 1552b94fcd..0000000000
--- a/examples/widgets/tools/i18n/mainwindow.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QGroupBox;
-class QLabel;
-class QListWidget;
-class QMenu;
-class QRadioButton;
-QT_END_NAMESPACE
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow(QWidget *parent = nullptr);
-
-private:
- void createGroupBox();
-
- QWidget *centralWidget;
- QLabel *label;
- QGroupBox *groupBox;
- QListWidget *listWidget;
- QRadioButton *perspectiveRadioButton;
- QRadioButton *isometricRadioButton;
- QRadioButton *obliqueRadioButton;
- QMenu *fileMenu;
- QAction *exitAction;
-};
-
-#endif
diff --git a/examples/widgets/tools/i18n/translations/i18n_ar.qm b/examples/widgets/tools/i18n/translations/i18n_ar.qm
deleted file mode 100644
index a134c468bb..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_ar.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_ar.ts b/examples/widgets/tools/i18n/translations/i18n_ar.ts
deleted file mode 100644
index a7ec2c9404..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_ar.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>First</source>
- <translation>أول</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>مثال التدويل</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>متماثل</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>اللغة: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>العربية</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>مصمت</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>منظور</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>ثانى</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>ثالث</translation>
- </message>
- <message>
- <source>View</source>
- <translation>مرئى</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>أخرج</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>الملف</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>RTL</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_cs.qm b/examples/widgets/tools/i18n/translations/i18n_cs.qm
deleted file mode 100644
index 5b7ff95b05..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_cs.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_cs.ts b/examples/widgets/tools/i18n/translations/i18n_cs.ts
deleted file mode 100644
index 6c4dee9b2e..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_cs.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>Pohled</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Soubor</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>&amp;Konec</translation>
- </message>
- <message>
- <source>First</source>
- <translation>První</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Třetí</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Jayzk: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Český</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Nakloněný</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Druhý</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometrický</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspektivní</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Ukázka lokalizace</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_de.qm b/examples/widgets/tools/i18n/translations/i18n_de.qm
deleted file mode 100644
index 177fc49b8b..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_de.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_de.ts b/examples/widgets/tools/i18n/translations/i18n_de.ts
deleted file mode 100644
index 249a61d020..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_de.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>Ansicht</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Datei</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>Be&amp;enden</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Erstens</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Drittens</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Deutsch</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Sprache: %1</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Schief</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Zweitens</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometrisch</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspektivisch</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Internationalisierungsbeispiel</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_el.qm b/examples/widgets/tools/i18n/translations/i18n_el.qm
deleted file mode 100644
index 5483291bb0..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_el.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_el.ts b/examples/widgets/tools/i18n/translations/i18n_el.ts
deleted file mode 100644
index d23a0aad3e..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_el.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Αρχείο</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>Έ&amp;ξοδος</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Πρώτο</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Παράδειγμα διεθνοποίησης</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Ισομετρική</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Γλώσσα: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Ελληνικά</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Πλάγια</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Προοπτική</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Δεύτερο</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Τρίτο</translation>
- </message>
- <message>
- <source>View</source>
- <translation>Όψη</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_en.qm b/examples/widgets/tools/i18n/translations/i18n_en.qm
deleted file mode 100644
index 9190ac7e6f..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_en.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_en.ts b/examples/widgets/tools/i18n/translations/i18n_en.ts
deleted file mode 100644
index ca38e958c1..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_en.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>E&amp;xit</source>
- <translation>E&amp;xit</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;File</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Internationalization Example</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Language: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>English</translation>
- </message>
- <message>
- <source>View</source>
- <translation>View</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspective</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometric</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Oblique</translation>
- </message>
- <message>
- <source>First</source>
- <translation>First</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Second</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Third</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_eo.qm b/examples/widgets/tools/i18n/translations/i18n_eo.qm
deleted file mode 100644
index a8457bef06..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_eo.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_eo.ts b/examples/widgets/tools/i18n/translations/i18n_eo.ts
deleted file mode 100644
index 16a37becd9..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_eo.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Dosiero</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Unue</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Ekzemplo pri internaciigo</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometria</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Lingvo: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Esperanto</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Oblikva</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspektiva</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Due</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Trie</translation>
- </message>
- <message>
- <source>View</source>
- <translation>Aspekto</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>&amp;Fini</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_fr.qm b/examples/widgets/tools/i18n/translations/i18n_fr.qm
deleted file mode 100644
index 3e8a69b80d..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_fr.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_fr.ts b/examples/widgets/tools/i18n/translations/i18n_fr.ts
deleted file mode 100644
index 0012892ef2..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_fr.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>Vue</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Fichier</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>&amp;Quitter</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Premier</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Troisième</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Langue : %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Français</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Oblique</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Deuxième</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isométrique</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspective</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Exemple d&apos;internationalisation</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_it.qm b/examples/widgets/tools/i18n/translations/i18n_it.qm
deleted file mode 100644
index 3dffd30548..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_it.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_it.ts b/examples/widgets/tools/i18n/translations/i18n_it.ts
deleted file mode 100644
index d516a277b6..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_it.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>First</source>
- <translation>Primo</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Esempio di localizzazione</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometrica</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Lingua: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Italiano</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Obliqua</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Prospettica</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Secondo</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Terzo</translation>
- </message>
- <message>
- <source>View</source>
- <translation>Vista</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>&amp;Esci</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;File</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_jp.qm b/examples/widgets/tools/i18n/translations/i18n_jp.qm
deleted file mode 100644
index 017bc96cfc..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_jp.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_jp.ts b/examples/widgets/tools/i18n/translations/i18n_jp.ts
deleted file mode 100644
index 067b5a8a0b..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_jp.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>&amp;File</source>
- <translation>ファイル(&amp;F)</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>終了(&amp;X)</translation>
- </message>
- <message>
- <source>First</source>
- <translation>第一行</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>国際化(i18n)の例</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>等角投影法</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>言語: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>日本語</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>斜め投影法</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>遠近法</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>第二行</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>第三行</translation>
- </message>
- <message>
- <source>View</source>
- <translation>表示方式</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_ko.qm b/examples/widgets/tools/i18n/translations/i18n_ko.qm
deleted file mode 100644
index d61b93db39..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_ko.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_ko.ts b/examples/widgets/tools/i18n/translations/i18n_ko.ts
deleted file mode 100644
index bfd5924518..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_ko.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>&amp;File</source>
- <translation>파일&amp;F</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>종료&amp;X</translation>
- </message>
- <message>
- <source>First</source>
- <translation>첫번째</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>국제화 예제</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>등측도</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>언어 : %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>한국어</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>빗각</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>원근화법</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>두번째</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>세번째</translation>
- </message>
- <message>
- <source>View</source>
- <translation>보기</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_no.qm b/examples/widgets/tools/i18n/translations/i18n_no.qm
deleted file mode 100644
index c84b0d74ba..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_no.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_no.ts b/examples/widgets/tools/i18n/translations/i18n_no.ts
deleted file mode 100644
index 2e06974997..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_no.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>Vis</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Fil</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>&amp;Avslutt</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Første</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Tredje</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Språk: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Norsk</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Skjevt</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Andre</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometrisk</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspektiv</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Internasjonaliseringseksempel</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_ru.qm b/examples/widgets/tools/i18n/translations/i18n_ru.qm
deleted file mode 100644
index a76e1b8703..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_ru.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_ru.ts b/examples/widgets/tools/i18n/translations/i18n_ru.ts
deleted file mode 100644
index 748cc12fd9..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_ru.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS><TS version="1.1" language="ru">
-<defaultcodec></defaultcodec>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>Вид</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>Файл</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>Выход</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Первый</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Третий</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Язык: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Русский</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Курсив</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Второй</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Изометрический</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Перспектива</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Пример интернационализации</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_sv.qm b/examples/widgets/tools/i18n/translations/i18n_sv.qm
deleted file mode 100644
index 7204b308b1..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_sv.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_sv.ts b/examples/widgets/tools/i18n/translations/i18n_sv.ts
deleted file mode 100644
index ac4ab98bd3..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_sv.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>Visa</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Arkiv</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>&amp;Avsluta</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Första</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Tredje</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Språk: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Svenska</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Skevt</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Andra</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometriskt</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspektivt</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Internationaliseringsexempel</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_zh.qm b/examples/widgets/tools/i18n/translations/i18n_zh.qm
deleted file mode 100644
index 32053f4633..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_zh.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_zh.ts b/examples/widgets/tools/i18n/translations/i18n_zh.ts
deleted file mode 100644
index 3b715470a8..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_zh.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>视图</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>文件[&amp;F]</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>退出[&amp;x]</translation>
- </message>
- <message>
- <source>First</source>
- <translation>第一个</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>第三个</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>语言: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>简体中文</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>斜投影</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>第二个</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>等角投影</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>透视投影</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>国际化范例</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/plugandpaint/CMakeLists.txt b/examples/widgets/tools/plugandpaint/CMakeLists.txt
deleted file mode 100644
index e94c2164d8..0000000000
--- a/examples/widgets/tools/plugandpaint/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(plugandpaint LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/plugandpaint")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-add_subdirectory(plugins)
-add_subdirectory(app)
diff --git a/examples/widgets/tools/plugandpaint/app/CMakeLists.txt b/examples/widgets/tools/plugandpaint/app/CMakeLists.txt
deleted file mode 100644
index 04b6bb16de..0000000000
--- a/examples/widgets/tools/plugandpaint/app/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-qt_add_executable(plugandpaint
- interfaces.h
- main.cpp
- mainwindow.cpp mainwindow.h
- paintarea.cpp paintarea.h
- plugindialog.cpp plugindialog.h
-)
-
-set_target_properties(plugandpaint PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(plugandpaint PRIVATE
- Qt::Widgets
- pnp_basictools
-)
-
-if(NOT QT6_IS_SHARED_LIBS_BUILD)
- target_link_libraries(plugandpaint PRIVATE
- pnp_extrafilters
- )
-endif()
-
-install(TARGETS plugandpaint
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/plugandpaint/app/app.pro b/examples/widgets/tools/plugandpaint/app/app.pro
deleted file mode 100644
index e5ff02ecf2..0000000000
--- a/examples/widgets/tools/plugandpaint/app/app.pro
+++ /dev/null
@@ -1,37 +0,0 @@
-#! [0]
-TARGET = plugandpaint
-DESTDIR = ..
-
-QT += widgets
-
-HEADERS = interfaces.h \
- mainwindow.h \
- paintarea.h \
- plugindialog.h
-SOURCES = main.cpp \
- mainwindow.cpp \
- paintarea.cpp \
- plugindialog.cpp
-
-LIBS = -L../plugins
-
-macx-xcode {
- LIBS += -lpnp_basictools$($${QMAKE_XCODE_LIBRARY_SUFFIX_SETTING})
-} else {
- android {
- LIBS += -lpnp_basictools_$${QT_ARCH}
- } else {
- LIBS += -lpnp_basictools
- }
- if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
- mac:LIBS = $$member(LIBS, 0) $$member(LIBS, 1)_debug
- win32:LIBS = $$member(LIBS, 0) $$member(LIBS, 1)d
- }
-}
-#! [0]
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/plugandpaint
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
diff --git a/examples/widgets/tools/plugandpaint/app/interfaces.h b/examples/widgets/tools/plugandpaint/app/interfaces.h
deleted file mode 100644
index 9cd0e34fda..0000000000
--- a/examples/widgets/tools/plugandpaint/app/interfaces.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef INTERFACES_H
-#define INTERFACES_H
-
-#include <QtPlugin>
-
-QT_BEGIN_NAMESPACE
-class QImage;
-class QPainter;
-class QWidget;
-class QPainterPath;
-class QPoint;
-class QRect;
-class QString;
-QT_END_NAMESPACE
-
-//! [0]
-class BrushInterface
-{
-public:
- virtual ~BrushInterface() = default;
-
- virtual QStringList brushes() const = 0;
- virtual QRect mousePress(const QString &brush, QPainter &painter,
- const QPoint &pos) = 0;
- virtual QRect mouseMove(const QString &brush, QPainter &painter,
- const QPoint &oldPos, const QPoint &newPos) = 0;
- virtual QRect mouseRelease(const QString &brush, QPainter &painter,
- const QPoint &pos) = 0;
-};
-//! [0]
-
-//! [1]
-class ShapeInterface
-{
-public:
- virtual ~ShapeInterface() = default;
-
- virtual QStringList shapes() const = 0;
- virtual QPainterPath generateShape(const QString &shape,
- QWidget *parent) = 0;
-};
-//! [1]
-
-//! [2]
-class FilterInterface
-{
-public:
- virtual ~FilterInterface() = default;
-
- virtual QStringList filters() const = 0;
- virtual QImage filterImage(const QString &filter, const QImage &image,
- QWidget *parent) = 0;
-};
-//! [2]
-
-QT_BEGIN_NAMESPACE
-//! [3] //! [4]
-#define BrushInterface_iid "org.qt-project.Qt.Examples.PlugAndPaint.BrushInterface/1.0"
-
-Q_DECLARE_INTERFACE(BrushInterface, BrushInterface_iid)
-//! [3]
-
-#define ShapeInterface_iid "org.qt-project.Qt.Examples.PlugAndPaint.ShapeInterface/1.0"
-
-Q_DECLARE_INTERFACE(ShapeInterface, ShapeInterface_iid)
-//! [5]
-#define FilterInterface_iid "org.qt-project.Qt.Examples.PlugAndPaint.FilterInterface/1.0"
-
-Q_DECLARE_INTERFACE(FilterInterface, FilterInterface_iid)
-//! [4] //! [5]
-QT_END_NAMESPACE
-
-#endif
diff --git a/examples/widgets/tools/plugandpaint/app/main.cpp b/examples/widgets/tools/plugandpaint/app/main.cpp
deleted file mode 100644
index 3fc647dcca..0000000000
--- a/examples/widgets/tools/plugandpaint/app/main.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-//! [0]
-#include "mainwindow.h"
-
-#include <QApplication>
-#include <QtPlugin>
-
-Q_IMPORT_PLUGIN(BasicToolsPlugin)
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- MainWindow window;
- window.show();
- return app.exec();
-}
-//! [0]
diff --git a/examples/widgets/tools/plugandpaint/app/mainwindow.cpp b/examples/widgets/tools/plugandpaint/app/mainwindow.cpp
deleted file mode 100644
index 8e58ae4ba8..0000000000
--- a/examples/widgets/tools/plugandpaint/app/mainwindow.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-
-#include "mainwindow.h"
-#include "interfaces.h"
-#include "paintarea.h"
-#include "plugindialog.h"
-
-#include <QAction>
-#include <QActionGroup>
-#include <QApplication>
-#include <QColorDialog>
-#include <QFileDialog>
-#include <QInputDialog>
-#include <QMenu>
-#include <QMenuBar>
-#include <QMessageBox>
-#include <QPluginLoader>
-#include <QScrollArea>
-#include <QTimer>
-
-MainWindow::MainWindow() : paintArea(new PaintArea)
- , scrollArea(new QScrollArea)
-{
- scrollArea->setBackgroundRole(QPalette::Dark);
- scrollArea->setWidget(paintArea);
- setCentralWidget(scrollArea);
-
- createActions();
- createMenus();
- loadPlugins();
-
- setWindowTitle(tr("Plug & Paint"));
-
- if (!brushActionGroup->actions().isEmpty())
- brushActionGroup->actions().first()->trigger();
-
- QTimer::singleShot(500, this, &MainWindow::aboutPlugins);
-}
-
-void MainWindow::open()
-{
- const QString fileName = QFileDialog::getOpenFileName(this,
- tr("Open File"),
- QDir::currentPath());
- if (!fileName.isEmpty()) {
- if (!paintArea->openImage(fileName)) {
- QMessageBox::information(this, tr("Plug & Paint"),
- tr("Cannot load %1.").arg(fileName));
- return;
- }
- paintArea->adjustSize();
- }
-}
-
-bool MainWindow::saveAs()
-{
- const QString initialPath = QDir::currentPath() + "/untitled.png";
-
- const QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
- initialPath);
- if (fileName.isEmpty())
- return false;
-
- return paintArea->saveImage(fileName, "png");
-}
-
-void MainWindow::brushColor()
-{
- const QColor newColor = QColorDialog::getColor(paintArea->brushColor());
- if (newColor.isValid())
- paintArea->setBrushColor(newColor);
-}
-
-void MainWindow::brushWidth()
-{
- bool ok;
- const int newWidth = QInputDialog::getInt(this, tr("Plug & Paint"),
- tr("Select brush width:"),
- paintArea->brushWidth(),
- 1, 50, 1, &ok);
- if (ok)
- paintArea->setBrushWidth(newWidth);
-}
-
-//! [0]
-void MainWindow::changeBrush()
-{
- auto action = qobject_cast<QAction *>(sender());
- if (!action)
- return;
- auto iBrush = qobject_cast<BrushInterface *>(action->parent());
- if (!iBrush)
- return;
- const QString brush = action->text();
-
- paintArea->setBrush(iBrush, brush);
-}
-//! [0]
-
-//! [1]
-void MainWindow::insertShape()
-{
- auto action = qobject_cast<QAction *>(sender());
- if (!action)
- return;
- auto iShape = qobject_cast<ShapeInterface *>(action->parent());
- if (!iShape)
- return;
-
- const QPainterPath path = iShape->generateShape(action->text(), this);
- if (!path.isEmpty())
- paintArea->insertShape(path);
-}
-//! [1]
-
-//! [2]
-void MainWindow::applyFilter()
-{
- auto action = qobject_cast<QAction *>(sender());
- if (!action)
- return;
- auto iFilter = qobject_cast<FilterInterface *>(action->parent());
- if (!iFilter)
- return;
-
- const QImage image = iFilter->filterImage(action->text(), paintArea->image(),
- this);
- paintArea->setImage(image);
-}
-//! [2]
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About Plug & Paint"),
- tr("The <b>Plug & Paint</b> example demonstrates how to write Qt "
- "applications that can be extended through plugins."));
-}
-
-//! [3]
-void MainWindow::aboutPlugins()
-{
- PluginDialog dialog(pluginsDir.path(), pluginFileNames, this);
- dialog.exec();
-}
-//! [3]
-
-void MainWindow::createActions()
-{
- openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcuts(QKeySequence::Open);
- connect(openAct, &QAction::triggered, this, &MainWindow::open);
-
- saveAsAct = new QAction(tr("&Save As..."), this);
- saveAsAct->setShortcuts(QKeySequence::SaveAs);
- connect(saveAsAct, &QAction::triggered, this, &MainWindow::saveAs);
-
- exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcuts(QKeySequence::Quit);
- connect(exitAct, &QAction::triggered, this, &MainWindow::close);
-
- brushColorAct = new QAction(tr("&Brush Color..."), this);
- connect(brushColorAct, &QAction::triggered, this, &MainWindow::brushColor);
-
- brushWidthAct = new QAction(tr("&Brush Width..."), this);
- connect(brushWidthAct, &QAction::triggered, this, &MainWindow::brushWidth);
-
- brushActionGroup = new QActionGroup(this);
-
- aboutAct = new QAction(tr("&About"), this);
- connect(aboutAct, &QAction::triggered, this, &MainWindow::about);
-
- aboutQtAct = new QAction(tr("About &Qt"), this);
- connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt);
-
- aboutPluginsAct = new QAction(tr("About &Plugins"), this);
- connect(aboutPluginsAct, &QAction::triggered, this, &MainWindow::aboutPlugins);
-}
-
-void MainWindow::createMenus()
-{
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(openAct);
- fileMenu->addAction(saveAsAct);
- fileMenu->addSeparator();
- fileMenu->addAction(exitAct);
-
- brushMenu = menuBar()->addMenu(tr("&Brush"));
- brushMenu->addAction(brushColorAct);
- brushMenu->addAction(brushWidthAct);
- brushMenu->addSeparator();
-
- shapesMenu = menuBar()->addMenu(tr("&Shapes"));
-
- filterMenu = menuBar()->addMenu(tr("&Filter"));
-
- menuBar()->addSeparator();
-
- helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(aboutAct);
- helpMenu->addAction(aboutQtAct);
- helpMenu->addAction(aboutPluginsAct);
-}
-
-//! [4]
-void MainWindow::loadPlugins()
-{
- const auto staticInstances = QPluginLoader::staticInstances();
- for (QObject *plugin : staticInstances)
- populateMenus(plugin);
-//! [4] //! [5]
-
- pluginsDir = QDir(QCoreApplication::applicationDirPath());
-
-#if defined(Q_OS_WIN)
- if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
- pluginsDir.cdUp();
-#elif defined(Q_OS_MAC)
- if (pluginsDir.dirName() == "MacOS") {
- pluginsDir.cdUp();
- pluginsDir.cdUp();
- pluginsDir.cdUp();
- }
-#endif
- pluginsDir.cd("plugins");
-//! [5]
-
-//! [6]
- const auto entryList = pluginsDir.entryList(QDir::Files);
- for (const QString &fileName : entryList) {
- QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
- QObject *plugin = loader.instance();
- if (plugin) {
- populateMenus(plugin);
- pluginFileNames += fileName;
-//! [6] //! [7]
- }
-//! [7] //! [8]
- }
-//! [8]
-
-//! [9]
- brushMenu->setEnabled(!brushActionGroup->actions().isEmpty());
- shapesMenu->setEnabled(!shapesMenu->actions().isEmpty());
- filterMenu->setEnabled(!filterMenu->actions().isEmpty());
-}
-//! [9]
-
-//! [10]
-void MainWindow::populateMenus(QObject *plugin)
-{
- auto iBrush = qobject_cast<BrushInterface *>(plugin);
- if (iBrush)
- addToMenu(plugin, iBrush->brushes(), brushMenu, &MainWindow::changeBrush,
- brushActionGroup);
-
- auto iShape = qobject_cast<ShapeInterface *>(plugin);
- if (iShape)
- addToMenu(plugin, iShape->shapes(), shapesMenu, &MainWindow::insertShape);
-
- auto iFilter = qobject_cast<FilterInterface *>(plugin);
- if (iFilter)
- addToMenu(plugin, iFilter->filters(), filterMenu, &MainWindow::applyFilter);
-}
-//! [10]
-
-void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
- QMenu *menu, Member member,
- QActionGroup *actionGroup)
-{
- for (const QString &text : texts) {
- auto action = new QAction(text, plugin);
- connect(action, &QAction::triggered, this, member);
- menu->addAction(action);
-
- if (actionGroup) {
- action->setCheckable(true);
- actionGroup->addAction(action);
- }
- }
-}
diff --git a/examples/widgets/tools/plugandpaint/app/mainwindow.h b/examples/widgets/tools/plugandpaint/app/mainwindow.h
deleted file mode 100644
index bc09471ba5..0000000000
--- a/examples/widgets/tools/plugandpaint/app/mainwindow.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QDir>
-#include <QMainWindow>
-#include <QStringList>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QActionGroup;
-class QMenu;
-class QScrollArea;
-QT_END_NAMESPACE
-class PaintArea;
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
-private slots:
- void open();
- bool saveAs();
- void brushColor();
- void brushWidth();
- void changeBrush();
- void insertShape();
- void applyFilter();
- void about();
- void aboutPlugins();
-
-private:
- typedef void (MainWindow::*Member)();
-
- void createActions();
- void createMenus();
- void loadPlugins();
- void populateMenus(QObject *plugin);
- void addToMenu(QObject *plugin, const QStringList &texts, QMenu *menu,
- Member member, QActionGroup *actionGroup = nullptr);
-
- PaintArea *paintArea = nullptr;
- QScrollArea *scrollArea = nullptr;
- QDir pluginsDir;
- QStringList pluginFileNames;
-
- QMenu *fileMenu = nullptr;
- QMenu *brushMenu = nullptr;
- QMenu *shapesMenu = nullptr;
- QMenu *filterMenu = nullptr;
- QMenu *helpMenu = nullptr;
- QActionGroup *brushActionGroup = nullptr;
- QAction *openAct = nullptr;
- QAction *saveAsAct = nullptr;
- QAction *exitAct = nullptr;
- QAction *brushWidthAct = nullptr;
- QAction *brushColorAct = nullptr;
- QAction *aboutAct = nullptr;
- QAction *aboutQtAct = nullptr;
- QAction *aboutPluginsAct = nullptr;
-};
-
-#endif
diff --git a/examples/widgets/tools/plugandpaint/app/paintarea.cpp b/examples/widgets/tools/plugandpaint/app/paintarea.cpp
deleted file mode 100644
index 3596f7979c..0000000000
--- a/examples/widgets/tools/plugandpaint/app/paintarea.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-
-#include "paintarea.h"
-#include "interfaces.h"
-
-#include <QMouseEvent>
-#include <QPainter>
-
-PaintArea::PaintArea(QWidget *parent) : QWidget(parent)
-{
- setAttribute(Qt::WA_StaticContents);
- setAttribute(Qt::WA_OpaquePaintEvent);
-
- theImage.fill(qRgb(255, 255, 255));
-}
-
-bool PaintArea::openImage(const QString &fileName)
-{
- QImage image;
- if (!image.load(fileName))
- return false;
-
- setImage(image);
- return true;
-}
-
-bool PaintArea::saveImage(const QString &fileName, const char *fileFormat)
-{
- return theImage.save(fileName, fileFormat);
-}
-
-void PaintArea::setImage(const QImage &image)
-{
- theImage = image.convertToFormat(QImage::Format_RGB32);
- update();
- updateGeometry();
-}
-
-void PaintArea::insertShape(const QPainterPath &path)
-{
- pendingPath = path;
-#ifndef QT_NO_CURSOR
- setCursor(Qt::CrossCursor);
-#endif
-}
-
-void PaintArea::setBrushColor(const QColor &color)
-{
- this->color = color;
-}
-
-void PaintArea::setBrushWidth(int width)
-{
- thickness = width;
-}
-
-//! [0]
-void PaintArea::setBrush(BrushInterface *brushInterface, const QString &brush)
-{
- this->brushInterface = brushInterface;
- this->brush = brush;
-}
-//! [0]
-
-QSize PaintArea::sizeHint() const
-{
- return theImage.size();
-}
-
-void PaintArea::paintEvent(QPaintEvent * /* event */)
-{
- QPainter painter(this);
- painter.drawImage(QPoint(0, 0), theImage);
-}
-
-void PaintArea::mousePressEvent(QMouseEvent *event)
-{
- if (event->button() == Qt::LeftButton) {
- if (!pendingPath.isEmpty()) {
- QPainter painter(&theImage);
- setupPainter(painter);
-
- const QRectF boundingRect = pendingPath.boundingRect();
- QLinearGradient gradient(boundingRect.topRight(),
- boundingRect.bottomLeft());
- gradient.setColorAt(0.0, QColor(color.red(), color.green(),
- color.blue(), 63));
- gradient.setColorAt(1.0, QColor(color.red(), color.green(),
- color.blue(), 191));
- painter.setBrush(gradient);
- painter.translate(event->position().toPoint() - boundingRect.center());
- painter.drawPath(pendingPath);
-
- pendingPath = QPainterPath();
-#ifndef QT_NO_CURSOR
- unsetCursor();
-#endif
- update();
- } else {
- if (brushInterface) {
- QPainter painter(&theImage);
- setupPainter(painter);
- const QRect rect = brushInterface->mousePress(brush, painter,
- event->position().toPoint());
- update(rect);
- }
-
- lastPos = event->position().toPoint();
- }
- }
-}
-
-//! [1]
-void PaintArea::mouseMoveEvent(QMouseEvent *event)
-{
- if ((event->buttons() & Qt::LeftButton) && lastPos != QPoint(-1, -1)) {
- if (brushInterface) {
- QPainter painter(&theImage);
- setupPainter(painter);
- const QRect rect = brushInterface->mouseMove(brush, painter, lastPos,
- event->position().toPoint());
- update(rect);
- }
-
- lastPos = event->position().toPoint();
- }
-}
-//! [1]
-
-void PaintArea::mouseReleaseEvent(QMouseEvent *event)
-{
- if (event->button() == Qt::LeftButton && lastPos != QPoint(-1, -1)) {
- if (brushInterface) {
- QPainter painter(&theImage);
- setupPainter(painter);
- QRect rect = brushInterface->mouseRelease(brush, painter,
- event->position().toPoint());
- update(rect);
- }
-
- lastPos = QPoint(-1, -1);
- }
-}
-
-void PaintArea::setupPainter(QPainter &painter)
-{
- painter.setRenderHint(QPainter::Antialiasing, true);
- painter.setPen(QPen(color, thickness, Qt::SolidLine, Qt::RoundCap,
- Qt::RoundJoin));
-}
diff --git a/examples/widgets/tools/plugandpaint/app/paintarea.h b/examples/widgets/tools/plugandpaint/app/paintarea.h
deleted file mode 100644
index f24db0ba89..0000000000
--- a/examples/widgets/tools/plugandpaint/app/paintarea.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef PAINTAREA_H
-#define PAINTAREA_H
-
-#include <QColor>
-#include <QImage>
-#include <QPainterPath>
-#include <QWidget>
-
-class BrushInterface;
-
-class PaintArea : public QWidget
-{
- Q_OBJECT
-
-public:
- PaintArea(QWidget *parent = nullptr);
-
- bool openImage(const QString &fileName);
- bool saveImage(const QString &fileName, const char *fileFormat);
- void setImage(const QImage &image);
- void insertShape(const QPainterPath &path);
- void setBrushColor(const QColor &color);
- void setBrushWidth(int width);
- void setBrush(BrushInterface *brushInterface, const QString &brush);
-
- QImage image() const { return theImage; }
- QColor brushColor() const { return color; }
- int brushWidth() const { return thickness; }
- QSize sizeHint() const override;
-
-protected:
- void paintEvent(QPaintEvent *event) override;
- void mousePressEvent(QMouseEvent *event) override;
- void mouseMoveEvent(QMouseEvent *event) override;
- void mouseReleaseEvent(QMouseEvent *event) override;
-
-private:
- void setupPainter(QPainter &painter);
-
- QImage theImage = {500, 400, QImage::Format_RGB32};
- QColor color = Qt::blue;
- int thickness = 3;
-
- BrushInterface *brushInterface = nullptr;
- QString brush;
- QPoint lastPos = {-1, -1};
-
- QPainterPath pendingPath;
-};
-
-#endif
diff --git a/examples/widgets/tools/plugandpaint/app/plugindialog.cpp b/examples/widgets/tools/plugandpaint/app/plugindialog.cpp
deleted file mode 100644
index 2ff5c4b1e3..0000000000
--- a/examples/widgets/tools/plugandpaint/app/plugindialog.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-
-#include "plugindialog.h"
-#include "interfaces.h"
-
-#include <QDir>
-#include <QGridLayout>
-#include <QHeaderView>
-#include <QLabel>
-#include <QPluginLoader>
-#include <QPushButton>
-#include <QStringList>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-
-PluginDialog::PluginDialog(const QString &path, const QStringList &fileNames,
- QWidget *parent) :
- QDialog(parent),
- label(new QLabel),
- treeWidget(new QTreeWidget),
- okButton(new QPushButton(tr("OK")))
-{
- treeWidget->setAlternatingRowColors(false);
- treeWidget->setSelectionMode(QAbstractItemView::NoSelection);
- treeWidget->setColumnCount(1);
- treeWidget->header()->hide();
-
- okButton->setDefault(true);
-
- connect(okButton, &QAbstractButton::clicked, this, &QWidget::close);
-
- QGridLayout *mainLayout = new QGridLayout;
- mainLayout->setColumnStretch(0, 1);
- mainLayout->setColumnStretch(2, 1);
- mainLayout->addWidget(label, 0, 0, 1, 3);
- mainLayout->addWidget(treeWidget, 1, 0, 1, 3);
- mainLayout->addWidget(okButton, 2, 1);
- setLayout(mainLayout);
-
- interfaceIcon.addPixmap(style()->standardPixmap(QStyle::SP_DirOpenIcon),
- QIcon::Normal, QIcon::On);
- interfaceIcon.addPixmap(style()->standardPixmap(QStyle::SP_DirClosedIcon),
- QIcon::Normal, QIcon::Off);
- featureIcon.addPixmap(style()->standardPixmap(QStyle::SP_FileIcon));
-
- setWindowTitle(tr("Plugin Information"));
- findPlugins(path, fileNames);
-}
-
-//! [0]
-void PluginDialog::findPlugins(const QString &path,
- const QStringList &fileNames)
-{
- label->setText(tr("Plug & Paint found the following plugins\n"
- "(looked in %1):")
- .arg(QDir::toNativeSeparators(path)));
-
- const QDir dir(path);
-
- const auto staticInstances = QPluginLoader::staticInstances();
- for (QObject *plugin : staticInstances)
- populateTreeWidget(plugin, tr("%1 (Static Plugin)")
- .arg(plugin->metaObject()->className()));
-
- for (const QString &fileName : fileNames) {
- QPluginLoader loader(dir.absoluteFilePath(fileName));
- QObject *plugin = loader.instance();
- if (plugin)
- populateTreeWidget(plugin, fileName);
- }
-}
-//! [0]
-
-//! [1]
-void PluginDialog::populateTreeWidget(QObject *plugin, const QString &text)
-{
- auto pluginItem = new QTreeWidgetItem(treeWidget);
- pluginItem->setText(0, text);
- pluginItem->setExpanded(true);
-
- QFont boldFont = pluginItem->font(0);
- boldFont.setBold(true);
- pluginItem->setFont(0, boldFont);
-
- if (plugin) {
- auto iBrush = qobject_cast<BrushInterface *>(plugin);
- if (iBrush)
- addItems(pluginItem, "BrushInterface", iBrush->brushes());
-
- auto iShape = qobject_cast<ShapeInterface *>(plugin);
- if (iShape)
- addItems(pluginItem, "ShapeInterface", iShape->shapes());
-
- auto iFilter = qobject_cast<FilterInterface *>(plugin);
- if (iFilter)
- addItems(pluginItem, "FilterInterface", iFilter->filters());
- }
-}
-//! [1]
-
-void PluginDialog::addItems(QTreeWidgetItem *pluginItem,
- const char *interfaceName,
- const QStringList &features)
-{
- auto interfaceItem = new QTreeWidgetItem(pluginItem);
- interfaceItem->setText(0, interfaceName);
- interfaceItem->setIcon(0, interfaceIcon);
-
- for (QString feature : features) {
- if (feature.endsWith("..."))
- feature.chop(3);
- auto featureItem = new QTreeWidgetItem(interfaceItem);
- featureItem->setText(0, feature);
- featureItem->setIcon(0, featureIcon);
- }
-}
diff --git a/examples/widgets/tools/plugandpaint/app/plugindialog.h b/examples/widgets/tools/plugandpaint/app/plugindialog.h
deleted file mode 100644
index 32b8aa6fe0..0000000000
--- a/examples/widgets/tools/plugandpaint/app/plugindialog.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef PLUGINDIALOG_H
-#define PLUGINDIALOG_H
-
-#include <QDialog>
-#include <QIcon>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-class QPushButton;
-class QTreeWidget;
-class QTreeWidgetItem;
-QT_END_NAMESPACE
-
-class PluginDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- PluginDialog(const QString &path, const QStringList &fileNames,
- QWidget *parent = nullptr);
-
-private:
- void findPlugins(const QString &path, const QStringList &fileNames);
- void populateTreeWidget(QObject *plugin, const QString &text);
- void addItems(QTreeWidgetItem *pluginItem, const char *interfaceName,
- const QStringList &features);
-
- QLabel *label = nullptr;
- QTreeWidget *treeWidget = nullptr;
- QPushButton *okButton = nullptr;
- QIcon interfaceIcon;
- QIcon featureIcon;
-};
-
-#endif
diff --git a/examples/widgets/tools/plugandpaint/plugandpaint.pro b/examples/widgets/tools/plugandpaint/plugandpaint.pro
deleted file mode 100644
index 58c4dbbb6e..0000000000
--- a/examples/widgets/tools/plugandpaint/plugandpaint.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-QT_FOR_CONFIG += widgets
-requires(qtConfig(inputdialog))
-
-TEMPLATE = subdirs
-SUBDIRS = plugins app
-
-app.depends = plugins
diff --git a/examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt
deleted file mode 100644
index 9a2d66d99e..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-add_subdirectory(basictools)
-add_subdirectory(extrafilters)
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt
deleted file mode 100644
index f1ef16085e..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-qt_add_plugin(pnp_basictools
- STATIC
- CLASS_NAME BasicToolsPlugin
- basictoolsplugin.cpp basictoolsplugin.h
-)
-
-target_include_directories(pnp_basictools PUBLIC
- ../../app
-)
-
-target_link_libraries(pnp_basictools PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/basictools.json b/examples/widgets/tools/plugandpaint/plugins/basictools/basictools.json
deleted file mode 100644
index 0967ef424b..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/basictools.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/basictools.pro b/examples/widgets/tools/plugandpaint/plugins/basictools/basictools.pro
deleted file mode 100644
index f5ba95252c..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/basictools.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-#! [0]
-TEMPLATE = lib
-CONFIG += plugin static
-QT += widgets
-INCLUDEPATH += ../../app
-HEADERS = basictoolsplugin.h
-SOURCES = basictoolsplugin.cpp
-TARGET = $$qtLibraryTarget(pnp_basictools)
-DESTDIR = ../../plugins
-#! [0]
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/plugandpaint/plugins
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
-uikit: CONFIG += debug_and_release
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp b/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp
deleted file mode 100644
index 6a350f38a4..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "basictoolsplugin.h"
-
-#include <QInputDialog>
-#include <QPainter>
-#include <QRandomGenerator>
-#include <QtMath>
-
-//! [0]
-QStringList BasicToolsPlugin::brushes() const
-{
- return {tr("Pencil"), tr("Air Brush"), tr("Random Letters")};
-}
-//! [0]
-
-//! [1]
-QRect BasicToolsPlugin::mousePress(const QString &brush, QPainter &painter,
- const QPoint &pos)
-{
- return mouseMove(brush, painter, pos, pos);
-}
-//! [1]
-
-//! [2]
-QRect BasicToolsPlugin::mouseMove(const QString &brush, QPainter &painter,
- const QPoint &oldPos, const QPoint &newPos)
-{
- painter.save();
-
- int rad = painter.pen().width() / 2;
- QRect boundingRect = QRect(oldPos, newPos).normalized()
- .adjusted(-rad, -rad, +rad, +rad);
- QColor color = painter.pen().color();
- int thickness = painter.pen().width();
- QColor transparentColor(color.red(), color.green(), color.blue(), 0);
-//! [2] //! [3]
-
- if (brush == tr("Pencil")) {
- painter.drawLine(oldPos, newPos);
- } else if (brush == tr("Air Brush")) {
- int numSteps = 2 + (newPos - oldPos).manhattanLength() / 2;
-
- painter.setBrush(QBrush(color, Qt::Dense6Pattern));
- painter.setPen(Qt::NoPen);
-
- for (int i = 0; i < numSteps; ++i) {
- int x = oldPos.x() + i * (newPos.x() - oldPos.x()) / (numSteps - 1);
- int y = oldPos.y() + i * (newPos.y() - oldPos.y()) / (numSteps - 1);
-
- painter.drawEllipse(x - (thickness / 2), y - (thickness / 2),
- thickness, thickness);
- }
- } else if (brush == tr("Random Letters")) {
- QChar ch(QRandomGenerator::global()->bounded('A', 'Z' + 1));
-
- QFont biggerFont = painter.font();
- biggerFont.setBold(true);
- biggerFont.setPointSize(biggerFont.pointSize() + thickness);
- painter.setFont(biggerFont);
-
- painter.drawText(newPos, QString(ch));
-
- QFontMetrics metrics(painter.font());
- boundingRect = metrics.boundingRect(ch);
- boundingRect.translate(newPos);
- boundingRect.adjust(-10, -10, +10, +10);
- }
- painter.restore();
- return boundingRect;
-}
-//! [3]
-
-//! [4]
-QRect BasicToolsPlugin::mouseRelease(const QString & /* brush */,
- QPainter & /* painter */,
- const QPoint & /* pos */)
-{
- return QRect(0, 0, 0, 0);
-}
-//! [4]
-
-//! [5]
-QStringList BasicToolsPlugin::shapes() const
-{
- return {tr("Circle"), tr("Star"), tr("Text...")};
-}
-//! [5]
-
-//! [6]
-QPainterPath BasicToolsPlugin::generateShape(const QString &shape,
- QWidget *parent)
-{
- QPainterPath path;
-
- if (shape == tr("Circle")) {
- path.addEllipse(0, 0, 50, 50);
- } else if (shape == tr("Star")) {
- path.moveTo(90, 50);
- for (int i = 1; i < 5; ++i) {
- path.lineTo(50 + 40 * std::cos(0.8 * i * M_PI),
- 50 + 40 * std::sin(0.8 * i * M_PI));
- }
- path.closeSubpath();
- } else if (shape == tr("Text...")) {
- QString text = QInputDialog::getText(parent, tr("Text Shape"),
- tr("Enter text:"),
- QLineEdit::Normal, tr("Qt"));
- if (!text.isEmpty()) {
- QFont timesFont("Times", 50);
- timesFont.setStyleStrategy(QFont::ForceOutline);
- path.addText(0, 0, timesFont, text);
- }
- }
-
- return path;
-}
-//! [6]
-
-//! [7]
-QStringList BasicToolsPlugin::filters() const
-{
- return {tr("Invert Pixels"), tr("Swap RGB"), tr("Grayscale")};
-}
-//! [7]
-
-//! [8]
-QImage BasicToolsPlugin::filterImage(const QString &filter, const QImage &image,
- QWidget * /* parent */)
-{
- QImage result = image.convertToFormat(QImage::Format_RGB32);
-
- if (filter == tr("Invert Pixels")) {
- result.invertPixels();
- } else if (filter == tr("Swap RGB")) {
- result = result.rgbSwapped();
- } else if (filter == tr("Grayscale")) {
- for (int y = 0; y < result.height(); ++y) {
- for (int x = 0; x < result.width(); ++x) {
- QRgb pixel = result.pixel(x, y);
- int gray = qGray(pixel);
- int alpha = qAlpha(pixel);
- result.setPixel(x, y, qRgba(gray, gray, gray, alpha));
- }
- }
- }
- return result;
-}
-//! [8]
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.h b/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.h
deleted file mode 100644
index 9fb3295bf5..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef BASICTOOLSPLUGIN_H
-#define BASICTOOLSPLUGIN_H
-
-//! [0]
-#include <interfaces.h>
-
-#include <QImage>
-#include <QObject>
-#include <QPainterPath>
-#include <QRect>
-#include <QStringList>
-#include <QtPlugin>
-
-//! [1]
-class BasicToolsPlugin : public QObject,
- public BrushInterface,
- public ShapeInterface,
- public FilterInterface
-{
- Q_OBJECT
-//! [4]
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.PlugAndPaint.BrushInterface" FILE "basictools.json")
-//! [4]
- Q_INTERFACES(BrushInterface ShapeInterface FilterInterface)
-//! [0]
-
-//! [2]
-public:
-//! [1]
- // BrushInterface
- QStringList brushes() const override;
- QRect mousePress(const QString &brush, QPainter &painter,
- const QPoint &pos) override;
- QRect mouseMove(const QString &brush, QPainter &painter,
- const QPoint &oldPos, const QPoint &newPos) override;
- QRect mouseRelease(const QString &brush, QPainter &painter,
- const QPoint &pos) override;
-
- // ShapeInterface
- QStringList shapes() const override;
- QPainterPath generateShape(const QString &shape, QWidget *parent) override;
-
- // FilterInterface
- QStringList filters() const override;
- QImage filterImage(const QString &filter, const QImage &image,
- QWidget *parent) override;
-//! [3]
-};
-//! [2] //! [3]
-
-#endif
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt
deleted file mode 100644
index 17e71d4d29..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-qt_add_plugin(pnp_extrafilters
- CLASS_NAME ExtraFiltersPlugin
- extrafiltersplugin.cpp extrafiltersplugin.h
-)
-
-set_target_properties(pnp_extrafilters PROPERTIES
- LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/app"
-)
-
-target_include_directories(pnp_extrafilters PUBLIC
- ../../app
-)
-
-target_link_libraries(pnp_extrafilters PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS pnp_extrafilters
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}/plugins"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}/plugins"
-)
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.json b/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.json
deleted file mode 100644
index 0967ef424b..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.pro b/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.pro
deleted file mode 100644
index e137b04823..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-#! [0]
-TEMPLATE = lib
-CONFIG += plugin
-QT += widgets
-INCLUDEPATH += ../../app
-HEADERS = extrafiltersplugin.h
-SOURCES = extrafiltersplugin.cpp
-TARGET = $$qtLibraryTarget(pnp_extrafilters)
-DESTDIR = ../../plugins
-
-#! [0]
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/plugandpaint/plugins
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
-uikit: CONFIG += debug_and_release
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp b/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp
deleted file mode 100644
index 5356efc328..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "extrafiltersplugin.h"
-
-#include <QInputDialog>
-
-QStringList ExtraFiltersPlugin::filters() const
-{
- return {tr("Flip Horizontally"), tr("Flip Vertically"),
- tr("Smudge..."), tr("Threshold...")};
-}
-
-QImage ExtraFiltersPlugin::filterImage(const QString &filter,
- const QImage &image, QWidget *parent)
-{
- QImage original = image.convertToFormat(QImage::Format_RGB32);
- QImage result = original;
-
- if (filter == tr("Flip Horizontally")) {
- for (int y = 0; y < original.height(); ++y) {
- for (int x = 0; x < original.width(); ++x) {
- QRgb pixel = original.pixel(original.width() - x - 1, y);
- result.setPixel(x, y, pixel);
- }
- }
- } else if (filter == tr("Flip Vertically")) {
- for (int y = 0; y < original.height(); ++y) {
- for (int x = 0; x < original.width(); ++x) {
- QRgb pixel = original.pixel(x, original.height() - y - 1);
- result.setPixel(x, y, pixel);
- }
- }
- } else if (filter == tr("Smudge...")) {
- bool ok;
- int numIters = QInputDialog::getInt(parent, tr("Smudge Filter"),
- tr("Enter number of iterations:"),
- 5, 1, 20, 1, &ok);
- if (ok) {
- for (int i = 0; i < numIters; ++i) {
- for (int y = 1; y < original.height() - 1; ++y) {
- for (int x = 1; x < original.width() - 1; ++x) {
- QRgb p1 = original.pixel(x, y);
- QRgb p2 = original.pixel(x, y + 1);
- QRgb p3 = original.pixel(x, y - 1);
- QRgb p4 = original.pixel(x + 1, y);
- QRgb p5 = original.pixel(x - 1, y);
-
- int red = (qRed(p1) + qRed(p2) + qRed(p3) + qRed(p4)
- + qRed(p5)) / 5;
- int green = (qGreen(p1) + qGreen(p2) + qGreen(p3)
- + qGreen(p4) + qGreen(p5)) / 5;
- int blue = (qBlue(p1) + qBlue(p2) + qBlue(p3)
- + qBlue(p4) + qBlue(p5)) / 5;
- int alpha = (qAlpha(p1) + qAlpha(p2) + qAlpha(p3)
- + qAlpha(p4) + qAlpha(p5)) / 5;
-
- result.setPixel(x, y, qRgba(red, green, blue, alpha));
- }
- }
- }
- }
- } else if (filter == tr("Threshold...")) {
- bool ok;
- int threshold = QInputDialog::getInt(parent, tr("Threshold Filter"),
- tr("Enter threshold:"),
- 10, 1, 256, 1, &ok);
- if (ok) {
- int factor = 256 / threshold;
- for (int y = 0; y < original.height(); ++y) {
- for (int x = 0; x < original.width(); ++x) {
- QRgb pixel = original.pixel(x, y);
- result.setPixel(x, y, qRgba(qRed(pixel) / factor * factor,
- qGreen(pixel) / factor * factor,
- qBlue(pixel) / factor * factor,
- qAlpha(pixel)));
- }
- }
- }
- }
- return result;
-}
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.h b/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.h
deleted file mode 100644
index 0fc50d2fd0..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef EXTRAFILTERSPLUGIN_H
-#define EXTRAFILTERSPLUGIN_H
-
-//! [0]
-#include <interfaces.h>
-
-#include <QObject>
-#include <QtPlugin>
-#include <QStringList>
-#include <QImage>
-
-class ExtraFiltersPlugin : public QObject, public FilterInterface
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.PlugAndPaint.FilterInterface" FILE "extrafilters.json")
- Q_INTERFACES(FilterInterface)
-
-public:
- QStringList filters() const override;
- QImage filterImage(const QString &filter, const QImage &image,
- QWidget *parent) override;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/tools/plugandpaint/plugins/plugins.pro b/examples/widgets/tools/plugandpaint/plugins/plugins.pro
deleted file mode 100644
index e15220c621..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/plugins.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = basictools \
- extrafilters
diff --git a/examples/widgets/tools/regularexpression/CMakeLists.txt b/examples/widgets/tools/regularexpression/CMakeLists.txt
index d745a36b84..af7701f1cf 100644
--- a/examples/widgets/tools/regularexpression/CMakeLists.txt
+++ b/examples/widgets/tools/regularexpression/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(regularexpression LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/regularexpression")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(regularexpression
main.cpp
regularexpressiondialog.cpp regularexpressiondialog.h
@@ -24,10 +18,10 @@ set_target_properties(regularexpression PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(regularexpression PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(regularexpression PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -43,7 +37,14 @@ qt_add_resources(regularexpression "regularexpression"
)
install(TARGETS regularexpression
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET regularexpression
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tools/settingseditor/CMakeLists.txt b/examples/widgets/tools/settingseditor/CMakeLists.txt
deleted file mode 100644
index f45c61b350..0000000000
--- a/examples/widgets/tools/settingseditor/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(settingseditor LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/settingseditor")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(settingseditor
- locationdialog.cpp locationdialog.h
- main.cpp
- mainwindow.cpp mainwindow.h
- settingstree.cpp settingstree.h
- variantdelegate.cpp variantdelegate.h
-)
-
-set_target_properties(settingseditor PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(settingseditor PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS settingseditor
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/settingseditor/inifiles/licensepage.ini b/examples/widgets/tools/settingseditor/inifiles/licensepage.ini
deleted file mode 100644
index 608d1b7885..0000000000
--- a/examples/widgets/tools/settingseditor/inifiles/licensepage.ini
+++ /dev/null
@@ -1,46 +0,0 @@
-[Field%201]
-Bottom=89
-Flags=MULTILINE|VSCROLL|READONLY
-Left=4
-Right=296
-State=No license agreement file found. Please contact support.
-Top=14
-Type=Text
-
-[Field%202]
-Bottom=8
-Left=4
-Right=294
-Text=Press Page Down to see the rest of the agreement.
-Top=0
-Type=Label
-
-[Field%203]
-Bottom=111
-Left=4
-Right=297
-Text=If you accept the terms of the agreement, select the first option below. You must accept the agreement to install this software. Click Next to continue.
-Top=92
-Type=Label
-
-[Field%204]
-Bottom=129
-Flags=GROUP|NOTIFY
-Left=4
-Right=299
-Text=I &accept the terms in the License Agreement
-Top=120
-Type=RadioButton
-
-[Field%205]
-Bottom=140
-Flags=NOTIFY
-Left=4
-Right=300
-State=1
-Text=I &do not accept the terms in the License Agreement
-Top=129
-Type=RadioButton
-
-[Settings]
-NumFields=5
diff --git a/examples/widgets/tools/settingseditor/inifiles/qsa.ini b/examples/widgets/tools/settingseditor/inifiles/qsa.ini
deleted file mode 100644
index 56a2964ee5..0000000000
--- a/examples/widgets/tools/settingseditor/inifiles/qsa.ini
+++ /dev/null
@@ -1,26 +0,0 @@
-[Field%201]
-Bottom=65
-Left=0
-Right=299
-Text=QSA Build Options
-Top=9
-Type=Groupbox
-
-[Field%202]
-Bottom=37
-Left=20
-Right=284
-Text=Don't compile QSA Workbench into QSA.
-Top=27
-Type=Checkbox
-
-[Field%203]
-Bottom=56
-Left=20
-Right=247
-Text=Don't compile QSA Workbench nor QSA Editor into QSA.
-Top=45
-Type=Checkbox
-
-[Settings]
-NumFields=3
diff --git a/examples/widgets/tools/settingseditor/locationdialog.cpp b/examples/widgets/tools/settingseditor/locationdialog.cpp
deleted file mode 100644
index cef83c0e49..0000000000
--- a/examples/widgets/tools/settingseditor/locationdialog.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "locationdialog.h"
-
-#include <QBoxLayout>
-#include <QComboBox>
-#include <QDialogButtonBox>
-#include <QDir>
-#include <QPushButton>
-#include <QGroupBox>
-#include <QHeaderView>
-#include <QLabel>
-#include <QLineEdit>
-#include <QTableWidget>
-#include <QTableWidgetItem>
-
-LocationDialog::LocationDialog(QWidget *parent)
- : QDialog(parent)
-{
- formatComboBox = new QComboBox;
- formatComboBox->addItem(tr("Native"));
- formatComboBox->addItem(tr("INI"));
-
- scopeComboBox = new QComboBox;
- scopeComboBox->addItem(tr("User"));
- scopeComboBox->addItem(tr("System"));
-
- organizationComboBox = new QComboBox;
- organizationComboBox->addItem(tr("QtProject"));
- organizationComboBox->setEditable(true);
-
- applicationComboBox = new QComboBox;
- applicationComboBox->addItem(tr("Any"));
- applicationComboBox->addItem(tr("Qt Creator"));
- applicationComboBox->addItem(tr("Application Example"));
- applicationComboBox->addItem(tr("Assistant"));
- applicationComboBox->addItem(tr("Designer"));
- applicationComboBox->addItem(tr("Linguist"));
- applicationComboBox->setEditable(true);
- applicationComboBox->setCurrentIndex(1);
-
- formatLabel = new QLabel(tr("&Format:"));
- formatLabel->setBuddy(formatComboBox);
-
- scopeLabel = new QLabel(tr("&Scope:"));
- scopeLabel->setBuddy(scopeComboBox);
-
- organizationLabel = new QLabel(tr("&Organization:"));
- organizationLabel->setBuddy(organizationComboBox);
-
- applicationLabel = new QLabel(tr("&Application:"));
- applicationLabel->setBuddy(applicationComboBox);
-
- locationsGroupBox = new QGroupBox(tr("Setting Locations"));
-
- const QStringList labels{tr("Location"), tr("Access")};
-
- locationsTable = new QTableWidget;
- locationsTable->setSelectionMode(QAbstractItemView::SingleSelection);
- locationsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
- locationsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
- locationsTable->setColumnCount(2);
- locationsTable->setHorizontalHeaderLabels(labels);
- locationsTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
- locationsTable->horizontalHeader()->resizeSection(1, 180);
- connect(locationsTable, &QTableWidget::itemActivated, this, &LocationDialog::itemActivated);
-
- buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
-
- connect(formatComboBox, &QComboBox::activated,
- this, &LocationDialog::updateLocationsTable);
- connect(scopeComboBox, &QComboBox::activated,
- this, &LocationDialog::updateLocationsTable);
- connect(organizationComboBox->lineEdit(),
- &QLineEdit::editingFinished,
- this, &LocationDialog::updateLocationsTable);
- connect(applicationComboBox->lineEdit(),
- &QLineEdit::editingFinished,
- this, &LocationDialog::updateLocationsTable);
- connect(applicationComboBox, &QComboBox::activated,
- this, &LocationDialog::updateLocationsTable);
- connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
-
- QVBoxLayout *locationsLayout = new QVBoxLayout(locationsGroupBox);
- locationsLayout->addWidget(locationsTable);
-
- QGridLayout *mainLayout = new QGridLayout(this);
- mainLayout->addWidget(formatLabel, 0, 0);
- mainLayout->addWidget(formatComboBox, 0, 1);
- mainLayout->addWidget(scopeLabel, 1, 0);
- mainLayout->addWidget(scopeComboBox, 1, 1);
- mainLayout->addWidget(organizationLabel, 2, 0);
- mainLayout->addWidget(organizationComboBox, 2, 1);
- mainLayout->addWidget(applicationLabel, 3, 0);
- mainLayout->addWidget(applicationComboBox, 3, 1);
- mainLayout->addWidget(locationsGroupBox, 4, 0, 1, 2);
- mainLayout->addWidget(buttonBox, 5, 0, 1, 2);
-
- updateLocationsTable();
-
- setWindowTitle(tr("Open Application Settings"));
- resize(650, 400);
-}
-
-QSettings::Format LocationDialog::format() const
-{
- if (formatComboBox->currentIndex() == 0)
- return QSettings::NativeFormat;
- else
- return QSettings::IniFormat;
-}
-
-QSettings::Scope LocationDialog::scope() const
-{
- if (scopeComboBox->currentIndex() == 0)
- return QSettings::UserScope;
- else
- return QSettings::SystemScope;
-}
-
-QString LocationDialog::organization() const
-{
- return organizationComboBox->currentText();
-}
-
-QString LocationDialog::application() const
-{
- if (applicationComboBox->currentText() == tr("Any"))
- return QString();
- else
- return applicationComboBox->currentText();
-}
-
-void LocationDialog::itemActivated(QTableWidgetItem *)
-{
- buttonBox->button(QDialogButtonBox::Ok)->animateClick();
-}
-
-void LocationDialog::updateLocationsTable()
-{
- locationsTable->setUpdatesEnabled(false);
- locationsTable->setRowCount(0);
-
- for (int i = 0; i < 2; ++i) {
- if (i == 0 && scope() == QSettings::SystemScope)
- continue;
-
- QSettings::Scope actualScope = (i == 0) ? QSettings::UserScope
- : QSettings::SystemScope;
- for (int j = 0; j < 2; ++j) {
- if (j == 0 && application().isEmpty())
- continue;
-
- QString actualApplication;
- if (j == 0)
- actualApplication = application();
- QSettings settings(format(), actualScope, organization(),
- actualApplication);
-
- int row = locationsTable->rowCount();
- locationsTable->setRowCount(row + 1);
-
- QTableWidgetItem *item0 = new QTableWidgetItem(QDir::toNativeSeparators(settings.fileName()));
-
- QTableWidgetItem *item1 = new QTableWidgetItem;
- bool disable = (settings.childKeys().isEmpty()
- && settings.childGroups().isEmpty());
-
- if (row == 0) {
- if (settings.isWritable()) {
- item1->setText(tr("Read-write"));
- disable = false;
- } else {
- item1->setText(tr("Read-only"));
- }
- buttonBox->button(QDialogButtonBox::Ok)->setDisabled(disable);
- } else {
- item1->setText(tr("Read-only fallback"));
- }
-
- if (disable) {
- item0->setFlags(item0->flags() & ~Qt::ItemIsEnabled);
- item1->setFlags(item1->flags() & ~Qt::ItemIsEnabled);
- }
-
- locationsTable->setItem(row, 0, item0);
- locationsTable->setItem(row, 1, item1);
- }
- }
- locationsTable->setUpdatesEnabled(true);
-}
diff --git a/examples/widgets/tools/settingseditor/locationdialog.h b/examples/widgets/tools/settingseditor/locationdialog.h
deleted file mode 100644
index 4bcef76ce7..0000000000
--- a/examples/widgets/tools/settingseditor/locationdialog.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef LOCATIONDIALOG_H
-#define LOCATIONDIALOG_H
-
-#include <QDialog>
-#include <QSettings>
-
-QT_BEGIN_NAMESPACE
-class QComboBox;
-class QDialogButtonBox;
-class QGroupBox;
-class QLabel;
-class QTableWidget;
-class QTableWidgetItem;
-QT_END_NAMESPACE
-
-class LocationDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- LocationDialog(QWidget *parent = nullptr);
-
- QSettings::Format format() const;
- QSettings::Scope scope() const;
- QString organization() const;
- QString application() const;
-
-private slots:
- void updateLocationsTable();
- void itemActivated(QTableWidgetItem *);
-
-private:
- QLabel *formatLabel;
- QLabel *scopeLabel;
- QLabel *organizationLabel;
- QLabel *applicationLabel;
- QComboBox *formatComboBox;
- QComboBox *scopeComboBox;
- QComboBox *organizationComboBox;
- QComboBox *applicationComboBox;
- QGroupBox *locationsGroupBox;
- QTableWidget *locationsTable;
- QDialogButtonBox *buttonBox;
-};
-
-#endif
diff --git a/examples/widgets/tools/settingseditor/main.cpp b/examples/widgets/tools/settingseditor/main.cpp
deleted file mode 100644
index f49701be5c..0000000000
--- a/examples/widgets/tools/settingseditor/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- QCoreApplication::setApplicationName("Settings Editor");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
-
- MainWindow mainWin;
- mainWin.show();
- return app.exec();
-}
diff --git a/examples/widgets/tools/settingseditor/mainwindow.cpp b/examples/widgets/tools/settingseditor/mainwindow.cpp
deleted file mode 100644
index 68178a3747..0000000000
--- a/examples/widgets/tools/settingseditor/mainwindow.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "locationdialog.h"
-#include "mainwindow.h"
-#include "settingstree.h"
-
-#include <QAction>
-#include <QApplication>
-#include <QFileDialog>
-#include <QInputDialog>
-#include <QLineEdit>
-#include <QMenuBar>
-#include <QMessageBox>
-#include <QScreen>
-#include <QStandardPaths>
-#include <QStatusBar>
-
-MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
- , settingsTree(new SettingsTree)
-{
- setCentralWidget(settingsTree);
-
- createActions();
-
- autoRefreshAct->setChecked(true);
- fallbacksAct->setChecked(true);
-
- setWindowTitle(QCoreApplication::applicationName());
- const QRect availableGeometry = screen()->availableGeometry();
- adjustSize();
- move((availableGeometry.width() - width()) / 2, (availableGeometry.height() - height()) / 2);
-}
-
-void MainWindow::openSettings()
-{
- if (!locationDialog)
- locationDialog = new LocationDialog(this);
-
- if (locationDialog->exec() != QDialog::Accepted)
- return;
-
- SettingsPtr settings(new QSettings(locationDialog->format(),
- locationDialog->scope(),
- locationDialog->organization(),
- locationDialog->application()));
-
- setSettingsObject(settings);
- fallbacksAct->setEnabled(true);
-}
-
-void MainWindow::openIniFile()
-{
- const QString directory = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
- const QString fileName =
- QFileDialog::getOpenFileName(this, tr("Open INI File"),
- directory, tr("INI Files (*.ini *.conf)"));
- if (fileName.isEmpty())
- return;
-
- SettingsPtr settings(new QSettings(fileName, QSettings::IniFormat));
-
- setSettingsObject(settings);
- fallbacksAct->setEnabled(false);
-}
-
-void MainWindow::openPropertyList()
-{
- const QString directory = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
- const QString fileName =
- QFileDialog::getOpenFileName(this, tr("Open Property List"),
- directory, tr("Property List Files (*.plist)"));
- if (fileName.isEmpty())
- return;
-
- SettingsPtr settings(new QSettings(fileName, QSettings::NativeFormat));
- setSettingsObject(settings);
- fallbacksAct->setEnabled(false);
-}
-
-void MainWindow::openRegistryPath()
-{
- const QString path =
- QInputDialog::getText(this, tr("Open Registry Path"),
- tr("Enter the path in the Windows registry:"),
- QLineEdit::Normal, "HKEY_CURRENT_USER\\");
- if (path.isEmpty())
- return;
-
- SettingsPtr settings(new QSettings(path, QSettings::NativeFormat));
-
- setSettingsObject(settings);
- fallbacksAct->setEnabled(false);
-}
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About Settings Editor"),
- tr("The <b>Settings Editor</b> example shows how to access "
- "application settings using Qt."));
-}
-
-void MainWindow::createActions()
-{
- QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
-
- QAction *openSettingsAct = fileMenu->addAction(tr("&Open Application Settings..."), this, &MainWindow::openSettings);
- openSettingsAct->setShortcuts(QKeySequence::Open);
-
- QAction *openIniFileAct = fileMenu->addAction(tr("Open I&NI File..."), this, &MainWindow::openIniFile);
- openIniFileAct->setShortcut(tr("Ctrl+N"));
-
-#ifdef Q_OS_MACOS
- QAction *openPropertyListAct = fileMenu->addAction(tr("Open Apple &Property List..."), this, &MainWindow::openPropertyList);
- openPropertyListAct->setShortcut(tr("Ctrl+P"));
-#endif // Q_OS_MACOS
-
-#ifdef Q_OS_WIN
- QAction *openRegistryPathAct = fileMenu->addAction(tr("Open Windows &Registry Path..."), this, &MainWindow::openRegistryPath);
- openRegistryPathAct->setShortcut(tr("Ctrl+G"));
-#endif // Q_OS_WIN
-
- fileMenu->addSeparator();
-
- refreshAct = fileMenu->addAction(tr("&Refresh"), settingsTree, &SettingsTree::refresh);
- refreshAct->setShortcut(tr("Ctrl+R"));
- refreshAct->setEnabled(false);
-
- fileMenu->addSeparator();
-
- QAction *exitAct = fileMenu->addAction(tr("E&xit"), this, &QWidget::close);
- exitAct->setShortcuts(QKeySequence::Quit);
-
- QMenu *optionsMenu = menuBar()->addMenu(tr("&Options"));
-
- autoRefreshAct = optionsMenu->addAction(tr("&Auto-Refresh"));
- autoRefreshAct->setShortcut(tr("Ctrl+A"));
- autoRefreshAct->setCheckable(true);
- autoRefreshAct->setEnabled(false);
- connect(autoRefreshAct, &QAction::triggered,
- settingsTree, &SettingsTree::setAutoRefresh);
- connect(autoRefreshAct, &QAction::triggered,
- refreshAct, &QAction::setDisabled);
-
- fallbacksAct = optionsMenu->addAction(tr("&Fallbacks"));
- fallbacksAct->setShortcut(tr("Ctrl+F"));
- fallbacksAct->setCheckable(true);
- fallbacksAct->setEnabled(false);
- connect(fallbacksAct, &QAction::triggered,
- settingsTree, &SettingsTree::setFallbacksEnabled);
-
- QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(tr("&About"), this, &MainWindow::about);
- helpMenu->addAction(tr("About &Qt"), qApp, &QCoreApplication::quit);
-}
-
-void MainWindow::setSettingsObject(const SettingsPtr &settings)
-{
- settings->setFallbacksEnabled(fallbacksAct->isChecked());
- settingsTree->setSettingsObject(settings);
-
- refreshAct->setEnabled(true);
- autoRefreshAct->setEnabled(true);
-
- QString niceName = QDir::cleanPath(settings->fileName());
- int pos = niceName.lastIndexOf(QLatin1Char('/'));
- if (pos != -1)
- niceName.remove(0, pos + 1);
-
- if (!settings->isWritable())
- niceName = tr("%1 (read only)").arg(niceName);
-
- setWindowTitle(tr("%1 - %2").arg(niceName, QCoreApplication::applicationName()));
- statusBar()->showMessage(tr("Opened \"%1\"").arg(QDir::toNativeSeparators(settings->fileName())));
-}
diff --git a/examples/widgets/tools/settingseditor/mainwindow.h b/examples/widgets/tools/settingseditor/mainwindow.h
deleted file mode 100644
index 84bdaef966..0000000000
--- a/examples/widgets/tools/settingseditor/mainwindow.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include <QSharedPointer>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QSettings;
-QT_END_NAMESPACE
-class LocationDialog;
-class SettingsTree;
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- typedef QSharedPointer<QSettings> SettingsPtr;
-
- MainWindow(QWidget *parent = nullptr);
-
-private slots:
- void openSettings();
- void openIniFile();
- void openPropertyList();
- void openRegistryPath();
- void about();
-
-private:
- void createActions();
- void setSettingsObject(const SettingsPtr &settings);
-
- SettingsTree *settingsTree = nullptr;
- LocationDialog *locationDialog = nullptr;
- QAction *refreshAct = nullptr;
- QAction *autoRefreshAct = nullptr;
- QAction *fallbacksAct = nullptr;
-};
-
-#endif
diff --git a/examples/widgets/tools/settingseditor/settingseditor.pro b/examples/widgets/tools/settingseditor/settingseditor.pro
deleted file mode 100644
index 4880b7e582..0000000000
--- a/examples/widgets/tools/settingseditor/settingseditor.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-QT += widgets
-requires(qtConfig(tablewidget))
-
-HEADERS = locationdialog.h \
- mainwindow.h \
- settingstree.h \
- variantdelegate.h
-SOURCES = locationdialog.cpp \
- main.cpp \
- mainwindow.cpp \
- settingstree.cpp \
- variantdelegate.cpp
-
-EXAMPLE_FILES = inifiles
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/settingseditor
-INSTALLS += target
diff --git a/examples/widgets/tools/settingseditor/settingstree.cpp b/examples/widgets/tools/settingseditor/settingstree.cpp
deleted file mode 100644
index 5de2a8cff1..0000000000
--- a/examples/widgets/tools/settingseditor/settingstree.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "settingstree.h"
-#include "variantdelegate.h"
-
-#include <QApplication>
-#include <QHeaderView>
-#include <QScreen>
-#include <QSettings>
-
-SettingsTree::SettingsTree(QWidget *parent)
- : QTreeWidget(parent),
- m_typeChecker(new TypeChecker)
-{
- setItemDelegate(new VariantDelegate(m_typeChecker, this));
-
- setHeaderLabels({tr("Setting"), tr("Type"), tr("Value")});
- header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
- header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
- header()->setSectionResizeMode(2, QHeaderView::Stretch);
-
- refreshTimer.setInterval(2000);
-
- groupIcon.addPixmap(style()->standardPixmap(QStyle::SP_DirClosedIcon),
- QIcon::Normal, QIcon::Off);
- groupIcon.addPixmap(style()->standardPixmap(QStyle::SP_DirOpenIcon),
- QIcon::Normal, QIcon::On);
- keyIcon.addPixmap(style()->standardPixmap(QStyle::SP_FileIcon));
-
- connect(&refreshTimer, &QTimer::timeout, this, &SettingsTree::maybeRefresh);
-}
-
-SettingsTree::~SettingsTree() = default;
-
-void SettingsTree::setSettingsObject(const SettingsPtr &newSettings)
-{
- settings = newSettings;
- clear();
-
- if (settings.isNull()) {
- refreshTimer.stop();
- } else {
- refresh();
- if (autoRefresh)
- refreshTimer.start();
- }
-}
-
-QSize SettingsTree::sizeHint() const
-{
- const QRect availableGeometry = screen()->availableGeometry();
- return QSize(availableGeometry.width() * 2 / 3, availableGeometry.height() * 2 / 3);
-}
-
-void SettingsTree::setAutoRefresh(bool autoRefresh)
-{
- this->autoRefresh = autoRefresh;
- if (!settings.isNull()) {
- if (autoRefresh) {
- maybeRefresh();
- refreshTimer.start();
- } else {
- refreshTimer.stop();
- }
- }
-}
-
-void SettingsTree::setFallbacksEnabled(bool enabled)
-{
- if (!settings.isNull()) {
- settings->setFallbacksEnabled(enabled);
- refresh();
- }
-}
-
-void SettingsTree::maybeRefresh()
-{
- if (state() != EditingState)
- refresh();
-}
-
-void SettingsTree::refresh()
-{
- if (settings.isNull())
- return;
-
- disconnect(this, &QTreeWidget::itemChanged,
- this, &SettingsTree::updateSetting);
-
- settings->sync();
- updateChildItems(nullptr);
-
- connect(this, &QTreeWidget::itemChanged,
- this, &SettingsTree::updateSetting);
-}
-
-bool SettingsTree::event(QEvent *event)
-{
- if (event->type() == QEvent::WindowActivate) {
- if (isActiveWindow() && autoRefresh)
- maybeRefresh();
- }
- return QTreeWidget::event(event);
-}
-
-void SettingsTree::updateSetting(QTreeWidgetItem *item)
-{
- QString key = item->text(0);
- QTreeWidgetItem *ancestor = item->parent();
- while (ancestor) {
- key.prepend(ancestor->text(0) + QLatin1Char('/'));
- ancestor = ancestor->parent();
- }
-
- settings->setValue(key, item->data(2, Qt::UserRole));
- if (autoRefresh)
- refresh();
-}
-
-void SettingsTree::updateChildItems(QTreeWidgetItem *parent)
-{
- int dividerIndex = 0;
-
- const QStringList childGroups = settings->childGroups();
- for (const QString &group : childGroups) {
- QTreeWidgetItem *child;
- int childIndex = findChild(parent, group, dividerIndex);
- if (childIndex != -1) {
- child = childAt(parent, childIndex);
- child->setText(1, QString());
- child->setText(2, QString());
- child->setData(2, Qt::UserRole, QVariant());
- moveItemForward(parent, childIndex, dividerIndex);
- } else {
- child = createItem(group, parent, dividerIndex);
- }
- child->setIcon(0, groupIcon);
- ++dividerIndex;
-
- settings->beginGroup(group);
- updateChildItems(child);
- settings->endGroup();
- }
-
- const QStringList childKeys = settings->childKeys();
- for (const QString &key : childKeys) {
- QTreeWidgetItem *child;
- int childIndex = findChild(parent, key, 0);
-
- if (childIndex == -1 || childIndex >= dividerIndex) {
- if (childIndex != -1) {
- child = childAt(parent, childIndex);
- for (int i = 0; i < child->childCount(); ++i)
- delete childAt(child, i);
- moveItemForward(parent, childIndex, dividerIndex);
- } else {
- child = createItem(key, parent, dividerIndex);
- }
- child->setIcon(0, keyIcon);
- ++dividerIndex;
- } else {
- child = childAt(parent, childIndex);
- }
-
- QVariant value = settings->value(key);
- if (value.userType() == QMetaType::UnknownType) {
- child->setText(1, "Invalid");
- } else {
- if (value.typeId() == QMetaType::QString) {
- const QString stringValue = value.toString();
- if (m_typeChecker->boolExp.match(stringValue).hasMatch()) {
- value.setValue(stringValue.compare("true", Qt::CaseInsensitive) == 0);
- } else if (m_typeChecker->signedIntegerExp.match(stringValue).hasMatch())
- value.setValue(stringValue.toInt());
- }
-
- child->setText(1, value.typeName());
- }
- child->setText(2, VariantDelegate::displayText(value));
- child->setData(2, Qt::UserRole, value);
- }
-
- while (dividerIndex < childCount(parent))
- delete childAt(parent, dividerIndex);
-}
-
-QTreeWidgetItem *SettingsTree::createItem(const QString &text,
- QTreeWidgetItem *parent, int index)
-{
- QTreeWidgetItem *after = nullptr;
- if (index != 0)
- after = childAt(parent, index - 1);
-
- QTreeWidgetItem *item;
- if (parent)
- item = new QTreeWidgetItem(parent, after);
- else
- item = new QTreeWidgetItem(this, after);
-
- item->setText(0, text);
- item->setFlags(item->flags() | Qt::ItemIsEditable);
- return item;
-}
-
-QTreeWidgetItem *SettingsTree::childAt(QTreeWidgetItem *parent, int index) const
-{
- return (parent ? parent->child(index) : topLevelItem(index));
-}
-
-int SettingsTree::childCount(QTreeWidgetItem *parent) const
-{
- return (parent ? parent->childCount() : topLevelItemCount());
-}
-
-int SettingsTree::findChild(QTreeWidgetItem *parent, const QString &text,
- int startIndex) const
-{
- for (int i = startIndex; i < childCount(parent); ++i) {
- if (childAt(parent, i)->text(0) == text)
- return i;
- }
- return -1;
-}
-
-void SettingsTree::moveItemForward(QTreeWidgetItem *parent, int oldIndex,
- int newIndex)
-{
- for (int i = 0; i < oldIndex - newIndex; ++i)
- delete childAt(parent, newIndex);
-}
diff --git a/examples/widgets/tools/settingseditor/settingstree.h b/examples/widgets/tools/settingseditor/settingstree.h
deleted file mode 100644
index 8dfa52113f..0000000000
--- a/examples/widgets/tools/settingseditor/settingstree.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef SETTINGSTREE_H
-#define SETTINGSTREE_H
-
-#include <QIcon>
-#include <QTimer>
-#include <QTreeWidget>
-#include <QSharedPointer>
-
-QT_BEGIN_NAMESPACE
-class QSettings;
-QT_END_NAMESPACE
-
-struct TypeChecker;
-
-class SettingsTree : public QTreeWidget
-{
- Q_OBJECT
-
-public:
- using SettingsPtr = QSharedPointer<QSettings>;
- using TypeCheckerPtr = QSharedPointer<TypeChecker>;
-
- SettingsTree(QWidget *parent = nullptr);
- ~SettingsTree();
-
- void setSettingsObject(const SettingsPtr &settings);
- QSize sizeHint() const override;
-
-public slots:
- void setAutoRefresh(bool autoRefresh);
- void setFallbacksEnabled(bool enabled);
- void maybeRefresh();
- void refresh();
-
-protected:
- bool event(QEvent *event) override;
-
-private slots:
- void updateSetting(QTreeWidgetItem *item);
-
-private:
- void updateChildItems(QTreeWidgetItem *parent);
- QTreeWidgetItem *createItem(const QString &text, QTreeWidgetItem *parent,
- int index);
- QTreeWidgetItem *childAt(QTreeWidgetItem *parent, int index) const;
- int childCount(QTreeWidgetItem *parent) const;
- int findChild(QTreeWidgetItem *parent, const QString &text, int startIndex) const;
- void moveItemForward(QTreeWidgetItem *parent, int oldIndex, int newIndex);
-
- SettingsPtr settings;
- TypeCheckerPtr m_typeChecker;
- QTimer refreshTimer;
- QIcon groupIcon;
- QIcon keyIcon;
- bool autoRefresh = false;
-};
-
-#endif
diff --git a/examples/widgets/tools/settingseditor/variantdelegate.cpp b/examples/widgets/tools/settingseditor/variantdelegate.cpp
deleted file mode 100644
index ed51a1645b..0000000000
--- a/examples/widgets/tools/settingseditor/variantdelegate.cpp
+++ /dev/null
@@ -1,377 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "variantdelegate.h"
-
-#include <QCheckBox>
-#include <QDateTime>
-#include <QLineEdit>
-#include <QSpinBox>
-#include <QRegularExpressionValidator>
-#include <QTextStream>
-
-#include <algorithm>
-
-static bool isPrintableChar(char c)
-{
- return uchar(c) >= 32 && uchar(c) < 128;
-}
-
-static bool isPrintable(const QByteArray &ba)
-{
- return std::all_of(ba.cbegin(), ba.cend(), isPrintableChar);
-}
-
-static QString byteArrayToString(const QByteArray &ba)
-{
- if (isPrintable(ba))
- return QString::fromLatin1(ba);
- QString result;
- for (char c : ba) {
- if (isPrintableChar(c)) {
- if (c == '\\')
- result += QLatin1Char(c);
- result += QLatin1Char(c);
- } else {
- const uint uc = uchar(c);
- result += "\\x";
- if (uc < 16)
- result += '0';
- result += QString::number(uc, 16);
- }
- }
- return result;
-}
-
-TypeChecker::TypeChecker()
-{
- boolExp.setPattern("^(true)|(false)$");
- boolExp.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
- Q_ASSERT(boolExp.isValid());
-
- byteArrayExp.setPattern(R"RX(^[\x00-\xff]*$)RX");
- charExp.setPattern("^.$");
- Q_ASSERT(charExp.isValid());
- colorExp.setPattern(R"RX(^\(([0-9]*),([0-9]*),([0-9]*),([0-9]*)\)$)RX");
- Q_ASSERT(colorExp.isValid());
- doubleExp.setPattern("");
- pointExp.setPattern(R"RX(^\((-?[0-9]*),(-?[0-9]*)\)$)RX");
- Q_ASSERT(pointExp.isValid());
- rectExp.setPattern(R"RX(^\((-?[0-9]*),(-?[0-9]*),(-?[0-9]*),(-?[0-9]*)\)$)RX");
- Q_ASSERT(rectExp.isValid());
- signedIntegerExp.setPattern("^-?[0-9]*$");
- Q_ASSERT(signedIntegerExp.isValid());
- sizeExp = pointExp;
- unsignedIntegerExp.setPattern("^[0-9]+$");
- Q_ASSERT(unsignedIntegerExp.isValid());
-
- const QString datePattern = "([0-9]{,4})-([0-9]{,2})-([0-9]{,2})";
- dateExp.setPattern('^' + datePattern + '$');
- Q_ASSERT(dateExp.isValid());
- const QString timePattern = "([0-9]{,2}):([0-9]{,2}):([0-9]{,2})";
- timeExp.setPattern('^' + timePattern + '$');
- Q_ASSERT(timeExp.isValid());
- dateTimeExp.setPattern('^' + datePattern + 'T' + timePattern + '$');
- Q_ASSERT(dateTimeExp.isValid());
-}
-
-VariantDelegate::VariantDelegate(const QSharedPointer<TypeChecker> &typeChecker,
- QObject *parent)
- : QStyledItemDelegate(parent),
- m_typeChecker(typeChecker)
-{
-}
-
-void VariantDelegate::paint(QPainter *painter,
- const QStyleOptionViewItem &option,
- const QModelIndex &index) const
-{
- if (index.column() == 2) {
- QVariant value = index.model()->data(index, Qt::UserRole);
- if (!isSupportedType(value.userType())) {
- QStyleOptionViewItem myOption = option;
- myOption.state &= ~QStyle::State_Enabled;
- QStyledItemDelegate::paint(painter, myOption, index);
- return;
- }
- }
-
- QStyledItemDelegate::paint(painter, option, index);
-}
-
-QWidget *VariantDelegate::createEditor(QWidget *parent,
- const QStyleOptionViewItem & /* option */,
- const QModelIndex &index) const
-{
- if (index.column() != 2)
- return nullptr;
-
- QVariant originalValue = index.model()->data(index, Qt::UserRole);
- if (!isSupportedType(originalValue.userType()))
- return nullptr;
-
- switch (originalValue.userType()) {
- case QMetaType::Bool:
- return new QCheckBox(parent);
- break;
- case QMetaType::Int:
- case QMetaType::LongLong: {
- auto spinBox = new QSpinBox(parent);
- spinBox->setRange(-32767, 32767);
- return spinBox;
- }
- case QMetaType::UInt:
- case QMetaType::ULongLong: {
- auto spinBox = new QSpinBox(parent);
- spinBox->setRange(0, 63335);
- return spinBox;
- }
- default:
- break;
- }
-
- QLineEdit *lineEdit = new QLineEdit(parent);
- lineEdit->setFrame(false);
-
- QRegularExpression regExp;
-
- switch (originalValue.userType()) {
- case QMetaType::Bool:
- regExp = m_typeChecker->boolExp;
- break;
- case QMetaType::QByteArray:
- regExp = m_typeChecker->byteArrayExp;
- break;
- case QMetaType::QChar:
- regExp = m_typeChecker->charExp;
- break;
- case QMetaType::QColor:
- regExp = m_typeChecker->colorExp;
- break;
- case QMetaType::QDate:
- regExp = m_typeChecker->dateExp;
- break;
- case QMetaType::QDateTime:
- regExp = m_typeChecker->dateTimeExp;
- break;
- case QMetaType::Double:
- regExp = m_typeChecker->doubleExp;
- break;
- case QMetaType::Int:
- case QMetaType::LongLong:
- regExp = m_typeChecker->signedIntegerExp;
- break;
- case QMetaType::QPoint:
- regExp = m_typeChecker->pointExp;
- break;
- case QMetaType::QRect:
- regExp = m_typeChecker->rectExp;
- break;
- case QMetaType::QSize:
- regExp = m_typeChecker->sizeExp;
- break;
- case QMetaType::QTime:
- regExp = m_typeChecker->timeExp;
- break;
- case QMetaType::UInt:
- case QMetaType::ULongLong:
- regExp = m_typeChecker->unsignedIntegerExp;
- break;
- default:
- break;
- }
-
- if (regExp.isValid()) {
- QValidator *validator = new QRegularExpressionValidator(regExp, lineEdit);
- lineEdit->setValidator(validator);
- }
-
- return lineEdit;
-}
-
-void VariantDelegate::setEditorData(QWidget *editor,
- const QModelIndex &index) const
-{
- QVariant value = index.model()->data(index, Qt::UserRole);
- if (auto spinBox = qobject_cast<QSpinBox *>(editor)) {
- const auto userType = value.userType();
- if (userType == QMetaType::UInt || userType == QMetaType::ULongLong)
- spinBox->setValue(value.toUInt());
- else
- spinBox->setValue(value.toInt());
- } else if (auto checkBox = qobject_cast<QCheckBox *>(editor)) {
- checkBox->setChecked(value.toBool());
- } else if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(editor)) {
- if (value.userType() == QMetaType::QByteArray
- && !isPrintable(value.toByteArray())) {
- lineEdit->setReadOnly(true);
- }
- lineEdit->setText(displayText(value));
- }
-}
-
-void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
- const QModelIndex &index) const
-{
- const QVariant originalValue = index.model()->data(index, Qt::UserRole);
- QVariant value;
-
- if (auto spinBox = qobject_cast<QSpinBox *>(editor)) {
- value.setValue(spinBox->value());
- } else if (auto checkBox = qobject_cast<QCheckBox *>(editor)) {
- value.setValue(checkBox->isChecked());
- } else if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(editor)) {
- if (!lineEdit->isModified())
- return;
-
- QString text = lineEdit->text();
- const QValidator *validator = lineEdit->validator();
- if (validator) {
- int pos;
- if (validator->validate(text, pos) != QValidator::Acceptable)
- return;
- }
-
- QRegularExpressionMatch match;
-
- switch (originalValue.userType()) {
- case QMetaType::QChar:
- value = text.at(0);
- break;
- case QMetaType::QColor:
- match = m_typeChecker->colorExp.match(text);
- value = QColor(qMin(match.captured(1).toInt(), 255),
- qMin(match.captured(2).toInt(), 255),
- qMin(match.captured(3).toInt(), 255),
- qMin(match.captured(4).toInt(), 255));
- break;
- case QMetaType::QDate:
- {
- QDate date = QDate::fromString(text, Qt::ISODate);
- if (!date.isValid())
- return;
- value = date;
- }
- break;
- case QMetaType::QDateTime:
- {
- QDateTime dateTime = QDateTime::fromString(text, Qt::ISODate);
- if (!dateTime.isValid())
- return;
- value = dateTime;
- }
- break;
- case QMetaType::QPoint:
- match = m_typeChecker->pointExp.match(text);
- value = QPoint(match.captured(1).toInt(), match.captured(2).toInt());
- break;
- case QMetaType::QRect:
- match = m_typeChecker->rectExp.match(text);
- value = QRect(match.captured(1).toInt(), match.captured(2).toInt(),
- match.captured(3).toInt(), match.captured(4).toInt());
- break;
- case QMetaType::QSize:
- match = m_typeChecker->sizeExp.match(text);
- value = QSize(match.captured(1).toInt(), match.captured(2).toInt());
- break;
- case QMetaType::QStringList:
- value = text.split(',');
- break;
- case QMetaType::QTime:
- {
- QTime time = QTime::fromString(text, Qt::ISODate);
- if (!time.isValid())
- return;
- value = time;
- }
- break;
- default:
- value = text;
- value.convert(originalValue.metaType());
- }
- }
-
- model->setData(index, displayText(value), Qt::DisplayRole);
- model->setData(index, value, Qt::UserRole);
-}
-
-bool VariantDelegate::isSupportedType(int type)
-{
- switch (type) {
- case QMetaType::Bool:
- case QMetaType::QByteArray:
- case QMetaType::QChar:
- case QMetaType::QColor:
- case QMetaType::QDate:
- case QMetaType::QDateTime:
- case QMetaType::Double:
- case QMetaType::Int:
- case QMetaType::LongLong:
- case QMetaType::QPoint:
- case QMetaType::QRect:
- case QMetaType::QSize:
- case QMetaType::QString:
- case QMetaType::QStringList:
- case QMetaType::QTime:
- case QMetaType::UInt:
- case QMetaType::ULongLong:
- return true;
- default:
- return false;
- }
-}
-
-QString VariantDelegate::displayText(const QVariant &value)
-{
- switch (value.userType()) {
- case QMetaType::Bool:
- return value.toBool() ? "✓" : "☐";
- case QMetaType::QByteArray:
- return byteArrayToString(value.toByteArray());
- case QMetaType::QChar:
- case QMetaType::Double:
- case QMetaType::Int:
- case QMetaType::LongLong:
- case QMetaType::QString:
- case QMetaType::UInt:
- case QMetaType::ULongLong:
- return value.toString();
- case QMetaType::QColor:
- {
- QColor color = qvariant_cast<QColor>(value);
- return QString("(%1,%2,%3,%4)")
- .arg(color.red()).arg(color.green())
- .arg(color.blue()).arg(color.alpha());
- }
- case QMetaType::QDate:
- return value.toDate().toString(Qt::ISODate);
- case QMetaType::QDateTime:
- return value.toDateTime().toString(Qt::ISODate);
- case QMetaType::UnknownType:
- return "<Invalid>";
- case QMetaType::QPoint:
- {
- QPoint point = value.toPoint();
- return QString("(%1,%2)").arg(point.x()).arg(point.y());
- }
- case QMetaType::QRect:
- {
- QRect rect = value.toRect();
- return QString("(%1,%2,%3,%4)")
- .arg(rect.x()).arg(rect.y())
- .arg(rect.width()).arg(rect.height());
- }
- case QMetaType::QSize:
- {
- QSize size = value.toSize();
- return QString("(%1,%2)").arg(size.width()).arg(size.height());
- }
- case QMetaType::QStringList:
- return value.toStringList().join(',');
- case QMetaType::QTime:
- return value.toTime().toString(Qt::ISODate);
- default:
- break;
- }
- return QString("<%1>").arg(value.typeName());
-}
diff --git a/examples/widgets/tools/settingseditor/variantdelegate.h b/examples/widgets/tools/settingseditor/variantdelegate.h
deleted file mode 100644
index dc06d51bbc..0000000000
--- a/examples/widgets/tools/settingseditor/variantdelegate.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef VARIANTDELEGATE_H
-#define VARIANTDELEGATE_H
-
-#include <QStyledItemDelegate>
-#include <QRegularExpression>
-#include <QSharedPointer>
-
-struct TypeChecker
-{
- TypeChecker();
-
- QRegularExpression boolExp;
- QRegularExpression byteArrayExp;
- QRegularExpression charExp;
- QRegularExpression colorExp;
- QRegularExpression dateExp;
- QRegularExpression dateTimeExp;
- QRegularExpression doubleExp;
- QRegularExpression pointExp;
- QRegularExpression rectExp;
- QRegularExpression signedIntegerExp;
- QRegularExpression sizeExp;
- QRegularExpression timeExp;
- QRegularExpression unsignedIntegerExp;
-};
-
-class VariantDelegate : public QStyledItemDelegate
-{
- Q_OBJECT
-
-public:
- explicit VariantDelegate(const QSharedPointer<TypeChecker> &typeChecker,
- QObject *parent = nullptr);
-
- void paint(QPainter *painter, const QStyleOptionViewItem &option,
- const QModelIndex &index) const override;
- QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
- const QModelIndex &index) const override;
- void setEditorData(QWidget *editor, const QModelIndex &index) const override;
- void setModelData(QWidget *editor, QAbstractItemModel *model,
- const QModelIndex &index) const override;
-
- static bool isSupportedType(int type);
- static QString displayText(const QVariant &value);
-
-private:
- QSharedPointer<TypeChecker> m_typeChecker;
-};
-
-#endif
diff --git a/examples/widgets/tools/styleplugin/CMakeLists.txt b/examples/widgets/tools/styleplugin/CMakeLists.txt
deleted file mode 100644
index 3cd2d9b78c..0000000000
--- a/examples/widgets/tools/styleplugin/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(styleplugin LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/styleplugin")
-
-find_package(Qt6 REQUIRED COMPONENTS Widgets)
-
-add_subdirectory(stylewindow)
-add_subdirectory(plugin)
diff --git a/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt b/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt
deleted file mode 100644
index aa191b2827..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-qt_add_plugin(simplestyleplugin
- CLASS_NAME SimpleStylePlugin
- simplestyle.cpp simplestyle.h
- simplestyleplugin.cpp simplestyleplugin.h
-)
-
-set_target_properties(simplestyleplugin PROPERTIES
- LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/stylewindow/styles"
-)
-
-target_link_libraries(simplestyleplugin PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS simplestyleplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/styleplugin/plugin/plugin.pro b/examples/widgets/tools/styleplugin/plugin/plugin.pro
deleted file mode 100644
index 35184fc82a..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/plugin.pro
+++ /dev/null
@@ -1,24 +0,0 @@
-#! [0]
-TEMPLATE = lib
-CONFIG += plugin
-QT += widgets
-HEADERS = simplestyle.h \
- simplestyleplugin.h
-SOURCES = simplestyle.cpp \
- simplestyleplugin.cpp
-TARGET = simplestyleplugin
-#! [0]
-win32 {
- CONFIG(debug, release|debug):DESTDIR = ../debug/styles/
- CONFIG(release, release|debug):DESTDIR = ../release/styles/
-} else {
- DESTDIR = ../styles/
-}
-
-EXAMPLE_FILES += simplestyle.json
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/styleplugin/styles
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
diff --git a/examples/widgets/tools/styleplugin/plugin/simplestyle.cpp b/examples/widgets/tools/styleplugin/plugin/simplestyle.cpp
deleted file mode 100644
index 93bea72bcd..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyle.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "simplestyle.h"
-
-void SimpleStyle::polish(QPalette &palette)
-{
- palette.setBrush(QPalette::Button, Qt::red);
-}
diff --git a/examples/widgets/tools/styleplugin/plugin/simplestyle.h b/examples/widgets/tools/styleplugin/plugin/simplestyle.h
deleted file mode 100644
index 315c4d836c..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyle.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef SIMPLESTYLE_H
-#define SIMPLESTYLE_H
-
-#include <QProxyStyle>
-
-class SimpleStyle : public QProxyStyle
-{
- Q_OBJECT
-
-public:
- SimpleStyle() = default;
-
- void polish(QPalette &palette) override;
-};
-
-#endif
diff --git a/examples/widgets/tools/styleplugin/plugin/simplestyle.json b/examples/widgets/tools/styleplugin/plugin/simplestyle.json
deleted file mode 100644
index a708e2aafe..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyle.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "Keys": [ "simplestyle" ]
-}
diff --git a/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.cpp b/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.cpp
deleted file mode 100644
index f28d22ccc9..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "simplestyleplugin.h"
-#include "simplestyle.h"
-
-//! [0]
-QStringList SimpleStylePlugin::keys() const
-{
- return {"SimpleStyle"};
-}
-//! [0]
-
-//! [1]
-QStyle *SimpleStylePlugin::create(const QString &key)
-{
- if (key.toLower() == "simplestyle")
- return new SimpleStyle;
- return nullptr;
-}
-//! [1]
diff --git a/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h b/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h
deleted file mode 100644
index 8a3dc45210..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef SIMPLESTYLEPLUGIN_H
-#define SIMPLESTYLEPLUGIN_H
-
-#include <QStylePlugin>
-
-//! [0]
-class SimpleStylePlugin : public QStylePlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "simplestyle.json")
-
-public:
- SimpleStylePlugin() = default;
-
- QStringList keys() const;
- QStyle *create(const QString &key) override;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/tools/styleplugin/styleplugin.pro b/examples/widgets/tools/styleplugin/styleplugin.pro
deleted file mode 100644
index 4f120637b0..0000000000
--- a/examples/widgets/tools/styleplugin/styleplugin.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = stylewindow \
- plugin
diff --git a/examples/widgets/tools/styleplugin/stylewindow/CMakeLists.txt b/examples/widgets/tools/styleplugin/stylewindow/CMakeLists.txt
deleted file mode 100644
index be69b98e1c..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-qt_add_executable(styleplugin
- main.cpp
- stylewindow.cpp stylewindow.h
-)
-
-set_target_properties(styleplugin PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(styleplugin PRIVATE
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-if(NOT QT6_IS_SHARED_LIBS_BUILD)
- target_link_libraries(styleplugin PRIVATE
- simplestyleplugin
- )
-endif()
-
-install(TARGETS styleplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/styleplugin/stylewindow/main.cpp b/examples/widgets/tools/styleplugin/stylewindow/main.cpp
deleted file mode 100644
index 0b4ca6320f..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/main.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-#include <QStyleFactory>
-
-#include "stylewindow.h"
-
-//! [0]
-int main(int argv, char *args[])
-{
- QApplication app(argv, args);
- QApplication::setStyle(QStyleFactory::create("simplestyle"));
-
- StyleWindow window;
- window.resize(200, 50);
- window.show();
-
- return app.exec();
-}
-//! [0]
diff --git a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.cpp b/examples/widgets/tools/styleplugin/stylewindow/stylewindow.cpp
deleted file mode 100644
index fd449057e6..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QGridLayout>
-#include <QGroupBox>
-#include <QPushButton>
-
-#include "stylewindow.h"
-
-StyleWindow::StyleWindow()
-{
- QPushButton *styledButton = new QPushButton(tr("Big Red Button"));
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(styledButton);
-
- QGroupBox *styleBox = new QGroupBox(tr("A simple style button"));
- styleBox->setLayout(layout);
-
- QGridLayout *outerLayout = new QGridLayout;
- outerLayout->addWidget(styleBox, 0, 0);
- setLayout(outerLayout);
-
- setWindowTitle(tr("Style Plugin Example"));
-}
diff --git a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.h b/examples/widgets/tools/styleplugin/stylewindow/stylewindow.h
deleted file mode 100644
index 50fa6b29f7..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef STYLEWINDOW_H
-#define STYLEWINDOW_H
-
-#include <QWidget>
-
-class StyleWindow : public QWidget
-{
- Q_OBJECT
-
-public:
- StyleWindow();
-};
-
-#endif
diff --git a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.pro b/examples/widgets/tools/styleplugin/stylewindow/stylewindow.pro
deleted file mode 100644
index cdc1bd2fda..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-QT += widgets
-
-HEADERS = stylewindow.h
-SOURCES = stylewindow.cpp \
- main.cpp
-
-TARGET = styleplugin
-win32 {
- debug:DESTDIR = ../debug/
- release:DESTDIR = ../release/
-} else {
- DESTDIR = ../
-}
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/styleplugin
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
diff --git a/examples/widgets/tools/tools.pro b/examples/widgets/tools/tools.pro
index d2a02deb6b..a6d483f7e2 100644
--- a/examples/widgets/tools/tools.pro
+++ b/examples/widgets/tools/tools.pro
@@ -2,20 +2,7 @@ TEMPLATE = subdirs
SUBDIRS = \
completer \
customcompleter \
- echoplugin \
- i18n \
- plugandpaint \
regularexpression \
- settingseditor \
- styleplugin \
treemodelcompleter \
- undo \
undoframework
-contains(DEFINES, QT_NO_TRANSLATION): SUBDIRS -= i18n
-
-!qtConfig(library) {
- SUBDIRS -= \
- echoplugin \
- plugandpaint
-}
diff --git a/examples/widgets/tools/treemodelcompleter/CMakeLists.txt b/examples/widgets/tools/treemodelcompleter/CMakeLists.txt
index f4b27ea7a1..4f512db3ee 100644
--- a/examples/widgets/tools/treemodelcompleter/CMakeLists.txt
+++ b/examples/widgets/tools/treemodelcompleter/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(treemodelcompleter LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/treemodelcompleter")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(treemodelcompleter
main.cpp
mainwindow.cpp mainwindow.h
@@ -25,10 +19,10 @@ set_target_properties(treemodelcompleter PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(treemodelcompleter PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(treemodelcompleter PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -44,7 +38,14 @@ qt_add_resources(treemodelcompleter "treemodelcompleter"
)
install(TARGETS treemodelcompleter
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET treemodelcompleter
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tools/treemodelcompleter/main.cpp b/examples/widgets/tools/treemodelcompleter/main.cpp
index 50ca573129..060dfe5bd8 100644
--- a/examples/widgets/tools/treemodelcompleter/main.cpp
+++ b/examples/widgets/tools/treemodelcompleter/main.cpp
@@ -7,8 +7,6 @@
//! [0]
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(treemodelcompleter);
-
QApplication app(argc, argv);
MainWindow window;
window.show();
diff --git a/examples/widgets/tools/undo/CMakeLists.txt b/examples/widgets/tools/undo/CMakeLists.txt
deleted file mode 100644
index 80b7ccc4e7..0000000000
--- a/examples/widgets/tools/undo/CMakeLists.txt
+++ /dev/null
@@ -1,69 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(undo LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/undo")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(undo
- commands.cpp commands.h
- document.cpp document.h
- main.cpp
- mainwindow.cpp mainwindow.h mainwindow.ui
-)
-
-set_target_properties(undo PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(undo PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(undo_resource_files
- "icons/background.png"
- "icons/blue.png"
- "icons/circle.png"
- "icons/exit.png"
- "icons/fileclose.png"
- "icons/filenew.png"
- "icons/fileopen.png"
- "icons/filesave.png"
- "icons/green.png"
- "icons/ok.png"
- "icons/rectangle.png"
- "icons/red.png"
- "icons/redo.png"
- "icons/remove.png"
- "icons/triangle.png"
- "icons/undo.png"
-)
-
-qt_add_resources(undo "undo"
- PREFIX
- "/"
- FILES
- ${undo_resource_files}
-)
-
-install(TARGETS undo
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/undo/commands.cpp b/examples/widgets/tools/undo/commands.cpp
deleted file mode 100644
index b06050fd99..0000000000
--- a/examples/widgets/tools/undo/commands.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "commands.h"
-
-static constexpr int setShapeRectCommandId = 1;
-static constexpr int setShapeColorCommandId = 2;
-
-/******************************************************************************
-** AddShapeCommand
-*/
-
-AddShapeCommand::AddShapeCommand(Document *doc, const Shape &shape, QUndoCommand *parent)
- : QUndoCommand(parent), m_doc(doc), m_shape(shape)
-{
-}
-
-void AddShapeCommand::undo()
-{
- m_doc->deleteShape(m_shapeName);
-}
-
-void AddShapeCommand::redo()
-{
- // A shape only gets a name when it is inserted into a document
- m_shapeName = m_doc->addShape(m_shape);
- setText(QObject::tr("Add %1").arg(m_shapeName));
-}
-
-/******************************************************************************
-** RemoveShapeCommand
-*/
-
-RemoveShapeCommand::RemoveShapeCommand(Document *doc, const QString &shapeName,
- QUndoCommand *parent)
- : QUndoCommand(parent), m_doc(doc), m_shape(doc->shape(shapeName))
- , m_shapeName(shapeName)
-{
- setText(QObject::tr("Remove %1").arg(shapeName));
-}
-
-void RemoveShapeCommand::undo()
-{
- m_shapeName = m_doc->addShape(m_shape);
-}
-
-void RemoveShapeCommand::redo()
-{
- m_doc->deleteShape(m_shapeName);
-}
-
-/******************************************************************************
-** SetShapeColorCommand
-*/
-
-SetShapeColorCommand::SetShapeColorCommand(Document *doc, const QString &shapeName,
- const QColor &color, QUndoCommand *parent)
- : QUndoCommand(parent), m_doc(doc), m_shapeName(shapeName)
- , m_oldColor(doc->shape(shapeName).color()), m_newColor(color)
-{
- setText(QObject::tr("Set %1's color").arg(shapeName));
-}
-
-void SetShapeColorCommand::undo()
-{
- m_doc->setShapeColor(m_shapeName, m_oldColor);
-}
-
-void SetShapeColorCommand::redo()
-{
- m_doc->setShapeColor(m_shapeName, m_newColor);
-}
-
-bool SetShapeColorCommand::mergeWith(const QUndoCommand *command)
-{
- if (command->id() != setShapeColorCommandId)
- return false;
-
- const SetShapeColorCommand *other = static_cast<const SetShapeColorCommand*>(command);
- if (m_shapeName != other->m_shapeName)
- return false;
-
- m_newColor = other->m_newColor;
- return true;
-}
-
-int SetShapeColorCommand::id() const
-{
- return setShapeColorCommandId;
-}
-
-/******************************************************************************
-** SetShapeRectCommand
-*/
-
-SetShapeRectCommand::SetShapeRectCommand(Document *doc, const QString &shapeName,
- const QRect &rect, QUndoCommand *parent)
- : QUndoCommand(parent), m_doc(doc), m_shapeName(shapeName)
- , m_oldRect(doc->shape(shapeName).rect()), m_newRect(rect)
-{
- setText(QObject::tr("Change %1's geometry").arg(shapeName));
-}
-
-void SetShapeRectCommand::undo()
-{
- m_doc->setShapeRect(m_shapeName, m_oldRect);
-}
-
-void SetShapeRectCommand::redo()
-{
- m_doc->setShapeRect(m_shapeName, m_newRect);
-}
-
-bool SetShapeRectCommand::mergeWith(const QUndoCommand *command)
-{
- if (command->id() != setShapeRectCommandId)
- return false;
-
- const SetShapeRectCommand *other = static_cast<const SetShapeRectCommand*>(command);
- if (m_shapeName != other->m_shapeName)
- return false;
-
- m_newRect = other->m_newRect;
- return true;
-}
-
-int SetShapeRectCommand::id() const
-{
- return setShapeRectCommandId;
-}
diff --git a/examples/widgets/tools/undo/commands.h b/examples/widgets/tools/undo/commands.h
deleted file mode 100644
index 5fc141da21..0000000000
--- a/examples/widgets/tools/undo/commands.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef COMMANDS_H
-#define COMMANDS_H
-
-#include <QUndoCommand>
-#include "document.h"
-
-class AddShapeCommand : public QUndoCommand
-{
-public:
- AddShapeCommand(Document *doc, const Shape &shape,
- QUndoCommand *parent = nullptr);
- void undo() override;
- void redo() override;
-
-private:
- Document *m_doc;
- Shape m_shape;
- QString m_shapeName;
-};
-
-class RemoveShapeCommand : public QUndoCommand
-{
-public:
- RemoveShapeCommand(Document *doc, const QString &shapeName,
- QUndoCommand *parent = nullptr);
- void undo() override;
- void redo() override;
-
-private:
- Document *m_doc;
- Shape m_shape;
- QString m_shapeName;
-};
-
-class SetShapeColorCommand : public QUndoCommand
-{
-public:
- SetShapeColorCommand(Document *doc, const QString &shapeName,
- const QColor &color, QUndoCommand *parent = nullptr);
-
- void undo() override;
- void redo() override;
-
- bool mergeWith(const QUndoCommand *command) override;
- int id() const override;
-
-private:
- Document *m_doc;
- QString m_shapeName;
- QColor m_oldColor;
- QColor m_newColor;
-};
-
-class SetShapeRectCommand : public QUndoCommand
-{
-public:
- SetShapeRectCommand(Document *doc, const QString &shapeName,
- const QRect &rect, QUndoCommand *parent = nullptr);
-
- void undo() override;
- void redo() override;
-
- bool mergeWith(const QUndoCommand *command) override;
- int id() const override;
-
-private:
- Document *m_doc;
- QString m_shapeName;
- QRect m_oldRect;
- QRect m_newRect;
-};
-
-#endif // COMMANDS_H
diff --git a/examples/widgets/tools/undo/document.cpp b/examples/widgets/tools/undo/document.cpp
deleted file mode 100644
index 1a6d633846..0000000000
--- a/examples/widgets/tools/undo/document.cpp
+++ /dev/null
@@ -1,401 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "document.h"
-#include "commands.h"
-
-#include <QPainter>
-#include <QPaintEvent>
-#include <QTextStream>
-#include <QUndoStack>
-
-static constexpr int resizeHandleWidth = 6;
-
-/******************************************************************************
-** Shape
-*/
-
-const QSize Shape::minSize(80, 50);
-
-Shape::Shape(Type type, const QColor &color, const QRect &rect)
- : m_type(type), m_rect(rect), m_color(color)
-{
-}
-
-Shape::Type Shape::type() const
-{
- return m_type;
-}
-
-QRect Shape::rect() const
-{
- return m_rect;
-}
-
-QColor Shape::color() const
-{
- return m_color;
-}
-
-QString Shape::name() const
-{
- return m_name;
-}
-
-QRect Shape::resizeHandle() const
-{
- QPoint br = m_rect.bottomRight();
- return QRect(br - QPoint(resizeHandleWidth, resizeHandleWidth), br);
-}
-
-QString Shape::typeToString(Type type)
-{
- switch (type) {
- case Rectangle:
- return QLatin1String("Rectangle");
- case Circle:
- return QLatin1String("Circle");
- case Triangle:
- return QLatin1String("Triangle");
- }
-
- return QString();
-}
-
-Shape::Type Shape::stringToType(const QString &s, bool *ok)
-{
- if (ok != nullptr)
- *ok = true;
-
- if (s == QLatin1String("Rectangle"))
- return Rectangle;
- if (s == QLatin1String("Circle"))
- return Circle;
- if (s == QLatin1String("Triangle"))
- return Triangle;
-
- if (ok != nullptr)
- *ok = false;
- return Rectangle;
-}
-
-/******************************************************************************
-** Document
-*/
-
-Document::Document(QWidget *parent)
- : QWidget(parent), m_undoStack(new QUndoStack(this))
-{
- setAutoFillBackground(true);
- setBackgroundRole(QPalette::Base);
-
- QPalette pal = palette();
- pal.setBrush(QPalette::Base, QPixmap(":/icons/background.png"));
- pal.setColor(QPalette::HighlightedText, Qt::red);
- setPalette(pal);
-}
-
-QString Document::addShape(const Shape &shape)
-{
- QString name = Shape::typeToString(shape.type());
- name = uniqueName(name);
-
- m_shapeList.append(shape);
- m_shapeList[m_shapeList.count() - 1].m_name = name;
- setCurrentShape(m_shapeList.count() - 1);
-
- return name;
-}
-
-void Document::deleteShape(const QString &shapeName)
-{
- int index = indexOf(shapeName);
- if (index == -1)
- return;
-
- update(m_shapeList.at(index).rect());
-
- m_shapeList.removeAt(index);
-
- if (index <= m_currentIndex) {
- m_currentIndex = -1;
- if (index == m_shapeList.count())
- --index;
- setCurrentShape(index);
- }
-}
-
-Shape Document::shape(const QString &shapeName) const
-{
- int index = indexOf(shapeName);
- if (index == -1)
- return Shape();
- return m_shapeList.at(index);
-}
-
-void Document::setShapeRect(const QString &shapeName, const QRect &rect)
-{
- int index = indexOf(shapeName);
- if (index == -1)
- return;
-
- Shape &shape = m_shapeList[index];
-
- update(shape.rect());
- update(rect);
-
- shape.m_rect = rect;
-}
-
-void Document::setShapeColor(const QString &shapeName, const QColor &color)
-{
-
- int index = indexOf(shapeName);
- if (index == -1)
- return;
-
- Shape &shape = m_shapeList[index];
- shape.m_color = color;
-
- update(shape.rect());
-}
-
-QUndoStack *Document::undoStack() const
-{
- return m_undoStack;
-}
-
-bool Document::load(QTextStream &stream)
-{
- m_shapeList.clear();
-
- while (!stream.atEnd()) {
- QString shapeType, shapeName, colorName;
- int left, top, width, height;
- stream >> shapeType >> shapeName >> colorName >> left >> top >> width >> height;
- if (stream.status() != QTextStream::Ok)
- return false;
- bool ok;
- Shape::Type type = Shape::stringToType(shapeType, &ok);
- if (!ok)
- return false;
- QColor color(colorName);
- if (!color.isValid())
- return false;
-
- Shape shape(type);
- shape.m_name = shapeName;
- shape.m_color = color;
- shape.m_rect = QRect(left, top, width, height);
-
- m_shapeList.append(shape);
- }
-
- m_currentIndex = m_shapeList.isEmpty() ? -1 : 0;
-
- return true;
-}
-
-void Document::save(QTextStream &stream)
-{
- for (int i = 0; i < m_shapeList.count(); ++i) {
- const Shape &shape = m_shapeList.at(i);
- QRect r = shape.rect();
- stream << Shape::typeToString(shape.type()) << QLatin1Char(' ')
- << shape.name() << QLatin1Char(' ')
- << shape.color().name() << QLatin1Char(' ')
- << r.left() << QLatin1Char(' ')
- << r.top() << QLatin1Char(' ')
- << r.width() << QLatin1Char(' ')
- << r.height();
- if (i != m_shapeList.count() - 1)
- stream << QLatin1Char('\n');
- }
- m_undoStack->setClean();
-}
-
-QString Document::fileName() const
-{
- return m_fileName;
-}
-
-void Document::setFileName(const QString &fileName)
-{
- m_fileName = fileName;
-}
-
-int Document::indexAt(const QPoint &pos) const
-{
- for (int i = m_shapeList.count() - 1; i >= 0; --i) {
- if (m_shapeList.at(i).rect().contains(pos))
- return i;
- }
- return -1;
-}
-
-void Document::mousePressEvent(QMouseEvent *event)
-{
- event->accept();
- int index = indexAt(event->position().toPoint());;
- if (index != -1) {
- setCurrentShape(index);
-
- const Shape &shape = m_shapeList.at(index);
- m_resizeHandlePressed = shape.resizeHandle().contains(event->position().toPoint());
-
- if (m_resizeHandlePressed)
- m_mousePressOffset = shape.rect().bottomRight() - event->position().toPoint();
- else
- m_mousePressOffset = event->position().toPoint() - shape.rect().topLeft();
- }
- m_mousePressIndex = index;
-}
-
-void Document::mouseReleaseEvent(QMouseEvent *event)
-{
- event->accept();
- m_mousePressIndex = -1;
-}
-
-void Document::mouseMoveEvent(QMouseEvent *event)
-{
- event->accept();
-
- if (m_mousePressIndex == -1)
- return;
-
- const Shape &shape = m_shapeList.at(m_mousePressIndex);
-
- QRect rect;
- if (m_resizeHandlePressed) {
- rect = QRect(shape.rect().topLeft(), event->position().toPoint() + m_mousePressOffset);
- } else {
- rect = shape.rect();
- rect.moveTopLeft(event->position().toPoint() - m_mousePressOffset);
- }
-
- QSize size = rect.size().expandedTo(Shape::minSize);
- rect.setSize(size);
-
- m_undoStack->push(new SetShapeRectCommand(this, shape.name(), rect));
-}
-
-static QGradient gradient(const QColor &color, const QRect &rect)
-{
- QColor c = color;
- c.setAlpha(160);
- QLinearGradient result(rect.topLeft(), rect.bottomRight());
- result.setColorAt(0, c.darker(150));
- result.setColorAt(0.5, c.lighter(200));
- result.setColorAt(1, c.darker(150));
- return result;
-}
-
-static QPolygon triangle(const QRect &rect)
-{
- QPolygon result(3);
- result.setPoint(0, rect.center().x(), rect.top());
- result.setPoint(1, rect.right(), rect.bottom());
- result.setPoint(2, rect.left(), rect.bottom());
- return result;
-}
-
-void Document::paintEvent(QPaintEvent *event)
-{
- QRegion paintRegion = event->region();
- QPainter painter(this);
- QPalette pal = palette();
-
- for (int i = 0; i < m_shapeList.count(); ++i) {
- const Shape &shape = m_shapeList.at(i);
-
- if (!paintRegion.contains(shape.rect()))
- continue;
-
- QPen pen = pal.text().color();
- pen.setWidth(i == m_currentIndex ? 2 : 1);
- painter.setPen(pen);
- painter.setBrush(gradient(shape.color(), shape.rect()));
-
- QRect rect = shape.rect();
- rect.adjust(1, 1, -resizeHandleWidth/2, -resizeHandleWidth/2);
-
- // paint the shape
- switch (shape.type()) {
- case Shape::Rectangle:
- painter.drawRect(rect);
- break;
- case Shape::Circle:
- painter.setRenderHint(QPainter::Antialiasing);
- painter.drawEllipse(rect);
- painter.setRenderHint(QPainter::Antialiasing, false);
- break;
- case Shape::Triangle:
- painter.setRenderHint(QPainter::Antialiasing);
- painter.drawPolygon(triangle(rect));
- painter.setRenderHint(QPainter::Antialiasing, false);
- break;
- }
-
- // paint the resize handle
- painter.setPen(pal.text().color());
- painter.setBrush(Qt::white);
- painter.drawRect(shape.resizeHandle().adjusted(0, 0, -1, -1));
-
- // paint the shape name
- painter.setBrush(pal.text());
- if (shape.type() == Shape::Triangle)
- rect.adjust(0, rect.height()/2, 0, 0);
- painter.drawText(rect, Qt::AlignCenter, shape.name());
- }
-}
-
-void Document::setCurrentShape(int index)
-{
- QString currentName;
-
- if (m_currentIndex != -1)
- update(m_shapeList.at(m_currentIndex).rect());
-
- m_currentIndex = index;
-
- if (m_currentIndex != -1) {
- const Shape &current = m_shapeList.at(m_currentIndex);
- update(current.rect());
- currentName = current.name();
- }
-
- emit currentShapeChanged(currentName);
-}
-
-int Document::indexOf(const QString &shapeName) const
-{
- for (int i = 0; i < m_shapeList.count(); ++i) {
- if (m_shapeList.at(i).name() == shapeName)
- return i;
- }
- return -1;
-}
-
-QString Document::uniqueName(const QString &name) const
-{
- QString unique;
-
- for (int i = 0; ; ++i) {
- unique = name;
- if (i > 0)
- unique += QString::number(i);
- if (indexOf(unique) == -1)
- break;
- }
-
- return unique;
-}
-
-QString Document::currentShapeName() const
-{
- if (m_currentIndex == -1)
- return QString();
- return m_shapeList.at(m_currentIndex).name();
-}
-
diff --git a/examples/widgets/tools/undo/document.h b/examples/widgets/tools/undo/document.h
deleted file mode 100644
index a3e5014bf0..0000000000
--- a/examples/widgets/tools/undo/document.h
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef DOCUMENT_H
-#define DOCUMENT_H
-
-#include <QWidget>
-
-QT_FORWARD_DECLARE_CLASS(QUndoStack)
-QT_FORWARD_DECLARE_CLASS(QTextStream)
-
-class Shape
-{
-public:
- enum Type { Rectangle, Circle, Triangle };
-
- explicit Shape(Type type = Rectangle, const QColor &color = Qt::red, const QRect &rect = QRect());
-
- Type type() const;
- QString name() const;
- QRect rect() const;
- QRect resizeHandle() const;
- QColor color() const;
-
- static QString typeToString(Type type);
- static Type stringToType(const QString &s, bool *ok = nullptr);
-
- static const QSize minSize;
-
-private:
- Type m_type;
- QRect m_rect;
- QColor m_color;
- QString m_name;
-
- friend class Document;
-};
-
-class Document : public QWidget
-{
- Q_OBJECT
-
-public:
- Document(QWidget *parent = nullptr);
-
- QString addShape(const Shape &shape);
- void deleteShape(const QString &shapeName);
- Shape shape(const QString &shapeName) const;
- QString currentShapeName() const;
-
- void setShapeRect(const QString &shapeName, const QRect &rect);
- void setShapeColor(const QString &shapeName, const QColor &color);
-
- bool load(QTextStream &stream);
- void save(QTextStream &stream);
-
- QString fileName() const;
- void setFileName(const QString &fileName);
-
- QUndoStack *undoStack() const;
-
-signals:
- void currentShapeChanged(const QString &shapeName);
-
-protected:
- void paintEvent(QPaintEvent *event) override;
- void mousePressEvent(QMouseEvent *event) override;
- void mouseReleaseEvent(QMouseEvent *event) override;
- void mouseMoveEvent(QMouseEvent *event) override;
-
-private:
- void setCurrentShape(int index);
- int indexOf(const QString &shapeName) const;
- int indexAt(const QPoint &pos) const;
- QString uniqueName(const QString &name) const;
-
- QList<Shape> m_shapeList;
- QPoint m_mousePressOffset;
- QString m_fileName;
- QUndoStack *m_undoStack = nullptr;
- int m_currentIndex = -1;
- int m_mousePressIndex = -1;
- bool m_resizeHandlePressed = false;
-};
-
-#endif // DOCUMENT_H
diff --git a/examples/widgets/tools/undo/icons/background.png b/examples/widgets/tools/undo/icons/background.png
deleted file mode 100644
index 3bc5ed8cf0..0000000000
--- a/examples/widgets/tools/undo/icons/background.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/blue.png b/examples/widgets/tools/undo/icons/blue.png
deleted file mode 100644
index 4e181bb61a..0000000000
--- a/examples/widgets/tools/undo/icons/blue.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/circle.png b/examples/widgets/tools/undo/icons/circle.png
deleted file mode 100644
index ed16c6e144..0000000000
--- a/examples/widgets/tools/undo/icons/circle.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/exit.png b/examples/widgets/tools/undo/icons/exit.png
deleted file mode 100644
index 539cb2ead9..0000000000
--- a/examples/widgets/tools/undo/icons/exit.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/fileclose.png b/examples/widgets/tools/undo/icons/fileclose.png
deleted file mode 100644
index c5483d14ab..0000000000
--- a/examples/widgets/tools/undo/icons/fileclose.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/filenew.png b/examples/widgets/tools/undo/icons/filenew.png
deleted file mode 100644
index 57e57e343b..0000000000
--- a/examples/widgets/tools/undo/icons/filenew.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/fileopen.png b/examples/widgets/tools/undo/icons/fileopen.png
deleted file mode 100644
index 33e0d6394c..0000000000
--- a/examples/widgets/tools/undo/icons/fileopen.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/filesave.png b/examples/widgets/tools/undo/icons/filesave.png
deleted file mode 100644
index 57fd5e2f34..0000000000
--- a/examples/widgets/tools/undo/icons/filesave.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/green.png b/examples/widgets/tools/undo/icons/green.png
deleted file mode 100644
index e2e7cc9e50..0000000000
--- a/examples/widgets/tools/undo/icons/green.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/ok.png b/examples/widgets/tools/undo/icons/ok.png
deleted file mode 100644
index e355ea91bc..0000000000
--- a/examples/widgets/tools/undo/icons/ok.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/red.png b/examples/widgets/tools/undo/icons/red.png
deleted file mode 100644
index 58c3e7253b..0000000000
--- a/examples/widgets/tools/undo/icons/red.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/main.cpp b/examples/widgets/tools/undo/main.cpp
deleted file mode 100644
index ce28152f75..0000000000
--- a/examples/widgets/tools/undo/main.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-#include "mainwindow.h"
-
-int main(int argc, char **argv)
-{
- Q_INIT_RESOURCE(undo);
-
- QApplication app(argc, argv);
-
- MainWindow win;
- win.resize(800, 600);
- win.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/tools/undo/mainwindow.cpp b/examples/widgets/tools/undo/mainwindow.cpp
deleted file mode 100644
index 20d382e217..0000000000
--- a/examples/widgets/tools/undo/mainwindow.cpp
+++ /dev/null
@@ -1,410 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-#include "document.h"
-#include "commands.h"
-
-#include <QUndoGroup>
-#include <QUndoStack>
-#include <QFileDialog>
-#include <QMessageBox>
-#include <QRandomGenerator>
-#include <QTextStream>
-#include <QToolButton>
-
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
-{
- setupUi(this);
-
- QWidget *w = documentTabs->widget(0);
- documentTabs->removeTab(0);
- delete w;
-
- connect(actionOpen, &QAction::triggered, this, &MainWindow::openDocument);
- connect(actionClose, &QAction::triggered, this, &MainWindow::closeDocument);
- connect(actionNew, &QAction::triggered, this, &MainWindow::newDocument);
- connect(actionSave, &QAction::triggered, this, &MainWindow::saveDocument);
- connect(actionExit, &QAction::triggered, this, &QWidget::close);
- connect(actionRed, &QAction::triggered, this, &MainWindow::setShapeColor);
- connect(actionGreen, &QAction::triggered, this, &MainWindow::setShapeColor);
- connect(actionBlue, &QAction::triggered, this, &MainWindow::setShapeColor);
- connect(actionAddCircle, &QAction::triggered, this, &MainWindow::addShape);
- connect(actionAddRectangle, &QAction::triggered, this, &MainWindow::addShape);
- connect(actionAddTriangle, &QAction::triggered, this, &MainWindow::addShape);
- connect(actionRemoveShape, &QAction::triggered, this, &MainWindow::removeShape);
- connect(actionAddRobot, &QAction::triggered, this, &MainWindow::addRobot);
- connect(actionAddSnowman, &QAction::triggered, this, &MainWindow::addSnowman);
- connect(actionAbout, &QAction::triggered, this, &MainWindow::about);
- connect(actionAboutQt, &QAction::triggered, this, &MainWindow::aboutQt);
-
- connect(undoLimit, &QSpinBox::valueChanged, this, &MainWindow::updateActions);
- connect(documentTabs, &QTabWidget::currentChanged, this, &MainWindow::updateActions);
-
- actionOpen->setShortcut(QString("Ctrl+O"));
- actionClose->setShortcut(QString("Ctrl+W"));
- actionNew->setShortcut(QString("Ctrl+N"));
- actionSave->setShortcut(QString("Ctrl+S"));
- actionExit->setShortcut(QString("Ctrl+Q"));
- actionRemoveShape->setShortcut(QString("Del"));
- actionRed->setShortcut(QString("Alt+R"));
- actionGreen->setShortcut(QString("Alt+G"));
- actionBlue->setShortcut(QString("Alt+B"));
- actionAddCircle->setShortcut(QString("Alt+C"));
- actionAddRectangle->setShortcut(QString("Alt+L"));
- actionAddTriangle->setShortcut(QString("Alt+T"));
-
- m_undoGroup = new QUndoGroup(this);
- undoView->setGroup(m_undoGroup);
- undoView->setCleanIcon(QIcon(":/icons/ok.png"));
-
- QAction *undoAction = m_undoGroup->createUndoAction(this);
- QAction *redoAction = m_undoGroup->createRedoAction(this);
- undoAction->setIcon(QIcon(":/icons/undo.png"));
- redoAction->setIcon(QIcon(":/icons/redo.png"));
- menuShape->insertAction(menuShape->actions().at(0), undoAction);
- menuShape->insertAction(undoAction, redoAction);
-
- toolBar->addAction(undoAction);
- toolBar->addAction(redoAction);
-
- newDocument();
- updateActions();
-};
-
-void MainWindow::updateActions()
-{
- Document *doc = currentDocument();
- m_undoGroup->setActiveStack(doc == nullptr ? nullptr : doc->undoStack());
- QString shapeName = doc == nullptr ? QString() : doc->currentShapeName();
-
- actionAddRobot->setEnabled(doc != nullptr);
- actionAddSnowman->setEnabled(doc != nullptr);
- actionAddCircle->setEnabled(doc != nullptr);
- actionAddRectangle->setEnabled(doc != nullptr);
- actionAddTriangle->setEnabled(doc != nullptr);
- actionClose->setEnabled(doc != nullptr);
- actionSave->setEnabled(doc != nullptr && !doc->undoStack()->isClean());
- undoLimit->setEnabled(doc != nullptr && doc->undoStack()->count() == 0);
-
- if (shapeName.isEmpty()) {
- actionRed->setEnabled(false);
- actionGreen->setEnabled(false);
- actionBlue->setEnabled(false);
- actionRemoveShape->setEnabled(false);
- } else {
- Shape shape = doc->shape(shapeName);
- actionRed->setEnabled(shape.color() != Qt::red);
- actionGreen->setEnabled(shape.color() != Qt::green);
- actionBlue->setEnabled(shape.color() != Qt::blue);
- actionRemoveShape->setEnabled(true);
- }
-
- if (doc != nullptr) {
- int index = documentTabs->indexOf(doc);
- Q_ASSERT(index != -1);
- static const QIcon unsavedIcon(":/icons/filesave.png");
- documentTabs->setTabIcon(index, doc->undoStack()->isClean() ? QIcon() : unsavedIcon);
-
- if (doc->undoStack()->count() == 0)
- doc->undoStack()->setUndoLimit(undoLimit->value());
- }
-}
-
-void MainWindow::openDocument()
-{
- QString fileName = QFileDialog::getOpenFileName(this);
- if (fileName.isEmpty())
- return;
-
- QFile file(fileName);
- if (!file.open(QIODevice::ReadOnly)) {
- QMessageBox::warning(this,
- tr("File error"),
- tr("Failed to open\n%1").arg(fileName));
- return;
- }
- QTextStream stream(&file);
-
- Document *doc = new Document();
- if (!doc->load(stream)) {
- QMessageBox::warning(this,
- tr("Parse error"),
- tr("Failed to parse\n%1").arg(fileName));
- delete doc;
- return;
- }
-
- doc->setFileName(fileName);
- addDocument(doc);
-}
-
-QString MainWindow::fixedWindowTitle(const Document *doc) const
-{
- QString title = doc->fileName();
-
- if (title.isEmpty())
- title = tr("Unnamed");
- else
- title = QFileInfo(title).fileName();
-
- QString result;
-
- for (int i = 0; ; ++i) {
- result = title;
- if (i > 0)
- result += QString::number(i);
-
- bool unique = true;
- for (int j = 0; j < documentTabs->count(); ++j) {
- const QWidget *widget = documentTabs->widget(j);
- if (widget == doc)
- continue;
- if (result == documentTabs->tabText(j)) {
- unique = false;
- break;
- }
- }
-
- if (unique)
- break;
- }
-
- return result;
-}
-
-void MainWindow::addDocument(Document *doc)
-{
- if (documentTabs->indexOf(doc) != -1)
- return;
- m_undoGroup->addStack(doc->undoStack());
- documentTabs->addTab(doc, fixedWindowTitle(doc));
- connect(doc, &Document::currentShapeChanged, this, &MainWindow::updateActions);
- connect(doc->undoStack(), &QUndoStack::indexChanged, this, &MainWindow::updateActions);
- connect(doc->undoStack(), &QUndoStack::cleanChanged, this, &MainWindow::updateActions);
-
- setCurrentDocument(doc);
-}
-
-void MainWindow::setCurrentDocument(Document *doc)
-{
- documentTabs->setCurrentWidget(doc);
-}
-
-Document *MainWindow::currentDocument() const
-{
- return qobject_cast<Document*>(documentTabs->currentWidget());
-}
-
-void MainWindow::removeDocument(Document *doc)
-{
- int index = documentTabs->indexOf(doc);
- if (index == -1)
- return;
-
- documentTabs->removeTab(index);
- m_undoGroup->removeStack(doc->undoStack());
- disconnect(doc, &Document::currentShapeChanged, this, &MainWindow::updateActions);
- disconnect(doc->undoStack(), &QUndoStack::indexChanged, this, &MainWindow::updateActions);
- disconnect(doc->undoStack(), &QUndoStack::cleanChanged, this, &MainWindow::updateActions);
-
- if (documentTabs->count() == 0) {
- newDocument();
- updateActions();
- }
-}
-
-void MainWindow::saveDocument()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- for (;;) {
- QString fileName = doc->fileName();
-
- if (fileName.isEmpty())
- fileName = QFileDialog::getSaveFileName(this);
- if (fileName.isEmpty())
- break;
-
- QFile file(fileName);
- if (!file.open(QIODevice::WriteOnly)) {
- QMessageBox::warning(this,
- tr("File error"),
- tr("Failed to open\n%1").arg(fileName));
- doc->setFileName(QString());
- } else {
- QTextStream stream(&file);
- doc->save(stream);
- doc->setFileName(fileName);
-
- int index = documentTabs->indexOf(doc);
- Q_ASSERT(index != -1);
- documentTabs->setTabText(index, fixedWindowTitle(doc));
-
- break;
- }
- }
-}
-
-void MainWindow::closeDocument()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- if (!doc->undoStack()->isClean()) {
- int button
- = QMessageBox::warning(this,
- tr("Unsaved changes"),
- tr("Would you like to save this document?"),
- QMessageBox::Yes, QMessageBox::No);
- if (button == QMessageBox::Yes)
- saveDocument();
- }
-
- removeDocument(doc);
- delete doc;
-}
-
-void MainWindow::newDocument()
-{
- addDocument(new Document());
-}
-
-static QColor randomColor()
-{
- int r = QRandomGenerator::global()->bounded(3);
- switch (r) {
- case 0:
- return Qt::red;
- case 1:
- return Qt::green;
- default:
- break;
- }
- return Qt::blue;
-}
-
-static QRect randomRect(const QSize &s)
-{
- QSize min = Shape::minSize;
-
- int left = qRound((s.width() - min.width()) * (QRandomGenerator::global()->bounded(1.0)));
- int top = qRound((s.height() - min.height()) * (QRandomGenerator::global()->bounded(1.0)));
- int width = qRound((s.width() - left - min.width()) * (QRandomGenerator::global()->bounded(1.0))) + min.width();
- int height = qRound((s.height() - top - min.height()) * (QRandomGenerator::global()->bounded(1.0))) + min.height();
-
- return QRect(left, top, width, height);
-}
-
-void MainWindow::addShape()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- Shape::Type type;
-
- if (sender() == actionAddCircle)
- type = Shape::Circle;
- else if (sender() == actionAddRectangle)
- type = Shape::Rectangle;
- else if (sender() == actionAddTriangle)
- type = Shape::Triangle;
- else return;
-
- Shape newShape(type, randomColor(), randomRect(doc->size()));
- doc->undoStack()->push(new AddShapeCommand(doc, newShape));
-}
-
-void MainWindow::removeShape()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- QString shapeName = doc->currentShapeName();
- if (shapeName.isEmpty())
- return;
-
- doc->undoStack()->push(new RemoveShapeCommand(doc, shapeName));
-}
-
-void MainWindow::setShapeColor()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- QString shapeName = doc->currentShapeName();
- if (shapeName.isEmpty())
- return;
-
- QColor color;
-
- if (sender() == actionRed)
- color = Qt::red;
- else if (sender() == actionGreen)
- color = Qt::green;
- else if (sender() == actionBlue)
- color = Qt::blue;
- else
- return;
-
- if (color == doc->shape(shapeName).color())
- return;
-
- doc->undoStack()->push(new SetShapeColorCommand(doc, shapeName, color));
-}
-
-void MainWindow::addSnowman()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- // Create a macro command using beginMacro() and endMacro()
-
- doc->undoStack()->beginMacro(tr("Add snowman"));
- doc->undoStack()->push(new AddShapeCommand(doc,
- Shape(Shape::Circle, Qt::blue, QRect(51, 30, 97, 95))));
- doc->undoStack()->push(new AddShapeCommand(doc,
- Shape(Shape::Circle, Qt::blue, QRect(27, 123, 150, 133))));
- doc->undoStack()->push(new AddShapeCommand(doc,
- Shape(Shape::Circle, Qt::blue, QRect(11, 253, 188, 146))));
- doc->undoStack()->endMacro();
-}
-
-void MainWindow::addRobot()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- // Compose a macro command by explicitly adding children to a parent command
-
- QUndoCommand *parent = new QUndoCommand(tr("Add robot"));
-
- new AddShapeCommand(doc, Shape(Shape::Rectangle, Qt::green, QRect(115, 15, 81, 70)), parent);
- new AddShapeCommand(doc, Shape(Shape::Rectangle, Qt::green, QRect(82, 89, 148, 188)), parent);
- new AddShapeCommand(doc, Shape(Shape::Rectangle, Qt::green, QRect(76, 280, 80, 165)), parent);
- new AddShapeCommand(doc, Shape(Shape::Rectangle, Qt::green, QRect(163, 280, 80, 164)), parent);
- new AddShapeCommand(doc, Shape(Shape::Circle, Qt::blue, QRect(116, 25, 80, 50)), parent);
- new AddShapeCommand(doc, Shape(Shape::Rectangle, Qt::green, QRect(232, 92, 80, 127)), parent);
- new AddShapeCommand(doc, Shape(Shape::Rectangle, Qt::green, QRect(2, 92, 80, 125)), parent);
-
- doc->undoStack()->push(parent);
-}
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About Undo"), tr("The Undo demonstration shows how to use the Qt Undo framework."));
-}
-
-void MainWindow::aboutQt()
-{
- QMessageBox::aboutQt(this, tr("About Qt"));
-}
diff --git a/examples/widgets/tools/undo/mainwindow.h b/examples/widgets/tools/undo/mainwindow.h
deleted file mode 100644
index cda67ea196..0000000000
--- a/examples/widgets/tools/undo/mainwindow.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include "ui_mainwindow.h"
-
-class Document;
-
-class MainWindow : public QMainWindow, public Ui::MainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow(QWidget *parent = nullptr);
-
- void addDocument(Document *doc);
- void removeDocument(Document *doc);
- void setCurrentDocument(Document *doc);
- Document *currentDocument() const;
-
-public slots:
- void openDocument();
- void saveDocument();
- void closeDocument();
- void newDocument();
-
- void addShape();
- void removeShape();
- void setShapeColor();
-
- void addSnowman();
- void addRobot();
-
- void about();
- void aboutQt();
-
-private slots:
- void updateActions();
-
-private:
- QUndoGroup *m_undoGroup;
-
- QString fixedWindowTitle(const Document *doc) const;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/widgets/tools/undo/mainwindow.ui b/examples/widgets/tools/undo/mainwindow.ui
deleted file mode 100644
index 91a0b437e5..0000000000
--- a/examples/widgets/tools/undo/mainwindow.ui
+++ /dev/null
@@ -1,322 +0,0 @@
-<ui version="4.0" >
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>567</width>
- <height>600</height>
- </rect>
- </property>
- <property name="iconSize" >
- <size>
- <width>32</width>
- <height>32</height>
- </size>
- </property>
- <widget class="QWidget" name="centralwidget" >
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>0</number>
- </property>
- <item>
- <widget class="QTabWidget" name="documentTabs" >
- <property name="currentIndex" >
- <number>0</number>
- </property>
- <widget class="QWidget" name="tab" >
- <attribute name="title" >
- <string>Tab 1</string>
- </attribute>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QMenuBar" name="menubar" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>567</width>
- <height>27</height>
- </rect>
- </property>
- <widget class="QMenu" name="menuFile" >
- <property name="title" >
- <string>File</string>
- </property>
- <addaction name="actionNew" />
- <addaction name="actionOpen" />
- <addaction name="actionSave" />
- <addaction name="actionClose" />
- <addaction name="separator" />
- <addaction name="actionExit" />
- </widget>
- <widget class="QMenu" name="menuShape" >
- <property name="title" >
- <string>Edit</string>
- </property>
- <widget class="QMenu" name="menuMacros" >
- <property name="title" >
- <string>Macros</string>
- </property>
- <addaction name="actionAddRobot" />
- <addaction name="actionAddSnowman" />
- </widget>
- <addaction name="separator" />
- <addaction name="actionAddCircle" />
- <addaction name="actionAddRectangle" />
- <addaction name="actionAddTriangle" />
- <addaction name="actionRemoveShape" />
- <addaction name="separator" />
- <addaction name="actionRed" />
- <addaction name="actionGreen" />
- <addaction name="actionBlue" />
- <addaction name="separator" />
- <addaction name="menuMacros" />
- </widget>
- <widget class="QMenu" name="menuHelp" >
- <property name="title" >
- <string>Help</string>
- </property>
- <addaction name="actionAbout" />
- <addaction name="actionAboutQt" />
- </widget>
- <addaction name="menuFile" />
- <addaction name="menuShape" />
- <addaction name="menuHelp" />
- </widget>
- <widget class="QStatusBar" name="statusbar" />
- <widget class="QToolBar" name="toolBar" >
- <property name="windowTitle" >
- <string>File actions</string>
- </property>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <attribute name="toolBarArea" >
- <enum>TopToolBarArea</enum>
- </attribute>
- <attribute name="toolBarBreak" >
- <bool>false</bool>
- </attribute>
- <addaction name="actionNew" />
- <addaction name="actionOpen" />
- <addaction name="actionSave" />
- <addaction name="actionClose" />
- <addaction name="separator" />
- </widget>
- <widget class="QToolBar" name="shapeToolBar" >
- <property name="windowTitle" >
- <string>Shape actions</string>
- </property>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <attribute name="toolBarArea" >
- <enum>LeftToolBarArea</enum>
- </attribute>
- <attribute name="toolBarBreak" >
- <bool>false</bool>
- </attribute>
- <addaction name="actionAddRectangle" />
- <addaction name="actionAddCircle" />
- <addaction name="actionAddTriangle" />
- <addaction name="actionRemoveShape" />
- <addaction name="separator" />
- <addaction name="actionRed" />
- <addaction name="actionGreen" />
- <addaction name="actionBlue" />
- </widget>
- <widget class="QDockWidget" name="dockWidget" >
- <property name="windowTitle" >
- <string>Undo Stack</string>
- </property>
- <attribute name="dockWidgetArea" >
- <number>2</number>
- </attribute>
- <widget class="QWidget" name="dockWidgetContents" >
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>4</number>
- </property>
- <item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>Undo limit</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSpinBox" name="undoLimit" />
- </item>
- </layout>
- </item>
- <item>
- <widget class="QUndoView" name="undoView" >
- <property name="alternatingRowColors" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- <action name="actionOpen" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/fileopen.png</iconset>
- </property>
- <property name="text" >
- <string>&amp;Open</string>
- </property>
- </action>
- <action name="actionClose" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/fileclose.png</iconset>
- </property>
- <property name="text" >
- <string>&amp;Close</string>
- </property>
- </action>
- <action name="actionNew" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/filenew.png</iconset>
- </property>
- <property name="text" >
- <string>&amp;New</string>
- </property>
- </action>
- <action name="actionSave" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/filesave.png</iconset>
- </property>
- <property name="text" >
- <string>&amp;Save</string>
- </property>
- </action>
- <action name="actionExit" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/exit.png</iconset>
- </property>
- <property name="text" >
- <string>E&amp;xit</string>
- </property>
- </action>
- <action name="actionRed" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/red.png</iconset>
- </property>
- <property name="text" >
- <string>Red</string>
- </property>
- </action>
- <action name="actionGreen" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/green.png</iconset>
- </property>
- <property name="text" >
- <string>Green</string>
- </property>
- </action>
- <action name="actionBlue" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/blue.png</iconset>
- </property>
- <property name="text" >
- <string>Blue</string>
- </property>
- </action>
- <action name="actionAddRectangle" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/rectangle.png</iconset>
- </property>
- <property name="text" >
- <string>Add Rectangle</string>
- </property>
- </action>
- <action name="actionAddCircle" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/circle.png</iconset>
- </property>
- <property name="text" >
- <string>Add Circle</string>
- </property>
- </action>
- <action name="actionRemoveShape" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/remove.png</iconset>
- </property>
- <property name="text" >
- <string>Remove Shape</string>
- </property>
- </action>
- <action name="actionAddRobot" >
- <property name="text" >
- <string>Add robot</string>
- </property>
- </action>
- <action name="actionAddSnowman" >
- <property name="text" >
- <string>Add snowan</string>
- </property>
- </action>
- <action name="actionAddTriangle" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/triangle.png</iconset>
- </property>
- <property name="text" >
- <string>addTriangle</string>
- </property>
- </action>
- <action name="actionAbout" >
- <property name="text" >
- <string>About</string>
- </property>
- </action>
- <action name="actionAboutQt" >
- <property name="text" >
- <string>About Qt</string>
- </property>
- </action>
- </widget>
- <customwidgets>
- <customwidget>
- <class>QUndoView</class>
- <extends>QListView</extends>
- <header>qundoview.h</header>
- </customwidget>
- </customwidgets>
- <resources>
- <include location="undo.qrc" />
- </resources>
- <connections/>
-</ui>
diff --git a/examples/widgets/tools/undo/undo.pro b/examples/widgets/tools/undo/undo.pro
deleted file mode 100644
index 9b7b577dd3..0000000000
--- a/examples/widgets/tools/undo/undo.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-QT += widgets
-requires(qtConfig(undoview))
-
-SOURCES += main.cpp mainwindow.cpp commands.cpp document.cpp
-HEADERS += mainwindow.h commands.h document.h
-FORMS += mainwindow.ui
-
-build_all:!build_pass {
- CONFIG -= build_all
- CONFIG += release
-}
-
-RESOURCES += undo.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/undo
-INSTALLS += target
diff --git a/examples/widgets/tools/undo/undo.qrc b/examples/widgets/tools/undo/undo.qrc
deleted file mode 100644
index 65619b8f1a..0000000000
--- a/examples/widgets/tools/undo/undo.qrc
+++ /dev/null
@@ -1,20 +0,0 @@
-<RCC>
- <qresource prefix="/" >
- <file>icons/background.png</file>
- <file>icons/blue.png</file>
- <file>icons/circle.png</file>
- <file>icons/exit.png</file>
- <file>icons/fileclose.png</file>
- <file>icons/filenew.png</file>
- <file>icons/fileopen.png</file>
- <file>icons/filesave.png</file>
- <file>icons/green.png</file>
- <file>icons/ok.png</file>
- <file>icons/rectangle.png</file>
- <file>icons/red.png</file>
- <file>icons/redo.png</file>
- <file>icons/remove.png</file>
- <file>icons/triangle.png</file>
- <file>icons/undo.png</file>
- </qresource>
-</RCC>
diff --git a/examples/widgets/tools/undoframework/CMakeLists.txt b/examples/widgets/tools/undoframework/CMakeLists.txt
index 6a20234c02..27912f04c7 100644
--- a/examples/widgets/tools/undoframework/CMakeLists.txt
+++ b/examples/widgets/tools/undoframework/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(undoframework LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/undoframework")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(undoframework
commands.cpp commands.h
diagramitem.cpp diagramitem.h
@@ -27,15 +21,20 @@ set_target_properties(undoframework PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(undoframework PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(undoframework PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
set(undoframework_resource_files
- "images/cross.png"
+ "icons/cross.png"
+ "icons/rectangle.png"
+ "icons/redo.png"
+ "icons/remove.png"
+ "icons/triangle.png"
+ "icons/undo.png"
)
qt_add_resources(undoframework "undoframework"
@@ -46,7 +45,14 @@ qt_add_resources(undoframework "undoframework"
)
install(TARGETS undoframework
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET undoframework
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tools/undoframework/images/cross.png b/examples/widgets/tools/undoframework/icons/cross.png
index 3570a242ae..3570a242ae 100644
--- a/examples/widgets/tools/undoframework/images/cross.png
+++ b/examples/widgets/tools/undoframework/icons/cross.png
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/rectangle.png b/examples/widgets/tools/undoframework/icons/rectangle.png
index 3a7d9795fd..3a7d9795fd 100644
--- a/examples/widgets/tools/undo/icons/rectangle.png
+++ b/examples/widgets/tools/undoframework/icons/rectangle.png
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/redo.png b/examples/widgets/tools/undoframework/icons/redo.png
index 5591517e1c..5591517e1c 100644
--- a/examples/widgets/tools/undo/icons/redo.png
+++ b/examples/widgets/tools/undoframework/icons/redo.png
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/remove.png b/examples/widgets/tools/undoframework/icons/remove.png
index 7a7b048c0a..7a7b048c0a 100644
--- a/examples/widgets/tools/undo/icons/remove.png
+++ b/examples/widgets/tools/undoframework/icons/remove.png
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/triangle.png b/examples/widgets/tools/undoframework/icons/triangle.png
index 2969131c31..2969131c31 100644
--- a/examples/widgets/tools/undo/icons/triangle.png
+++ b/examples/widgets/tools/undoframework/icons/triangle.png
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/undo.png b/examples/widgets/tools/undoframework/icons/undo.png
index 8cf63a8ec9..8cf63a8ec9 100644
--- a/examples/widgets/tools/undo/icons/undo.png
+++ b/examples/widgets/tools/undoframework/icons/undo.png
Binary files differ
diff --git a/examples/widgets/tools/undoframework/main.cpp b/examples/widgets/tools/undoframework/main.cpp
index c43b2fccd7..8dfa3ffb4b 100644
--- a/examples/widgets/tools/undoframework/main.cpp
+++ b/examples/widgets/tools/undoframework/main.cpp
@@ -8,8 +8,6 @@
//! [0]
int main(int argv, char *args[])
{
- Q_INIT_RESOURCE(undoframework);
-
QApplication app(argv, args);
MainWindow mainWindow;
diff --git a/examples/widgets/tools/undoframework/mainwindow.cpp b/examples/widgets/tools/undoframework/mainwindow.cpp
index 6b13d0d328..c2a6c1cff6 100644
--- a/examples/widgets/tools/undoframework/mainwindow.cpp
+++ b/examples/widgets/tools/undoframework/mainwindow.cpp
@@ -7,70 +7,75 @@
#include "commands.h"
#include <QAction>
+#include <QDockWidget>
#include <QGraphicsView>
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
+#include <QToolBar>
#include <QUndoView>
//! [0]
MainWindow::MainWindow()
{
undoStack = new QUndoStack(this);
+ diagramScene = new DiagramScene();
+
+ const QBrush pixmapBrush(QPixmap(":/icons/cross.png").scaled(30, 30));
+ diagramScene->setBackgroundBrush(pixmapBrush);
+ diagramScene->setSceneRect(QRect(0, 0, 500, 500));
createActions();
createMenus();
+ createToolBars();
createUndoView();
- diagramScene = new DiagramScene();
- QBrush pixmapBrush(QPixmap(":/images/cross.png").scaled(30, 30));
- diagramScene->setBackgroundBrush(pixmapBrush);
- diagramScene->setSceneRect(QRect(0, 0, 500, 500));
-
connect(diagramScene, &DiagramScene::itemMoved,
this, &MainWindow::itemMoved);
+ connect(diagramScene, &DiagramScene::selectionChanged,
+ this, &MainWindow::updateActions);
setWindowTitle("Undo Framework");
QGraphicsView *view = new QGraphicsView(diagramScene);
setCentralWidget(view);
- resize(700, 500);
+ adjustSize();
}
//! [0]
//! [1]
void MainWindow::createUndoView()
{
- undoView = new QUndoView(undoStack);
- undoView->setWindowTitle(tr("Command List"));
- undoView->show();
- undoView->setAttribute(Qt::WA_QuitOnClose, false);
+ QDockWidget *undoDockWidget = new QDockWidget;
+ undoDockWidget->setWindowTitle(tr("Command List"));
+ undoDockWidget->setWidget(new QUndoView(undoStack));
+ addDockWidget(Qt::RightDockWidgetArea, undoDockWidget);
}
//! [1]
//! [2]
void MainWindow::createActions()
{
- deleteAction = new QAction(tr("&Delete Item"), this);
+ deleteAction = new QAction(QIcon(":/icons/remove.png"), tr("&Delete Item"), this);
deleteAction->setShortcut(tr("Del"));
connect(deleteAction, &QAction::triggered, this, &MainWindow::deleteItem);
-//! [2] //! [3]
+//! [2]
-//! [3] //! [4]
- addBoxAction = new QAction(tr("Add &Box"), this);
-//! [4]
+ addBoxAction = new QAction(QIcon(":/icons/rectangle.png"), tr("Add &Box"), this);
addBoxAction->setShortcut(tr("Ctrl+O"));
connect(addBoxAction, &QAction::triggered, this, &MainWindow::addBox);
- addTriangleAction = new QAction(tr("Add &Triangle"), this);
+ addTriangleAction = new QAction(QIcon(":/icons/triangle.png"), tr("Add &Triangle"), this);
addTriangleAction->setShortcut(tr("Ctrl+T"));
connect(addTriangleAction, &QAction::triggered, this, &MainWindow::addTriangle);
//! [5]
undoAction = undoStack->createUndoAction(this, tr("&Undo"));
+ undoAction->setIcon(QIcon(":/icons/undo.png"));
undoAction->setShortcuts(QKeySequence::Undo);
redoAction = undoStack->createRedoAction(this, tr("&Redo"));
+ redoAction->setIcon(QIcon(":/icons/redo.png"));
redoAction->setShortcuts(QKeySequence::Redo);
//! [5]
@@ -83,46 +88,66 @@ void MainWindow::createActions()
aboutShortcuts << tr("Ctrl+A") << tr("Ctrl+B");
aboutAction->setShortcuts(aboutShortcuts);
connect(aboutAction, &QAction::triggered, this, &MainWindow::about);
+
+//! [6]
+ updateActions();
}
+void MainWindow::updateActions()
+{
+ deleteAction->setEnabled(!diagramScene->selectedItems().isEmpty());
+}
//! [6]
+
+//! [7]
void MainWindow::createMenus()
{
-//! [6]
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(exitAction);
-//! [7]
editMenu = menuBar()->addMenu(tr("&Edit"));
editMenu->addAction(undoAction);
editMenu->addAction(redoAction);
editMenu->addSeparator();
editMenu->addAction(deleteAction);
- connect(editMenu, &QMenu::aboutToShow,
- this, &MainWindow::itemMenuAboutToShow);
- connect(editMenu, &QMenu::aboutToHide,
- this, &MainWindow::itemMenuAboutToHide);
-
//! [7]
+
itemMenu = menuBar()->addMenu(tr("&Item"));
itemMenu->addAction(addBoxAction);
itemMenu->addAction(addTriangleAction);
+//! [8]
helpMenu = menuBar()->addMenu(tr("&About"));
helpMenu->addAction(aboutAction);
-//! [8]
}
+
+void MainWindow::createToolBars()
+{
+ QToolBar *editToolBar = new QToolBar;
+ editToolBar->addAction(undoAction);
+ editToolBar->addAction(redoAction);
+ editToolBar->addSeparator();
+ editToolBar->addAction(deleteAction);
//! [8]
+ QToolBar *itemToolBar = new QToolBar;
+ itemToolBar->addAction(addBoxAction);
+ itemToolBar->addAction(addTriangleAction);
+//! [9]
+ addToolBar(editToolBar);
+ addToolBar(itemToolBar);
+}
//! [9]
+
+//! [11]
void MainWindow::itemMoved(DiagramItem *movedItem,
const QPointF &oldPosition)
{
undoStack->push(new MoveCommand(movedItem, oldPosition));
}
-//! [9]
+//! [11]
-//! [10]
+//! [12]
void MainWindow::deleteItem()
{
if (diagramScene->selectedItems().isEmpty())
@@ -131,20 +156,6 @@ void MainWindow::deleteItem()
QUndoCommand *deleteCommand = new DeleteCommand(diagramScene);
undoStack->push(deleteCommand);
}
-//! [10]
-
-//! [11]
-void MainWindow::itemMenuAboutToHide()
-{
- deleteAction->setEnabled(true);
-}
-//! [11]
-
-//! [12]
-void MainWindow::itemMenuAboutToShow()
-{
- deleteAction->setEnabled(!diagramScene->selectedItems().isEmpty());
-}
//! [12]
//! [13]
diff --git a/examples/widgets/tools/undoframework/mainwindow.h b/examples/widgets/tools/undoframework/mainwindow.h
index c635ed0172..5ef1dddf75 100644
--- a/examples/widgets/tools/undoframework/mainwindow.h
+++ b/examples/widgets/tools/undoframework/mainwindow.h
@@ -32,12 +32,12 @@ private slots:
void addBox();
void addTriangle();
void about();
- void itemMenuAboutToShow();
- void itemMenuAboutToHide();
+ void updateActions();
private:
void createActions();
void createMenus();
+ void createToolBars();
void createUndoView();
QAction *deleteAction = nullptr;
diff --git a/examples/widgets/tools/undoframework/undoframework.qrc b/examples/widgets/tools/undoframework/undoframework.qrc
index 6321d94d8d..298cc768bd 100644
--- a/examples/widgets/tools/undoframework/undoframework.qrc
+++ b/examples/widgets/tools/undoframework/undoframework.qrc
@@ -1,6 +1,10 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
- <file>images/cross.png</file>
+ <file>icons/cross.png</file>
+ <file>icons/rectangle.png</file>
+ <file>icons/redo.png</file>
+ <file>icons/remove.png</file>
+ <file>icons/triangle.png</file>
+ <file>icons/undo.png</file>
</qresource>
</RCC>
-
diff --git a/examples/widgets/touch/CMakeLists.txt b/examples/widgets/touch/CMakeLists.txt
index 13efae441b..6b5aebb98a 100644
--- a/examples/widgets/touch/CMakeLists.txt
+++ b/examples/widgets/touch/CMakeLists.txt
@@ -1,10 +1,7 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-if(NOT TARGET Qt::Widgets)
+if(NOT TARGET Qt6::Widgets)
return()
endif()
-qt_internal_add_example(pinchzoom)
-qt_internal_add_example(fingerpaint)
qt_internal_add_example(knobs)
-qt_internal_add_example(dials)
diff --git a/examples/widgets/touch/dials/CMakeLists.txt b/examples/widgets/touch/dials/CMakeLists.txt
deleted file mode 100644
index 334c531478..0000000000
--- a/examples/widgets/touch/dials/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(dials LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/touch/dials")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(dials
- dials.ui
- main.cpp
-)
-
-set_target_properties(dials PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(dials PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS dials
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/touch/dials/dials.pro b/examples/widgets/touch/dials/dials.pro
deleted file mode 100644
index 0e823551cc..0000000000
--- a/examples/widgets/touch/dials/dials.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-QT += widgets
-
-SOURCES += main.cpp
-FORMS += dials.ui
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/touch/dials
-INSTALLS += target
diff --git a/examples/widgets/touch/dials/dials.ui b/examples/widgets/touch/dials/dials.ui
deleted file mode 100644
index 8ca7ae9475..0000000000
--- a/examples/widgets/touch/dials/dials.ui
+++ /dev/null
@@ -1,77 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Dials</class>
- <widget class="QWidget" name="Dials">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>300</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QDial" name="dial_1">
- <property name="notchesVisible">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QDial" name="dial_2">
- <property name="notchesVisible">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QDial" name="dial_3">
- <property name="notchesVisible">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="3">
- <widget class="QDial" name="dial_4">
- <property name="notchesVisible">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QDial" name="dial_5">
- <property name="notchesVisible">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QDial" name="dial_6">
- <property name="notchesVisible">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="QDial" name="dial_7">
- <property name="notchesVisible">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="3">
- <widget class="QDial" name="dial_8">
- <property name="notchesVisible">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/widgets/touch/dials/doc/images/touch-dials-example.png b/examples/widgets/touch/dials/doc/images/touch-dials-example.png
deleted file mode 100644
index 60e1776fc3..0000000000
--- a/examples/widgets/touch/dials/doc/images/touch-dials-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/touch/dials/doc/src/touch-dials.qdoc b/examples/widgets/touch/dials/doc/src/touch-dials.qdoc
deleted file mode 100644
index 448430ed79..0000000000
--- a/examples/widgets/touch/dials/doc/src/touch-dials.qdoc
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example touch/dials
- \title Touch Dials Example
- \ingroup touchinputexamples
- \brief Shows how to apply touch to a set of standard Qt widgets.
-
- The Touch Dials example shows how to apply touch to a set of
- standard Qt widgets.
-
- \image touch-dials-example.png
-*/
diff --git a/examples/widgets/touch/dials/main.cpp b/examples/widgets/touch/dials/main.cpp
deleted file mode 100644
index 63fdb7db3b..0000000000
--- a/examples/widgets/touch/dials/main.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-#include <QWidget>
-#include <QDial>
-
-#include "ui_dials.h"
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
- QWidget window;
- Ui::Dials dialsUi;
- dialsUi.setupUi(&window);
- const QList<QAbstractSlider *> sliders = window.findChildren<QAbstractSlider *>();
- for (QAbstractSlider *slider : sliders)
- slider->setAttribute(Qt::WA_AcceptTouchEvents);
- window.showMaximized();
- return app.exec();
-}
diff --git a/examples/widgets/touch/fingerpaint/CMakeLists.txt b/examples/widgets/touch/fingerpaint/CMakeLists.txt
deleted file mode 100644
index f7dc475fa4..0000000000
--- a/examples/widgets/touch/fingerpaint/CMakeLists.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(fingerpaint LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/touch/fingerpaint")
-
-find_package(Qt6
- REQUIRED COMPONENTS Core Gui Widgets
- OPTIONAL_COMPONENTS PrintSupport
-)
-
-qt_add_executable(fingerpaint
- main.cpp
- mainwindow.cpp mainwindow.h
- scribblearea.cpp scribblearea.h
-)
-
-set_target_properties(fingerpaint PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(fingerpaint PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-if (TARGET Qt::PrintSupport)
- target_link_libraries(fingerpaint PUBLIC Qt::PrintSupport)
-endif()
-
-if(TARGET Qt::PrintSupport)
- target_link_libraries(fingerpaint PUBLIC
- Qt::PrintSupport
- )
-endif()
-
-install(TARGETS fingerpaint
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/touch/fingerpaint/doc/src/fingerpaint.qdoc b/examples/widgets/touch/fingerpaint/doc/src/fingerpaint.qdoc
deleted file mode 100644
index 0e3319004c..0000000000
--- a/examples/widgets/touch/fingerpaint/doc/src/fingerpaint.qdoc
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example touch/fingerpaint
- \title Finger Paint Example
- \ingroup touchinputexamples
- \brief Shows the use of a touchscreen to make a simple painting application.
-
- The Finger Paint example shows the use of a touchscreen with a custom widget
- to create a simple painting application.
-
- \image touch-fingerpaint-example.png
-
- This example was specifically designed to work with a touchscreen, using
- QTouchEvent instead of QMouseEvent to handle user input over the custom
- widget. As a result, it is not possible to draw with the mouse cursor.
-*/
diff --git a/examples/widgets/touch/fingerpaint/fingerpaint.pro b/examples/widgets/touch/fingerpaint/fingerpaint.pro
deleted file mode 100644
index 6370da6607..0000000000
--- a/examples/widgets/touch/fingerpaint/fingerpaint.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-QT += widgets
-requires(qtConfig(filedialog))
-qtHaveModule(printsupport): QT += printsupport
-
-HEADERS = mainwindow.h \
- scribblearea.h
-SOURCES = main.cpp \
- mainwindow.cpp \
- scribblearea.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/touch/fingerpaint
-INSTALLS += target
diff --git a/examples/widgets/touch/fingerpaint/main.cpp b/examples/widgets/touch/fingerpaint/main.cpp
deleted file mode 100644
index d283c7b85c..0000000000
--- a/examples/widgets/touch/fingerpaint/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- MainWindow window;
- window.showMaximized();
- return app.exec();
-}
diff --git a/examples/widgets/touch/fingerpaint/mainwindow.cpp b/examples/widgets/touch/fingerpaint/mainwindow.cpp
deleted file mode 100644
index b9109fceeb..0000000000
--- a/examples/widgets/touch/fingerpaint/mainwindow.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-#include "mainwindow.h"
-#include "scribblearea.h"
-
-//! [0]
-MainWindow::MainWindow()
-{
- scribbleArea = new ScribbleArea;
- setCentralWidget(scribbleArea);
-
- createActions();
- createMenus();
-
- setWindowTitle(tr("Finger Paint"));
- resize(500, 500);
-}
-//! [0]
-
-//! [1]
-void MainWindow::closeEvent(QCloseEvent *event)
-//! [1] //! [2]
-{
- if (maybeSave()) {
- event->accept();
- } else {
- event->ignore();
- }
-}
-//! [2]
-
-//! [3]
-void MainWindow::open()
-//! [3] //! [4]
-{
- if (maybeSave()) {
- QString fileName = QFileDialog::getOpenFileName(this,
- tr("Open File"), QDir::currentPath());
- if (!fileName.isEmpty())
- scribbleArea->openImage(fileName);
- }
-}
-//! [4]
-
-//! [5]
-void MainWindow::save()
-//! [5] //! [6]
-{
- QAction *action = qobject_cast<QAction *>(sender());
- QByteArray fileFormat = action->data().toByteArray();
- saveFile(fileFormat);
-}
-//! [6]
-
-//! [11]
-void MainWindow::about()
-//! [11] //! [12]
-{
- QMessageBox::about(this, tr("About Scribble"),
- tr("<p>The <b>Scribble</b> example shows how to use QMainWindow as the "
- "base widget for an application, and how to reimplement some of "
- "QWidget's event handlers to receive the events generated for "
- "the application's widgets:</p><p> We reimplement the mouse event "
- "handlers to facilitate drawing, the paint event handler to "
- "update the application and the resize event handler to optimize "
- "the application's appearance. In addition we reimplement the "
- "close event handler to intercept the close events before "
- "terminating the application.</p><p> The example also demonstrates "
- "how to use QPainter to draw an image in real time, as well as "
- "to repaint widgets.</p>"));
-}
-//! [12]
-
-//! [13]
-void MainWindow::createActions()
-//! [13] //! [14]
-{
- openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcut(tr("Ctrl+O"));
- connect(openAct, &QAction::triggered, this, &MainWindow::open);
-
- const QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats();
- for (const QByteArray &format : imageFormats) {
- QString text = tr("%1...").arg(QString(format).toUpper());
-
- QAction *action = new QAction(text, this);
- action->setData(format);
- connect(action, &QAction::triggered, this, &MainWindow::save);
- saveAsActs.append(action);
- }
-
- printAct = new QAction(tr("&Print..."), this);
- connect(printAct, &QAction::triggered, scribbleArea, &ScribbleArea::print);
-
- exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcut(tr("Ctrl+Q"));
- connect(exitAct, &QAction::triggered, this, &QWidget::close);
-
- clearScreenAct = new QAction(tr("&Clear Screen"), this);
- clearScreenAct->setShortcut(tr("Ctrl+L"));
- connect(clearScreenAct, &QAction::triggered,
- scribbleArea, &ScribbleArea::clearImage);
-
- aboutAct = new QAction(tr("&About"), this);
- connect(aboutAct, &QAction::triggered, this, &MainWindow::about);
-
- aboutQtAct = new QAction(tr("About &Qt"), this);
- connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt);
-}
-//! [14]
-
-//! [15]
-void MainWindow::createMenus()
-//! [15] //! [16]
-{
- saveAsMenu = new QMenu(tr("&Save As"), this);
- saveAsMenu->addActions(saveAsActs);
-
- fileMenu = new QMenu(tr("&File"), this);
- fileMenu->addAction(openAct);
- fileMenu->addMenu(saveAsMenu);
- fileMenu->addAction(printAct);
- fileMenu->addSeparator();
- fileMenu->addAction(exitAct);
-
- optionMenu = new QMenu(tr("&Options"), this);
- optionMenu->addAction(clearScreenAct);
-
- helpMenu = new QMenu(tr("&Help"), this);
- helpMenu->addAction(aboutAct);
- helpMenu->addAction(aboutQtAct);
-
- menuBar()->addMenu(fileMenu);
- menuBar()->addMenu(optionMenu);
- menuBar()->addMenu(helpMenu);
-}
-//! [16]
-
-//! [17]
-bool MainWindow::maybeSave()
-//! [17] //! [18]
-{
- if (scribbleArea->isModified()) {
- QMessageBox::StandardButton ret;
- ret = QMessageBox::warning(this, tr("Scribble"),
- tr("The image has been modified.\n"
- "Do you want to save your changes?"),
- QMessageBox::Save | QMessageBox::Discard
- | QMessageBox::Cancel);
- if (ret == QMessageBox::Save) {
- return saveFile("png");
- } else if (ret == QMessageBox::Cancel) {
- return false;
- }
- }
- return true;
-}
-//! [18]
-
-//! [19]
-bool MainWindow::saveFile(const QByteArray &fileFormat)
-//! [19] //! [20]
-{
- QString initialPath = QDir::currentPath() + "/untitled." + fileFormat;
-
- QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
- initialPath,
- tr("%1 Files (*.%2);;All Files (*)")
- .arg(QString::fromLatin1(fileFormat.toUpper()))
- .arg(QString::fromLatin1(fileFormat)));
- if (fileName.isEmpty()) {
- return false;
- } else {
- return scribbleArea->saveImage(fileName, fileFormat.constData());
- }
-}
-//! [20]
diff --git a/examples/widgets/touch/fingerpaint/mainwindow.h b/examples/widgets/touch/fingerpaint/mainwindow.h
deleted file mode 100644
index a4aac1e36b..0000000000
--- a/examples/widgets/touch/fingerpaint/mainwindow.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QList>
-#include <QMainWindow>
-
-class ScribbleArea;
-
-//! [0]
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
-protected:
- void closeEvent(QCloseEvent *event) override;
-
-private slots:
- void open();
- void save();
- void about();
-
-private:
- void createActions();
- void createMenus();
- bool maybeSave();
- bool saveFile(const QByteArray &fileFormat);
-
- ScribbleArea *scribbleArea;
-
- QMenu *saveAsMenu;
- QMenu *fileMenu;
- QMenu *optionMenu;
- QMenu *helpMenu;
-
- QAction *openAct;
- QList<QAction *> saveAsActs;
- QAction *exitAct;
- QAction *printAct;
- QAction *clearScreenAct;
- QAction *aboutAct;
- QAction *aboutQtAct;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/touch/fingerpaint/scribblearea.cpp b/examples/widgets/touch/fingerpaint/scribblearea.cpp
deleted file mode 100644
index fb5e62906b..0000000000
--- a/examples/widgets/touch/fingerpaint/scribblearea.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#if defined(QT_PRINTSUPPORT_LIB)
-#include <QtPrintSupport/qtprintsupportglobal.h>
-#if QT_CONFIG(printdialog)
-#include <QPrinter>
-#include <QPrintDialog>
-#endif
-#endif
-
-#include "scribblearea.h"
-
-static const qreal MinimumDiameter = 3.0;
-static const qreal MaximumDiameter = 50.0;
-
-//! [0]
-ScribbleArea::ScribbleArea(QWidget *parent)
- : QWidget(parent)
-{
- setAttribute(Qt::WA_AcceptTouchEvents);
- setAttribute(Qt::WA_StaticContents);
- modified = false;
-
- myPenColors
- << QColor("green")
- << QColor("purple")
- << QColor("red")
- << QColor("blue")
- << QColor("yellow")
-
- << QColor("pink")
- << QColor("orange")
- << QColor("brown")
- << QColor("grey")
- << QColor("black");
-}
-//! [0]
-
-//! [1]
-bool ScribbleArea::openImage(const QString &fileName)
-//! [1] //! [2]
-{
- QImage loadedImage;
- if (!loadedImage.load(fileName))
- return false;
-
- QSize newSize = loadedImage.size().expandedTo(size());
- resizeImage(&loadedImage, newSize);
- image = loadedImage;
- modified = false;
- update();
- return true;
-}
-//! [2]
-
-//! [3]
-bool ScribbleArea::saveImage(const QString &fileName, const char *fileFormat)
-//! [3] //! [4]
-{
- QImage visibleImage = image;
- resizeImage(&visibleImage, size());
-
- if (visibleImage.save(fileName, fileFormat)) {
- modified = false;
- return true;
- } else {
- return false;
- }
-}
-//! [4]
-
-//! [9]
-void ScribbleArea::clearImage()
-//! [9] //! [10]
-{
- image.fill(qRgb(255, 255, 255));
- modified = true;
- update();
-}
-//! [10]
-
-//! [12] //! [13]
-void ScribbleArea::paintEvent(QPaintEvent *event)
-//! [13] //! [14]
-{
- QPainter painter(this);
- const QRect rect = event->rect();
- painter.drawImage(rect.topLeft(), image, rect);
-}
-//! [14]
-
-//! [15]
-void ScribbleArea::resizeEvent(QResizeEvent *event)
-//! [15] //! [16]
-{
- if (width() > image.width() || height() > image.height()) {
- int newWidth = qMax(width() + 128, image.width());
- int newHeight = qMax(height() + 128, image.height());
- resizeImage(&image, QSize(newWidth, newHeight));
- update();
- }
- QWidget::resizeEvent(event);
-}
-//! [16]
-
-//! [19]
-void ScribbleArea::resizeImage(QImage *image, const QSize &newSize)
-//! [19] //! [20]
-{
- if (image->size() == newSize)
- return;
-
- QImage newImage(newSize, QImage::Format_RGB32);
- newImage.fill(qRgb(255, 255, 255));
- QPainter painter(&newImage);
- painter.drawImage(QPoint(0, 0), *image);
- *image = newImage;
-}
-//! [20]
-
-//! [21]
-void ScribbleArea::print()
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
- QPrinter printer(QPrinter::HighResolution);
-
- QPrintDialog printDialog(&printer, this);
-//! [21] //! [22]
- if (printDialog.exec() == QDialog::Accepted) {
- QPainter painter(&printer);
- QRect rect = painter.viewport();
- QSize size = image.size();
- size.scale(rect.size(), Qt::KeepAspectRatio);
- painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
- painter.setWindow(image.rect());
- painter.drawImage(0, 0, image);
- }
-#endif // QT_CONFIG(printdialog)
-}
-//! [22]
-
-bool ScribbleArea::event(QEvent *event)
-{
- switch (event->type()) {
- case QEvent::TouchBegin:
- case QEvent::TouchUpdate:
- case QEvent::TouchEnd:
- {
- const QTouchEvent *touch = static_cast<QTouchEvent *>(event);
- const auto touchPoints = static_cast<QTouchEvent *>(event)->points();
- for (const QTouchEvent::TouchPoint &touchPoint : touchPoints) {
- switch (touchPoint.state()) {
- case QEventPoint::Stationary:
- case QEventPoint::Released:
- // don't do anything if this touch point hasn't moved or has been released
- continue;
- default:
- {
- QSizeF diams = touchPoint.ellipseDiameters();
- if (diams.isEmpty()) {
- qreal diameter = MaximumDiameter;
- if (touch->pointingDevice()->capabilities().testFlag(QPointingDevice::Capability::Pressure))
- diameter = MinimumDiameter + (MaximumDiameter - MinimumDiameter) * touchPoint.pressure();
- diams = QSizeF(diameter, diameter);
- }
-
- QPainter painter(&image);
- painter.setPen(Qt::NoPen);
- painter.setBrush(myPenColors.at(touchPoint.id() % myPenColors.count()));
- painter.drawEllipse(touchPoint.position(), diams.width() / 2, diams.height() / 2);
- painter.end();
-
- modified = true;
- const int rad = 2;
- QRectF rect(QPointF(), diams);
- rect.moveCenter(touchPoint.position());
- update(rect.toRect().adjusted(-rad,-rad, +rad, +rad));
- }
- break;
- }
- }
- break;
- }
- default:
- return QWidget::event(event);
- }
- return true;
-}
diff --git a/examples/widgets/touch/fingerpaint/scribblearea.h b/examples/widgets/touch/fingerpaint/scribblearea.h
deleted file mode 100644
index 624f07074a..0000000000
--- a/examples/widgets/touch/fingerpaint/scribblearea.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef SCRIBBLEAREA_H
-#define SCRIBBLEAREA_H
-
-#include <QColor>
-#include <QImage>
-#include <QPoint>
-#include <QWidget>
-
-//! [0]
-class ScribbleArea : public QWidget
-{
- Q_OBJECT
-
-public:
- ScribbleArea(QWidget *parent = nullptr);
-
- bool openImage(const QString &fileName);
- bool saveImage(const QString &fileName, const char *fileFormat);
-
- bool isModified() const { return modified; }
-
-public slots:
- void clearImage();
- void print();
-
-protected:
- void paintEvent(QPaintEvent *event) override;
- void resizeEvent(QResizeEvent *event) override;
- bool event(QEvent *event) override;
-
-private:
- void resizeImage(QImage *image, const QSize &newSize);
-
- bool modified;
- QList<QColor> myPenColors;
- QImage image;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/touch/knobs/CMakeLists.txt b/examples/widgets/touch/knobs/CMakeLists.txt
index f097f44a7f..eae0e58b36 100644
--- a/examples/widgets/touch/knobs/CMakeLists.txt
+++ b/examples/widgets/touch/knobs/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(knobs LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/touch/knobs")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(knobs
knob.cpp knob.h
main.cpp
@@ -24,14 +18,21 @@ set_target_properties(knobs PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(knobs PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(knobs PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS knobs
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET knobs
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/touch/knobs/doc/images/touch-knobs-example.png b/examples/widgets/touch/knobs/doc/images/touch-knobs-example.png
index 1cbd90d101..7b75ff377c 100644
--- a/examples/widgets/touch/knobs/doc/images/touch-knobs-example.png
+++ b/examples/widgets/touch/knobs/doc/images/touch-knobs-example.png
Binary files differ
diff --git a/examples/widgets/touch/knobs/doc/src/touch-knobs.qdoc b/examples/widgets/touch/knobs/doc/src/touch-knobs.qdoc
index 3a41c5005b..fc6daa3732 100644
--- a/examples/widgets/touch/knobs/doc/src/touch-knobs.qdoc
+++ b/examples/widgets/touch/knobs/doc/src/touch-knobs.qdoc
@@ -4,6 +4,7 @@
/*!
\example touch/knobs
\title Touch Knobs Example
+ \examplecategory {User Interface Components}
\ingroup touchinputexamples
\brief Shows how to create custom controls that accept touch input.
diff --git a/examples/widgets/touch/knobs/main.cpp b/examples/widgets/touch/knobs/main.cpp
index 6f6910b4ae..74b64a99eb 100644
--- a/examples/widgets/touch/knobs/main.cpp
+++ b/examples/widgets/touch/knobs/main.cpp
@@ -12,6 +12,7 @@ int main(int argc, char **argv)
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.setRenderHints(QPainter::Antialiasing);
Knob *knob1 = new Knob;
knob1->setPos(-110, 0);
diff --git a/examples/widgets/touch/pinchzoom/CMakeLists.txt b/examples/widgets/touch/pinchzoom/CMakeLists.txt
deleted file mode 100644
index 88f7e312d2..0000000000
--- a/examples/widgets/touch/pinchzoom/CMakeLists.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(pinchzoom LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/touch/pinchzoom")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(pinchzoom
- graphicsview.cpp graphicsview.h
- main.cpp
- mouse.cpp mouse.h
-)
-
-set_target_properties(pinchzoom PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(pinchzoom PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(mice_resource_files
- "images/cheese.jpg"
-)
-
-qt_add_resources(pinchzoom "mice"
- PREFIX
- "/"
- FILES
- ${mice_resource_files}
-)
-
-install(TARGETS pinchzoom
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/touch/pinchzoom/doc/images/pinch-zoom-example.png b/examples/widgets/touch/pinchzoom/doc/images/pinch-zoom-example.png
deleted file mode 100644
index 7db51fbf55..0000000000
--- a/examples/widgets/touch/pinchzoom/doc/images/pinch-zoom-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/touch/pinchzoom/doc/src/pinchzoom.qdoc b/examples/widgets/touch/pinchzoom/doc/src/pinchzoom.qdoc
deleted file mode 100644
index aef5c59407..0000000000
--- a/examples/widgets/touch/pinchzoom/doc/src/pinchzoom.qdoc
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example touch/pinchzoom
- \title Pinch Zoom Example
- \ingroup touchinputexamples
- \brief Shows how to recognize a gesture.
-
- The Pinch Zoom example shows how to use low-level touch information
- to recognize a gesture.
-
- \image touch-pinchzoom-example.png
-*/
diff --git a/examples/widgets/touch/pinchzoom/graphicsview.cpp b/examples/widgets/touch/pinchzoom/graphicsview.cpp
deleted file mode 100644
index 61042e7e02..0000000000
--- a/examples/widgets/touch/pinchzoom/graphicsview.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "graphicsview.h"
-
-#include <QScrollBar>
-#include <QTouchEvent>
-
-GraphicsView::GraphicsView(QGraphicsScene *scene, QWidget *parent)
- : QGraphicsView(scene, parent)
-{
- viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
- setDragMode(ScrollHandDrag);
-}
-
-bool GraphicsView::viewportEvent(QEvent *event)
-{
- switch (event->type()) {
- case QEvent::TouchBegin:
- case QEvent::TouchUpdate:
- case QEvent::TouchEnd:
- {
- QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
- const auto touchPoints = touchEvent->points();
- if (touchPoints.count() == 2) {
- // determine scale factor
- const QEventPoint &touchPoint0 = touchPoints.first();
- const QEventPoint &touchPoint1 = touchPoints.last();
- qreal currentScaleFactor =
- QLineF(touchPoint0.position(), touchPoint1.position()).length()
- / QLineF(touchPoint0.pressPosition(), touchPoint1.pressPosition()).length();
- if (touchEvent->touchPointStates() & QEventPoint::Released) {
- // if one of the fingers is released, remember the current scale
- // factor so that adding another finger later will continue zooming
- // by adding new scale factor to the existing remembered value.
- totalScaleFactor *= currentScaleFactor;
- currentScaleFactor = 1;
- }
- setTransform(QTransform::fromScale(totalScaleFactor * currentScaleFactor,
- totalScaleFactor * currentScaleFactor));
- }
- return true;
- }
- default:
- break;
- }
- return QGraphicsView::viewportEvent(event);
-}
diff --git a/examples/widgets/touch/pinchzoom/graphicsview.h b/examples/widgets/touch/pinchzoom/graphicsview.h
deleted file mode 100644
index e6a300f418..0000000000
--- a/examples/widgets/touch/pinchzoom/graphicsview.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#pragma once
-#include <QGraphicsView>
-
-class GraphicsView : public QGraphicsView
-{
- Q_OBJECT
-
-public:
- GraphicsView(QGraphicsScene *scene = nullptr, QWidget *parent = nullptr);
-
- bool viewportEvent(QEvent *event) override;
-
-private:
- qreal totalScaleFactor = 1;
-};
diff --git a/examples/widgets/touch/pinchzoom/images/cheese.jpg b/examples/widgets/touch/pinchzoom/images/cheese.jpg
deleted file mode 100644
index dea5795fd0..0000000000
--- a/examples/widgets/touch/pinchzoom/images/cheese.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/touch/pinchzoom/main.cpp b/examples/widgets/touch/pinchzoom/main.cpp
deleted file mode 100644
index 85b5cad1f8..0000000000
--- a/examples/widgets/touch/pinchzoom/main.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "graphicsview.h"
-#include "mouse.h"
-
-#include <QApplication>
-#include <cmath>
-
-static constexpr int MouseCount = 7;
-
-//! [0]
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-//! [0]
-
-//! [1]
- QGraphicsScene scene;
- scene.setSceneRect(-300, -300, 600, 600);
-//! [1] //! [2]
- scene.setItemIndexMethod(QGraphicsScene::NoIndex);
-//! [2]
-
-//! [3]
- for (int i = 0; i < MouseCount; ++i) {
- Mouse *mouse = new Mouse;
- mouse->setPos(::sin((i * 6.28) / MouseCount) * 200,
- ::cos((i * 6.28) / MouseCount) * 200);
- scene.addItem(mouse);
- }
-//! [3]
-
-//! [4]
- GraphicsView view(&scene);
- view.setRenderHint(QPainter::Antialiasing);
- view.setBackgroundBrush(QPixmap(":/images/cheese.jpg"));
-//! [4] //! [5]
- view.setCacheMode(QGraphicsView::CacheBackground);
- view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
-//! [5] //! [6]
- view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice"));
- view.showMaximized();
-
- return app.exec();
-}
-//! [6]
diff --git a/examples/widgets/touch/pinchzoom/mice.qrc b/examples/widgets/touch/pinchzoom/mice.qrc
deleted file mode 100644
index accdb4d0a6..0000000000
--- a/examples/widgets/touch/pinchzoom/mice.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/" >
- <file>images/cheese.jpg</file>
- </qresource>
-</RCC>
diff --git a/examples/widgets/touch/pinchzoom/mouse.cpp b/examples/widgets/touch/pinchzoom/mouse.cpp
deleted file mode 100644
index ae0d497833..0000000000
--- a/examples/widgets/touch/pinchzoom/mouse.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mouse.h"
-
-#include <QGraphicsScene>
-#include <QPainter>
-#include <QRandomGenerator>
-#include <QStyleOption>
-#include <qmath.h>
-
-constexpr qreal Pi = M_PI;
-constexpr qreal TwoPi = 2 * M_PI;
-
-static qreal normalizeAngle(qreal angle)
-{
- while (angle < 0)
- angle += TwoPi;
- while (angle > TwoPi)
- angle -= TwoPi;
- return angle;
-}
-
-//! [0]
-Mouse::Mouse() : color(QRandomGenerator::global()->bounded(256),
- QRandomGenerator::global()->bounded(256),
- QRandomGenerator::global()->bounded(256))
-{
- setTransform(QTransform().rotate(QRandomGenerator::global()->bounded(360 * 16)), true);
- startTimer(1000 / 33);
-}
-//! [0]
-
-//! [1]
-QRectF Mouse::boundingRect() const
-{
- qreal adjust = 0.5;
- return QRectF(-18 - adjust, -22 - adjust,
- 36 + adjust, 60 + adjust);
-}
-//! [1]
-
-//! [2]
-QPainterPath Mouse::shape() const
-{
- QPainterPath path;
- path.addRect(-10, -20, 20, 40);
- return path;
-}
-//! [2]
-
-//! [3]
-void Mouse::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
-{
- // Body
- painter->setBrush(color);
- painter->drawEllipse(-10, -20, 20, 40);
-
- // Eyes
- painter->setBrush(Qt::white);
- painter->drawEllipse(-10, -17, 8, 8);
- painter->drawEllipse(2, -17, 8, 8);
-
- // Nose
- painter->setBrush(Qt::black);
- painter->drawEllipse(QRectF(-2, -22, 4, 4));
-
- // Pupils
- painter->drawEllipse(QRectF(-8.0 + mouseEyeDirection, -17, 4, 4));
- painter->drawEllipse(QRectF(4.0 + mouseEyeDirection, -17, 4, 4));
-
- // Ears
- painter->setBrush(scene()->collidingItems(this).isEmpty() ? Qt::darkYellow : Qt::red);
- painter->drawEllipse(-17, -12, 16, 16);
- painter->drawEllipse(1, -12, 16, 16);
-
- // Tail
- QPainterPath path(QPointF(0, 20));
- path.cubicTo(-5, 22, -5, 22, 0, 25);
- path.cubicTo(5, 27, 5, 32, 0, 30);
- path.cubicTo(-5, 32, -5, 42, 0, 35);
- painter->setBrush(Qt::NoBrush);
- painter->drawPath(path);
-}
-//! [3]
-
-//! [4]
-void Mouse::timerEvent(QTimerEvent *)
-{
-//! [4]
- // Don't move too far away
-//! [5]
- QLineF lineToCenter(QPointF(0, 0), mapFromScene(0, 0));
- if (lineToCenter.length() > 150) {
- qreal angleToCenter = std::atan2(lineToCenter.dy(), lineToCenter.dx());
- angleToCenter = normalizeAngle((Pi - angleToCenter) + Pi / 2);
-
- if (angleToCenter < Pi && angleToCenter > Pi / 4) {
- // Rotate left
- angle += (angle < -Pi / 2) ? 0.25 : -0.25;
- } else if (angleToCenter >= Pi && angleToCenter < (Pi + Pi / 2 + Pi / 4)) {
- // Rotate right
- angle += (angle < Pi / 2) ? 0.25 : -0.25;
- }
- } else if (::sin(angle) < 0) {
- angle += 0.25;
- } else if (::sin(angle) > 0) {
- angle -= 0.25;
-//! [5] //! [6]
- }
-//! [6]
-
- // Try not to crash with any other mice
-//! [7]
- QList<QGraphicsItem *> dangerMice = scene()->items(QPolygonF()
- << mapToScene(0, 0)
- << mapToScene(-30, -50)
- << mapToScene(30, -50));
- for (QGraphicsItem *item : dangerMice) {
- if (item == this)
- continue;
-
- QLineF lineToMouse(QPointF(0, 0), mapFromItem(item, 0, 0));
- qreal angleToMouse = std::atan2(lineToMouse.dy(), lineToMouse.dx());
- angleToMouse = normalizeAngle((Pi - angleToMouse) + Pi / 2);
-
- if (angleToMouse >= 0 && angleToMouse < Pi / 2) {
- // Rotate right
- angle += 0.5;
- } else if (angleToMouse <= TwoPi && angleToMouse > (TwoPi - Pi / 2)) {
- // Rotate left
- angle -= 0.5;
-//! [7] //! [8]
- }
-//! [8] //! [9]
- }
-//! [9]
-
- // Add some random movement
-//! [10]
- if (dangerMice.size() > 1 && QRandomGenerator::global()->bounded(10) == 0) {
- if (QRandomGenerator::global()->bounded(1))
- angle += QRandomGenerator::global()->bounded(1 / 500.0);
- else
- angle -= QRandomGenerator::global()->bounded(1 / 500.0);
- }
-//! [10]
-
-//! [11]
- speed += (-50 + QRandomGenerator::global()->bounded(100)) / 100.0;
-
- qreal dx = ::sin(angle) * 10;
- mouseEyeDirection = (qAbs(dx / 5) < 1) ? 0 : dx / 5;
-
- setTransform(QTransform().rotate(dx), true);
- setPos(mapToParent(0, -(3 + sin(speed) * 3)));
-}
-//! [11]
diff --git a/examples/widgets/touch/pinchzoom/mouse.h b/examples/widgets/touch/pinchzoom/mouse.h
deleted file mode 100644
index 6b3ef98c22..0000000000
--- a/examples/widgets/touch/pinchzoom/mouse.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MOUSE_H
-#define MOUSE_H
-
-#include <QGraphicsObject>
-
-//! [0]
-class Mouse : public QGraphicsObject
-{
- Q_OBJECT
-
-public:
- Mouse();
-
- QRectF boundingRect() const override;
- QPainterPath shape() const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget) override;
-
-protected:
- void timerEvent(QTimerEvent *event) override;
-
-private:
- qreal angle = 0;
- qreal speed = 0;
- qreal mouseEyeDirection = 0;
- QColor color;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/touch/pinchzoom/pinchzoom.pro b/examples/widgets/touch/pinchzoom/pinchzoom.pro
deleted file mode 100644
index ebbc7ddf1f..0000000000
--- a/examples/widgets/touch/pinchzoom/pinchzoom.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-QT += widgets
-
-HEADERS += \
- mouse.h \
- graphicsview.h
-SOURCES += \
- main.cpp \
- mouse.cpp \
- graphicsview.cpp
-
-RESOURCES += \
- mice.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/touch/pinchzoom
-INSTALLS += target
diff --git a/examples/widgets/touch/touch.pro b/examples/widgets/touch/touch.pro
index 018ec134eb..4fff58e074 100644
--- a/examples/widgets/touch/touch.pro
+++ b/examples/widgets/touch/touch.pro
@@ -1,4 +1,4 @@
requires(qtHaveModule(widgets))
TEMPLATE = subdirs
-SUBDIRS = pinchzoom fingerpaint knobs dials
+SUBDIRS = knobs
diff --git a/examples/widgets/tutorials/CMakeLists.txt b/examples/widgets/tutorials/CMakeLists.txt
index 02d196db90..e1192d9c6f 100644
--- a/examples/widgets/tutorials/CMakeLists.txt
+++ b/examples/widgets/tutorials/CMakeLists.txt
@@ -1,8 +1,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(addressbook)
add_subdirectory(widgets)
add_subdirectory(modelview)
-add_subdirectory(gettingStarted)
qt_internal_add_example(notepad)
diff --git a/examples/widgets/tutorials/addressbook/CMakeLists.txt b/examples/widgets/tutorials/addressbook/CMakeLists.txt
deleted file mode 100644
index c33e586df9..0000000000
--- a/examples/widgets/tutorials/addressbook/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-qt_internal_add_example(part1)
-qt_internal_add_example(part2)
-qt_internal_add_example(part3)
-qt_internal_add_example(part4)
-qt_internal_add_example(part5)
-qt_internal_add_example(part6)
-qt_internal_add_example(part7)
diff --git a/examples/widgets/tutorials/addressbook/README b/examples/widgets/tutorials/addressbook/README
deleted file mode 100644
index 07897b9683..0000000000
--- a/examples/widgets/tutorials/addressbook/README
+++ /dev/null
@@ -1,40 +0,0 @@
-The Address Book Tutorial shows how to put together a simple yet
-fully-functioning GUI application. The tutorial chapters can be found in the
-Qt documentation, which can be viewed using Qt Assistant or a Web browser.
-
-The tutorial is also available online at
-
-http://qt-project.org/doc/qt-5.0/qtwidgets/tutorials-addressbook.html
-
-All programs corresponding to the chapters in the tutorial should
-automatically be built when Qt is compiled, or will be provided as
-pre-built executables if you have obtained a binary package of Qt.
-
-If you have only compiled the Qt libraries, use the following instructions
-to build the tutorial.
-
-On Linux/Unix:
-
-Typing 'make' in this directory builds all the programs (part1/part1,
-part2/part2, part3/part3 and so on). Typing 'make' in each subdirectory
-builds just that tutorial program.
-
-On Windows:
-
-Create a single Visual Studio project for the tutorial directory in
-the usual way. You can do this by typing the following at the command
-line:
-
-qmake -tp vc
-
-You should now be able to open the project file in Visual Studio and
-build all of the tutorial programs at the same time.
-
-On Mac OS X:
-
-Create an Xcode project with the .pro file in the tutorial directory.
-You can do this by typing the following at the command line:
-
-qmake -spec macx-xcode
-
-Then open the generated Xcode project in Xcode and build it.
diff --git a/examples/widgets/tutorials/addressbook/addressbook.pro b/examples/widgets/tutorials/addressbook/addressbook.pro
deleted file mode 100644
index d31424998e..0000000000
--- a/examples/widgets/tutorials/addressbook/addressbook.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = part1 part2 part3 part4 part5 part6 part7
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/addressbook
-INSTALLS += target
diff --git a/examples/widgets/tutorials/addressbook/part1/CMakeLists.txt b/examples/widgets/tutorials/addressbook/part1/CMakeLists.txt
deleted file mode 100644
index 87292f0eb6..0000000000
--- a/examples/widgets/tutorials/addressbook/part1/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(part1 LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part1")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(part1
- addressbook.cpp addressbook.h
- main.cpp
-)
-
-set_target_properties(part1 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(part1 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS part1
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tutorials/addressbook/part1/addressbook.cpp b/examples/widgets/tutorials/addressbook/part1/addressbook.cpp
deleted file mode 100644
index eae818dbbf..0000000000
--- a/examples/widgets/tutorials/addressbook/part1/addressbook.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-//! [constructor and input fields]
-AddressBook::AddressBook(QWidget *parent)
- : QWidget(parent)
-{
- QLabel *nameLabel = new QLabel(tr("Name:"));
- nameLine = new QLineEdit;
-
- QLabel *addressLabel = new QLabel(tr("Address:"));
- addressText = new QTextEdit;
-//! [constructor and input fields]
-
-//! [layout]
- QGridLayout *mainLayout = new QGridLayout;
- mainLayout->addWidget(nameLabel, 0, 0);
- mainLayout->addWidget(nameLine, 0, 1);
- mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
- mainLayout->addWidget(addressText, 1, 1);
-//! [layout]
-
-//![setting the layout]
- setLayout(mainLayout);
- setWindowTitle(tr("Simple Address Book"));
-}
-//! [setting the layout]
diff --git a/examples/widgets/tutorials/addressbook/part1/addressbook.h b/examples/widgets/tutorials/addressbook/part1/addressbook.h
deleted file mode 100644
index f2e28b4135..0000000000
--- a/examples/widgets/tutorials/addressbook/part1/addressbook.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef ADDRESSBOOK_H
-#define ADDRESSBOOK_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-class QLineEdit;
-class QTextEdit;
-QT_END_NAMESPACE
-
-//! [class definition]
-class AddressBook : public QWidget
-{
- Q_OBJECT
-
-public:
- AddressBook(QWidget *parent = nullptr);
-
-private:
- QLineEdit *nameLine;
- QTextEdit *addressText;
-};
-//! [class definition]
-
-#endif
diff --git a/examples/widgets/tutorials/addressbook/part1/main.cpp b/examples/widgets/tutorials/addressbook/part1/main.cpp
deleted file mode 100644
index 879fb606a2..0000000000
--- a/examples/widgets/tutorials/addressbook/part1/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-//! [main function]
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- AddressBook addressBook;
- addressBook.show();
-
- return app.exec();
-}
-//! [main function]
diff --git a/examples/widgets/tutorials/addressbook/part1/part1.pro b/examples/widgets/tutorials/addressbook/part1/part1.pro
deleted file mode 100644
index 35d4a0152e..0000000000
--- a/examples/widgets/tutorials/addressbook/part1/part1.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += widgets
-
-SOURCES = addressbook.cpp \
- main.cpp
-HEADERS = addressbook.h
-
-QMAKE_PROJECT_NAME = ab_part1
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/addressbook/part1
-INSTALLS += target
diff --git a/examples/widgets/tutorials/addressbook/part2/CMakeLists.txt b/examples/widgets/tutorials/addressbook/part2/CMakeLists.txt
deleted file mode 100644
index 032af2a8e2..0000000000
--- a/examples/widgets/tutorials/addressbook/part2/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(part2 LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part2")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(part2
- addressbook.cpp addressbook.h
- main.cpp
-)
-
-set_target_properties(part2 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(part2 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS part2
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tutorials/addressbook/part2/addressbook.cpp b/examples/widgets/tutorials/addressbook/part2/addressbook.cpp
deleted file mode 100644
index 085103c791..0000000000
--- a/examples/widgets/tutorials/addressbook/part2/addressbook.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-AddressBook::AddressBook(QWidget *parent)
- : QWidget(parent)
-{
- QLabel *nameLabel = new QLabel(tr("Name:"));
- nameLine = new QLineEdit;
-//! [setting readonly 1]
- nameLine->setReadOnly(true);
-//! [setting readonly 1]
- QLabel *addressLabel = new QLabel(tr("Address:"));
- addressText = new QTextEdit;
-//! [setting readonly 2]
- addressText->setReadOnly(true);
-//! [setting readonly 2]
-
-//! [pushbutton declaration]
- addButton = new QPushButton(tr("&Add"));
- addButton->show();
- submitButton = new QPushButton(tr("&Submit"));
- submitButton->hide();
- cancelButton = new QPushButton(tr("&Cancel"));
- cancelButton->hide();
-//! [pushbutton declaration]
-//! [connecting signals and slots]
- connect(addButton, &QPushButton::clicked,
- this, &AddressBook::addContact);
- connect(submitButton, &QPushButton::clicked,
- this, &AddressBook::submitContact);
- connect(cancelButton, &QPushButton::clicked,
- this, &AddressBook::cancel);
-//! [connecting signals and slots]
-//! [vertical layout]
- QVBoxLayout *buttonLayout1 = new QVBoxLayout;
- buttonLayout1->addWidget(addButton, Qt::AlignTop);
- buttonLayout1->addWidget(submitButton);
- buttonLayout1->addWidget(cancelButton);
- buttonLayout1->addStretch();
-//! [vertical layout]
-//! [grid layout]
- QGridLayout *mainLayout = new QGridLayout;
- mainLayout->addWidget(nameLabel, 0, 0);
- mainLayout->addWidget(nameLine, 0, 1);
- mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
- mainLayout->addWidget(addressText, 1, 1);
- mainLayout->addLayout(buttonLayout1, 1, 2);
-//! [grid layout]
- setLayout(mainLayout);
- setWindowTitle(tr("Simple Address Book"));
-}
-//! [addContact]
-void AddressBook::addContact()
-{
- oldName = nameLine->text();
- oldAddress = addressText->toPlainText();
-
- nameLine->clear();
- addressText->clear();
-
- nameLine->setReadOnly(false);
- nameLine->setFocus(Qt::OtherFocusReason);
- addressText->setReadOnly(false);
-
- addButton->setEnabled(false);
- submitButton->show();
- cancelButton->show();
-}
-//! [addContact]
-
-//! [submitContact part1]
-void AddressBook::submitContact()
-{
- QString name = nameLine->text();
- QString address = addressText->toPlainText();
-
- if (name.isEmpty() || address.isEmpty()) {
- QMessageBox::information(this, tr("Empty Field"),
- tr("Please enter a name and address."));
- return;
- }
-//! [submitContact part1]
-//! [submitContact part2]
- if (!contacts.contains(name)) {
- contacts.insert(name, address);
- QMessageBox::information(this, tr("Add Successful"),
- tr("\"%1\" has been added to your address book.").arg(name));
- } else {
- QMessageBox::information(this, tr("Add Unsuccessful"),
- tr("Sorry, \"%1\" is already in your address book.").arg(name));
- return;
- }
-//! [submitContact part2]
-//! [submitContact part3]
- if (contacts.isEmpty()) {
- nameLine->clear();
- addressText->clear();
- }
-
- nameLine->setReadOnly(true);
- addressText->setReadOnly(true);
- addButton->setEnabled(true);
- submitButton->hide();
- cancelButton->hide();
-}
-//! [submitContact part3]
-//! [cancel]
-void AddressBook::cancel()
-{
- nameLine->setText(oldName);
- nameLine->setReadOnly(true);
-
- addressText->setText(oldAddress);
- addressText->setReadOnly(true);
-
- addButton->setEnabled(true);
- submitButton->hide();
- cancelButton->hide();
-}
-//! [cancel]
diff --git a/examples/widgets/tutorials/addressbook/part2/addressbook.h b/examples/widgets/tutorials/addressbook/part2/addressbook.h
deleted file mode 100644
index ecc1a71cee..0000000000
--- a/examples/widgets/tutorials/addressbook/part2/addressbook.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef ADDRESSBOOK_H
-#define ADDRESSBOOK_H
-
-#include <QWidget>
-#include <QMap>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-class QLineEdit;
-class QPushButton;
-class QTextEdit;
-QT_END_NAMESPACE
-
-class AddressBook : public QWidget
-{
- Q_OBJECT
-
-public:
- AddressBook(QWidget *parent = nullptr);
-
-//! [slots]
-public slots:
- void addContact();
- void submitContact();
- void cancel();
-//! [slots]
-
-//! [pushbutton declaration]
-private:
- QPushButton *addButton;
- QPushButton *submitButton;
- QPushButton *cancelButton;
- QLineEdit *nameLine;
- QTextEdit *addressText;
-//! [pushbutton declaration]
-
-//! [remaining private variables]
- QMap<QString, QString> contacts;
- QString oldName;
- QString oldAddress;
-};
-//! [remaining private variables]
-
-#endif
diff --git a/examples/widgets/tutorials/addressbook/part2/main.cpp b/examples/widgets/tutorials/addressbook/part2/main.cpp
deleted file mode 100644
index 879fb606a2..0000000000
--- a/examples/widgets/tutorials/addressbook/part2/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-//! [main function]
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- AddressBook addressBook;
- addressBook.show();
-
- return app.exec();
-}
-//! [main function]
diff --git a/examples/widgets/tutorials/addressbook/part2/part2.pro b/examples/widgets/tutorials/addressbook/part2/part2.pro
deleted file mode 100644
index 643ffcfebd..0000000000
--- a/examples/widgets/tutorials/addressbook/part2/part2.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += widgets
-
-SOURCES = addressbook.cpp \
- main.cpp
-HEADERS = addressbook.h
-
-QMAKE_PROJECT_NAME = ab_part2
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/addressbook/part2
-INSTALLS += target
diff --git a/examples/widgets/tutorials/addressbook/part3/CMakeLists.txt b/examples/widgets/tutorials/addressbook/part3/CMakeLists.txt
deleted file mode 100644
index 941dff356f..0000000000
--- a/examples/widgets/tutorials/addressbook/part3/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(part3 LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part3")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(part3
- addressbook.cpp addressbook.h
- main.cpp
-)
-
-set_target_properties(part3 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(part3 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS part3
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tutorials/addressbook/part3/addressbook.cpp b/examples/widgets/tutorials/addressbook/part3/addressbook.cpp
deleted file mode 100644
index 1b37e56880..0000000000
--- a/examples/widgets/tutorials/addressbook/part3/addressbook.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-AddressBook::AddressBook(QWidget *parent)
- : QWidget(parent)
-{
- QLabel *nameLabel = new QLabel(tr("Name:"));
- nameLine = new QLineEdit;
- nameLine->setReadOnly(true);
-
- QLabel *addressLabel = new QLabel(tr("Address:"));
- addressText = new QTextEdit;
- addressText->setReadOnly(true);
-
- addButton = new QPushButton(tr("&Add"));
- addButton->show();
- submitButton = new QPushButton(tr("&Submit"));
- submitButton->hide();
- cancelButton = new QPushButton(tr("&Cancel"));
- cancelButton->hide();
-//! [navigation pushbuttons]
- nextButton = new QPushButton(tr("&Next"));
- nextButton->setEnabled(false);
- previousButton = new QPushButton(tr("&Previous"));
- previousButton->setEnabled(false);
-//! [navigation pushbuttons]
- connect(addButton, &QPushButton::clicked,
- this, &AddressBook::addContact);
- connect(submitButton, &QPushButton::clicked,
- this, &AddressBook::submitContact);
- connect(cancelButton, &QPushButton::clicked,
- this, &AddressBook::cancel);
-//! [connecting navigation signals]
- connect(nextButton, &QPushButton::clicked,
- this, &AddressBook::next);
- connect(previousButton, &QPushButton::clicked,
- this, &AddressBook::previous);
-//! [connecting navigation signals]
-
- QVBoxLayout *buttonLayout1 = new QVBoxLayout;
- buttonLayout1->addWidget(addButton, Qt::AlignTop);
- buttonLayout1->addWidget(submitButton);
- buttonLayout1->addWidget(cancelButton);
- buttonLayout1->addStretch();
-//! [navigation layout]
- QHBoxLayout *buttonLayout2 = new QHBoxLayout;
- buttonLayout2->addWidget(previousButton);
- buttonLayout2->addWidget(nextButton);
-//! [ navigation layout]
- QGridLayout *mainLayout = new QGridLayout;
- mainLayout->addWidget(nameLabel, 0, 0);
- mainLayout->addWidget(nameLine, 0, 1);
- mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
- mainLayout->addWidget(addressText, 1, 1);
- mainLayout->addLayout(buttonLayout1, 1, 2);
-//! [adding navigation layout]
- mainLayout->addLayout(buttonLayout2, 2, 1);
-//! [adding navigation layout]
- setLayout(mainLayout);
- setWindowTitle(tr("Simple Address Book"));
-}
-
-void AddressBook::addContact()
-{
- oldName = nameLine->text();
- oldAddress = addressText->toPlainText();
-
- nameLine->clear();
- addressText->clear();
-
- nameLine->setReadOnly(false);
- nameLine->setFocus(Qt::OtherFocusReason);
- addressText->setReadOnly(false);
-
- addButton->setEnabled(false);
-//! [disabling navigation]
- nextButton->setEnabled(false);
- previousButton->setEnabled(false);
-//! [disabling navigation]
- submitButton->show();
- cancelButton->show();
-}
-
-void AddressBook::submitContact()
-{
- QString name = nameLine->text();
- QString address = addressText->toPlainText();
-
- if (name.isEmpty() || address.isEmpty()) {
- QMessageBox::information(this, tr("Empty Field"),
- tr("Please enter a name and address."));
- return;
- }
-
- if (!contacts.contains(name)) {
- contacts.insert(name, address);
- QMessageBox::information(this, tr("Add Successful"),
- tr("\"%1\" has been added to your address book.").arg(name));
- } else {
- QMessageBox::information(this, tr("Add Unsuccessful"),
- tr("Sorry, \"%1\" is already in your address book.").arg(name));
- }
-
- if (contacts.isEmpty()) {
- nameLine->clear();
- addressText->clear();
- }
-
- nameLine->setReadOnly(true);
- addressText->setReadOnly(true);
- addButton->setEnabled(true);
-
-//! [enabling navigation]
- int number = contacts.size();
- nextButton->setEnabled(number > 1);
- previousButton->setEnabled(number > 1);
-//! [enabling navigation]
- submitButton->hide();
- cancelButton->hide();
-}
-
-void AddressBook::cancel()
-{
- nameLine->setText(oldName);
- addressText->setText(oldAddress);
-
- if (contacts.isEmpty()) {
- nameLine->clear();
- addressText->clear();
- }
-
- nameLine->setReadOnly(true);
- addressText->setReadOnly(true);
- addButton->setEnabled(true);
-
- int number = contacts.size();
- nextButton->setEnabled(number > 1);
- previousButton->setEnabled(number > 1);
-
- submitButton->hide();
- cancelButton->hide();
-}
-
-//! [next() function]
-void AddressBook::next()
-{
- QString name = nameLine->text();
- QMap<QString, QString>::iterator i = contacts.find(name);
-
- if (i != contacts.end())
- i++;
-
- if (i == contacts.end())
- i = contacts.begin();
-
- nameLine->setText(i.key());
- addressText->setText(i.value());
-}
-//! [next() function]
-//! [previous() function]
-void AddressBook::previous()
-{
- QString name = nameLine->text();
- QMap<QString, QString>::iterator i = contacts.find(name);
-
- if (i == contacts.end()){
- nameLine->clear();
- addressText->clear();
- return;
- }
-
- if (i == contacts.begin())
- i = contacts.end();
-
- i--;
- nameLine->setText(i.key());
- addressText->setText(i.value());
-}
-//! [previous() function]
diff --git a/examples/widgets/tutorials/addressbook/part3/addressbook.h b/examples/widgets/tutorials/addressbook/part3/addressbook.h
deleted file mode 100644
index 0e3aea1e05..0000000000
--- a/examples/widgets/tutorials/addressbook/part3/addressbook.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef ADDRESSBOOK_H
-#define ADDRESSBOOK_H
-
-#include <QWidget>
-#include <QMap>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-class QLineEdit;
-class QPushButton;
-class QTextEdit;
-QT_END_NAMESPACE
-
-class AddressBook : public QWidget
-{
- Q_OBJECT
-
-public:
- AddressBook(QWidget *parent = nullptr);
-
-public slots:
- void addContact();
- void submitContact();
- void cancel();
-//! [navigation functions]
- void next();
- void previous();
-//! [navigation functions]
-
-private:
- QPushButton *addButton;
- QPushButton *submitButton;
- QPushButton *cancelButton;
-//! [navigation pushbuttons]
- QPushButton *nextButton;
- QPushButton *previousButton;
-//! [navigation pushbuttons]
- QLineEdit *nameLine;
- QTextEdit *addressText;
-
- QMap<QString, QString> contacts;
- QString oldName;
- QString oldAddress;
-};
-
-#endif
diff --git a/examples/widgets/tutorials/addressbook/part3/main.cpp b/examples/widgets/tutorials/addressbook/part3/main.cpp
deleted file mode 100644
index 1f3aac3397..0000000000
--- a/examples/widgets/tutorials/addressbook/part3/main.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- AddressBook addressBook;
- addressBook.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/tutorials/addressbook/part3/part3.pro b/examples/widgets/tutorials/addressbook/part3/part3.pro
deleted file mode 100644
index 3bacdd9501..0000000000
--- a/examples/widgets/tutorials/addressbook/part3/part3.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += widgets
-
-SOURCES = addressbook.cpp \
- main.cpp
-HEADERS = addressbook.h
-
-QMAKE_PROJECT_NAME = ab_part3
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/addressbook/part3
-INSTALLS += target
diff --git a/examples/widgets/tutorials/addressbook/part4/CMakeLists.txt b/examples/widgets/tutorials/addressbook/part4/CMakeLists.txt
deleted file mode 100644
index 4f2b05dd1d..0000000000
--- a/examples/widgets/tutorials/addressbook/part4/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(part4 LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part4")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(part4
- addressbook.cpp addressbook.h
- main.cpp
-)
-
-set_target_properties(part4 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(part4 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS part4
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tutorials/addressbook/part4/addressbook.cpp b/examples/widgets/tutorials/addressbook/part4/addressbook.cpp
deleted file mode 100644
index a54a888073..0000000000
--- a/examples/widgets/tutorials/addressbook/part4/addressbook.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-AddressBook::AddressBook(QWidget *parent)
- : QWidget(parent)
-{
- QLabel *nameLabel = new QLabel(tr("Name:"));
- nameLine = new QLineEdit;
- nameLine->setReadOnly(true);
-
- QLabel *addressLabel = new QLabel(tr("Address:"));
- addressText = new QTextEdit;
- addressText->setReadOnly(true);
-
- addButton = new QPushButton(tr("&Add"));
-//! [edit and remove buttons]
- editButton = new QPushButton(tr("&Edit"));
- editButton->setEnabled(false);
- removeButton = new QPushButton(tr("&Remove"));
- removeButton->setEnabled(false);
-//! [edit and remove buttons]
- submitButton = new QPushButton(tr("&Submit"));
- submitButton->hide();
- cancelButton = new QPushButton(tr("&Cancel"));
- cancelButton->hide();
-
- nextButton = new QPushButton(tr("&Next"));
- nextButton->setEnabled(false);
- previousButton = new QPushButton(tr("&Previous"));
- previousButton->setEnabled(false);
-
- connect(addButton, &QPushButton::clicked,
- this, &AddressBook::addContact);
- connect(submitButton, &QPushButton::clicked,
- this, &AddressBook::submitContact);
-//! [connecting edit and remove]
- connect(editButton, &QPushButton::clicked,
- this, &AddressBook::editContact);
- connect(removeButton, &QPushButton::clicked,
- this, &AddressBook::removeContact);
-//! [connecting edit and remove]
- connect(cancelButton, &QPushButton::clicked,
- this, &AddressBook::cancel);
- connect(nextButton, &QPushButton::clicked,
- this, &AddressBook::next);
- connect(previousButton, &QPushButton::clicked,
- this, &AddressBook::previous);
-
- QVBoxLayout *buttonLayout1 = new QVBoxLayout;
- buttonLayout1->addWidget(addButton);
-//! [adding edit and remove to the layout]
- buttonLayout1->addWidget(editButton);
- buttonLayout1->addWidget(removeButton);
-//! [adding edit and remove to the layout]
- buttonLayout1->addWidget(submitButton);
- buttonLayout1->addWidget(cancelButton);
- buttonLayout1->addStretch();
-
- QHBoxLayout *buttonLayout2 = new QHBoxLayout;
- buttonLayout2->addWidget(previousButton);
- buttonLayout2->addWidget(nextButton);
-
- QGridLayout *mainLayout = new QGridLayout;
- mainLayout->addWidget(nameLabel, 0, 0);
- mainLayout->addWidget(nameLine, 0, 1);
- mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
- mainLayout->addWidget(addressText, 1, 1);
- mainLayout->addLayout(buttonLayout1, 1, 2);
- mainLayout->addLayout(buttonLayout2, 2, 1);
-
- setLayout(mainLayout);
- setWindowTitle(tr("Simple Address Book"));
-}
-
-void AddressBook::addContact()
-{
- oldName = nameLine->text();
- oldAddress = addressText->toPlainText();
-
- nameLine->clear();
- addressText->clear();
-
- updateInterface(AddingMode);
-}
-//! [editContact() function]
-void AddressBook::editContact()
-{
- oldName = nameLine->text();
- oldAddress = addressText->toPlainText();
-
- updateInterface(EditingMode);
-}
-//! [editContact() function]
-//! [submitContact() function beginning]
-void AddressBook::submitContact()
-{
-//! [submitContact() function beginning]
- QString name = nameLine->text();
- QString address = addressText->toPlainText();
-
- if (name.isEmpty() || address.isEmpty()) {
- QMessageBox::information(this, tr("Empty Field"),
- tr("Please enter a name and address."));
- return;
- }
-//! [submitContact() function part1]
- if (currentMode == AddingMode) {
-
- if (!contacts.contains(name)) {
- contacts.insert(name, address);
- QMessageBox::information(this, tr("Add Successful"),
- tr("\"%1\" has been added to your address book.").arg(name));
- } else {
- QMessageBox::information(this, tr("Add Unsuccessful"),
- tr("Sorry, \"%1\" is already in your address book.").arg(name));
- }
-//! [submitContact() function part1]
-//! [submitContact() function part2]
- } else if (currentMode == EditingMode) {
-
- if (oldName != name) {
- if (!contacts.contains(name)) {
- QMessageBox::information(this, tr("Edit Successful"),
- tr("\"%1\" has been edited in your address book.").arg(oldName));
- contacts.remove(oldName);
- contacts.insert(name, address);
- } else {
- QMessageBox::information(this, tr("Edit Unsuccessful"),
- tr("Sorry, \"%1\" is already in your address book.").arg(name));
- }
- } else if (oldAddress != address) {
- QMessageBox::information(this, tr("Edit Successful"),
- tr("\"%1\" has been edited in your address book.").arg(name));
- contacts[name] = address;
- }
- }
-
- updateInterface(NavigationMode);
-}
-//! [submitContact() function part2]
-
-void AddressBook::cancel()
-{
- nameLine->setText(oldName);
- addressText->setText(oldAddress);
- updateInterface(NavigationMode);
-}
-//! [removeContact() function]
-void AddressBook::removeContact()
-{
- QString name = nameLine->text();
- QString address = addressText->toPlainText();
-
- if (contacts.contains(name)) {
-
- int button = QMessageBox::question(this,
- tr("Confirm Remove"),
- tr("Are you sure you want to remove \"%1\"?").arg(name),
- QMessageBox::Yes | QMessageBox::No);
-
- if (button == QMessageBox::Yes) {
-
- previous();
- contacts.remove(name);
-
- QMessageBox::information(this, tr("Remove Successful"),
- tr("\"%1\" has been removed from your address book.").arg(name));
- }
- }
-
- updateInterface(NavigationMode);
-}
-//! [removeContact() function]
-void AddressBook::next()
-{
- QString name = nameLine->text();
- QMap<QString, QString>::iterator i = contacts.find(name);
-
- if (i != contacts.end())
- i++;
-
- if (i == contacts.end())
- i = contacts.begin();
-
- nameLine->setText(i.key());
- addressText->setText(i.value());
-}
-
-void AddressBook::previous()
-{
- QString name = nameLine->text();
- QMap<QString, QString>::iterator i = contacts.find(name);
-
- if (i == contacts.end()) {
- nameLine->clear();
- addressText->clear();
- return;
- }
-
- if (i == contacts.begin())
- i = contacts.end();
-
- i--;
- nameLine->setText(i.key());
- addressText->setText(i.value());
-}
-//! [update interface() part 1]
-void AddressBook::updateInterface(Mode mode)
-{
- currentMode = mode;
-
- switch (currentMode) {
-
- case AddingMode:
- case EditingMode:
-
- nameLine->setReadOnly(false);
- nameLine->setFocus(Qt::OtherFocusReason);
- addressText->setReadOnly(false);
-
- addButton->setEnabled(false);
- editButton->setEnabled(false);
- removeButton->setEnabled(false);
-
- nextButton->setEnabled(false);
- previousButton->setEnabled(false);
-
- submitButton->show();
- cancelButton->show();
- break;
-//! [update interface() part 1]
-//! [update interface() part 2]
- case NavigationMode:
-
- if (contacts.isEmpty()) {
- nameLine->clear();
- addressText->clear();
- }
-
- nameLine->setReadOnly(true);
- addressText->setReadOnly(true);
- addButton->setEnabled(true);
-
- int number = contacts.size();
- editButton->setEnabled(number >= 1);
- removeButton->setEnabled(number >= 1);
- nextButton->setEnabled(number > 1);
- previousButton->setEnabled(number >1 );
-
- submitButton->hide();
- cancelButton->hide();
- break;
- }
-}
-//! [update interface() part 2]
diff --git a/examples/widgets/tutorials/addressbook/part4/addressbook.h b/examples/widgets/tutorials/addressbook/part4/addressbook.h
deleted file mode 100644
index e77bbd3961..0000000000
--- a/examples/widgets/tutorials/addressbook/part4/addressbook.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef ADDRESSBOOK_H
-#define ADDRESSBOOK_H
-
-#include <QWidget>
-#include <QMap>
-
-QT_BEGIN_NAMESPACE
-class QPushButton;
-class QLabel;
-class QLineEdit;
-class QTextEdit;
-QT_END_NAMESPACE
-
-class AddressBook : public QWidget
-{
- Q_OBJECT
-
-public:
- AddressBook(QWidget *parent = nullptr);
-//! [Mode enum]
- enum Mode { NavigationMode, AddingMode, EditingMode };
-//! [Mode enum]
-
-public slots:
- void addContact();
- void submitContact();
- void cancel();
-//! [edit and remove slots]
- void editContact();
- void removeContact();
-//! [edit and remove slots]
- void next();
- void previous();
-
-private:
-//! [updateInterface() declaration]
- void updateInterface(Mode mode);
-//! [updateInterface() declaration]
- QPushButton *addButton;
-//! [buttons declaration]
- QPushButton *editButton;
- QPushButton *removeButton;
-//! [buttons declaration]
- QPushButton *submitButton;
- QPushButton *cancelButton;
- QPushButton *nextButton;
- QPushButton *previousButton;
- QLineEdit *nameLine;
- QTextEdit *addressText;
-
- QMap<QString, QString> contacts;
- QString oldName;
- QString oldAddress;
-//! [mode declaration]
- Mode currentMode;
-//! [mode declaration]
-};
-
-#endif
diff --git a/examples/widgets/tutorials/addressbook/part4/main.cpp b/examples/widgets/tutorials/addressbook/part4/main.cpp
deleted file mode 100644
index 1f3aac3397..0000000000
--- a/examples/widgets/tutorials/addressbook/part4/main.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- AddressBook addressBook;
- addressBook.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/tutorials/addressbook/part4/part4.pro b/examples/widgets/tutorials/addressbook/part4/part4.pro
deleted file mode 100644
index 02cc5b8e07..0000000000
--- a/examples/widgets/tutorials/addressbook/part4/part4.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += widgets
-
-SOURCES = addressbook.cpp \
- main.cpp
-HEADERS = addressbook.h
-
-QMAKE_PROJECT_NAME = ab_part4
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/addressbook/part4
-INSTALLS += target
diff --git a/examples/widgets/tutorials/addressbook/part5/CMakeLists.txt b/examples/widgets/tutorials/addressbook/part5/CMakeLists.txt
deleted file mode 100644
index b1a1bc2cf2..0000000000
--- a/examples/widgets/tutorials/addressbook/part5/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(part5 LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part5")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(part5
- addressbook.cpp addressbook.h
- finddialog.cpp finddialog.h
- main.cpp
-)
-
-set_target_properties(part5 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(part5 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS part5
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tutorials/addressbook/part5/addressbook.cpp b/examples/widgets/tutorials/addressbook/part5/addressbook.cpp
deleted file mode 100644
index 52aa5a0b28..0000000000
--- a/examples/widgets/tutorials/addressbook/part5/addressbook.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-AddressBook::AddressBook(QWidget *parent)
- : QWidget(parent)
-{
- QLabel *nameLabel = new QLabel(tr("Name:"));
- nameLine = new QLineEdit;
- nameLine->setReadOnly(true);
-
- QLabel *addressLabel = new QLabel(tr("Address:"));
- addressText = new QTextEdit;
- addressText->setReadOnly(true);
-
- addButton = new QPushButton(tr("&Add"));
-
- editButton = new QPushButton(tr("&Edit"));
- editButton->setEnabled(false);
- removeButton = new QPushButton(tr("&Remove"));
- removeButton->setEnabled(false);
-//! [instantiating findButton]
- findButton = new QPushButton(tr("&Find"));
- findButton->setEnabled(false);
-//! [instantiating findButton]
- submitButton = new QPushButton(tr("&Submit"));
- submitButton->hide();
- cancelButton = new QPushButton(tr("&Cancel"));
- cancelButton->hide();
-
- nextButton = new QPushButton(tr("&Next"));
- nextButton->setEnabled(false);
- previousButton = new QPushButton(tr("&Previous"));
- previousButton->setEnabled(false);
-
-//! [instantiating FindDialog]
- dialog = new FindDialog(this);
-//! [instantiating FindDialog]
-
- connect(addButton, &QPushButton::clicked,
- this, &AddressBook::addContact);
- connect(submitButton, &QPushButton::clicked,
- this, &AddressBook::submitContact);
- connect(editButton, &QPushButton::clicked,
- this, &AddressBook::editContact);
- connect(removeButton, &QPushButton::clicked,
- this, &AddressBook::removeContact);
- connect(cancelButton, &QPushButton::clicked,
- this, &AddressBook::cancel);
-//! [signals and slots for find]
- connect(findButton, &QPushButton::clicked,
- this, &AddressBook::findContact);
-//! [signals and slots for find]
- connect(nextButton, &QPushButton::clicked,
- this, &AddressBook::next);
- connect(previousButton, &QPushButton::clicked,
- this, &AddressBook::previous);
-
- QVBoxLayout *buttonLayout1 = new QVBoxLayout;
- buttonLayout1->addWidget(addButton);
- buttonLayout1->addWidget(editButton);
- buttonLayout1->addWidget(removeButton);
-//! [adding findButton to layout]
- buttonLayout1->addWidget(findButton);
-//! [adding findButton to layout]
- buttonLayout1->addWidget(submitButton);
- buttonLayout1->addWidget(cancelButton);
- buttonLayout1->addStretch();
-
- QHBoxLayout *buttonLayout2 = new QHBoxLayout;
- buttonLayout2->addWidget(previousButton);
- buttonLayout2->addWidget(nextButton);
-
- QGridLayout *mainLayout = new QGridLayout;
- mainLayout->addWidget(nameLabel, 0, 0);
- mainLayout->addWidget(nameLine, 0, 1);
- mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
- mainLayout->addWidget(addressText, 1, 1);
- mainLayout->addLayout(buttonLayout1, 1, 2);
- mainLayout->addLayout(buttonLayout2, 2, 1);
-
- setLayout(mainLayout);
- setWindowTitle(tr("Simple Address Book"));
-}
-
-void AddressBook::addContact()
-{
- oldName = nameLine->text();
- oldAddress = addressText->toPlainText();
-
- nameLine->clear();
- addressText->clear();
-
- updateInterface(AddingMode);
-}
-
-void AddressBook::editContact()
-{
- oldName = nameLine->text();
- oldAddress = addressText->toPlainText();
-
- updateInterface(EditingMode);
-}
-
-void AddressBook::submitContact()
-{
- QString name = nameLine->text();
- QString address = addressText->toPlainText();
-
- if (name.isEmpty() || address.isEmpty()) {
- QMessageBox::information(this, tr("Empty Field"),
- tr("Please enter a name and address."));
- return;
- }
-
- if (currentMode == AddingMode) {
-
- if (!contacts.contains(name)) {
- contacts.insert(name, address);
- QMessageBox::information(this, tr("Add Successful"),
- tr("\"%1\" has been added to your address book.").arg(name));
- } else {
- QMessageBox::information(this, tr("Add Unsuccessful"),
- tr("Sorry, \"%1\" is already in your address book.").arg(name));
- }
- } else if (currentMode == EditingMode) {
-
- if (oldName != name) {
- if (!contacts.contains(name)) {
- QMessageBox::information(this, tr("Edit Successful"),
- tr("\"%1\" has been edited in your address book.").arg(oldName));
- contacts.remove(oldName);
- contacts.insert(name, address);
- } else {
- QMessageBox::information(this, tr("Edit Unsuccessful"),
- tr("Sorry, \"%1\" is already in your address book.").arg(name));
- }
- } else if (oldAddress != address) {
- QMessageBox::information(this, tr("Edit Successful"),
- tr("\"%1\" has been edited in your address book.").arg(name));
- contacts[name] = address;
- }
- }
-
- updateInterface(NavigationMode);
-}
-
-void AddressBook::cancel()
-{
- nameLine->setText(oldName);
- addressText->setText(oldAddress);
- updateInterface(NavigationMode);
-}
-
-void AddressBook::removeContact()
-{
- QString name = nameLine->text();
- QString address = addressText->toPlainText();
-
- if (contacts.contains(name)) {
-
- int button = QMessageBox::question(this,
- tr("Confirm Remove"),
- tr("Are you sure you want to remove \"%1\"?").arg(name),
- QMessageBox::Yes | QMessageBox::No);
-
- if (button == QMessageBox::Yes) {
-
- previous();
- contacts.remove(name);
-
- QMessageBox::information(this, tr("Remove Successful"),
- tr("\"%1\" has been removed from your address book.").arg(name));
- }
- }
-
- updateInterface(NavigationMode);
-}
-
-void AddressBook::next()
-{
- QString name = nameLine->text();
- QMap<QString, QString>::iterator i = contacts.find(name);
-
- if (i != contacts.end())
- i++;
-
- if (i == contacts.end())
- i = contacts.begin();
-
- nameLine->setText(i.key());
- addressText->setText(i.value());
-}
-
-void AddressBook::previous()
-{
- QString name = nameLine->text();
- QMap<QString, QString>::iterator i = contacts.find(name);
-
- if (i == contacts.end()) {
- nameLine->clear();
- addressText->clear();
- return;
- }
-
- if (i == contacts.begin())
- i = contacts.end();
-
- i--;
- nameLine->setText(i.key());
- addressText->setText(i.value());
-}
-//! [findContact() function]
-void AddressBook::findContact()
-{
- dialog->show();
-
- if (dialog->exec() == QDialog::Accepted) {
- QString contactName = dialog->getFindText();
-
- if (contacts.contains(contactName)) {
- nameLine->setText(contactName);
- addressText->setText(contacts.value(contactName));
- } else {
- QMessageBox::information(this, tr("Contact Not Found"),
- tr("Sorry, \"%1\" is not in your address book.").arg(contactName));
- return;
- }
- }
-
- updateInterface(NavigationMode);
-}
-//! [findContact() function]
-
-void AddressBook::updateInterface(Mode mode)
-{
- currentMode = mode;
-
- switch (currentMode) {
-
- case AddingMode:
- case EditingMode:
-
- nameLine->setReadOnly(false);
- nameLine->setFocus(Qt::OtherFocusReason);
- addressText->setReadOnly(false);
-
- addButton->setEnabled(false);
- editButton->setEnabled(false);
- removeButton->setEnabled(false);
-
- nextButton->setEnabled(false);
- previousButton->setEnabled(false);
-
- submitButton->show();
- cancelButton->show();
- break;
-
- case NavigationMode:
-
- if (contacts.isEmpty()) {
- nameLine->clear();
- addressText->clear();
- }
-
- nameLine->setReadOnly(true);
- addressText->setReadOnly(true);
- addButton->setEnabled(true);
-
- int number = contacts.size();
- editButton->setEnabled(number >= 1);
- removeButton->setEnabled(number >= 1);
- findButton->setEnabled(number > 2);
- nextButton->setEnabled(number > 1);
- previousButton->setEnabled(number > 1);
-
- submitButton->hide();
- cancelButton->hide();
- break;
- }
-}
diff --git a/examples/widgets/tutorials/addressbook/part5/addressbook.h b/examples/widgets/tutorials/addressbook/part5/addressbook.h
deleted file mode 100644
index 93da08038c..0000000000
--- a/examples/widgets/tutorials/addressbook/part5/addressbook.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef ADDRESSBOOK_H
-#define ADDRESSBOOK_H
-
-#include <QWidget>
-#include <QMap>
-//! [include finddialog's header]
-#include "finddialog.h"
-//! [include finddialog's header]
-QT_BEGIN_NAMESPACE
-class QPushButton;
-class QLabel;
-class QLineEdit;
-class QTextEdit;
-QT_END_NAMESPACE
-
-
-class AddressBook : public QWidget
-{
- Q_OBJECT
-
-public:
- AddressBook(QWidget *parent = nullptr);
- enum Mode { NavigationMode, AddingMode, EditingMode };
-
-public slots:
- void addContact();
- void editContact();
- void submitContact();
- void cancel();
- void removeContact();
-//! [findContact() declaration]
- void findContact();
-//! [findContact() declaration]
- void next();
- void previous();
-
-private:
- void updateInterface(Mode mode);
-
- QPushButton *addButton;
- QPushButton *editButton;
- QPushButton *removeButton;
-//! [findButton declaration]
- QPushButton *findButton;
-//! [findButton declaration]
- QPushButton *submitButton;
- QPushButton *cancelButton;
- QPushButton *nextButton;
- QPushButton *previousButton;
- QLineEdit *nameLine;
- QTextEdit *addressText;
-
- QMap<QString, QString> contacts;
-//! [FindDialog declaration]
- FindDialog *dialog;
-//! [FindDialog declaration]
- QString oldName;
- QString oldAddress;
- Mode currentMode;
-};
-
-#endif
diff --git a/examples/widgets/tutorials/addressbook/part5/finddialog.cpp b/examples/widgets/tutorials/addressbook/part5/finddialog.cpp
deleted file mode 100644
index d5daa661d0..0000000000
--- a/examples/widgets/tutorials/addressbook/part5/finddialog.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "finddialog.h"
-
-//! [constructor]
-FindDialog::FindDialog(QWidget *parent)
- : QDialog(parent)
-{
- QLabel *findLabel = new QLabel(tr("Enter the name of a contact:"));
- lineEdit = new QLineEdit;
-
- findButton = new QPushButton(tr("&Find"));
- findText = "";
-
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(findLabel);
- layout->addWidget(lineEdit);
- layout->addWidget(findButton);
-
- setLayout(layout);
- setWindowTitle(tr("Find a Contact"));
- connect(findButton, &QPushButton::clicked,
- this, &FindDialog::findClicked);
- connect(findButton, &QPushButton::clicked,
- this, &FindDialog::accept);
-}
-//! [constructor]
-//! [findClicked() function]
-void FindDialog::findClicked()
-{
- QString text = lineEdit->text();
-
- if (text.isEmpty()) {
- QMessageBox::information(this, tr("Empty Field"),
- tr("Please enter a name."));
- return;
- } else {
- findText = text;
- lineEdit->clear();
- hide();
- }
-}
-//! [findClicked() function]
-//! [getFindText() function]
-QString FindDialog::getFindText()
-{
- return findText;
-}
-//! [getFindText() function]
diff --git a/examples/widgets/tutorials/addressbook/part5/finddialog.h b/examples/widgets/tutorials/addressbook/part5/finddialog.h
deleted file mode 100644
index 7cedcffa60..0000000000
--- a/examples/widgets/tutorials/addressbook/part5/finddialog.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef FINDDIALOG_H
-#define FINDDIALOG_H
-//! [FindDialog header]
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-class QLineEdit;
-class QPushButton;
-QT_END_NAMESPACE
-
-class FindDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- FindDialog(QWidget *parent = nullptr);
- QString getFindText();
-
-public slots:
- void findClicked();
-
-private:
- QPushButton *findButton;
- QLineEdit *lineEdit;
- QString findText;
-};
-//! [FindDialog header]
-#endif
diff --git a/examples/widgets/tutorials/addressbook/part5/main.cpp b/examples/widgets/tutorials/addressbook/part5/main.cpp
deleted file mode 100644
index 1f3aac3397..0000000000
--- a/examples/widgets/tutorials/addressbook/part5/main.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- AddressBook addressBook;
- addressBook.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/tutorials/addressbook/part5/part5.pro b/examples/widgets/tutorials/addressbook/part5/part5.pro
deleted file mode 100644
index da5469f655..0000000000
--- a/examples/widgets/tutorials/addressbook/part5/part5.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-QT += widgets
-
-SOURCES = addressbook.cpp \
- finddialog.cpp \
- main.cpp
-HEADERS = addressbook.h \
- finddialog.h
-
-QMAKE_PROJECT_NAME = ab_part5
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/addressbook/part5
-INSTALLS += target
diff --git a/examples/widgets/tutorials/addressbook/part6/CMakeLists.txt b/examples/widgets/tutorials/addressbook/part6/CMakeLists.txt
deleted file mode 100644
index 3a2f1af699..0000000000
--- a/examples/widgets/tutorials/addressbook/part6/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(part6 LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part6")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(part6
- addressbook.cpp addressbook.h
- finddialog.cpp finddialog.h
- main.cpp
-)
-
-set_target_properties(part6 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(part6 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS part6
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tutorials/addressbook/part6/addressbook.cpp b/examples/widgets/tutorials/addressbook/part6/addressbook.cpp
deleted file mode 100644
index 455ccc899a..0000000000
--- a/examples/widgets/tutorials/addressbook/part6/addressbook.cpp
+++ /dev/null
@@ -1,366 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-AddressBook::AddressBook(QWidget *parent)
- : QWidget(parent)
-{
- QLabel *nameLabel = new QLabel(tr("Name:"));
- nameLine = new QLineEdit;
- nameLine->setReadOnly(true);
-
- QLabel *addressLabel = new QLabel(tr("Address:"));
- addressText = new QTextEdit;
- addressText->setReadOnly(true);
-
- addButton = new QPushButton(tr("&Add"));
-
- editButton = new QPushButton(tr("&Edit"));
- editButton->setEnabled(false);
- removeButton = new QPushButton(tr("&Remove"));
- removeButton->setEnabled(false);
- findButton = new QPushButton(tr("&Find"));
- findButton->setEnabled(false);
- submitButton = new QPushButton(tr("&Submit"));
- submitButton->hide();
- cancelButton = new QPushButton(tr("&Cancel"));
- cancelButton->hide();
-
- nextButton = new QPushButton(tr("&Next"));
- nextButton->setEnabled(false);
- previousButton = new QPushButton(tr("&Previous"));
- previousButton->setEnabled(false);
-
- loadButton = new QPushButton(tr("&Load..."));
-//! [tooltip 1]
- loadButton->setToolTip(tr("Load contacts from a file"));
-//! [tooltip 1]
- saveButton = new QPushButton(tr("&Save..."));
-//! [tooltip 2]
- saveButton->setToolTip(tr("Save contacts to a file"));
-//! [tooltip 2]
- saveButton->setEnabled(false);
-
- dialog = new FindDialog(this);
-
- connect(addButton, &QPushButton::clicked,
- this, &AddressBook::addContact);
- connect(submitButton, &QPushButton::clicked,
- this, &AddressBook::submitContact);
- connect(editButton, &QPushButton::clicked,
- this, &AddressBook::editContact);
- connect(removeButton, &QPushButton::clicked,
- this, &AddressBook::removeContact);
- connect(cancelButton, &QPushButton::clicked,
- this, &AddressBook::cancel);
- connect(findButton, &QPushButton::clicked,
- this, &AddressBook::findContact);
- connect(nextButton, &QPushButton::clicked,
- this, &AddressBook::next);
- connect(previousButton, &QPushButton::clicked,
- this, &AddressBook::previous);
- connect(loadButton, &QPushButton::clicked,
- this, &AddressBook::loadFromFile);
- connect(saveButton, &QPushButton::clicked,
- this, &AddressBook::saveToFile);
-
- QVBoxLayout *buttonLayout1 = new QVBoxLayout;
- buttonLayout1->addWidget(addButton);
- buttonLayout1->addWidget(editButton);
- buttonLayout1->addWidget(removeButton);
- buttonLayout1->addWidget(findButton);
- buttonLayout1->addWidget(submitButton);
- buttonLayout1->addWidget(cancelButton);
- buttonLayout1->addWidget(loadButton);
- buttonLayout1->addWidget(saveButton);
- buttonLayout1->addStretch();
-
- QHBoxLayout *buttonLayout2 = new QHBoxLayout;
- buttonLayout2->addWidget(previousButton);
- buttonLayout2->addWidget(nextButton);
-
- QGridLayout *mainLayout = new QGridLayout;
- mainLayout->addWidget(nameLabel, 0, 0);
- mainLayout->addWidget(nameLine, 0, 1);
- mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
- mainLayout->addWidget(addressText, 1, 1);
- mainLayout->addLayout(buttonLayout1, 1, 2);
- mainLayout->addLayout(buttonLayout2, 2, 1);
-
- setLayout(mainLayout);
- setWindowTitle(tr("Simple Address Book"));
-}
-
-void AddressBook::addContact()
-{
- oldName = nameLine->text();
- oldAddress = addressText->toPlainText();
-
- nameLine->clear();
- addressText->clear();
-
- updateInterface(AddingMode);
-}
-
-void AddressBook::editContact()
-{
- oldName = nameLine->text();
- oldAddress = addressText->toPlainText();
-
- updateInterface(EditingMode);
-}
-
-void AddressBook::submitContact()
-{
- QString name = nameLine->text();
- QString address = addressText->toPlainText();
-
- if (name.isEmpty() || address.isEmpty()) {
- QMessageBox::information(this, tr("Empty Field"),
- tr("Please enter a name and address."));
- return;
- }
-
- if (currentMode == AddingMode) {
-
- if (!contacts.contains(name)) {
- contacts.insert(name, address);
- QMessageBox::information(this, tr("Add Successful"),
- tr("\"%1\" has been added to your address book.").arg(name));
- } else {
- QMessageBox::information(this, tr("Add Unsuccessful"),
- tr("Sorry, \"%1\" is already in your address book.").arg(name));
- }
- } else if (currentMode == EditingMode) {
-
- if (oldName != name) {
- if (!contacts.contains(name)) {
- QMessageBox::information(this, tr("Edit Successful"),
- tr("\"%1\" has been edited in your address book.").arg(oldName));
- contacts.remove(oldName);
- contacts.insert(name, address);
- } else {
- QMessageBox::information(this, tr("Edit Unsuccessful"),
- tr("Sorry, \"%1\" is already in your address book.").arg(name));
- }
- } else if (oldAddress != address) {
- QMessageBox::information(this, tr("Edit Successful"),
- tr("\"%1\" has been edited in your address book.").arg(name));
- contacts[name] = address;
- }
- }
-
- updateInterface(NavigationMode);
-}
-
-void AddressBook::cancel()
-{
- nameLine->setText(oldName);
- addressText->setText(oldAddress);
- updateInterface(NavigationMode);
-}
-
-void AddressBook::removeContact()
-{
- QString name = nameLine->text();
- QString address = addressText->toPlainText();
-
- if (contacts.contains(name)) {
-
- int button = QMessageBox::question(this,
- tr("Confirm Remove"),
- tr("Are you sure you want to remove \"%1\"?").arg(name),
- QMessageBox::Yes | QMessageBox::No);
-
- if (button == QMessageBox::Yes) {
-
- previous();
- contacts.remove(name);
-
- QMessageBox::information(this, tr("Remove Successful"),
- tr("\"%1\" has been removed from your address book.").arg(name));
- }
- }
-
- updateInterface(NavigationMode);
-}
-
-void AddressBook::next()
-{
- QString name = nameLine->text();
- QMap<QString, QString>::iterator i = contacts.find(name);
-
- if (i != contacts.end())
- i++;
-
- if (i == contacts.end())
- i = contacts.begin();
-
- nameLine->setText(i.key());
- addressText->setText(i.value());
-}
-
-void AddressBook::previous()
-{
- QString name = nameLine->text();
- QMap<QString, QString>::iterator i = contacts.find(name);
-
- if (i == contacts.end()) {
- nameLine->clear();
- addressText->clear();
- return;
- }
-
- if (i == contacts.begin())
- i = contacts.end();
-
- i--;
- nameLine->setText(i.key());
- addressText->setText(i.value());
-}
-
-void AddressBook::findContact()
-{
- dialog->show();
-
- if (dialog->exec() == 1) {
- QString contactName = dialog->getFindText();
-
- if (contacts.contains(contactName)) {
- nameLine->setText(contactName);
- addressText->setText(contacts.value(contactName));
- } else {
- QMessageBox::information(this, tr("Contact Not Found"),
- tr("Sorry, \"%1\" is not in your address book.").arg(contactName));
- return;
- }
- }
-
- updateInterface(NavigationMode);
-}
-
-void AddressBook::updateInterface(Mode mode)
-{
- currentMode = mode;
-
- switch (currentMode) {
-
- case AddingMode:
- case EditingMode:
-
- nameLine->setReadOnly(false);
- nameLine->setFocus(Qt::OtherFocusReason);
- addressText->setReadOnly(false);
-
- addButton->setEnabled(false);
- editButton->setEnabled(false);
- removeButton->setEnabled(false);
-
- nextButton->setEnabled(false);
- previousButton->setEnabled(false);
-
- submitButton->show();
- cancelButton->show();
-
- loadButton->setEnabled(false);
- saveButton->setEnabled(false);
- break;
-
- case NavigationMode:
-
- if (contacts.isEmpty()) {
- nameLine->clear();
- addressText->clear();
- }
-
- nameLine->setReadOnly(true);
- addressText->setReadOnly(true);
- addButton->setEnabled(true);
-
- int number = contacts.size();
- editButton->setEnabled(number >= 1);
- removeButton->setEnabled(number >= 1);
- findButton->setEnabled(number > 2);
- nextButton->setEnabled(number > 1);
- previousButton->setEnabled(number > 1);
-
- submitButton->hide();
- cancelButton->hide();
-
- loadButton->setEnabled(true);
- saveButton->setEnabled(number >= 1);
- break;
- }
-}
-
-//! [saveToFile() function part1]
-void AddressBook::saveToFile()
-{
- QString fileName = QFileDialog::getSaveFileName(this,
- tr("Save Address Book"), "",
- tr("Address Book (*.abk);;All Files (*)"));
-
-//! [saveToFile() function part1]
-//! [saveToFile() function part2]
- if (fileName.isEmpty())
- return;
- else {
- QFile file(fileName);
- if (!file.open(QIODevice::WriteOnly)) {
- QMessageBox::information(this, tr("Unable to open file"),
- file.errorString());
- return;
- }
-
-//! [saveToFile() function part2]
-//! [saveToFile() function part3]
- QDataStream out(&file);
- out.setVersion(QDataStream::Qt_4_5);
- out << contacts;
- }
-}
-//! [saveToFile() function part3]
-
-//! [loadFromFile() function part1]
-void AddressBook::loadFromFile()
-{
- QString fileName = QFileDialog::getOpenFileName(this,
- tr("Open Address Book"), "",
- tr("Address Book (*.abk);;All Files (*)"));
-//! [loadFromFile() function part1]
-
-//! [loadFromFile() function part2]
- if (fileName.isEmpty())
- return;
- else {
-
- QFile file(fileName);
-
- if (!file.open(QIODevice::ReadOnly)) {
- QMessageBox::information(this, tr("Unable to open file"),
- file.errorString());
- return;
- }
-
- QDataStream in(&file);
- in.setVersion(QDataStream::Qt_4_5);
- contacts.clear(); // clear existing contacts
- in >> contacts;
-//! [loadFromFile() function part2]
-
-//! [loadFromFile() function part3]
- if (contacts.isEmpty()) {
- QMessageBox::information(this, tr("No contacts in file"),
- tr("The file you are attempting to open contains no contacts."));
- } else {
- QMap<QString, QString>::iterator i = contacts.begin();
- nameLine->setText(i.key());
- addressText->setText(i.value());
- }
- }
-
- updateInterface(NavigationMode);
-}
-//! [loadFromFile() function part3]
diff --git a/examples/widgets/tutorials/addressbook/part6/addressbook.h b/examples/widgets/tutorials/addressbook/part6/addressbook.h
deleted file mode 100644
index 26389d7446..0000000000
--- a/examples/widgets/tutorials/addressbook/part6/addressbook.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef ADDRESSBOOK_H
-#define ADDRESSBOOK_H
-
-#include <QWidget>
-#include <QMap>
-#include "finddialog.h"
-
-QT_BEGIN_NAMESPACE
-class QPushButton;
-class QLabel;
-class QLineEdit;
-class QTextEdit;
-QT_END_NAMESPACE
-
-
-class AddressBook : public QWidget
-{
- Q_OBJECT
-
-public:
- AddressBook(QWidget *parent = nullptr);
- enum Mode { NavigationMode, AddingMode, EditingMode };
-
-public slots:
- void addContact();
- void editContact();
- void submitContact();
- void cancel();
- void removeContact();
- void findContact();
- void next();
- void previous();
-//! [save and load functions declaration]
- void saveToFile();
- void loadFromFile();
-//! [save and load functions declaration]
-
-private:
- void updateInterface(Mode mode);
-
- QPushButton *addButton;
- QPushButton *editButton;
- QPushButton *removeButton;
- QPushButton *findButton;
- QPushButton *submitButton;
- QPushButton *cancelButton;
- QPushButton *nextButton;
- QPushButton *previousButton;
-//! [save and load buttons declaration]
- QPushButton *loadButton;
- QPushButton *saveButton;
-//! [save and load buttons declaration]
- QLineEdit *nameLine;
- QTextEdit *addressText;
-
- QMap<QString, QString> contacts;
- FindDialog *dialog;
- QString oldName;
- QString oldAddress;
- Mode currentMode;
-};
-
-#endif
diff --git a/examples/widgets/tutorials/addressbook/part6/finddialog.cpp b/examples/widgets/tutorials/addressbook/part6/finddialog.cpp
deleted file mode 100644
index 90729d9c12..0000000000
--- a/examples/widgets/tutorials/addressbook/part6/finddialog.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "finddialog.h"
-
-FindDialog::FindDialog(QWidget *parent)
- : QDialog(parent)
-{
- QLabel *findLabel = new QLabel(tr("Enter the name of a contact:"));
- lineEdit = new QLineEdit;
-
- findButton = new QPushButton(tr("&Find"));
- findText = "";
-
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(findLabel);
- layout->addWidget(lineEdit);
- layout->addWidget(findButton);
-
- setLayout(layout);
- setWindowTitle(tr("Find a Contact"));
- connect(findButton, &QPushButton::clicked,
- this, &FindDialog::findClicked);
- connect(findButton, &QPushButton::clicked,
- this, &FindDialog::accept);
-}
-
-void FindDialog::findClicked()
-{
- QString text = lineEdit->text();
-
- if (text.isEmpty()) {
- QMessageBox::information(this, tr("Empty Field"),
- tr("Please enter a name."));
- return;
- } else {
- findText = text;
- lineEdit->clear();
- hide();
- }
-}
-
-QString FindDialog::getFindText()
-{
- return findText;
-}
diff --git a/examples/widgets/tutorials/addressbook/part6/finddialog.h b/examples/widgets/tutorials/addressbook/part6/finddialog.h
deleted file mode 100644
index 7c9a3af30f..0000000000
--- a/examples/widgets/tutorials/addressbook/part6/finddialog.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef FINDDIALOG_H
-#define FINDDIALOG_H
-
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-class QLineEdit;
-class QPushButton;
-QT_END_NAMESPACE
-
-class FindDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- FindDialog(QWidget *parent = nullptr);
- QString getFindText();
-
-public slots:
- void findClicked();
-
-private:
- QPushButton *findButton;
- QLineEdit *lineEdit;
- QString findText;
-};
-
-#endif
diff --git a/examples/widgets/tutorials/addressbook/part6/main.cpp b/examples/widgets/tutorials/addressbook/part6/main.cpp
deleted file mode 100644
index 1f3aac3397..0000000000
--- a/examples/widgets/tutorials/addressbook/part6/main.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- AddressBook addressBook;
- addressBook.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/tutorials/addressbook/part6/part6.pro b/examples/widgets/tutorials/addressbook/part6/part6.pro
deleted file mode 100644
index 6796f30a73..0000000000
--- a/examples/widgets/tutorials/addressbook/part6/part6.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-QT += widgets
-requires(qtConfig(filedialog))
-
-SOURCES = addressbook.cpp \
- finddialog.cpp \
- main.cpp
-HEADERS = addressbook.h \
- finddialog.h
-
-QMAKE_PROJECT_NAME = ab_part6
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/addressbook/part6
-INSTALLS += target
diff --git a/examples/widgets/tutorials/addressbook/part7/CMakeLists.txt b/examples/widgets/tutorials/addressbook/part7/CMakeLists.txt
deleted file mode 100644
index 0913e886d0..0000000000
--- a/examples/widgets/tutorials/addressbook/part7/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(part7 LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part7")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(part7
- addressbook.cpp addressbook.h
- finddialog.cpp finddialog.h
- main.cpp
-)
-
-set_target_properties(part7 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(part7 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS part7
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tutorials/addressbook/part7/addressbook.cpp b/examples/widgets/tutorials/addressbook/part7/addressbook.cpp
deleted file mode 100644
index 30878d7bbc..0000000000
--- a/examples/widgets/tutorials/addressbook/part7/addressbook.cpp
+++ /dev/null
@@ -1,419 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-AddressBook::AddressBook(QWidget *parent)
- : QWidget(parent)
-{
- QLabel *nameLabel = new QLabel(tr("Name:"));
- nameLine = new QLineEdit;
- nameLine->setReadOnly(true);
-
- QLabel *addressLabel = new QLabel(tr("Address:"));
- addressText = new QTextEdit;
- addressText->setReadOnly(true);
-
- addButton = new QPushButton(tr("&Add"));
-
- editButton = new QPushButton(tr("&Edit"));
- editButton->setEnabled(false);
- removeButton = new QPushButton(tr("&Remove"));
- removeButton->setEnabled(false);
- findButton = new QPushButton(tr("&Find"));
- findButton->setEnabled(false);
- submitButton = new QPushButton(tr("&Submit"));
- submitButton->hide();
- cancelButton = new QPushButton(tr("&Cancel"));
- cancelButton->hide();
-
- nextButton = new QPushButton(tr("&Next"));
- nextButton->setEnabled(false);
- previousButton = new QPushButton(tr("&Previous"));
- previousButton->setEnabled(false);
-
- loadButton = new QPushButton(tr("&Load..."));
- loadButton->setToolTip(tr("Load contacts from a file"));
- saveButton = new QPushButton(tr("&Save..."));
- saveButton->setToolTip(tr("Save contacts to a file"));
- saveButton->setEnabled(false);
-
- exportButton = new QPushButton(tr("E&xport"));
- exportButton->setToolTip(tr("Export as vCard"));
- exportButton->setEnabled(false);
-
- dialog = new FindDialog(this);
-
- connect(addButton, &QPushButton::clicked,
- this, &AddressBook::addContact);
- connect(submitButton, &QPushButton::clicked,
- this, &AddressBook::submitContact);
- connect(editButton, &QPushButton::clicked,
- this, &AddressBook::editContact);
- connect(removeButton, &QPushButton::clicked,
- this, &AddressBook::removeContact);
- connect(cancelButton, &QPushButton::clicked,
- this, &AddressBook::cancel);
- connect(findButton, &QPushButton::clicked,
- this, &AddressBook::findContact);
- connect(nextButton, &QPushButton::clicked,
- this, &AddressBook::next);
- connect(previousButton, &QPushButton::clicked,
- this, &AddressBook::previous);
- connect(loadButton, &QPushButton::clicked,
- this, &AddressBook::loadFromFile);
- connect(saveButton, &QPushButton::clicked,
- this, &AddressBook::saveToFile);
- connect(exportButton, &QPushButton::clicked,
- this, &AddressBook::exportAsVCard);
-
- QVBoxLayout *buttonLayout1 = new QVBoxLayout;
- buttonLayout1->addWidget(addButton);
- buttonLayout1->addWidget(editButton);
- buttonLayout1->addWidget(removeButton);
- buttonLayout1->addWidget(findButton);
- buttonLayout1->addWidget(submitButton);
- buttonLayout1->addWidget(cancelButton);
- buttonLayout1->addWidget(loadButton);
- buttonLayout1->addWidget(saveButton);
- buttonLayout1->addWidget(exportButton);
- buttonLayout1->addStretch();
-
- QHBoxLayout *buttonLayout2 = new QHBoxLayout;
- buttonLayout2->addWidget(previousButton);
- buttonLayout2->addWidget(nextButton);
-
- QGridLayout *mainLayout = new QGridLayout;
- mainLayout->addWidget(nameLabel, 0, 0);
- mainLayout->addWidget(nameLine, 0, 1);
- mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop);
- mainLayout->addWidget(addressText, 1, 1);
- mainLayout->addLayout(buttonLayout1, 1, 2);
- mainLayout->addLayout(buttonLayout2, 2, 1);
-
- setLayout(mainLayout);
- setWindowTitle(tr("Simple Address Book"));
-}
-
-void AddressBook::addContact()
-{
- oldName = nameLine->text();
- oldAddress = addressText->toPlainText();
-
- nameLine->clear();
- addressText->clear();
-
- updateInterface(AddingMode);
-}
-
-void AddressBook::editContact()
-{
- oldName = nameLine->text();
- oldAddress = addressText->toPlainText();
-
- updateInterface(EditingMode);
-}
-
-void AddressBook::submitContact()
-{
- QString name = nameLine->text();
- QString address = addressText->toPlainText();
-
- if (name.isEmpty() || address.isEmpty()) {
- QMessageBox::information(this, tr("Empty Field"),
- tr("Please enter a name and address."));
- return;
- }
-
- if (currentMode == AddingMode) {
-
- if (!contacts.contains(name)) {
- contacts.insert(name, address);
- QMessageBox::information(this, tr("Add Successful"),
- tr("\"%1\" has been added to your address book.").arg(name));
- } else {
- QMessageBox::information(this, tr("Add Unsuccessful"),
- tr("Sorry, \"%1\" is already in your address book.").arg(name));
- }
- } else if (currentMode == EditingMode) {
-
- if (oldName != name) {
- if (!contacts.contains(name)) {
- QMessageBox::information(this, tr("Edit Successful"),
- tr("\"%1\" has been edited in your address book.").arg(oldName));
- contacts.remove(oldName);
- contacts.insert(name, address);
- } else {
- QMessageBox::information(this, tr("Edit Unsuccessful"),
- tr("Sorry, \"%1\" is already in your address book.").arg(name));
- }
- } else if (oldAddress != address) {
- QMessageBox::information(this, tr("Edit Successful"),
- tr("\"%1\" has been edited in your address book.").arg(name));
- contacts[name] = address;
- }
- }
-
- updateInterface(NavigationMode);
-}
-
-void AddressBook::cancel()
-{
- nameLine->setText(oldName);
- addressText->setText(oldAddress);
- updateInterface(NavigationMode);
-}
-
-void AddressBook::removeContact()
-{
- QString name = nameLine->text();
- QString address = addressText->toPlainText();
-
- if (contacts.contains(name)) {
-
- int button = QMessageBox::question(this,
- tr("Confirm Remove"),
- tr("Are you sure you want to remove \"%1\"?").arg(name),
- QMessageBox::Yes | QMessageBox::No);
-
- if (button == QMessageBox::Yes) {
-
- previous();
- contacts.remove(name);
-
- QMessageBox::information(this, tr("Remove Successful"),
- tr("\"%1\" has been removed from your address book.").arg(name));
- }
- }
-
- updateInterface(NavigationMode);
-}
-
-void AddressBook::next()
-{
- QString name = nameLine->text();
- QMap<QString, QString>::iterator i = contacts.find(name);
-
- if (i != contacts.end())
- i++;
-
- if (i == contacts.end())
- i = contacts.begin();
-
- nameLine->setText(i.key());
- addressText->setText(i.value());
-}
-
-void AddressBook::previous()
-{
- QString name = nameLine->text();
- QMap<QString, QString>::iterator i = contacts.find(name);
-
- if (i == contacts.end()) {
- nameLine->clear();
- addressText->clear();
- return;
- }
-
- if (i == contacts.begin())
- i = contacts.end();
-
- i--;
- nameLine->setText(i.key());
- addressText->setText(i.value());
-}
-
-void AddressBook::findContact()
-{
- dialog->show();
-
- if (dialog->exec() == 1) {
- QString contactName = dialog->getFindText();
-
- if (contacts.contains(contactName)) {
- nameLine->setText(contactName);
- addressText->setText(contacts.value(contactName));
- } else {
- QMessageBox::information(this, tr("Contact Not Found"),
- tr("Sorry, \"%1\" is not in your address book.").arg(contactName));
- return;
- }
- }
-
- updateInterface(NavigationMode);
-}
-void AddressBook::updateInterface(Mode mode)
-{
- currentMode = mode;
-
- switch (currentMode) {
-
- case AddingMode:
- case EditingMode:
-
- nameLine->setReadOnly(false);
- nameLine->setFocus(Qt::OtherFocusReason);
- addressText->setReadOnly(false);
-
- addButton->setEnabled(false);
- editButton->setEnabled(false);
- removeButton->setEnabled(false);
-
- nextButton->setEnabled(false);
- previousButton->setEnabled(false);
-
- submitButton->show();
- cancelButton->show();
-
- loadButton->setEnabled(false);
- saveButton->setEnabled(false);
- exportButton->setEnabled(false);
- break;
-
- case NavigationMode:
-
- if (contacts.isEmpty()) {
- nameLine->clear();
- addressText->clear();
- }
-
- nameLine->setReadOnly(true);
- addressText->setReadOnly(true);
- addButton->setEnabled(true);
-
- int number = contacts.size();
- editButton->setEnabled(number >= 1);
- removeButton->setEnabled(number >= 1);
- findButton->setEnabled(number > 2);
- nextButton->setEnabled(number > 1);
- previousButton->setEnabled(number > 1);
-
- submitButton->hide();
- cancelButton->hide();
-
- exportButton->setEnabled(number >= 1);
-
- loadButton->setEnabled(true);
- saveButton->setEnabled(number >= 1);
- break;
- }
-}
-
-void AddressBook::saveToFile()
-{
- QString fileName = QFileDialog::getSaveFileName(this,
- tr("Save Address Book"), "",
- tr("Address Book (*.abk);;All Files (*)"));
-
- if (fileName.isEmpty())
- return;
- else {
- QFile file(fileName);
-
- if (!file.open(QIODevice::WriteOnly)) {
- QMessageBox::information(this, tr("Unable to open file"),
- file.errorString());
- return;
- }
-
- QDataStream out(&file);
- out.setVersion(QDataStream::Qt_4_3);
- out << contacts;
- }
-
- updateInterface(NavigationMode);
-}
-
-void AddressBook::loadFromFile()
-{
- QString fileName = QFileDialog::getOpenFileName(this,
- tr("Open Address Book"), "",
- tr("Address Book (*.abk);;All Files (*)"));
-
- if (fileName.isEmpty())
- return;
- else {
- QFile file(fileName);
-
- if (!file.open(QIODevice::ReadOnly)) {
- QMessageBox::information(this, tr("Unable to open file"),
- file.errorString());
- return;
- }
-
- QDataStream in(&file);
- in.setVersion(QDataStream::Qt_4_3);
- in >> contacts;
-
- QMap<QString, QString>::iterator i = contacts.begin();
- nameLine->setText(i.key());
- addressText->setText(i.value());
- }
-
- updateInterface(NavigationMode);
-}
-
-//! [export function part1]
-void AddressBook::exportAsVCard()
-{
- QString name = nameLine->text();
- QString address = addressText->toPlainText();
- QString firstName;
- QString lastName;
- QStringList nameList;
-
- int index = name.indexOf(" ");
-
- if (index != -1) {
- nameList = name.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts);
- firstName = nameList.first();
- lastName = nameList.last();
- } else {
- firstName = name;
- lastName = "";
- }
-
- QString fileName = QFileDialog::getSaveFileName(this,
- tr("Export Contact"), "",
- tr("vCard Files (*.vcf);;All Files (*)"));
-
- if (fileName.isEmpty())
- return;
-
- QFile file(fileName);
-//! [export function part1]
-
-//! [export function part2]
- if (!file.open(QIODevice::WriteOnly)) {
- QMessageBox::information(this, tr("Unable to open file"),
- file.errorString());
- return;
- }
-
- QTextStream out(&file);
-//! [export function part2]
-
-//! [export function part3]
- out << "BEGIN:VCARD" << '\n';
- out << "VERSION:2.1" << '\n';
- out << "N:" << lastName << ';' << firstName << '\n';
-
- if (!nameList.isEmpty())
- out << "FN:" << nameList.join(' ') << '\n';
- else
- out << "FN:" << firstName << '\n';
-//! [export function part3]
-
-//! [export function part4]
- address.replace(";", "\\;", Qt::CaseInsensitive);
- address.replace('\n', ";", Qt::CaseInsensitive);
- address.replace(",", " ", Qt::CaseInsensitive);
-
- out << "ADR;HOME:;" << address << '\n';
- out << "END:VCARD" << '\n';
-
- QMessageBox::information(this, tr("Export Successful"),
- tr("\"%1\" has been exported as a vCard.").arg(name));
-}
-//! [export function part4]
diff --git a/examples/widgets/tutorials/addressbook/part7/addressbook.h b/examples/widgets/tutorials/addressbook/part7/addressbook.h
deleted file mode 100644
index c408a97642..0000000000
--- a/examples/widgets/tutorials/addressbook/part7/addressbook.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef ADDRESSBOOK_H
-#define ADDRESSBOOK_H
-
-#include <QWidget>
-#include <QMap>
-#include "finddialog.h"
-
-QT_BEGIN_NAMESPACE
-class QPushButton;
-class QLabel;
-class QLineEdit;
-class QTextEdit;
-QT_END_NAMESPACE
-
-
-class AddressBook : public QWidget
-{
- Q_OBJECT
-
-public:
- AddressBook(QWidget *parent = nullptr);
- enum Mode { NavigationMode, AddingMode, EditingMode };
-
-public slots:
- void addContact();
- void editContact();
- void submitContact();
- void cancel();
- void removeContact();
- void findContact();
- void next();
- void previous();
- void saveToFile();
- void loadFromFile();
-//! [exportAsVCard() declaration]
- void exportAsVCard();
-//! [exportAsVCard() declaration]
-
-private:
- void updateInterface(Mode mode);
-
- QPushButton *addButton;
- QPushButton *editButton;
- QPushButton *removeButton;
- QPushButton *findButton;
- QPushButton *submitButton;
- QPushButton *cancelButton;
- QPushButton *nextButton;
- QPushButton *previousButton;
- QPushButton *loadButton;
- QPushButton *saveButton;
-//! [exportButton declaration]
- QPushButton *exportButton;
-//! [exportButton declaration]
- QLineEdit *nameLine;
- QTextEdit *addressText;
-
- QMap<QString, QString> contacts;
- FindDialog *dialog;
- QString oldName;
- QString oldAddress;
- Mode currentMode;
-};
-
-#endif
diff --git a/examples/widgets/tutorials/addressbook/part7/finddialog.cpp b/examples/widgets/tutorials/addressbook/part7/finddialog.cpp
deleted file mode 100644
index 90729d9c12..0000000000
--- a/examples/widgets/tutorials/addressbook/part7/finddialog.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "finddialog.h"
-
-FindDialog::FindDialog(QWidget *parent)
- : QDialog(parent)
-{
- QLabel *findLabel = new QLabel(tr("Enter the name of a contact:"));
- lineEdit = new QLineEdit;
-
- findButton = new QPushButton(tr("&Find"));
- findText = "";
-
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(findLabel);
- layout->addWidget(lineEdit);
- layout->addWidget(findButton);
-
- setLayout(layout);
- setWindowTitle(tr("Find a Contact"));
- connect(findButton, &QPushButton::clicked,
- this, &FindDialog::findClicked);
- connect(findButton, &QPushButton::clicked,
- this, &FindDialog::accept);
-}
-
-void FindDialog::findClicked()
-{
- QString text = lineEdit->text();
-
- if (text.isEmpty()) {
- QMessageBox::information(this, tr("Empty Field"),
- tr("Please enter a name."));
- return;
- } else {
- findText = text;
- lineEdit->clear();
- hide();
- }
-}
-
-QString FindDialog::getFindText()
-{
- return findText;
-}
diff --git a/examples/widgets/tutorials/addressbook/part7/finddialog.h b/examples/widgets/tutorials/addressbook/part7/finddialog.h
deleted file mode 100644
index 7c9a3af30f..0000000000
--- a/examples/widgets/tutorials/addressbook/part7/finddialog.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef FINDDIALOG_H
-#define FINDDIALOG_H
-
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-class QLineEdit;
-class QPushButton;
-QT_END_NAMESPACE
-
-class FindDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- FindDialog(QWidget *parent = nullptr);
- QString getFindText();
-
-public slots:
- void findClicked();
-
-private:
- QPushButton *findButton;
- QLineEdit *lineEdit;
- QString findText;
-};
-
-#endif
diff --git a/examples/widgets/tutorials/addressbook/part7/main.cpp b/examples/widgets/tutorials/addressbook/part7/main.cpp
deleted file mode 100644
index 1f3aac3397..0000000000
--- a/examples/widgets/tutorials/addressbook/part7/main.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-#include "addressbook.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- AddressBook addressBook;
- addressBook.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/tutorials/addressbook/part7/part7.pro b/examples/widgets/tutorials/addressbook/part7/part7.pro
deleted file mode 100644
index 6a99799c67..0000000000
--- a/examples/widgets/tutorials/addressbook/part7/part7.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-QT += widgets
-requires(qtConfig(filedialog))
-
-SOURCES = addressbook.cpp \
- finddialog.cpp \
- main.cpp
-HEADERS = addressbook.h \
- finddialog.h
-
-QMAKE_PROJECT_NAME = ab_part7
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/addressbook/part7
-INSTALLS += target
diff --git a/examples/widgets/tutorials/gettingStarted/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/CMakeLists.txt
deleted file mode 100644
index 42cac47b96..0000000000
--- a/examples/widgets/tutorials/gettingStarted/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_subdirectory(gsQt)
diff --git a/examples/widgets/tutorials/gettingStarted/gettingStarted.pro b/examples/widgets/tutorials/gettingStarted/gettingStarted.pro
deleted file mode 100644
index 3e37725410..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gettingStarted.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += dir_gsqt
-
-dir_gsqt.file = gsQt/gsqt.pro
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt
deleted file mode 100644
index a0fd350393..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-qt_internal_add_example(part1)
-qt_internal_add_example(part2)
-qt_internal_add_example(part3)
-qt_internal_add_example(part4)
-qt_internal_add_example(part5)
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/gsqt.pro b/examples/widgets/tutorials/gettingStarted/gsQt/gsqt.pro
deleted file mode 100644
index 320f3c3ee4..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/gsqt.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS = part1 \
- part2 \
- part3 \
- part4 \
- part5
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt
deleted file mode 100644
index df8c0b4b32..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(getting_started_part1 LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part1")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(getting_started_part1
- main.cpp
-)
-
-set_target_properties(getting_started_part1 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(getting_started_part1 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS getting_started_part1
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part1/main.cpp b/examples/widgets/tutorials/gettingStarted/gsQt/part1/main.cpp
deleted file mode 100644
index ef8c6ed1b8..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part1/main.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QTextEdit textEdit;
- textEdit.show();
-
- return app.exec();
-}
-
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part1/part1.pro b/examples/widgets/tutorials/gettingStarted/gsQt/part1/part1.pro
deleted file mode 100644
index 391606bfd7..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part1/part1.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-
-QT += widgets
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/gettingStarted/gsQt/part1
-INSTALLS += target
-
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt
deleted file mode 100644
index 09656718af..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(getting_started_part2 LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part2")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(getting_started_part2
- main.cpp
-)
-
-set_target_properties(getting_started_part2 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(getting_started_part2 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS getting_started_part2
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part2/main.cpp b/examples/widgets/tutorials/gettingStarted/gsQt/part2/main.cpp
deleted file mode 100644
index 722d7889d0..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part2/main.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QTextEdit *textEdit = new QTextEdit;
- QPushButton *quitButton = new QPushButton("&Quit");
-
- QObject::connect(quitButton, &QPushButton::clicked,
- qApp, &QApplication::quit);
-
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(textEdit);
- layout->addWidget(quitButton);
-
- QWidget window;
- window.setLayout(layout);
-
- window.show();
-
- return app.exec();
-}
-
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part2/part2.pro b/examples/widgets/tutorials/gettingStarted/gsQt/part2/part2.pro
deleted file mode 100644
index e7422e4a31..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part2/part2.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-
-QT += widgets
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/gettingStarted/gsQt/part2
-INSTALLS += target
-
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt
deleted file mode 100644
index 0f9a732b36..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(getting_started_part3 LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part3")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(getting_started_part3
- main.cpp
-)
-
-set_target_properties(getting_started_part3 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(getting_started_part3 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS getting_started_part3
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part3/main.cpp b/examples/widgets/tutorials/gettingStarted/gsQt/part3/main.cpp
deleted file mode 100644
index 5424dc3caa..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part3/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-class Notepad : public QWidget
-{
- Q_OBJECT
-
-public:
- Notepad();
-
-private slots:
- void quit();
-
-private:
- QTextEdit *textEdit;
- QPushButton *quitButton;
-
-};
-
-Notepad::Notepad()
-{
- textEdit = new QTextEdit;
- quitButton = new QPushButton(tr("Quit"));
-
- connect(quitButton, &QPushButton::clicked,
- this, &Notepad::quit);
-
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(textEdit);
- layout->addWidget(quitButton);
-
- setLayout(layout);
-
- setWindowTitle(tr("Notepad"));
-}
-
-void Notepad::quit()
-{
- QMessageBox messageBox;
- messageBox.setWindowTitle(tr("Notepad"));
- messageBox.setText(tr("Do you really want to quit?"));
- messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
- messageBox.setDefaultButton(QMessageBox::No);
- if (messageBox.exec() == QMessageBox::Yes)
- qApp->quit();
-}
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- Notepad notepad;
- notepad.show();
-
- return app.exec();
-}
-
-#include "main.moc"
-
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part3/part3.pro b/examples/widgets/tutorials/gettingStarted/gsQt/part3/part3.pro
deleted file mode 100644
index 1577848de5..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part3/part3.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-
-QT += widgets
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/gettingStarted/gsQt/part3
-INSTALLS += target
-
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt
deleted file mode 100644
index 78a3f89945..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(getting_started_part4 LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part4")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(getting_started_part4
- main.cpp
-)
-
-set_target_properties(getting_started_part4 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(getting_started_part4 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS getting_started_part4
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part4/main.cpp b/examples/widgets/tutorials/gettingStarted/gsQt/part4/main.cpp
deleted file mode 100644
index de6436add4..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part4/main.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-class Notepad : public QMainWindow
-{
- Q_OBJECT
-
-public:
- Notepad();
-
-private slots:
- void load();
- void save();
-
-private:
- QTextEdit *textEdit;
-
- QAction *loadAction;
- QAction *saveAction;
- QAction *exitAction;
-
- QMenu *fileMenu;
-};
-
-Notepad::Notepad()
-{
- loadAction = new QAction(tr("&Load"), this);
- saveAction = new QAction(tr("&Save"), this);
- exitAction = new QAction(tr("E&xit"), this);
-
- connect(loadAction, &QAction::triggered,
- this, &Notepad::load);
- connect(saveAction, &QAction::triggered,
- this, &Notepad::save);
- connect(exitAction, &QAction::triggered,
- qApp, &QApplication::quit);
-
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(loadAction);
- fileMenu->addAction(saveAction);
- fileMenu->addSeparator();
- fileMenu->addAction(exitAction);
-
- textEdit = new QTextEdit;
- setCentralWidget(textEdit);
-
- setWindowTitle(tr("Notepad"));
-}
-
-void Notepad::load()
-{
-
-}
-
-void Notepad::save()
-{
-
-}
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- Notepad notepad;
- notepad.show();
-
- return app.exec();
-};
-
-#include "main.moc"
-
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part4/part4.pro b/examples/widgets/tutorials/gettingStarted/gsQt/part4/part4.pro
deleted file mode 100644
index 086fac69e9..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part4/part4.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-
-QT += widgets
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/gettingStarted/gsQt/part4
-INSTALLS += target
-
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt b/examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt
deleted file mode 100644
index 37b40a6a49..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(getting_started_part5 LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part5")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(getting_started_part5
- main.cpp
-)
-
-set_target_properties(getting_started_part5 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(getting_started_part5 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS getting_started_part5
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part5/main.cpp b/examples/widgets/tutorials/gettingStarted/gsQt/part5/main.cpp
deleted file mode 100644
index 037f1771a1..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part5/main.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtWidgets>
-
-class Notepad : public QMainWindow
-{
- Q_OBJECT
-
-public:
- Notepad();
-
-private slots:
- void open();
- void save();
-
-private:
- QTextEdit *textEdit;
-
- QAction *openAction;
- QAction *saveAction;
- QAction *exitAction;
-
- QMenu *fileMenu;
-};
-
-Notepad::Notepad()
-{
- openAction = new QAction(tr("&Load"), this);
- saveAction = new QAction(tr("&Save"), this);
- exitAction = new QAction(tr("E&xit"), this);
-
- connect(openAction, &QAction::triggered,
- this, &Notepad::open);
- connect(saveAction, &QAction::triggered,
- this, &Notepad::save);
- connect(exitAction, &QAction::triggered,
- qApp, &QApplication::quit);
-
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(openAction);
- fileMenu->addAction(saveAction);
- fileMenu->addSeparator();
- fileMenu->addAction(exitAction);
-
- textEdit = new QTextEdit;
- setCentralWidget(textEdit);
-
- setWindowTitle(tr("Notepad"));
-}
-
-void Notepad::open()
-{
- QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",
- tr("Text Files (*.txt);;C++ Files (*.cpp *.h)"));
-
- if (!fileName.isEmpty()) {
- QFile file(fileName);
- if (!file.open(QIODevice::ReadOnly)) {
- QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
- return;
- }
- QTextStream in(&file);
- textEdit->setText(in.readAll());
- file.close();
- }
-}
-
-void Notepad::save()
-{
-
- QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "",
- tr("Text Files (*.txt);;C++ Files (*.cpp *.h)"));
-
- if (!fileName.isEmpty()) {
- QFile file(fileName);
- if (!file.open(QIODevice::WriteOnly)) {
- // error message
- } else {
- QTextStream stream(&file);
- stream << textEdit->toPlainText();
- stream.flush();
- file.close();
- }
- }
-}
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- Notepad notepad;
- notepad.show();
-
- return app.exec();
-}
-
-#include "main.moc"
-
diff --git a/examples/widgets/tutorials/gettingStarted/gsQt/part5/part5.pro b/examples/widgets/tutorials/gettingStarted/gsQt/part5/part5.pro
deleted file mode 100644
index 12378f305a..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part5/part5.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-QT += widgets
-requires(qtConfig(filedialog))
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/gettingStarted/gsQt/part5
-INSTALLS += target
-
diff --git a/examples/widgets/tutorials/modelview/1_readonly/CMakeLists.txt b/examples/widgets/tutorials/modelview/1_readonly/CMakeLists.txt
index f219f31096..3ff7f06721 100644
--- a/examples/widgets/tutorials/modelview/1_readonly/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/1_readonly/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(mv_readonly LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/1_readonly")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(mv_readonly
main.cpp
mymodel.cpp mymodel.h
@@ -24,14 +18,21 @@ set_target_properties(mv_readonly PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(mv_readonly PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(mv_readonly PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS mv_readonly
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET mv_readonly
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tutorials/modelview/2_formatting/CMakeLists.txt b/examples/widgets/tutorials/modelview/2_formatting/CMakeLists.txt
index 09c36f5fbb..a758b6eaa5 100644
--- a/examples/widgets/tutorials/modelview/2_formatting/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/2_formatting/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(mv_formatting LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/2_formatting")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(mv_formatting
main.cpp
mymodel.cpp mymodel.h
@@ -24,14 +18,21 @@ set_target_properties(mv_formatting PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(mv_formatting PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(mv_formatting PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS mv_formatting
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET mv_formatting
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tutorials/modelview/3_changingmodel/CMakeLists.txt b/examples/widgets/tutorials/modelview/3_changingmodel/CMakeLists.txt
index 80750a27c1..1b8dd84c92 100644
--- a/examples/widgets/tutorials/modelview/3_changingmodel/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/3_changingmodel/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(mv_changingmodel LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/3_changingmodel")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(mv_changingmodel
main.cpp
mymodel.cpp mymodel.h
@@ -24,14 +18,21 @@ set_target_properties(mv_changingmodel PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(mv_changingmodel PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(mv_changingmodel PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS mv_changingmodel
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET mv_changingmodel
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tutorials/modelview/4_headers/CMakeLists.txt b/examples/widgets/tutorials/modelview/4_headers/CMakeLists.txt
index 49297961c4..b0c05e4212 100644
--- a/examples/widgets/tutorials/modelview/4_headers/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/4_headers/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(mv_headers LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/4_headers")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(mv_headers
main.cpp
mymodel.cpp mymodel.h
@@ -24,14 +18,21 @@ set_target_properties(mv_headers PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(mv_headers PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(mv_headers PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS mv_headers
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET mv_headers
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tutorials/modelview/5_edit/CMakeLists.txt b/examples/widgets/tutorials/modelview/5_edit/CMakeLists.txt
index 8ea3ef342e..f0269ac2bc 100644
--- a/examples/widgets/tutorials/modelview/5_edit/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/5_edit/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(mv_edit LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/5_edit")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(mv_edit
main.cpp
mainwindow.cpp mainwindow.h
@@ -25,14 +19,21 @@ set_target_properties(mv_edit PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(mv_edit PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(mv_edit PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS mv_edit
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET mv_edit
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tutorials/modelview/6_treeview/CMakeLists.txt b/examples/widgets/tutorials/modelview/6_treeview/CMakeLists.txt
index 11d5812433..2a47ebc24a 100644
--- a/examples/widgets/tutorials/modelview/6_treeview/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/6_treeview/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(mv_tree LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/6_treeview")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(mv_tree
main.cpp
mainwindow.cpp mainwindow.h
@@ -24,14 +18,21 @@ set_target_properties(mv_tree PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(mv_tree PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(mv_tree PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS mv_tree
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET mv_tree
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tutorials/modelview/7_selections/CMakeLists.txt b/examples/widgets/tutorials/modelview/7_selections/CMakeLists.txt
index 64235eda65..0eda358808 100644
--- a/examples/widgets/tutorials/modelview/7_selections/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/7_selections/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(mv_selections LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/7_selections")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(mv_selections
main.cpp
mainwindow.cpp mainwindow.h
@@ -24,14 +18,21 @@ set_target_properties(mv_selections PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(mv_selections PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(mv_selections PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS mv_selections
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET mv_selections
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tutorials/modelview/CMakeLists.txt b/examples/widgets/tutorials/modelview/CMakeLists.txt
index feaacbcc2d..cbf36834cb 100644
--- a/examples/widgets/tutorials/modelview/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/CMakeLists.txt
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
qt_internal_add_example(1_readonly)
qt_internal_add_example(2_formatting)
diff --git a/examples/widgets/tutorials/notepad/CMakeLists.txt b/examples/widgets/tutorials/notepad/CMakeLists.txt
index 874ebd42f8..43048830c2 100644
--- a/examples/widgets/tutorials/notepad/CMakeLists.txt
+++ b/examples/widgets/tutorials/notepad/CMakeLists.txt
@@ -1,23 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(notepad LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/notepad")
-
find_package(Qt6
REQUIRED COMPONENTS Core Gui Widgets
OPTIONAL_COMPONENTS PrintSupport
)
+qt_standard_project_setup()
+
qt_add_executable(notepad
main.cpp
notepad.cpp notepad.h notepad.ui
@@ -28,12 +21,16 @@ set_target_properties(notepad PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(notepad PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(notepad PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
+if(TARGET Qt6::PrintSupport)
+ target_link_libraries(notepad PRIVATE Qt6::PrintSupport)
+endif()
+
# Resources:
set(notepad_resource_files
"images/bold.png"
@@ -63,14 +60,15 @@ qt_add_resources(notepad "notepad"
${notepad_resource_files}
)
-if(TARGET Qt::PrintSupport)
- target_link_libraries(notepad PUBLIC
- Qt::PrintSupport
- )
-endif()
-
install(TARGETS notepad
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET notepad
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tutorials/gettingstartedqt.qdoc b/examples/widgets/tutorials/notepad/gettingstartedqt.qdoc
index 152bf8c114..0979cecb18 100644
--- a/examples/widgets/tutorials/gettingstartedqt.qdoc
+++ b/examples/widgets/tutorials/notepad/gettingstartedqt.qdoc
@@ -4,6 +4,7 @@
/*!
\example tutorials/notepad
\title Getting Started Programming with Qt Widgets
+ \examplecategory {User Interface Components}
\brief A tutorial for Qt Widgets based notepad application.
In this topic, we teach basic Qt knowledge by implementing a simple
@@ -142,25 +143,25 @@
The wizard generates a user interface definition in XML format: notepad.ui.
When you open the notepad.ui file in Qt Creator, it automatically
- opens in the integrated Qt Designer.
+ opens in the integrated \QD.
When you build the application, Qt Creator launches the Qt
\l{User Interface Compiler (uic)} that reads the .ui file and creates
a corresponding C++ header file, ui_notepad.h.
- \section2 Using Qt Designer
+ \section2 Using \QD
The wizard creates an application that uses a QMainWindow. It has
its own layout to which you can add a menu bar, dock widgets, toolbars,
and a status bar. The center area can be occupied by any kind of widget.
The wizard places the Notepad widget there.
- To add widgets in Qt Designer:
+ To add widgets in \QD:
\list 1
\li In the Qt Creator \uicontrol Edit mode, double-click the notepad.ui
file in the \uicontrol Projects view to launch the file in the integrated
- Qt Designer.
+ \QD.
\li Drag and drop widgets Text Edit (QTextEdit) to the form.
\li Press \key {Ctrl+A} (or \key {Cmd+A}) to select the widgets and click
\uicontrol {Lay out Vertically} (or press \key {Ctrl+L}) to apply a vertical
@@ -168,7 +169,7 @@
\li Press \key {Ctrl+S} (or \key {Cmd+S}) to save your changes.
\endlist
- The UI now looks as follows in Qt Designer:
+ The UI now looks as follows in \QD:
\image notepad4.png
@@ -316,8 +317,8 @@
\li About
\li Here
\row
- \li Using Qt Designer
- \li \l{Qt Designer Manual}
+ \li Using \QD
+ \li \l{Qt Widgets Designer Manual}
\row
\li Layouts
\li \l{Layout Management},
@@ -487,10 +488,6 @@
\li About
\li Here
\row
- \li MDI applications
- \li QMdiArea,
- \l{MDI Example}
- \row
\li Files and I/O devices
\li QFile, QIODevice
\row
diff --git a/examples/widgets/tutorials/tutorials.pro b/examples/widgets/tutorials/tutorials.pro
index 0aaa119d8f..d9dbbd2860 100644
--- a/examples/widgets/tutorials/tutorials.pro
+++ b/examples/widgets/tutorials/tutorials.pro
@@ -1,2 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS += addressbook widgets modelview gettingStarted notepad
+SUBDIRS += widgets modelview notepad
diff --git a/examples/widgets/tutorials/widgets/CMakeLists.txt b/examples/widgets/tutorials/widgets/CMakeLists.txt
index 6e8d3fa3e4..40590745a9 100644
--- a/examples/widgets/tutorials/widgets/CMakeLists.txt
+++ b/examples/widgets/tutorials/widgets/CMakeLists.txt
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
qt_internal_add_example(toplevel)
qt_internal_add_example(childwidget)
diff --git a/examples/widgets/tutorials/widgets/childwidget/CMakeLists.txt b/examples/widgets/tutorials/widgets/childwidget/CMakeLists.txt
index cb20505729..a4f8b5b8a2 100644
--- a/examples/widgets/tutorials/widgets/childwidget/CMakeLists.txt
+++ b/examples/widgets/tutorials/widgets/childwidget/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(childwidget LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/widgets/childwidget")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(childwidget
main.cpp
)
@@ -23,14 +17,21 @@ set_target_properties(childwidget PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(childwidget PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(childwidget PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS childwidget
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET childwidget
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tutorials/widgets/nestedlayouts/CMakeLists.txt b/examples/widgets/tutorials/widgets/nestedlayouts/CMakeLists.txt
index 9dbe1539eb..cb6db0ec48 100644
--- a/examples/widgets/tutorials/widgets/nestedlayouts/CMakeLists.txt
+++ b/examples/widgets/tutorials/widgets/nestedlayouts/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(nestedlayouts LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/widgets/nestedlayouts")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(nestedlayouts
main.cpp
)
@@ -23,14 +17,21 @@ set_target_properties(nestedlayouts PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(nestedlayouts PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(nestedlayouts PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS nestedlayouts
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET nestedlayouts
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tutorials/widgets/toplevel/CMakeLists.txt b/examples/widgets/tutorials/widgets/toplevel/CMakeLists.txt
index de932e9f11..2d241556f9 100644
--- a/examples/widgets/tutorials/widgets/toplevel/CMakeLists.txt
+++ b/examples/widgets/tutorials/widgets/toplevel/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(toplevel LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/widgets/toplevel")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(toplevel
main.cpp
)
@@ -23,14 +17,21 @@ set_target_properties(toplevel PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(toplevel PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(toplevel PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS toplevel
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET toplevel
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tutorials/widgets/windowlayout/CMakeLists.txt b/examples/widgets/tutorials/widgets/windowlayout/CMakeLists.txt
index 52ab8554a4..ea6e21e968 100644
--- a/examples/widgets/tutorials/widgets/windowlayout/CMakeLists.txt
+++ b/examples/widgets/tutorials/widgets/windowlayout/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(windowlayout LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/widgets/windowlayout")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(windowlayout
main.cpp
)
@@ -23,14 +17,21 @@ set_target_properties(windowlayout PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(windowlayout PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(windowlayout PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS windowlayout
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET windowlayout
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/widgets.pro b/examples/widgets/widgets.pro
index 2dbbefa141..e8ac9d83bd 100644
--- a/examples/widgets/widgets.pro
+++ b/examples/widgets/widgets.pro
@@ -8,7 +8,6 @@ SUBDIRS = \
desktop \
dialogs \
draganddrop \
- effects \
gallery \
gestures \
graphicsview \
@@ -16,16 +15,13 @@ SUBDIRS = \
layouts \
mainwindows \
painting \
+ rhi \
richtext \
- scroller \
tools \
touch \
tutorials \
widgets
-qtHaveModule(gui):qtConfig(opengl): \
- SUBDIRS += windowcontainer
-
contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= mainwindows
!qtConfig(draganddrop): SUBDIRS -= draganddrop
!qtConfig(animation): SUBDIRS -= animation
diff --git a/examples/widgets/widgets/CMakeLists.txt b/examples/widgets/widgets/CMakeLists.txt
index e341da5459..0dcc71d230 100644
--- a/examples/widgets/widgets/CMakeLists.txt
+++ b/examples/widgets/widgets/CMakeLists.txt
@@ -1,30 +1,15 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
qt_internal_add_example(analogclock)
qt_internal_add_example(calculator)
qt_internal_add_example(calendarwidget)
-qt_internal_add_example(charactermap)
-qt_internal_add_example(codeeditor)
-qt_internal_add_example(digitalclock)
-qt_internal_add_example(elidedlabel)
qt_internal_add_example(groupbox)
-qt_internal_add_example(icons)
-qt_internal_add_example(imageviewer)
qt_internal_add_example(lineedits)
-if(QT_FEATURE_movie)
- qt_internal_add_example(movie)
-endif()
-qt_internal_add_example(mousebuttons)
qt_internal_add_example(scribble)
qt_internal_add_example(shapedclock)
+qt_internal_add_example(shortcuteditor)
qt_internal_add_example(sliders)
qt_internal_add_example(spinboxes)
-qt_internal_add_example(styles)
-qt_internal_add_example(stylesheet)
qt_internal_add_example(tablet)
-qt_internal_add_example(tetrix)
-qt_internal_add_example(tooltips)
-qt_internal_add_example(validators)
-qt_internal_add_example(wiggly)
qt_internal_add_example(windowflags)
diff --git a/examples/widgets/widgets/analogclock/CMakeLists.txt b/examples/widgets/widgets/analogclock/CMakeLists.txt
index 791d351302..82b9ef3928 100644
--- a/examples/widgets/widgets/analogclock/CMakeLists.txt
+++ b/examples/widgets/widgets/analogclock/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(analogclock LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/analogclock")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(analogclock
analogclock.cpp analogclock.h
main.cpp
@@ -24,14 +18,21 @@ set_target_properties(analogclock PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(analogclock PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(analogclock PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS analogclock
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET analogclock
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/widgets/analogclock/analogclock.cpp b/examples/widgets/widgets/analogclock/analogclock.cpp
index 34d135ed4a..feb7f4e8b5 100644
--- a/examples/widgets/widgets/analogclock/analogclock.cpp
+++ b/examples/widgets/widgets/analogclock/analogclock.cpp
@@ -31,22 +31,31 @@ AnalogClock::AnalogClock(QWidget *parent)
void AnalogClock::paintEvent(QPaintEvent *)
//! [8] //! [10]
{
- static const QPoint hourHand[3] = {
- QPoint(7, 8),
- QPoint(-7, 8),
- QPoint(0, -40)
+ static const QPoint hourHand[4] = {
+ QPoint(5, 14),
+ QPoint(-5, 14),
+ QPoint(-4, -71),
+ QPoint(4, -71)
};
- static const QPoint minuteHand[3] = {
- QPoint(7, 8),
- QPoint(-7, 8),
- QPoint(0, -70)
+ static const QPoint minuteHand[4] = {
+ QPoint(4, 14),
+ QPoint(-4, 14),
+ QPoint(-3, -89),
+ QPoint(3, -89)
};
- QColor hourColor(127, 0, 127);
- QColor minuteColor(0, 127, 127, 191);
+ static const QPoint secondsHand[4] = {
+ QPoint(1, 14),
+ QPoint(-1, 14),
+ QPoint(-1, -89),
+ QPoint(1, -89)
+ };
+
+ const QColor hourColor(palette().color(QPalette::Text));
+ const QColor minuteColor(palette().color(QPalette::Text));
+ const QColor secondsColor(palette().color(QPalette::Accent));
int side = qMin(width(), height());
- QTime time = QTime::currentTime();
//! [10]
//! [11]
@@ -55,45 +64,58 @@ void AnalogClock::paintEvent(QPaintEvent *)
painter.setRenderHint(QPainter::Antialiasing);
//! [12] //! [13]
painter.translate(width() / 2, height() / 2);
-//! [13] //! [14]
painter.scale(side / 200.0, side / 200.0);
-//! [9] //! [14]
+//! [9] //! [13]
+
+//! [14]
+ QTime time = QTime::currentTime();
+//! [14]
//! [15]
painter.setPen(Qt::NoPen);
//! [15] //! [16]
painter.setBrush(hourColor);
//! [16]
+//! [18]
-//! [17] //! [18]
+//! [17]
painter.save();
//! [17] //! [19]
painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0)));
- painter.drawConvexPolygon(hourHand, 3);
+ painter.drawConvexPolygon(hourHand, 4);
painter.restore();
//! [18] //! [19]
//! [20]
- painter.setPen(hourColor);
-//! [20] //! [21]
-
for (int i = 0; i < 12; ++i) {
- painter.drawLine(88, 0, 96, 0);
+ painter.drawRect(73, -3, 16, 6);
painter.rotate(30.0);
}
+//! [20]
+
//! [21]
+ painter.setBrush(minuteColor);
//! [22]
- painter.setPen(Qt::NoPen);
-//! [22] //! [23]
- painter.setBrush(minuteColor);
+ painter.save();
+ painter.rotate(6.0 * time.minute());
+ painter.drawConvexPolygon(minuteHand, 4);
+ painter.restore();
+//! [21] //! [22]
+
+
+//! [23]
+ painter.setBrush(secondsColor);
+//! [23]
//! [24]
painter.save();
- painter.rotate(6.0 * (time.minute() + time.second() / 60.0));
- painter.drawConvexPolygon(minuteHand, 3);
+ painter.rotate(6.0 * time.second());
+ painter.drawConvexPolygon(secondsHand, 4);
+ painter.drawEllipse(-3, -3, 6, 6);
+ painter.drawEllipse(-5, -68, 10, 10);
painter.restore();
-//! [23] //! [24]
+//! [24]
//! [25]
painter.setPen(minuteColor);
@@ -101,10 +123,10 @@ void AnalogClock::paintEvent(QPaintEvent *)
//! [27]
for (int j = 0; j < 60; ++j) {
- if ((j % 5) != 0)
- painter.drawLine(92, 0, 96, 0);
+ painter.drawLine(92, 0, 96, 0);
painter.rotate(6.0);
}
//! [27]
+
}
//! [26]
diff --git a/examples/widgets/widgets/calculator/CMakeLists.txt b/examples/widgets/widgets/calculator/CMakeLists.txt
index c75bcb36fe..abf12d5663 100644
--- a/examples/widgets/widgets/calculator/CMakeLists.txt
+++ b/examples/widgets/widgets/calculator/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(calculator LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/calculator")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(calculator
button.cpp button.h
calculator.cpp calculator.h
@@ -25,14 +19,21 @@ set_target_properties(calculator PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(calculator PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(calculator PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS calculator
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET calculator
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/widgets/calculator/calculator.cpp b/examples/widgets/widgets/calculator/calculator.cpp
index 5858d304d2..073b10f985 100644
--- a/examples/widgets/widgets/calculator/calculator.cpp
+++ b/examples/widgets/widgets/calculator/calculator.cpp
@@ -29,29 +29,29 @@ Calculator::Calculator(QWidget *parent)
//! [4]
for (int i = 0; i < NumDigitButtons; ++i)
- digitButtons[i] = createButton(QString::number(i), SLOT(digitClicked()));
+ digitButtons[i] = createButton(QString::number(i), &Calculator::digitClicked);
- Button *pointButton = createButton(tr("."), SLOT(pointClicked()));
- Button *changeSignButton = createButton(tr("\302\261"), SLOT(changeSignClicked()));
+ Button *pointButton = createButton(tr("."), &Calculator::pointClicked);
+ Button *changeSignButton = createButton(tr("\302\261"), &Calculator::changeSignClicked);
- Button *backspaceButton = createButton(tr("Backspace"), SLOT(backspaceClicked()));
- Button *clearButton = createButton(tr("Clear"), SLOT(clear()));
- Button *clearAllButton = createButton(tr("Clear All"), SLOT(clearAll()));
+ Button *backspaceButton = createButton(tr("Backspace"), &Calculator::backspaceClicked);
+ Button *clearButton = createButton(tr("Clear"), &Calculator::clear);
+ Button *clearAllButton = createButton(tr("Clear All"), &Calculator::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 *clearMemoryButton = createButton(tr("MC"), &Calculator::clearMemory);
+ Button *readMemoryButton = createButton(tr("MR"), &Calculator::readMemory);
+ Button *setMemoryButton = createButton(tr("MS"), &Calculator::setMemory);
+ Button *addToMemoryButton = createButton(tr("M+"), &Calculator::addToMemory);
- Button *divisionButton = createButton(tr("\303\267"), SLOT(multiplicativeOperatorClicked()));
- Button *timesButton = createButton(tr("\303\227"), SLOT(multiplicativeOperatorClicked()));
- Button *minusButton = createButton(tr("-"), SLOT(additiveOperatorClicked()));
- Button *plusButton = createButton(tr("+"), SLOT(additiveOperatorClicked()));
+ Button *divisionButton = createButton(tr("\303\267"), &Calculator::multiplicativeOperatorClicked);
+ Button *timesButton = createButton(tr("\303\227"), &Calculator::multiplicativeOperatorClicked);
+ Button *minusButton = createButton(tr("-"), &Calculator::additiveOperatorClicked);
+ Button *plusButton = createButton(tr("+"), &Calculator::additiveOperatorClicked);
- Button *squareRootButton = createButton(tr("Sqrt"), SLOT(unaryOperatorClicked()));
- Button *powerButton = createButton(tr("x\302\262"), SLOT(unaryOperatorClicked()));
- Button *reciprocalButton = createButton(tr("1/x"), SLOT(unaryOperatorClicked()));
- Button *equalButton = createButton(tr("="), SLOT(equalClicked()));
+ Button *squareRootButton = createButton(tr("Sqrt"), &Calculator::unaryOperatorClicked);
+ Button *powerButton = createButton(tr("x\302\262"), &Calculator::unaryOperatorClicked);
+ Button *reciprocalButton = createButton(tr("1/x"), &Calculator::unaryOperatorClicked);
+ Button *equalButton = createButton(tr("="), &Calculator::equalClicked);
//! [4]
//! [5]
@@ -324,10 +324,11 @@ void Calculator::addToMemory()
}
//! [32]
//! [34]
-Button *Calculator::createButton(const QString &text, const char *member)
+template<typename PointerToMemberFunction>
+Button *Calculator::createButton(const QString &text, const PointerToMemberFunction &member)
{
Button *button = new Button(text);
- connect(button, SIGNAL(clicked()), this, member);
+ connect(button, &Button::clicked, this, member);
return button;
}
//! [34]
diff --git a/examples/widgets/widgets/calculator/calculator.h b/examples/widgets/widgets/calculator/calculator.h
index d4fa112909..42e9ac5335 100644
--- a/examples/widgets/widgets/calculator/calculator.h
+++ b/examples/widgets/widgets/calculator/calculator.h
@@ -39,7 +39,8 @@ private slots:
//! [1]
private:
//! [1] //! [2]
- Button *createButton(const QString &text, const char *member);
+ template<typename PointerToMemberFunction>
+ Button *createButton(const QString &text, const PointerToMemberFunction &member);
void abortOperation();
bool calculate(double rightOperand, const QString &pendingOperator);
//! [2]
diff --git a/examples/widgets/widgets/calendarwidget/CMakeLists.txt b/examples/widgets/widgets/calendarwidget/CMakeLists.txt
index 0d850e4a09..9e8f7681ca 100644
--- a/examples/widgets/widgets/calendarwidget/CMakeLists.txt
+++ b/examples/widgets/widgets/calendarwidget/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(calendarwidget LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/calendarwidget")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(calendarwidget
main.cpp
window.cpp window.h
@@ -24,14 +18,21 @@ set_target_properties(calendarwidget PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(calendarwidget PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(calendarwidget PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS calendarwidget
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET calendarwidget
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/widgets/charactermap/CMakeLists.txt b/examples/widgets/widgets/charactermap/CMakeLists.txt
deleted file mode 100644
index 9642e9f17e..0000000000
--- a/examples/widgets/widgets/charactermap/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(charactermap LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/charactermap")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(charactermap
- characterwidget.cpp characterwidget.h
- main.cpp
- mainwindow.cpp mainwindow.h
-)
-
-set_target_properties(charactermap PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(charactermap PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS charactermap
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/charactermap/charactermap.pro b/examples/widgets/widgets/charactermap/charactermap.pro
deleted file mode 100644
index 373aabca73..0000000000
--- a/examples/widgets/widgets/charactermap/charactermap.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-QT += widgets
-requires(qtConfig(combobox))
-
-HEADERS = characterwidget.h \
- mainwindow.h
-SOURCES = characterwidget.cpp \
- mainwindow.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/charactermap
-INSTALLS += target
diff --git a/examples/widgets/widgets/charactermap/characterwidget.cpp b/examples/widgets/widgets/charactermap/characterwidget.cpp
deleted file mode 100644
index 6287a44e80..0000000000
--- a/examples/widgets/widgets/charactermap/characterwidget.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "characterwidget.h"
-
-#include <QFontDatabase>
-#include <QMouseEvent>
-#include <QPainter>
-#include <QToolTip>
-
-//! [0]
-CharacterWidget::CharacterWidget(QWidget *parent)
- : QWidget(parent)
-{
- calculateSquareSize();
- setMouseTracking(true);
-}
-//! [0]
-
-//! [1]
-void CharacterWidget::updateFont(const QFont &font)
-{
- displayFont.setFamily(font.family());
- calculateSquareSize();
- adjustSize();
- update();
-}
-//! [1]
-
-//! [2]
-void CharacterWidget::updateSize(const QString &fontSize)
-{
- displayFont.setPointSize(fontSize.toInt());
- calculateSquareSize();
- adjustSize();
- update();
-}
-//! [2]
-
-void CharacterWidget::updateStyle(const QString &fontStyle)
-{
- const QFont::StyleStrategy oldStrategy = displayFont.styleStrategy();
- displayFont = QFontDatabase::font(displayFont.family(), fontStyle, displayFont.pointSize());
- displayFont.setStyleStrategy(oldStrategy);
- calculateSquareSize();
- adjustSize();
- update();
-}
-
-void CharacterWidget::updateFontMerging(bool enable)
-{
- if (enable)
- displayFont.setStyleStrategy(QFont::PreferDefault);
- else
- displayFont.setStyleStrategy(QFont::NoFontMerging);
- adjustSize();
- update();
-}
-
-void CharacterWidget::calculateSquareSize()
-{
- squareSize = qMax(16, 4 + QFontMetrics(displayFont, this).height());
-}
-
-//! [3]
-QSize CharacterWidget::sizeHint() const
-{
- return QSize(columns*squareSize, (65536 / columns) * squareSize);
-}
-//! [3]
-
-//! [4]
-void CharacterWidget::mouseMoveEvent(QMouseEvent *event)
-{
- QPoint widgetPosition = mapFromGlobal(event->globalPosition().toPoint());
- uint key = (widgetPosition.y() / squareSize) * columns + widgetPosition.x() / squareSize;
-
- QString text = QString::fromLatin1("<p>Character: <span style=\"font-size: 24pt; font-family: %1\">").arg(displayFont.family())
- + QChar(key)
- + QString::fromLatin1("</span><p>Value: 0x")
- + QString::number(key, 16);
- QToolTip::showText(event->globalPosition().toPoint(), text, this);
-}
-//! [4]
-
-//! [5]
-void CharacterWidget::mousePressEvent(QMouseEvent *event)
-{
- if (event->button() == Qt::LeftButton) {
- lastKey = (event->position().toPoint().y() / squareSize) * columns + event->position().toPoint().x() / squareSize;
- if (QChar(lastKey).category() != QChar::Other_NotAssigned)
- emit characterSelected(QString(QChar(lastKey)));
- update();
- }
- else
- QWidget::mousePressEvent(event);
-}
-//! [5]
-
-//! [6]
-void CharacterWidget::paintEvent(QPaintEvent *event)
-{
- QPainter painter(this);
- painter.fillRect(event->rect(), QBrush(Qt::white));
- painter.setFont(displayFont);
-//! [6]
-
-//! [7]
- QRect redrawRect = event->rect();
- int beginRow = redrawRect.top() / squareSize;
- int endRow = redrawRect.bottom() / squareSize;
- int beginColumn = redrawRect.left() / squareSize;
- int endColumn = redrawRect.right() / squareSize;
-//! [7]
-
-//! [8]
- painter.setPen(QPen(Qt::gray));
- for (int row = beginRow; row <= endRow; ++row) {
- for (int column = beginColumn; column <= endColumn; ++column) {
- painter.drawRect(column * squareSize, row * squareSize, squareSize, squareSize);
- }
-//! [8] //! [9]
- }
-//! [9]
-
-//! [10]
- QFontMetrics fontMetrics(displayFont);
- painter.setPen(QPen(Qt::black));
- for (int row = beginRow; row <= endRow; ++row) {
- for (int column = beginColumn; column <= endColumn; ++column) {
- int key = row * columns + column;
- painter.setClipRect(column * squareSize, row * squareSize, squareSize, squareSize);
-
- if (key == lastKey)
- painter.fillRect(column * squareSize + 1, row * squareSize + 1,
- squareSize, squareSize, QBrush(Qt::red));
-
- painter.drawText(column * squareSize + (squareSize / 2) -
- fontMetrics.horizontalAdvance(QChar(key)) / 2,
- row * squareSize + 4 + fontMetrics.ascent(),
- QString(QChar(key)));
- }
- }
-}
-//! [10]
diff --git a/examples/widgets/widgets/charactermap/characterwidget.h b/examples/widgets/widgets/charactermap/characterwidget.h
deleted file mode 100644
index b8aa76d111..0000000000
--- a/examples/widgets/widgets/charactermap/characterwidget.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef CHARACTERWIDGET_H
-#define CHARACTERWIDGET_H
-
-#include <QFont>
-#include <QSize>
-#include <QString>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QMouseEvent;
-class QPaintEvent;
-QT_END_NAMESPACE
-
-//! [0]
-class CharacterWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- CharacterWidget(QWidget *parent = nullptr);
- QSize sizeHint() const override;
-
-public slots:
- void updateFont(const QFont &font);
- void updateSize(const QString &fontSize);
- void updateStyle(const QString &fontStyle);
- void updateFontMerging(bool enable);
-
-signals:
- void characterSelected(const QString &character);
-
-protected:
- void mouseMoveEvent(QMouseEvent *event) override;
- void mousePressEvent(QMouseEvent *event) override;
- void paintEvent(QPaintEvent *event) override;
-
-private:
- void calculateSquareSize();
-
- QFont displayFont;
- int columns = 16;
- int lastKey = -1;
- int squareSize = 0;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/charactermap/mainwindow.cpp b/examples/widgets/widgets/charactermap/mainwindow.cpp
deleted file mode 100644
index fcc00f9642..0000000000
--- a/examples/widgets/widgets/charactermap/mainwindow.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-#include "characterwidget.h"
-
-#include <QApplication>
-#include <QBoxLayout>
-#include <QCheckBox>
-#include <QClipboard>
-#include <QDialog>
-#include <QDialogButtonBox>
-#include <QFontComboBox>
-#include <QLabel>
-#include <QLineEdit>
-#include <QMenuBar>
-#include <QPlainTextEdit>
-#include <QPushButton>
-#include <QScreen>
-#include <QScrollArea>
-#include <QStatusBar>
-#include <QTextStream>
-
-//! [0]
-Q_DECLARE_METATYPE(QFontComboBox::FontFilter)
-
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
-{
- QMenu *fileMenu = menuBar()->addMenu(tr("File"));
- fileMenu->addAction(tr("Quit"), this, &QWidget::close);
- QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(tr("Show Font Info"), this, &MainWindow::showInfo);
- helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
-
- QWidget *centralWidget = new QWidget;
-
- QLabel *filterLabel = new QLabel(tr("Filter:"));
- filterCombo = new QComboBox;
- filterCombo->addItem(tr("All"), QVariant::fromValue(QFontComboBox::AllFonts));
- filterCombo->addItem(tr("Scalable"), QVariant::fromValue(QFontComboBox::ScalableFonts));
- filterCombo->addItem(tr("Monospaced"), QVariant::fromValue(QFontComboBox::MonospacedFonts));
- filterCombo->addItem(tr("Proportional"), QVariant::fromValue(QFontComboBox::ProportionalFonts));
- filterCombo->setCurrentIndex(0);
- connect(filterCombo, &QComboBox::currentIndexChanged,
- this, &MainWindow::filterChanged);
-
- QLabel *fontLabel = new QLabel(tr("Font:"));
- fontCombo = new QFontComboBox;
- QLabel *sizeLabel = new QLabel(tr("Size:"));
- sizeCombo = new QComboBox;
- QLabel *styleLabel = new QLabel(tr("Style:"));
- styleCombo = new QComboBox;
- QLabel *fontMergingLabel = new QLabel(tr("Automatic Font Merging:"));
- fontMerging = new QCheckBox;
- fontMerging->setChecked(true);
-
- scrollArea = new QScrollArea;
- characterWidget = new CharacterWidget;
- scrollArea->setWidget(characterWidget);
-//! [0]
-
-//! [1]
- findStyles(fontCombo->currentFont());
-//! [1]
- findSizes(fontCombo->currentFont());
-
-//! [2]
- lineEdit = new QLineEdit;
- lineEdit->setClearButtonEnabled(true);
-#ifndef QT_NO_CLIPBOARD
- QPushButton *clipboardButton = new QPushButton(tr("&To clipboard"));
-//! [2]
-
-#endif
-
-//! [4]
- connect(fontCombo, &QFontComboBox::currentFontChanged,
- this, &MainWindow::findStyles);
- connect(fontCombo, &QFontComboBox::currentFontChanged,
- this, &MainWindow::findSizes);
- connect(fontCombo, &QFontComboBox::currentFontChanged,
- characterWidget, &CharacterWidget::updateFont);
- connect(sizeCombo, &QComboBox::currentTextChanged,
- characterWidget, &CharacterWidget::updateSize);
- connect(styleCombo, &QComboBox::currentTextChanged,
- characterWidget, &CharacterWidget::updateStyle);
-//! [4] //! [5]
- connect(characterWidget, &CharacterWidget::characterSelected,
- this, &MainWindow::insertCharacter);
-
-#ifndef QT_NO_CLIPBOARD
- connect(clipboardButton, &QAbstractButton::clicked, this, &MainWindow::updateClipboard);
-#endif
-//! [5]
- connect(fontMerging, &QAbstractButton::toggled, characterWidget, &CharacterWidget::updateFontMerging);
-
-//! [6]
- QHBoxLayout *controlsLayout = new QHBoxLayout;
- controlsLayout->addWidget(filterLabel);
- controlsLayout->addWidget(filterCombo, 1);
- controlsLayout->addWidget(fontLabel);
- controlsLayout->addWidget(fontCombo, 1);
- controlsLayout->addWidget(sizeLabel);
- controlsLayout->addWidget(sizeCombo, 1);
- controlsLayout->addWidget(styleLabel);
- controlsLayout->addWidget(styleCombo, 1);
- controlsLayout->addWidget(fontMergingLabel);
- controlsLayout->addWidget(fontMerging, 1);
- controlsLayout->addStretch(1);
-
- QHBoxLayout *lineLayout = new QHBoxLayout;
- lineLayout->addWidget(lineEdit, 1);
- lineLayout->addSpacing(12);
-#ifndef QT_NO_CLIPBOARD
- lineLayout->addWidget(clipboardButton);
-#endif
-
- QVBoxLayout *centralLayout = new QVBoxLayout;
- centralLayout->addLayout(controlsLayout);
- centralLayout->addWidget(scrollArea, 1);
- centralLayout->addSpacing(4);
- centralLayout->addLayout(lineLayout);
- centralWidget->setLayout(centralLayout);
-
- setCentralWidget(centralWidget);
- setWindowTitle(tr("Character Map"));
-}
-//! [6]
-
-//! [7]
-void MainWindow::findStyles(const QFont &font)
-{
- QString currentItem = styleCombo->currentText();
- styleCombo->clear();
-//! [7]
-
-//! [8]
- const QStringList styles = QFontDatabase::styles(font.family());
- for (const QString &style : styles)
- styleCombo->addItem(style);
-
- int styleIndex = styleCombo->findText(currentItem);
-
- if (styleIndex == -1)
- styleCombo->setCurrentIndex(0);
- else
- styleCombo->setCurrentIndex(styleIndex);
-}
-//! [8]
-
-void MainWindow::filterChanged(int f)
-{
- const QFontComboBox::FontFilter filter =
- qvariant_cast<QFontComboBox::FontFilter>(filterCombo->itemData(f));
- fontCombo->setFontFilters(filter);
- statusBar()->showMessage(tr("%n font(s) found", nullptr, fontCombo->count()));
-}
-
-void MainWindow::findSizes(const QFont &font)
-{
- QString currentSize = sizeCombo->currentText();
-
- {
- const QSignalBlocker blocker(sizeCombo);
- // sizeCombo signals are now blocked until end of scope
- sizeCombo->clear();
-
- if (QFontDatabase::isSmoothlyScalable(font.family(), QFontDatabase::styleString(font))) {
- const QList<int> sizes = QFontDatabase::standardSizes();
- for (const int size : sizes) {
- sizeCombo->addItem(QVariant(size).toString());
- sizeCombo->setEditable(true);
- }
-
- } else {
- const QList<int> sizes = QFontDatabase::smoothSizes(font.family(), QFontDatabase::styleString(font));
- for (const int size : sizes ) {
- sizeCombo->addItem(QVariant(size).toString());
- sizeCombo->setEditable(false);
- }
- }
- }
-
- int sizeIndex = sizeCombo->findText(currentSize);
-
- if(sizeIndex == -1)
- sizeCombo->setCurrentIndex(qMax(0, sizeCombo->count() / 3));
- else
- sizeCombo->setCurrentIndex(sizeIndex);
-}
-
-//! [9]
-void MainWindow::insertCharacter(const QString &character)
-{
- lineEdit->insert(character);
-}
-//! [9]
-
-//! [10]
-#ifndef QT_NO_CLIPBOARD
-void MainWindow::updateClipboard()
-{
-//! [11]
- QGuiApplication::clipboard()->setText(lineEdit->text(), QClipboard::Clipboard);
-//! [11]
- QGuiApplication::clipboard()->setText(lineEdit->text(), QClipboard::Selection);
-}
-#endif
-
-class FontInfoDialog : public QDialog
-{
-public:
- explicit FontInfoDialog(QWidget *parent = nullptr);
-
-private:
- QString text() const;
-};
-
-FontInfoDialog::FontInfoDialog(QWidget *parent) : QDialog(parent)
-{
- setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
- QPlainTextEdit *textEdit = new QPlainTextEdit(text(), this);
- textEdit->setReadOnly(true);
- textEdit->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
- mainLayout->addWidget(textEdit);
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
- mainLayout->addWidget(buttonBox);
-}
-
-QString FontInfoDialog::text() const
-{
- QString text;
- QTextStream str(&text);
- const QFont defaultFont = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
- const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
- const QFont titleFont = QFontDatabase::systemFont(QFontDatabase::TitleFont);
- const QFont smallestReadableFont = QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont);
-
- str << "Qt " << QT_VERSION_STR << " on " << QGuiApplication::platformName()
- << ", " << logicalDpiX() << "DPI";
- if (!qFuzzyCompare(devicePixelRatio(), qreal(1)))
- str << ", device pixel ratio: " << devicePixelRatio();
- str << "\n\nDefault font : " << defaultFont.family() << ", " << defaultFont.pointSizeF() << "pt\n"
- << "Fixed font : " << fixedFont.family() << ", " << fixedFont.pointSizeF() << "pt\n"
- << "Title font : " << titleFont.family() << ", " << titleFont.pointSizeF() << "pt\n"
- << "Smallest font: " << smallestReadableFont.family() << ", " << smallestReadableFont.pointSizeF() << "pt\n";
-
- return text;
-}
-
-void MainWindow::showInfo()
-{
- const QRect screenGeometry = screen()->geometry();
- FontInfoDialog *dialog = new FontInfoDialog(this);
- dialog->setWindowTitle(tr("Fonts"));
- dialog->setAttribute(Qt::WA_DeleteOnClose);
- dialog->resize(screenGeometry.width() / 4, screenGeometry.height() / 4);
- dialog->show();
-}
-
-//! [10]
diff --git a/examples/widgets/widgets/charactermap/mainwindow.h b/examples/widgets/widgets/charactermap/mainwindow.h
deleted file mode 100644
index b8f3c166eb..0000000000
--- a/examples/widgets/widgets/charactermap/mainwindow.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include <QString>
-
-QT_BEGIN_NAMESPACE
-class QClipboard;
-class QComboBox;
-class QFontComboBox;
-class QLineEdit;
-class QScrollArea;
-class QCheckBox;
-QT_END_NAMESPACE
-class CharacterWidget;
-
-//! [0]
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow(QWidget *parent = nullptr);
-
-public slots:
- void filterChanged(int);
- void findStyles(const QFont &font);
- void findSizes(const QFont &font);
- void insertCharacter(const QString &character);
-#ifndef QT_NO_CLIPBOARD
- void updateClipboard();
-#endif
- void showInfo();
-
-private:
- CharacterWidget *characterWidget;
- QComboBox *filterCombo;
- QComboBox *styleCombo;
- QComboBox *sizeCombo;
- QFontComboBox *fontCombo;
- QLineEdit *lineEdit;
- QScrollArea *scrollArea;
- QCheckBox *fontMerging;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/codeeditor/CMakeLists.txt b/examples/widgets/widgets/codeeditor/CMakeLists.txt
deleted file mode 100644
index 31fb1b0718..0000000000
--- a/examples/widgets/widgets/codeeditor/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(codeeditor LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/codeeditor")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(codeeditor
- codeeditor.cpp codeeditor.h
- main.cpp
-)
-
-set_target_properties(codeeditor PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(codeeditor PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS codeeditor
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/codeeditor/codeeditor.cpp b/examples/widgets/widgets/codeeditor/codeeditor.cpp
deleted file mode 100644
index 15f84622e4..0000000000
--- a/examples/widgets/widgets/codeeditor/codeeditor.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "codeeditor.h"
-
-#include <QPainter>
-#include <QTextBlock>
-
-//![constructor]
-
-CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
-{
- lineNumberArea = new LineNumberArea(this);
-
- connect(this, &CodeEditor::blockCountChanged, this, &CodeEditor::updateLineNumberAreaWidth);
- connect(this, &CodeEditor::updateRequest, this, &CodeEditor::updateLineNumberArea);
- connect(this, &CodeEditor::cursorPositionChanged, this, &CodeEditor::highlightCurrentLine);
-
- updateLineNumberAreaWidth(0);
- highlightCurrentLine();
-}
-
-//![constructor]
-
-//![extraAreaWidth]
-
-int CodeEditor::lineNumberAreaWidth()
-{
- int digits = 1;
- int max = qMax(1, blockCount());
- while (max >= 10) {
- max /= 10;
- ++digits;
- }
-
- int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits;
-
- return space;
-}
-
-//![extraAreaWidth]
-
-//![slotUpdateExtraAreaWidth]
-
-void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */)
-{
- setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
-}
-
-//![slotUpdateExtraAreaWidth]
-
-//![slotUpdateRequest]
-
-void CodeEditor::updateLineNumberArea(const QRect &rect, int dy)
-{
- if (dy)
- lineNumberArea->scroll(0, dy);
- else
- lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height());
-
- if (rect.contains(viewport()->rect()))
- updateLineNumberAreaWidth(0);
-}
-
-//![slotUpdateRequest]
-
-//![resizeEvent]
-
-void CodeEditor::resizeEvent(QResizeEvent *e)
-{
- QPlainTextEdit::resizeEvent(e);
-
- QRect cr = contentsRect();
- lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
-}
-
-//![resizeEvent]
-
-//![cursorPositionChanged]
-
-void CodeEditor::highlightCurrentLine()
-{
- QList<QTextEdit::ExtraSelection> extraSelections;
-
- if (!isReadOnly()) {
- QTextEdit::ExtraSelection selection;
-
- QColor lineColor = QColor(Qt::yellow).lighter(160);
-
- selection.format.setBackground(lineColor);
- selection.format.setProperty(QTextFormat::FullWidthSelection, true);
- selection.cursor = textCursor();
- selection.cursor.clearSelection();
- extraSelections.append(selection);
- }
-
- setExtraSelections(extraSelections);
-}
-
-//![cursorPositionChanged]
-
-//![extraAreaPaintEvent_0]
-
-void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
-{
- QPainter painter(lineNumberArea);
- painter.fillRect(event->rect(), Qt::lightGray);
-
-//![extraAreaPaintEvent_0]
-
-//![extraAreaPaintEvent_1]
- QTextBlock block = firstVisibleBlock();
- int blockNumber = block.blockNumber();
- int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top());
- int bottom = top + qRound(blockBoundingRect(block).height());
-//![extraAreaPaintEvent_1]
-
-//![extraAreaPaintEvent_2]
- while (block.isValid() && top <= event->rect().bottom()) {
- if (block.isVisible() && bottom >= event->rect().top()) {
- QString number = QString::number(blockNumber + 1);
- painter.setPen(Qt::black);
- painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(),
- Qt::AlignRight, number);
- }
-
- block = block.next();
- top = bottom;
- bottom = top + qRound(blockBoundingRect(block).height());
- ++blockNumber;
- }
-}
-//![extraAreaPaintEvent_2]
-
diff --git a/examples/widgets/widgets/codeeditor/codeeditor.h b/examples/widgets/widgets/codeeditor/codeeditor.h
deleted file mode 100644
index e8e6a583f0..0000000000
--- a/examples/widgets/widgets/codeeditor/codeeditor.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef CODEEDITOR_H
-#define CODEEDITOR_H
-
-#include <QPlainTextEdit>
-
-QT_BEGIN_NAMESPACE
-class QPaintEvent;
-class QResizeEvent;
-class QSize;
-class QWidget;
-QT_END_NAMESPACE
-
-class LineNumberArea;
-
-//![codeeditordefinition]
-
-class CodeEditor : public QPlainTextEdit
-{
- Q_OBJECT
-
-public:
- CodeEditor(QWidget *parent = nullptr);
-
- void lineNumberAreaPaintEvent(QPaintEvent *event);
- int lineNumberAreaWidth();
-
-protected:
- void resizeEvent(QResizeEvent *event) override;
-
-private slots:
- void updateLineNumberAreaWidth(int newBlockCount);
- void highlightCurrentLine();
- void updateLineNumberArea(const QRect &rect, int dy);
-
-private:
- QWidget *lineNumberArea;
-};
-
-//![codeeditordefinition]
-//![extraarea]
-
-class LineNumberArea : public QWidget
-{
-public:
- LineNumberArea(CodeEditor *editor) : QWidget(editor), codeEditor(editor)
- {}
-
- QSize sizeHint() const override
- {
- return QSize(codeEditor->lineNumberAreaWidth(), 0);
- }
-
-protected:
- void paintEvent(QPaintEvent *event) override
- {
- codeEditor->lineNumberAreaPaintEvent(event);
- }
-
-private:
- CodeEditor *codeEditor;
-};
-
-//![extraarea]
-
-#endif
diff --git a/examples/widgets/widgets/codeeditor/codeeditor.pro b/examples/widgets/widgets/codeeditor/codeeditor.pro
deleted file mode 100644
index 5618160d17..0000000000
--- a/examples/widgets/widgets/codeeditor/codeeditor.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-QT += widgets
-
-HEADERS = codeeditor.h
-SOURCES = main.cpp \
- codeeditor.cpp
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/codeeditor
-INSTALLS += target
diff --git a/examples/widgets/widgets/codeeditor/main.cpp b/examples/widgets/widgets/codeeditor/main.cpp
deleted file mode 100644
index 20b72b18ae..0000000000
--- a/examples/widgets/widgets/codeeditor/main.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "codeeditor.h"
-
-int main(int argv, char **args)
-{
- QApplication app(argv, args);
-
- CodeEditor editor;
- editor.setWindowTitle(QObject::tr("Code Editor Example"));
- editor.show();
-
- return app.exec();
-}
-
diff --git a/examples/widgets/widgets/digitalclock/CMakeLists.txt b/examples/widgets/widgets/digitalclock/CMakeLists.txt
deleted file mode 100644
index 43f0106add..0000000000
--- a/examples/widgets/widgets/digitalclock/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(digitalclock LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/digitalclock")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(digitalclock
- digitalclock.cpp digitalclock.h
- main.cpp
-)
-
-set_target_properties(digitalclock PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(digitalclock PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS digitalclock
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/digitalclock/digitalclock.cpp b/examples/widgets/widgets/digitalclock/digitalclock.cpp
deleted file mode 100644
index 4eec982c25..0000000000
--- a/examples/widgets/widgets/digitalclock/digitalclock.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "digitalclock.h"
-
-#include <QTime>
-#include <QTimer>
-
-//! [0]
-DigitalClock::DigitalClock(QWidget *parent)
- : QLCDNumber(parent)
-{
- setSegmentStyle(Filled);
-
- QTimer *timer = new QTimer(this);
- connect(timer, &QTimer::timeout, this, &DigitalClock::showTime);
- timer->start(1000);
-
- showTime();
-
- setWindowTitle(tr("Digital Clock"));
- resize(150, 60);
-}
-//! [0]
-
-//! [1]
-void DigitalClock::showTime()
-//! [1] //! [2]
-{
- QTime time = QTime::currentTime();
- QString text = time.toString("hh:mm");
- if ((time.second() % 2) == 0)
- text[2] = ' ';
- display(text);
-}
-//! [2]
diff --git a/examples/widgets/widgets/digitalclock/digitalclock.h b/examples/widgets/widgets/digitalclock/digitalclock.h
deleted file mode 100644
index 7b028cb06e..0000000000
--- a/examples/widgets/widgets/digitalclock/digitalclock.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef DIGITALCLOCK_H
-#define DIGITALCLOCK_H
-
-#include <QLCDNumber>
-
-//! [0]
-class DigitalClock : public QLCDNumber
-{
- Q_OBJECT
-
-public:
- DigitalClock(QWidget *parent = nullptr);
-
-private slots:
- void showTime();
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/digitalclock/digitalclock.pro b/examples/widgets/widgets/digitalclock/digitalclock.pro
deleted file mode 100644
index 4e4bc0f557..0000000000
--- a/examples/widgets/widgets/digitalclock/digitalclock.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QT += widgets
-
-HEADERS = digitalclock.h
-SOURCES = digitalclock.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/digitalclock
-INSTALLS += target
diff --git a/examples/widgets/widgets/digitalclock/main.cpp b/examples/widgets/widgets/digitalclock/main.cpp
deleted file mode 100644
index d930e72f23..0000000000
--- a/examples/widgets/widgets/digitalclock/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "digitalclock.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- DigitalClock clock;
- clock.show();
- return app.exec();
-}
diff --git a/examples/widgets/widgets/elidedlabel/CMakeLists.txt b/examples/widgets/widgets/elidedlabel/CMakeLists.txt
deleted file mode 100644
index c7e2f96aa7..0000000000
--- a/examples/widgets/widgets/elidedlabel/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(elidedlabel LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/elidedlabel")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(elidedlabel
- elidedlabel.cpp elidedlabel.h
- main.cpp
- testwidget.cpp testwidget.h
-)
-
-set_target_properties(elidedlabel PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(elidedlabel PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS elidedlabel
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/elidedlabel/elidedlabel.cpp b/examples/widgets/widgets/elidedlabel/elidedlabel.cpp
deleted file mode 100644
index 68ba133811..0000000000
--- a/examples/widgets/widgets/elidedlabel/elidedlabel.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "elidedlabel.h"
-
-#include <QPainter>
-#include <QSizePolicy>
-#include <QTextLayout>
-
-//! [0]
-ElidedLabel::ElidedLabel(const QString &text, QWidget *parent)
- : QFrame(parent)
- , elided(false)
- , content(text)
-{
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
-}
-//! [0]
-
-//! [1]
-void ElidedLabel::setText(const QString &newText)
-{
- content = newText;
- update();
-}
-//! [1]
-
-//! [2]
-void ElidedLabel::paintEvent(QPaintEvent *event)
-{
- QFrame::paintEvent(event);
-
- QPainter painter(this);
- QFontMetrics fontMetrics = painter.fontMetrics();
-
- bool didElide = false;
- int lineSpacing = fontMetrics.lineSpacing();
- int y = 0;
-
- QTextLayout textLayout(content, painter.font());
- textLayout.beginLayout();
- forever {
- QTextLine line = textLayout.createLine();
-
- if (!line.isValid())
- break;
-
- line.setLineWidth(width());
- int nextLineY = y + lineSpacing;
-
- if (height() >= nextLineY + lineSpacing) {
- line.draw(&painter, QPoint(0, y));
- y = nextLineY;
- //! [2]
- //! [3]
- } else {
- QString lastLine = content.mid(line.textStart());
- QString elidedLastLine = fontMetrics.elidedText(lastLine, Qt::ElideRight, width());
- painter.drawText(QPoint(0, y + fontMetrics.ascent()), elidedLastLine);
- line = textLayout.createLine();
- didElide = line.isValid();
- break;
- }
- }
- textLayout.endLayout();
- //! [3]
-
- //! [4]
- if (didElide != elided) {
- elided = didElide;
- emit elisionChanged(didElide);
- }
-}
-//! [4]
diff --git a/examples/widgets/widgets/elidedlabel/elidedlabel.h b/examples/widgets/widgets/elidedlabel/elidedlabel.h
deleted file mode 100644
index 342dd5d6a1..0000000000
--- a/examples/widgets/widgets/elidedlabel/elidedlabel.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef ELIDEDLABEL_H
-#define ELIDEDLABEL_H
-
-#include <QFrame>
-#include <QString>
-
-//! [0]
-class ElidedLabel : public QFrame
-{
- Q_OBJECT
- Q_PROPERTY(QString text READ text WRITE setText)
- Q_PROPERTY(bool isElided READ isElided)
-
-public:
- explicit ElidedLabel(const QString &text, QWidget *parent = nullptr);
-
- void setText(const QString &text);
- const QString & text() const { return content; }
- bool isElided() const { return elided; }
-
-protected:
- void paintEvent(QPaintEvent *event) override;
-
-signals:
- void elisionChanged(bool elided);
-
-private:
- bool elided;
- QString content;
-};
-//! [0]
-
-#endif // TEXTWRAPPINGWIDGET_H
diff --git a/examples/widgets/widgets/elidedlabel/elidedlabel.pro b/examples/widgets/widgets/elidedlabel/elidedlabel.pro
deleted file mode 100644
index 34040c92af..0000000000
--- a/examples/widgets/widgets/elidedlabel/elidedlabel.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-# Nokia Qt Examples: elided label example
-
-QT += core gui widgets
-requires(qtConfig(combobox))
-
-TARGET = elidedlabel
-TEMPLATE = app
-
-SOURCES += \
- main.cpp\
- testwidget.cpp \
- elidedlabel.cpp
-
-HEADERS += \
- testwidget.h \
- elidedlabel.h
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/elidedlabel
-INSTALLS += target
diff --git a/examples/widgets/widgets/elidedlabel/main.cpp b/examples/widgets/widgets/elidedlabel/main.cpp
deleted file mode 100644
index 6a1380264e..0000000000
--- a/examples/widgets/widgets/elidedlabel/main.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "testwidget.h"
-
-#include <QApplication>
-
-//! [0]
-int main( int argc, char *argv[] )
-{
- QApplication application( argc, argv );
- TestWidget w;
- w.showFullScreen();
- return application.exec();
-}
-//! [0]
diff --git a/examples/widgets/widgets/elidedlabel/testwidget.cpp b/examples/widgets/widgets/elidedlabel/testwidget.cpp
deleted file mode 100644
index 72fcd382d3..0000000000
--- a/examples/widgets/widgets/elidedlabel/testwidget.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "testwidget.h"
-#include "elidedlabel.h"
-
-#include <QGridLayout>
-#include <QLabel>
-#include <QPushButton>
-
-//! [0]
-TestWidget::TestWidget(QWidget *parent)
- : QWidget(parent)
-{
- const QString romeo = tr(
- "But soft, what light through yonder window breaks? / "
- "It is the east, and Juliet is the sun. / "
- "Arise, fair sun, and kill the envious moon, / "
- "Who is already sick and pale with grief / "
- "That thou, her maid, art far more fair than she."
- );
-
- const QString macbeth = tr(
- "To-morrow, and to-morrow, and to-morrow, / "
- "Creeps in this petty pace from day to day, / "
- "To the last syllable of recorded time; / "
- "And all our yesterdays have lighted fools / "
- "The way to dusty death. Out, out, brief candle! / "
- "Life's but a walking shadow, a poor player, / "
- "That struts and frets his hour upon the stage, / "
- "And then is heard no more. It is a tale / "
- "Told by an idiot, full of sound and fury, / "
- "Signifying nothing."
- );
-
- const QString harry = tr("Feeling lucky, punk?");
-
- textSamples << romeo << macbeth << harry;
- //! [0]
-
- //! [1]
- sampleIndex = 0;
- elidedText = new ElidedLabel(textSamples[sampleIndex], this);
- elidedText->setFrameStyle(QFrame::Box);
- //! [1]
-
- //! [2]
- QPushButton *switchButton = new QPushButton(tr("Switch text"));
- connect(switchButton, &QPushButton::clicked, this, &TestWidget::switchText);
-
- QPushButton *exitButton = new QPushButton(tr("Exit"));
- connect(exitButton, &QPushButton::clicked, this, &TestWidget::close);
-
- QLabel *label = new QLabel(tr("Elided"));
- label->setVisible(elidedText->isElided());
- connect(elidedText, &ElidedLabel::elisionChanged, label, &QLabel::setVisible);
- //! [2]
-
- //! [3]
- widthSlider = new QSlider(Qt::Horizontal);
- widthSlider->setMinimum(0);
- connect(widthSlider, &QSlider::valueChanged, this, &TestWidget::onWidthChanged);
-
- heightSlider = new QSlider(Qt::Vertical);
- heightSlider->setInvertedAppearance(true);
- heightSlider->setMinimum(0);
- connect(heightSlider, &QSlider::valueChanged, this, &TestWidget::onHeightChanged);
- //! [3]
-
- //! [4]
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(label, 0, 1, Qt::AlignCenter);
- layout->addWidget(switchButton, 0, 2);
- layout->addWidget(exitButton, 0, 3);
- layout->addWidget(widthSlider, 1, 1, 1, 3);
- layout->addWidget(heightSlider, 2, 0);
- layout->addWidget(elidedText, 2, 1, 1, 3, Qt::AlignTop | Qt::AlignLeft);
-
- setLayout(layout);
- //! [4]
-}
-
-//! [6]
-void TestWidget::resizeEvent(QResizeEvent *event)
-{
- Q_UNUSED(event);
-
- int maxWidth = widthSlider->width();
- widthSlider->setMaximum(maxWidth);
- widthSlider->setValue(maxWidth / 2);
-
- int maxHeight = heightSlider->height();
- heightSlider->setMaximum(maxHeight);
- heightSlider->setValue(maxHeight / 2);
-
- elidedText->setFixedSize(widthSlider->value(), heightSlider->value());
-}
-//! [6]
-
-//! [7]
-void TestWidget::switchText()
-{
- sampleIndex = (sampleIndex + 1) % textSamples.size();
- elidedText->setText(textSamples.at(sampleIndex));
-}
-//! [7]
-
-//! [8]
-void TestWidget::onWidthChanged(int width)
-{
- elidedText->setFixedWidth(width);
-}
-
-void TestWidget::onHeightChanged(int height)
-{
- elidedText->setFixedHeight(height);
-}
-//! [8]
-
diff --git a/examples/widgets/widgets/elidedlabel/testwidget.h b/examples/widgets/widgets/elidedlabel/testwidget.h
deleted file mode 100644
index b98250e760..0000000000
--- a/examples/widgets/widgets/elidedlabel/testwidget.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef TESTWIDGET_H
-#define TESTWIDGET_H
-
-#include <QSlider>
-#include <QStringList>
-#include <QWidget>
-
-class ElidedLabel;
-
-//! [0]
-class TestWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- TestWidget(QWidget *parent = nullptr);
-
-protected:
- void resizeEvent(QResizeEvent *event) override;
-
-private slots:
- void switchText();
- void onWidthChanged(int width);
- void onHeightChanged(int height);
-
-private:
- int sampleIndex;
- QStringList textSamples;
- ElidedLabel *elidedText;
- QSlider *heightSlider;
- QSlider *widthSlider;
-};
-//! [0]
-
-#endif // TESTWIDGET_H
diff --git a/examples/widgets/widgets/groupbox/CMakeLists.txt b/examples/widgets/widgets/groupbox/CMakeLists.txt
index 304b1fe083..ab2469eaad 100644
--- a/examples/widgets/widgets/groupbox/CMakeLists.txt
+++ b/examples/widgets/widgets/groupbox/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(groupbox LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/groupbox")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(groupbox
main.cpp
window.cpp window.h
@@ -24,14 +18,21 @@ set_target_properties(groupbox PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(groupbox PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(groupbox PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS groupbox
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET groupbox
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/widgets/icons/CMakeLists.txt b/examples/widgets/widgets/icons/CMakeLists.txt
deleted file mode 100644
index baede5b418..0000000000
--- a/examples/widgets/widgets/icons/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(icons LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/icons")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(icons
- iconpreviewarea.cpp iconpreviewarea.h
- iconsizespinbox.cpp iconsizespinbox.h
- imagedelegate.cpp imagedelegate.h
- main.cpp
- mainwindow.cpp mainwindow.h
-)
-
-set_target_properties(icons PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_compile_definitions(icons PUBLIC
- SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}"
-)
-
-target_link_libraries(icons PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS icons
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/icons/iconpreviewarea.cpp b/examples/widgets/widgets/icons/iconpreviewarea.cpp
deleted file mode 100644
index 42a5fa7914..0000000000
--- a/examples/widgets/widgets/icons/iconpreviewarea.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "iconpreviewarea.h"
-
-#include <QGridLayout>
-#include <QLabel>
-#include <QWindow>
-
-//! [0]
-IconPreviewArea::IconPreviewArea(QWidget *parent)
- : QWidget(parent)
-{
- QGridLayout *mainLayout = new QGridLayout(this);
-
- for (int row = 0; row < NumStates; ++row) {
- stateLabels[row] = createHeaderLabel(IconPreviewArea::iconStateNames().at(row));
- mainLayout->addWidget(stateLabels[row], row + 1, 0);
- }
- Q_ASSERT(NumStates == 2);
-
- for (int column = 0; column < NumModes; ++column) {
- modeLabels[column] = createHeaderLabel(IconPreviewArea::iconModeNames().at(column));
- mainLayout->addWidget(modeLabels[column], 0, column + 1);
- }
- Q_ASSERT(NumModes == 4);
-
- for (int column = 0; column < NumModes; ++column) {
- for (int row = 0; row < NumStates; ++row) {
- pixmapLabels[column][row] = createPixmapLabel();
- mainLayout->addWidget(pixmapLabels[column][row], row + 1, column + 1);
- }
- }
-}
-//! [0]
-
-//! [42]
-QList<QIcon::Mode> IconPreviewArea::iconModes()
-{
- static const QList<QIcon::Mode> result = { QIcon::Normal, QIcon::Active, QIcon::Disabled,
- QIcon::Selected };
- return result;
-}
-
-QList<QIcon::State> IconPreviewArea::iconStates()
-{
- static const QList<QIcon::State> result = { QIcon::Off, QIcon::On };
- return result;
-}
-
-QStringList IconPreviewArea::iconModeNames()
-{
- static const QStringList result = {tr("Normal"), tr("Active"), tr("Disabled"), tr("Selected")};
- return result;
-}
-
-QStringList IconPreviewArea::iconStateNames()
-{
- static const QStringList result = {tr("Off"), tr("On")};
- return result;
-}
-//! [42]
-
-//! [1]
-void IconPreviewArea::setIcon(const QIcon &icon)
-{
- this->icon = icon;
- updatePixmapLabels();
-}
-//! [1]
-
-//! [2]
-void IconPreviewArea::setSize(const QSize &size)
-{
- if (size != this->size) {
- this->size = size;
- updatePixmapLabels();
- }
-}
-//! [2]
-
-//! [3]
-QLabel *IconPreviewArea::createHeaderLabel(const QString &text)
-{
- QLabel *label = new QLabel(tr("<b>%1</b>").arg(text));
- label->setAlignment(Qt::AlignCenter);
- return label;
-}
-//! [3]
-
-//! [4]
-QLabel *IconPreviewArea::createPixmapLabel()
-{
- QLabel *label = new QLabel;
- label->setEnabled(false);
- label->setAlignment(Qt::AlignCenter);
- label->setFrameShape(QFrame::Box);
- label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- label->setBackgroundRole(QPalette::Base);
- label->setAutoFillBackground(true);
- label->setMinimumSize(132, 132);
- return label;
-}
-//! [4]
-
-//! [5]
-void IconPreviewArea::updatePixmapLabels()
-{
- for (int column = 0; column < NumModes; ++column) {
- for (int row = 0; row < NumStates; ++row) {
- const QPixmap pixmap =
- icon.pixmap(size, devicePixelRatio(), IconPreviewArea::iconModes().at(column),
- IconPreviewArea::iconStates().at(row));
- QLabel *pixmapLabel = pixmapLabels[column][row];
- pixmapLabel->setPixmap(pixmap);
- pixmapLabel->setEnabled(!pixmap.isNull());
- QString toolTip;
- if (!pixmap.isNull()) {
- const QSize actualSize = icon.actualSize(size);
- toolTip =
- tr("Size: %1x%2\nActual size: %3x%4\nDevice pixel ratio: %5")
- .arg(size.width()).arg(size.height())
- .arg(actualSize.width()).arg(actualSize.height())
- .arg(pixmap.devicePixelRatio());
- }
- pixmapLabel->setToolTip(toolTip);
- }
- }
-}
-//! [5]
diff --git a/examples/widgets/widgets/icons/iconpreviewarea.h b/examples/widgets/widgets/icons/iconpreviewarea.h
deleted file mode 100644
index c59ebc42ba..0000000000
--- a/examples/widgets/widgets/icons/iconpreviewarea.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef ICONPREVIEWAREA_H
-#define ICONPREVIEWAREA_H
-
-#include <QIcon>
-#include <QWidget>
-#include <QStringList>
-#include <QList>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-QT_END_NAMESPACE
-
-//! [0]
-class IconPreviewArea : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit IconPreviewArea(QWidget *parent = nullptr);
-
- void setIcon(const QIcon &icon);
- void setSize(const QSize &size);
-
- static QList<QIcon::Mode> iconModes();
- static QList<QIcon::State> iconStates();
- static QStringList iconModeNames();
- static QStringList iconStateNames();
-
-private:
- QLabel *createHeaderLabel(const QString &text);
- QLabel *createPixmapLabel();
- void updatePixmapLabels();
-
- enum { NumModes = 4, NumStates = 2 };
-
- QIcon icon;
- QSize size;
- QLabel *stateLabels[NumStates];
- QLabel *modeLabels[NumModes];
- QLabel *pixmapLabels[NumModes][NumStates];
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/icons/icons.pro b/examples/widgets/widgets/icons/icons.pro
deleted file mode 100644
index 243ce6b092..0000000000
--- a/examples/widgets/widgets/icons/icons.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-QT += widgets
-requires(qtConfig(combobox))
-
-HEADERS = iconpreviewarea.h \
- iconsizespinbox.h \
- imagedelegate.h \
- mainwindow.h
-SOURCES = iconpreviewarea.cpp \
- iconsizespinbox.cpp \
- imagedelegate.cpp \
- main.cpp \
- mainwindow.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD/\\\"
-
-EXAMPLE_FILES = images/*
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/icons
-INSTALLS += target
diff --git a/examples/widgets/widgets/icons/iconsizespinbox.cpp b/examples/widgets/widgets/icons/iconsizespinbox.cpp
deleted file mode 100644
index 16c88f4dd0..0000000000
--- a/examples/widgets/widgets/icons/iconsizespinbox.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "iconsizespinbox.h"
-
-#include <QRegularExpression>
-
-//! [0]
-IconSizeSpinBox::IconSizeSpinBox(QWidget *parent)
- : QSpinBox(parent)
-{
-}
-//! [0]
-
-//! [1]
-int IconSizeSpinBox::valueFromText(const QString &text) const
-{
- static const QRegularExpression regExp(tr("(\\d+)(\\s*[xx]\\s*\\d+)?"));
- Q_ASSERT(regExp.isValid());
-
- const QRegularExpressionMatch match = regExp.match(text);
- if (match.isValid())
- return match.captured(1).toInt();
- return 0;
-}
-//! [1]
-
-//! [2]
-QString IconSizeSpinBox::textFromValue(int value) const
-{
- return tr("%1 x %1").arg(value);
-}
-//! [2]
diff --git a/examples/widgets/widgets/icons/iconsizespinbox.h b/examples/widgets/widgets/icons/iconsizespinbox.h
deleted file mode 100644
index ac304b4794..0000000000
--- a/examples/widgets/widgets/icons/iconsizespinbox.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef ICONSIZESPINBOX_H
-#define ICONSIZESPINBOX_H
-
-#include <QSpinBox>
-
-//! [0]
-class IconSizeSpinBox : public QSpinBox
-{
- Q_OBJECT
-
-public:
- explicit IconSizeSpinBox(QWidget *parent = nullptr);
-
- int valueFromText(const QString &text) const override;
- QString textFromValue(int value) const override;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/icons/imagedelegate.cpp b/examples/widgets/widgets/icons/imagedelegate.cpp
deleted file mode 100644
index ec3c227c71..0000000000
--- a/examples/widgets/widgets/icons/imagedelegate.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "imagedelegate.h"
-#include "iconpreviewarea.h"
-
-#include <QComboBox>
-
-//! [0]
-ImageDelegate::ImageDelegate(QObject *parent)
- : QStyledItemDelegate(parent)
-{}
-//! [0]
-
-//! [1]
-QWidget *ImageDelegate::createEditor(QWidget *parent,
- const QStyleOptionViewItem & /* option */,
- const QModelIndex &index) const
-{
- QComboBox *comboBox = new QComboBox(parent);
- if (index.column() == 1)
- comboBox->addItems(IconPreviewArea::iconModeNames());
- else if (index.column() == 2)
- comboBox->addItems(IconPreviewArea::iconStateNames());
-
- connect(comboBox, &QComboBox::activated,
- this, &ImageDelegate::emitCommitData);
-
- return comboBox;
-}
-//! [1]
-
-//! [2]
-void ImageDelegate::setEditorData(QWidget *editor,
- const QModelIndex &index) const
-{
- QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
- if (!comboBox)
- return;
-
- int pos = comboBox->findText(index.model()->data(index).toString(),
- Qt::MatchExactly);
- comboBox->setCurrentIndex(pos);
-}
-//! [2]
-
-//! [3]
-void ImageDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
- const QModelIndex &index) const
-{
- QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
- if (!comboBox)
- return;
-
- model->setData(index, comboBox->currentText());
-}
-//! [3]
-
-//! [4]
-void ImageDelegate::emitCommitData()
-{
- emit commitData(qobject_cast<QWidget *>(sender()));
-}
-//! [4]
diff --git a/examples/widgets/widgets/icons/imagedelegate.h b/examples/widgets/widgets/icons/imagedelegate.h
deleted file mode 100644
index 29707e68c6..0000000000
--- a/examples/widgets/widgets/icons/imagedelegate.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef IMAGEDELEGATE_H
-#define IMAGEDELEGATE_H
-
-#include <QStyledItemDelegate>
-
-//! [0]
-class ImageDelegate : public QStyledItemDelegate
-{
- Q_OBJECT
-
-public:
- explicit ImageDelegate(QObject *parent = nullptr);
-//! [0]
-
-//! [1]
- QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
- const QModelIndex &index) const override;
- void setEditorData(QWidget *editor, const QModelIndex &index) const override;
- void setModelData(QWidget *editor, QAbstractItemModel *model,
- const QModelIndex &index) const override;
-
-//! [1] //! [2]
-private slots:
- void emitCommitData();
-//! [2]
-};
-
-#endif
diff --git a/examples/widgets/widgets/icons/images/designer.png b/examples/widgets/widgets/icons/images/designer.png
deleted file mode 100644
index 9f8578b49e..0000000000
--- a/examples/widgets/widgets/icons/images/designer.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/images/find_disabled.png b/examples/widgets/widgets/icons/images/find_disabled.png
deleted file mode 100644
index e85e33fe05..0000000000
--- a/examples/widgets/widgets/icons/images/find_disabled.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/images/find_normal.png b/examples/widgets/widgets/icons/images/find_normal.png
deleted file mode 100644
index 728c27f905..0000000000
--- a/examples/widgets/widgets/icons/images/find_normal.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/images/monkey_off_128x128.png b/examples/widgets/widgets/icons/images/monkey_off_128x128.png
deleted file mode 100644
index f878267287..0000000000
--- a/examples/widgets/widgets/icons/images/monkey_off_128x128.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/images/monkey_off_16x16.png b/examples/widgets/widgets/icons/images/monkey_off_16x16.png
deleted file mode 100644
index 0ac57d7d4f..0000000000
--- a/examples/widgets/widgets/icons/images/monkey_off_16x16.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/images/monkey_off_32x32.png b/examples/widgets/widgets/icons/images/monkey_off_32x32.png
deleted file mode 100644
index 1f7fab694c..0000000000
--- a/examples/widgets/widgets/icons/images/monkey_off_32x32.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/images/monkey_off_64x64.png b/examples/widgets/widgets/icons/images/monkey_off_64x64.png
deleted file mode 100644
index 47d8f6de35..0000000000
--- a/examples/widgets/widgets/icons/images/monkey_off_64x64.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/images/monkey_on_128x128.png b/examples/widgets/widgets/icons/images/monkey_on_128x128.png
deleted file mode 100644
index 8e1c7468bf..0000000000
--- a/examples/widgets/widgets/icons/images/monkey_on_128x128.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/images/monkey_on_16x16.png b/examples/widgets/widgets/icons/images/monkey_on_16x16.png
deleted file mode 100644
index 082e8527f1..0000000000
--- a/examples/widgets/widgets/icons/images/monkey_on_16x16.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/images/monkey_on_32x32.png b/examples/widgets/widgets/icons/images/monkey_on_32x32.png
deleted file mode 100644
index bf9acc6cae..0000000000
--- a/examples/widgets/widgets/icons/images/monkey_on_32x32.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/images/monkey_on_64x64.png b/examples/widgets/widgets/icons/images/monkey_on_64x64.png
deleted file mode 100644
index 990f604d98..0000000000
--- a/examples/widgets/widgets/icons/images/monkey_on_64x64.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/images/qt_extended_16x16.png b/examples/widgets/widgets/icons/images/qt_extended_16x16.png
deleted file mode 100644
index 30bcb45ed2..0000000000
--- a/examples/widgets/widgets/icons/images/qt_extended_16x16.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/images/qt_extended_32x32.png b/examples/widgets/widgets/icons/images/qt_extended_32x32.png
deleted file mode 100644
index d609c1e1e5..0000000000
--- a/examples/widgets/widgets/icons/images/qt_extended_32x32.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/images/qt_extended_48x48.png b/examples/widgets/widgets/icons/images/qt_extended_48x48.png
deleted file mode 100644
index 0e524fed5f..0000000000
--- a/examples/widgets/widgets/icons/images/qt_extended_48x48.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/icons/main.cpp b/examples/widgets/widgets/icons/main.cpp
deleted file mode 100644
index b7ed18ff94..0000000000
--- a/examples/widgets/widgets/icons/main.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-#include <QCommandLineParser>
-#include <QScreen>
-
-#include "mainwindow.h"
-
-//! [45]
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- QCoreApplication::setApplicationName(MainWindow::tr("Icons"));
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser commandLineParser;
- commandLineParser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
- commandLineParser.addHelpOption();
- commandLineParser.addVersionOption();
- commandLineParser.addPositionalArgument(MainWindow::tr("[file]"), MainWindow::tr("Icon file(s) to open."));
- commandLineParser.process(QCoreApplication::arguments());
-
- MainWindow mainWin;
- if (!commandLineParser.positionalArguments().isEmpty())
- mainWin.loadImages(commandLineParser.positionalArguments());
-
- const QRect availableGeometry = mainWin.screen()->availableGeometry();
- mainWin.resize(availableGeometry.width() / 2, availableGeometry.height() * 2 / 3);
- mainWin.move((availableGeometry.width() - mainWin.width()) / 2, (availableGeometry.height() - mainWin.height()) / 2);
-
- mainWin.show();
- return app.exec();
-}
-//! [45]
diff --git a/examples/widgets/widgets/icons/mainwindow.cpp b/examples/widgets/widgets/icons/mainwindow.cpp
deleted file mode 100644
index 9c03401b6d..0000000000
--- a/examples/widgets/widgets/icons/mainwindow.cpp
+++ /dev/null
@@ -1,478 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-#include "iconpreviewarea.h"
-#include "iconsizespinbox.h"
-#include "imagedelegate.h"
-
-#include <QActionGroup>
-#include <QApplication>
-#include <QButtonGroup>
-#include <QCheckBox>
-#include <QFileDialog>
-#include <QHeaderView>
-#include <QFormLayout>
-#include <QGridLayout>
-#include <QGroupBox>
-#include <QImageReader>
-#include <QLabel>
-#include <QMenuBar>
-#include <QMessageBox>
-#include <QRadioButton>
-#include <QScreen>
-#include <QStandardPaths>
-#include <QStyleFactory>
-#include <QTableWidget>
-#include <QWindow>
-
-//! [40]
-enum { OtherSize = QStyle::PM_CustomBase };
-//! [40]
-
-//! [0]
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
-{
- QWidget *centralWidget = new QWidget(this);
- setCentralWidget(centralWidget);
-
- createActions();
-
- QGridLayout *mainLayout = new QGridLayout(centralWidget);
-
- QGroupBox *previewGroupBox = new QGroupBox(tr("Preview"));
- previewArea = new IconPreviewArea(previewGroupBox);
- QVBoxLayout *previewLayout = new QVBoxLayout(previewGroupBox);
- previewLayout->addWidget(previewArea);
-
- mainLayout->addWidget(previewGroupBox, 0, 0, 1, 2);
- mainLayout->addWidget(createImagesGroupBox(), 1, 0);
- QVBoxLayout *vBox = new QVBoxLayout;
- vBox->addWidget(createIconSizeGroupBox());
- vBox->addWidget(createHighDpiIconSizeGroupBox());
- vBox->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
- mainLayout->addLayout(vBox, 1, 1);
- createContextMenu();
-
- setWindowTitle(tr("Icons"));
- checkCurrentStyle();
- sizeButtonGroup->button(OtherSize)->click();
-}
-//! [0]
-
-//! [44]
-void MainWindow::show()
-{
- QMainWindow::show();
- connect(windowHandle(), &QWindow::screenChanged, this, &MainWindow::screenChanged);
- screenChanged();
-}
-//! [44]
-
-//! [1]
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About Icons"),
- tr("The <b>Icons</b> example illustrates how Qt renders an icon in "
- "different modes (active, normal, disabled, and selected) and "
- "states (on and off) based on a set of images."));
-}
-//! [1]
-
-//! [2]
-void MainWindow::changeStyle(bool checked)
-{
- if (!checked)
- return;
-
- const QAction *action = qobject_cast<QAction *>(sender());
-//! [2] //! [3]
- QStyle *style = QStyleFactory::create(action->data().toString());
-//! [3] //! [4]
- Q_ASSERT(style);
- QApplication::setStyle(style);
-
- const QList<QAbstractButton*> buttons = sizeButtonGroup->buttons();
- for (QAbstractButton *button : buttons) {
- const QStyle::PixelMetric metric = static_cast<QStyle::PixelMetric>(sizeButtonGroup->id(button));
- const int value = style->pixelMetric(metric);
- switch (metric) {
- case QStyle::PM_SmallIconSize:
- button->setText(tr("Small (%1 x %1)").arg(value));
- break;
- case QStyle::PM_LargeIconSize:
- button->setText(tr("Large (%1 x %1)").arg(value));
- break;
- case QStyle::PM_ToolBarIconSize:
- button->setText(tr("Toolbars (%1 x %1)").arg(value));
- break;
- case QStyle::PM_ListViewIconSize:
- button->setText(tr("List views (%1 x %1)").arg(value));
- break;
- case QStyle::PM_IconViewIconSize:
- button->setText(tr("Icon views (%1 x %1)").arg(value));
- break;
- case QStyle::PM_TabBarIconSize:
- button->setText(tr("Tab bars (%1 x %1)").arg(value));
- break;
- default:
- break;
- }
- }
-
- triggerChangeSize();
-}
-//! [4]
-
-//! [5]
-void MainWindow::changeSize(QAbstractButton *button, bool checked)
-{
- if (!checked)
- return;
-
- const int index = sizeButtonGroup->id(button);
- const bool other = index == int(OtherSize);
- const int extent = other
- ? otherSpinBox->value()
- : QApplication::style()->pixelMetric(static_cast<QStyle::PixelMetric>(index));
-
- previewArea->setSize(QSize(extent, extent));
- otherSpinBox->setEnabled(other);
-}
-
-void MainWindow::triggerChangeSize()
-{
- changeSize(sizeButtonGroup->checkedButton(), true);
-}
-//! [5]
-
-//! [6]
-void MainWindow::changeIcon()
-{
- QIcon icon;
-
- for (int row = 0; row < imagesTable->rowCount(); ++row) {
- const QTableWidgetItem *fileItem = imagesTable->item(row, 0);
- const QTableWidgetItem *modeItem = imagesTable->item(row, 1);
- const QTableWidgetItem *stateItem = imagesTable->item(row, 2);
-
- if (fileItem->checkState() == Qt::Checked) {
- const int modeIndex = IconPreviewArea::iconModeNames().indexOf(modeItem->text());
- Q_ASSERT(modeIndex >= 0);
- const int stateIndex = IconPreviewArea::iconStateNames().indexOf(stateItem->text());
- Q_ASSERT(stateIndex >= 0);
- const QIcon::Mode mode = IconPreviewArea::iconModes().at(modeIndex);
- const QIcon::State state = IconPreviewArea::iconStates().at(stateIndex);
-//! [6]
-
-//! [8]
- const QString fileName = fileItem->data(Qt::UserRole).toString();
- QImage image(fileName);
- if (!image.isNull())
- icon.addPixmap(QPixmap::fromImage(image), mode, state);
-//! [8]
- }
- }
-//! [11]
- previewArea->setIcon(icon);
-//! [11]
-}
-
-void MainWindow::addSampleImages()
-{
- addImages(QLatin1String(SRCDIR) + QLatin1String("/images"));
-}
-
-void MainWindow::addOtherImages()
-{
- static bool firstInvocation = true;
- QString directory;
- if (firstInvocation) {
- firstInvocation = false;
- directory = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).value(0, QString());
- }
- addImages(directory);
-}
-
-//! [12]
-void MainWindow::addImages(const QString &directory)
-{
- QFileDialog fileDialog(this, tr("Open Images"), directory);
- QStringList mimeTypeFilters;
- const QList<QByteArray> mimeTypes = QImageReader::supportedMimeTypes();
- for (const QByteArray &mimeTypeName : mimeTypes)
- mimeTypeFilters.append(mimeTypeName);
- mimeTypeFilters.sort();
- fileDialog.setMimeTypeFilters(mimeTypeFilters);
- fileDialog.selectMimeTypeFilter(QLatin1String("image/png"));
- fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
- fileDialog.setFileMode(QFileDialog::ExistingFiles);
- if (!nativeFileDialogAct->isChecked())
- fileDialog.setOption(QFileDialog::DontUseNativeDialog);
- if (fileDialog.exec() == QDialog::Accepted)
- loadImages(fileDialog.selectedFiles());
-//! [12]
-}
-
-void MainWindow::loadImages(const QStringList &fileNames)
-{
- for (const QString &fileName : fileNames) {
- const int row = imagesTable->rowCount();
- imagesTable->setRowCount(row + 1);
-//! [13]
- const QFileInfo fileInfo(fileName);
- const QString imageName = fileInfo.baseName();
- const QString fileName2x = fileInfo.absolutePath()
- + QLatin1Char('/') + imageName + QLatin1String("@2x.") + fileInfo.suffix();
- const QFileInfo fileInfo2x(fileName2x);
- const QImage image(fileName);
- const QString toolTip =
- tr("Directory: %1\nFile: %2\nFile@2x: %3\nSize: %4x%5")
- .arg(QDir::toNativeSeparators(fileInfo.absolutePath()), fileInfo.fileName())
- .arg(fileInfo2x.exists() ? fileInfo2x.fileName() : tr("<None>"))
- .arg(image.width()).arg(image.height());
- QTableWidgetItem *fileItem = new QTableWidgetItem(imageName);
- fileItem->setData(Qt::UserRole, fileName);
- fileItem->setIcon(QPixmap::fromImage(image));
- fileItem->setFlags((fileItem->flags() | Qt::ItemIsUserCheckable) & ~Qt::ItemIsEditable);
- fileItem->setToolTip(toolTip);
-//! [13]
-
-//! [15]
- QIcon::Mode mode = QIcon::Normal;
- QIcon::State state = QIcon::Off;
- if (guessModeStateAct->isChecked()) {
- if (imageName.contains(QLatin1String("_act"), Qt::CaseInsensitive))
- mode = QIcon::Active;
- else if (imageName.contains(QLatin1String("_dis"), Qt::CaseInsensitive))
- mode = QIcon::Disabled;
- else if (imageName.contains(QLatin1String("_sel"), Qt::CaseInsensitive))
- mode = QIcon::Selected;
-
- if (imageName.contains(QLatin1String("_on"), Qt::CaseInsensitive))
- state = QIcon::On;
-//! [15]
- }
-
-//! [18]
- imagesTable->setItem(row, 0, fileItem);
- QTableWidgetItem *modeItem =
- new QTableWidgetItem(IconPreviewArea::iconModeNames().at(IconPreviewArea::iconModes().indexOf(mode)));
- modeItem->setToolTip(toolTip);
- imagesTable->setItem(row, 1, modeItem);
- QTableWidgetItem *stateItem =
- new QTableWidgetItem(IconPreviewArea::iconStateNames().at(IconPreviewArea::iconStates().indexOf(state)));
- stateItem->setToolTip(toolTip);
- imagesTable->setItem(row, 2, stateItem);
- imagesTable->openPersistentEditor(modeItem);
- imagesTable->openPersistentEditor(stateItem);
-
- fileItem->setCheckState(Qt::Checked);
-//! [18]
- }
-}
-
-//! [20]
-void MainWindow::removeAllImages()
-{
- imagesTable->setRowCount(0);
- changeIcon();
-}
-//! [20]
-
-//! [21]
-QWidget *MainWindow::createImagesGroupBox()
-{
- QGroupBox *imagesGroupBox = new QGroupBox(tr("Images"));
-
- imagesTable = new QTableWidget;
- imagesTable->setSelectionMode(QAbstractItemView::NoSelection);
- imagesTable->setItemDelegate(new ImageDelegate(this));
-//! [21]
-
-//! [22]
- const QStringList labels({tr("Image"), tr("Mode"), tr("State")});
-
- imagesTable->horizontalHeader()->setDefaultSectionSize(90);
- imagesTable->setColumnCount(3);
- imagesTable->setHorizontalHeaderLabels(labels);
- imagesTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
- imagesTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Fixed);
- imagesTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed);
- imagesTable->verticalHeader()->hide();
-//! [22]
-
-//! [24]
- connect(imagesTable, &QTableWidget::itemChanged,
- this, &MainWindow::changeIcon);
-
- QVBoxLayout *layout = new QVBoxLayout(imagesGroupBox);
- layout->addWidget(imagesTable);
- return imagesGroupBox;
-//! [24]
-}
-
-//! [26]
-QWidget *MainWindow::createIconSizeGroupBox()
-{
- QGroupBox *iconSizeGroupBox = new QGroupBox(tr("Icon Size"));
-
- sizeButtonGroup = new QButtonGroup(this);
- sizeButtonGroup->setExclusive(true);
-
- connect(sizeButtonGroup, &QButtonGroup::buttonToggled,
- this, &MainWindow::changeSize);
-
- QRadioButton *smallRadioButton = new QRadioButton;
- sizeButtonGroup->addButton(smallRadioButton, QStyle::PM_SmallIconSize);
- QRadioButton *largeRadioButton = new QRadioButton;
- sizeButtonGroup->addButton(largeRadioButton, QStyle::PM_LargeIconSize);
- QRadioButton *toolBarRadioButton = new QRadioButton;
- sizeButtonGroup->addButton(toolBarRadioButton, QStyle::PM_ToolBarIconSize);
- QRadioButton *listViewRadioButton = new QRadioButton;
- sizeButtonGroup->addButton(listViewRadioButton, QStyle::PM_ListViewIconSize);
- QRadioButton *iconViewRadioButton = new QRadioButton;
- sizeButtonGroup->addButton(iconViewRadioButton, QStyle::PM_IconViewIconSize);
- QRadioButton *tabBarRadioButton = new QRadioButton;
- sizeButtonGroup->addButton(tabBarRadioButton, QStyle::PM_TabBarIconSize);
- QRadioButton *otherRadioButton = new QRadioButton(tr("Other:"));
- sizeButtonGroup->addButton(otherRadioButton, OtherSize);
- otherSpinBox = new IconSizeSpinBox;
- otherSpinBox->setRange(8, 256);
- const QString spinBoxToolTip =
- tr("Enter a custom size within %1..%2")
- .arg(otherSpinBox->minimum()).arg(otherSpinBox->maximum());
- otherSpinBox->setValue(64);
- otherSpinBox->setToolTip(spinBoxToolTip);
- otherRadioButton->setToolTip(spinBoxToolTip);
-//! [26]
-
-//! [27]
- connect(otherSpinBox, &QSpinBox::valueChanged,
- this, &MainWindow::triggerChangeSize);
-
- QHBoxLayout *otherSizeLayout = new QHBoxLayout;
- otherSizeLayout->addWidget(otherRadioButton);
- otherSizeLayout->addWidget(otherSpinBox);
- otherSizeLayout->addStretch();
-
- QGridLayout *layout = new QGridLayout(iconSizeGroupBox);
- layout->addWidget(smallRadioButton, 0, 0);
- layout->addWidget(largeRadioButton, 1, 0);
- layout->addWidget(toolBarRadioButton, 2, 0);
- layout->addWidget(listViewRadioButton, 0, 1);
- layout->addWidget(iconViewRadioButton, 1, 1);
- layout->addWidget(tabBarRadioButton, 2, 1);
- layout->addLayout(otherSizeLayout, 3, 0, 1, 2);
- layout->setRowStretch(4, 1);
- return iconSizeGroupBox;
-//! [27]
-}
-
-void MainWindow::screenChanged()
-{
- devicePixelRatioLabel->setText(QString::number(devicePixelRatio()));
- if (const QWindow *window = windowHandle()) {
- const QScreen *screen = window->screen();
- const QString screenDescription =
- tr("\"%1\" (%2x%3)").arg(screen->name())
- .arg(screen->geometry().width()).arg(screen->geometry().height());
- screenNameLabel->setText(screenDescription);
- }
- changeIcon();
-}
-
-QWidget *MainWindow::createHighDpiIconSizeGroupBox()
-{
- QGroupBox *highDpiGroupBox = new QGroupBox(tr("High DPI Scaling"));
- QFormLayout *layout = new QFormLayout(highDpiGroupBox);
- devicePixelRatioLabel = new QLabel(highDpiGroupBox);
- screenNameLabel = new QLabel(highDpiGroupBox);
- layout->addRow(tr("Screen:"), screenNameLabel);
- layout->addRow(tr("Device pixel ratio:"), devicePixelRatioLabel);
- return highDpiGroupBox;
-}
-
-//! [28]
-void MainWindow::createActions()
-{
- QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
-
- addSampleImagesAct = new QAction(tr("Add &Sample Images..."), this);
- addSampleImagesAct->setShortcut(tr("Ctrl+A"));
- connect(addSampleImagesAct, &QAction::triggered, this, &MainWindow::addSampleImages);
- fileMenu->addAction(addSampleImagesAct);
-
- addOtherImagesAct = new QAction(tr("&Add Images..."), this);
- addOtherImagesAct->setShortcut(QKeySequence::Open);
- connect(addOtherImagesAct, &QAction::triggered, this, &MainWindow::addOtherImages);
- fileMenu->addAction(addOtherImagesAct);
-
- removeAllImagesAct = new QAction(tr("&Remove All Images"), this);
- removeAllImagesAct->setShortcut(tr("Ctrl+R"));
- connect(removeAllImagesAct, &QAction::triggered,
- this, &MainWindow::removeAllImages);
- fileMenu->addAction(removeAllImagesAct);
-
- fileMenu->addSeparator();
-
- QAction *exitAct = fileMenu->addAction(tr("&Quit"), this, &QWidget::close);
- exitAct->setShortcuts(QKeySequence::Quit);
-
- QMenu *viewMenu = menuBar()->addMenu(tr("&View"));
-
- styleActionGroup = new QActionGroup(this);
- const QStringList styleKeys = QStyleFactory::keys();
- for (const QString &styleName : styleKeys) {
- QAction *action = new QAction(tr("%1 Style").arg(styleName), styleActionGroup);
- action->setData(styleName);
- action->setCheckable(true);
- connect(action, &QAction::triggered, this, &MainWindow::changeStyle);
- viewMenu->addAction(action);
- }
-
- QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings"));
-
- guessModeStateAct = new QAction(tr("&Guess Image Mode/State"), this);
- guessModeStateAct->setCheckable(true);
- guessModeStateAct->setChecked(true);
- settingsMenu->addAction(guessModeStateAct);
-
- nativeFileDialogAct = new QAction(tr("&Use Native File Dialog"), this);
- nativeFileDialogAct->setCheckable(true);
- nativeFileDialogAct->setChecked(true);
- settingsMenu->addAction(nativeFileDialogAct);
-
- QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(tr("&About"), this, &MainWindow::about);
- helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
-}
-//! [28]
-
-//! [30]
-void MainWindow::createContextMenu()
-{
- imagesTable->setContextMenuPolicy(Qt::ActionsContextMenu);
- imagesTable->addAction(addSampleImagesAct);
- imagesTable->addAction(addOtherImagesAct);
- imagesTable->addAction(removeAllImagesAct);
-}
-//! [30]
-
-//! [31]
-void MainWindow::checkCurrentStyle()
-{
- const QList<QAction *> actions = styleActionGroup->actions();
- for (QAction *action : actions) {
- const QString styleName = action->data().toString();
- const std::unique_ptr<QStyle> candidate{QStyleFactory::create(styleName)};
- Q_ASSERT(candidate);
- if (candidate->metaObject()->className()
- == QApplication::style()->metaObject()->className()) {
- action->trigger();
- return;
- }
- }
-}
-//! [31]
diff --git a/examples/widgets/widgets/icons/mainwindow.h b/examples/widgets/widgets/icons/mainwindow.h
deleted file mode 100644
index fb6e0493f7..0000000000
--- a/examples/widgets/widgets/icons/mainwindow.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QIcon>
-#include <QList>
-#include <QMainWindow>
-#include <QPixmap>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QActionGroup;
-class QLabel;
-class QButtonGroup;
-class QTableWidget;
-class QAbstractButton;
-QT_END_NAMESPACE
-class IconPreviewArea;
-class IconSizeSpinBox;
-
-//! [0]
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow(QWidget *parent = nullptr);
-
- void loadImages(const QStringList &fileNames);
-
- void show();
-
-private slots:
- void about();
- void changeStyle(bool checked);
- void changeSize(QAbstractButton *button, bool);
- void triggerChangeSize();
- void changeIcon();
- void addSampleImages();
- void addOtherImages();
- void removeAllImages();
- void screenChanged();
-
-private:
- QWidget *createImagesGroupBox();
- QWidget *createIconSizeGroupBox();
- QWidget *createHighDpiIconSizeGroupBox();
- void createActions();
- void createContextMenu();
- void checkCurrentStyle();
- void addImages(const QString &directory);
-
- IconPreviewArea *previewArea;
-
- QTableWidget *imagesTable;
-
- QButtonGroup *sizeButtonGroup;
- IconSizeSpinBox *otherSpinBox;
-
- QLabel *devicePixelRatioLabel;
- QLabel *screenNameLabel;
-
- QAction *addOtherImagesAct;
- QAction *addSampleImagesAct;
- QAction *removeAllImagesAct;
- QAction *guessModeStateAct;
- QAction *nativeFileDialogAct;
- QActionGroup *styleActionGroup;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/imageviewer/CMakeLists.txt b/examples/widgets/widgets/imageviewer/CMakeLists.txt
deleted file mode 100644
index dffca22ced..0000000000
--- a/examples/widgets/widgets/imageviewer/CMakeLists.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(imageviewer LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/imageviewer")
-
-find_package(Qt6
- REQUIRED COMPONENTS Core Gui Widgets
- OPTIONAL_COMPONENTS PrintSupport
-)
-
-qt_add_executable(imageviewer
- imageviewer.cpp imageviewer.h
- main.cpp
-)
-
-set_target_properties(imageviewer PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(imageviewer PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-if (TARGET Qt::PrintSupport)
- target_link_libraries(imageviewer PUBLIC Qt::PrintSupport)
-endif()
-
-if(TARGET Qt::PrintSupport)
- target_link_libraries(imageviewer PUBLIC
- Qt::PrintSupport
- )
-endif()
-
-install(TARGETS imageviewer
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/imageviewer/imageviewer.cpp b/examples/widgets/widgets/imageviewer/imageviewer.cpp
deleted file mode 100644
index d2bffc01d5..0000000000
--- a/examples/widgets/widgets/imageviewer/imageviewer.cpp
+++ /dev/null
@@ -1,363 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "imageviewer.h"
-
-#include <QApplication>
-#include <QClipboard>
-#include <QColorSpace>
-#include <QDir>
-#include <QFileDialog>
-#include <QImageReader>
-#include <QImageWriter>
-#include <QLabel>
-#include <QMenuBar>
-#include <QMessageBox>
-#include <QMimeData>
-#include <QPainter>
-#include <QScreen>
-#include <QScrollArea>
-#include <QScrollBar>
-#include <QStandardPaths>
-#include <QStatusBar>
-
-#if defined(QT_PRINTSUPPORT_LIB)
-# include <QtPrintSupport/qtprintsupportglobal.h>
-
-# if QT_CONFIG(printdialog)
-# include <QPrintDialog>
-# endif
-#endif
-
-//! [0]
-ImageViewer::ImageViewer(QWidget *parent)
- : QMainWindow(parent), imageLabel(new QLabel)
- , scrollArea(new QScrollArea)
-{
- imageLabel->setBackgroundRole(QPalette::Base);
- imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
- imageLabel->setScaledContents(true);
-
- scrollArea->setBackgroundRole(QPalette::Dark);
- scrollArea->setWidget(imageLabel);
- scrollArea->setVisible(false);
- setCentralWidget(scrollArea);
-
- createActions();
-
- resize(QGuiApplication::primaryScreen()->availableSize() * 3 / 5);
-}
-
-//! [0]
-//! [2]
-
-bool ImageViewer::loadFile(const QString &fileName)
-{
- QImageReader reader(fileName);
- reader.setAutoTransform(true);
- const QImage newImage = reader.read();
- if (newImage.isNull()) {
- QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
- tr("Cannot load %1: %2")
- .arg(QDir::toNativeSeparators(fileName), reader.errorString()));
- return false;
- }
-//! [2]
-
- setImage(newImage);
-
- setWindowFilePath(fileName);
-
- const QString description = image.colorSpace().isValid()
- ? image.colorSpace().description() : tr("unknown");
- const QString message = tr("Opened \"%1\", %2x%3, Depth: %4 (%5)")
- .arg(QDir::toNativeSeparators(fileName)).arg(image.width()).arg(image.height())
- .arg(image.depth()).arg(description);
- statusBar()->showMessage(message);
- return true;
-}
-
-void ImageViewer::setImage(const QImage &newImage)
-{
- image = newImage;
- if (image.colorSpace().isValid())
- image.convertToColorSpace(QColorSpace::SRgb);
- imageLabel->setPixmap(QPixmap::fromImage(image));
-//! [4]
- scaleFactor = 1.0;
-
- scrollArea->setVisible(true);
- printAct->setEnabled(true);
- fitToWindowAct->setEnabled(true);
- updateActions();
-
- if (!fitToWindowAct->isChecked())
- imageLabel->adjustSize();
-}
-
-//! [4]
-
-bool ImageViewer::saveFile(const QString &fileName)
-{
- QImageWriter writer(fileName);
-
- if (!writer.write(image)) {
- QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
- tr("Cannot write %1: %2")
- .arg(QDir::toNativeSeparators(fileName), writer.errorString()));
- return false;
- }
- const QString message = tr("Wrote \"%1\"").arg(QDir::toNativeSeparators(fileName));
- statusBar()->showMessage(message);
- return true;
-}
-
-//! [1]
-
-static void initializeImageFileDialog(QFileDialog &dialog, QFileDialog::AcceptMode acceptMode)
-{
- static bool firstDialog = true;
-
- if (firstDialog) {
- firstDialog = false;
- const QStringList picturesLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
- dialog.setDirectory(picturesLocations.isEmpty() ? QDir::currentPath() : picturesLocations.last());
- }
-
- QStringList mimeTypeFilters;
- const QByteArrayList supportedMimeTypes = acceptMode == QFileDialog::AcceptOpen
- ? QImageReader::supportedMimeTypes() : QImageWriter::supportedMimeTypes();
- for (const QByteArray &mimeTypeName : supportedMimeTypes)
- mimeTypeFilters.append(mimeTypeName);
- mimeTypeFilters.sort();
- dialog.setMimeTypeFilters(mimeTypeFilters);
- dialog.selectMimeTypeFilter("image/jpeg");
- dialog.setAcceptMode(acceptMode);
- if (acceptMode == QFileDialog::AcceptSave)
- dialog.setDefaultSuffix("jpg");
-}
-
-void ImageViewer::open()
-{
- QFileDialog dialog(this, tr("Open File"));
- initializeImageFileDialog(dialog, QFileDialog::AcceptOpen);
-
- while (dialog.exec() == QDialog::Accepted && !loadFile(dialog.selectedFiles().constFirst())) {}
-}
-//! [1]
-
-void ImageViewer::saveAs()
-{
- QFileDialog dialog(this, tr("Save File As"));
- initializeImageFileDialog(dialog, QFileDialog::AcceptSave);
-
- while (dialog.exec() == QDialog::Accepted && !saveFile(dialog.selectedFiles().constFirst())) {}
-}
-
-//! [5]
-void ImageViewer::print()
-//! [5] //! [6]
-{
- Q_ASSERT(!imageLabel->pixmap(Qt::ReturnByValue).isNull());
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
-//! [6] //! [7]
- QPrintDialog dialog(&printer, this);
-//! [7] //! [8]
- if (dialog.exec()) {
- QPainter painter(&printer);
- QPixmap pixmap = imageLabel->pixmap(Qt::ReturnByValue);
- QRect rect = painter.viewport();
- QSize size = pixmap.size();
- size.scale(rect.size(), Qt::KeepAspectRatio);
- painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
- painter.setWindow(pixmap.rect());
- painter.drawPixmap(0, 0, pixmap);
- }
-#endif
-}
-//! [8]
-
-void ImageViewer::copy()
-{
-#ifndef QT_NO_CLIPBOARD
- QGuiApplication::clipboard()->setImage(image);
-#endif // !QT_NO_CLIPBOARD
-}
-
-#ifndef QT_NO_CLIPBOARD
-static QImage clipboardImage()
-{
- if (const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData()) {
- if (mimeData->hasImage()) {
- const QImage image = qvariant_cast<QImage>(mimeData->imageData());
- if (!image.isNull())
- return image;
- }
- }
- return QImage();
-}
-#endif // !QT_NO_CLIPBOARD
-
-void ImageViewer::paste()
-{
-#ifndef QT_NO_CLIPBOARD
- const QImage newImage = clipboardImage();
- if (newImage.isNull()) {
- statusBar()->showMessage(tr("No image in clipboard"));
- } else {
- setImage(newImage);
- setWindowFilePath(QString());
- const QString message = tr("Obtained image from clipboard, %1x%2, Depth: %3")
- .arg(newImage.width()).arg(newImage.height()).arg(newImage.depth());
- statusBar()->showMessage(message);
- }
-#endif // !QT_NO_CLIPBOARD
-}
-
-//! [9]
-void ImageViewer::zoomIn()
-//! [9] //! [10]
-{
- scaleImage(1.25);
-}
-
-void ImageViewer::zoomOut()
-{
- scaleImage(0.8);
-}
-
-//! [10] //! [11]
-void ImageViewer::normalSize()
-//! [11] //! [12]
-{
- imageLabel->adjustSize();
- scaleFactor = 1.0;
-}
-//! [12]
-
-//! [13]
-void ImageViewer::fitToWindow()
-//! [13] //! [14]
-{
- bool fitToWindow = fitToWindowAct->isChecked();
- scrollArea->setWidgetResizable(fitToWindow);
- if (!fitToWindow)
- normalSize();
- updateActions();
-}
-//! [14]
-
-
-//! [15]
-void ImageViewer::about()
-//! [15] //! [16]
-{
- QMessageBox::about(this, tr("About Image Viewer"),
- tr("<p>The <b>Image Viewer</b> example shows how to combine QLabel "
- "and QScrollArea to display an image. QLabel is typically used "
- "for displaying a text, but it can also display an image. "
- "QScrollArea provides a scrolling view around another widget. "
- "If the child widget exceeds the size of the frame, QScrollArea "
- "automatically provides scroll bars. </p><p>The example "
- "demonstrates how QLabel's ability to scale its contents "
- "(QLabel::scaledContents), and QScrollArea's ability to "
- "automatically resize its contents "
- "(QScrollArea::widgetResizable), can be used to implement "
- "zooming and scaling features. </p><p>In addition the example "
- "shows how to use QPainter to print an image.</p>"));
-}
-//! [16]
-
-//! [17]
-void ImageViewer::createActions()
-//! [17] //! [18]
-{
- QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
-
- QAction *openAct = fileMenu->addAction(tr("&Open..."), this, &ImageViewer::open);
- openAct->setShortcut(QKeySequence::Open);
-
- saveAsAct = fileMenu->addAction(tr("&Save As..."), this, &ImageViewer::saveAs);
- saveAsAct->setEnabled(false);
-
- printAct = fileMenu->addAction(tr("&Print..."), this, &ImageViewer::print);
- printAct->setShortcut(QKeySequence::Print);
- printAct->setEnabled(false);
-
- fileMenu->addSeparator();
-
- QAction *exitAct = fileMenu->addAction(tr("E&xit"), this, &QWidget::close);
- exitAct->setShortcut(tr("Ctrl+Q"));
-
- QMenu *editMenu = menuBar()->addMenu(tr("&Edit"));
-
- copyAct = editMenu->addAction(tr("&Copy"), this, &ImageViewer::copy);
- copyAct->setShortcut(QKeySequence::Copy);
- copyAct->setEnabled(false);
-
- QAction *pasteAct = editMenu->addAction(tr("&Paste"), this, &ImageViewer::paste);
- pasteAct->setShortcut(QKeySequence::Paste);
-
- QMenu *viewMenu = menuBar()->addMenu(tr("&View"));
-
- zoomInAct = viewMenu->addAction(tr("Zoom &In (25%)"), this, &ImageViewer::zoomIn);
- zoomInAct->setShortcut(QKeySequence::ZoomIn);
- zoomInAct->setEnabled(false);
-
- zoomOutAct = viewMenu->addAction(tr("Zoom &Out (25%)"), this, &ImageViewer::zoomOut);
- zoomOutAct->setShortcut(QKeySequence::ZoomOut);
- zoomOutAct->setEnabled(false);
-
- normalSizeAct = viewMenu->addAction(tr("&Normal Size"), this, &ImageViewer::normalSize);
- normalSizeAct->setShortcut(tr("Ctrl+S"));
- normalSizeAct->setEnabled(false);
-
- viewMenu->addSeparator();
-
- fitToWindowAct = viewMenu->addAction(tr("&Fit to Window"), this, &ImageViewer::fitToWindow);
- fitToWindowAct->setEnabled(false);
- fitToWindowAct->setCheckable(true);
- fitToWindowAct->setShortcut(tr("Ctrl+F"));
-
- QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
-
- helpMenu->addAction(tr("&About"), this, &ImageViewer::about);
- helpMenu->addAction(tr("About &Qt"), this, &QApplication::aboutQt);
-}
-//! [18]
-
-//! [21]
-void ImageViewer::updateActions()
-//! [21] //! [22]
-{
- saveAsAct->setEnabled(!image.isNull());
- copyAct->setEnabled(!image.isNull());
- zoomInAct->setEnabled(!fitToWindowAct->isChecked());
- zoomOutAct->setEnabled(!fitToWindowAct->isChecked());
- normalSizeAct->setEnabled(!fitToWindowAct->isChecked());
-}
-//! [22]
-
-//! [23]
-void ImageViewer::scaleImage(double factor)
-//! [23] //! [24]
-{
- scaleFactor *= factor;
- imageLabel->resize(scaleFactor * imageLabel->pixmap(Qt::ReturnByValue).size());
-
- adjustScrollBar(scrollArea->horizontalScrollBar(), factor);
- adjustScrollBar(scrollArea->verticalScrollBar(), factor);
-
- zoomInAct->setEnabled(scaleFactor < 3.0);
- zoomOutAct->setEnabled(scaleFactor > 0.333);
-}
-//! [24]
-
-//! [25]
-void ImageViewer::adjustScrollBar(QScrollBar *scrollBar, double factor)
-//! [25] //! [26]
-{
- scrollBar->setValue(int(factor * scrollBar->value()
- + ((factor - 1) * scrollBar->pageStep()/2)));
-}
-//! [26]
diff --git a/examples/widgets/widgets/imageviewer/imageviewer.h b/examples/widgets/widgets/imageviewer/imageviewer.h
deleted file mode 100644
index e9e6858c74..0000000000
--- a/examples/widgets/widgets/imageviewer/imageviewer.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef IMAGEVIEWER_H
-#define IMAGEVIEWER_H
-
-#include <QMainWindow>
-#include <QImage>
-#if defined(QT_PRINTSUPPORT_LIB)
-# include <QtPrintSupport/qtprintsupportglobal.h>
-
-# if QT_CONFIG(printer)
-# include <QPrinter>
-# endif
-#endif
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QLabel;
-class QMenu;
-class QScrollArea;
-class QScrollBar;
-QT_END_NAMESPACE
-
-//! [0]
-class ImageViewer : public QMainWindow
-{
- Q_OBJECT
-
-public:
- ImageViewer(QWidget *parent = nullptr);
- bool loadFile(const QString &);
-
-private slots:
- void open();
- void saveAs();
- void print();
- void copy();
- void paste();
- void zoomIn();
- void zoomOut();
- void normalSize();
- void fitToWindow();
- void about();
-
-private:
- void createActions();
- void createMenus();
- void updateActions();
- bool saveFile(const QString &fileName);
- void setImage(const QImage &newImage);
- void scaleImage(double factor);
- void adjustScrollBar(QScrollBar *scrollBar, double factor);
-
- QImage image;
- QLabel *imageLabel;
- QScrollArea *scrollArea;
- double scaleFactor = 1;
-
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
- QPrinter printer;
-#endif
-
- QAction *saveAsAct;
- QAction *printAct;
- QAction *copyAct;
- QAction *zoomInAct;
- QAction *zoomOutAct;
- QAction *normalSizeAct;
- QAction *fitToWindowAct;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/imageviewer/imageviewer.pro b/examples/widgets/widgets/imageviewer/imageviewer.pro
deleted file mode 100644
index d3db63ec20..0000000000
--- a/examples/widgets/widgets/imageviewer/imageviewer.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += widgets
-requires(qtConfig(filedialog))
-qtHaveModule(printsupport): QT += printsupport
-
-HEADERS = imageviewer.h
-SOURCES = imageviewer.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/imageviewer
-INSTALLS += target
diff --git a/examples/widgets/widgets/imageviewer/main.cpp b/examples/widgets/widgets/imageviewer/main.cpp
deleted file mode 100644
index 013f7d8689..0000000000
--- a/examples/widgets/widgets/imageviewer/main.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-#include <QCommandLineParser>
-
-#include "imageviewer.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- QGuiApplication::setApplicationDisplayName(ImageViewer::tr("Image Viewer"));
- QCommandLineParser commandLineParser;
- commandLineParser.addHelpOption();
- commandLineParser.addPositionalArgument(ImageViewer::tr("[file]"), ImageViewer::tr("Image file to open."));
- commandLineParser.process(QCoreApplication::arguments());
- ImageViewer imageViewer;
- if (!commandLineParser.positionalArguments().isEmpty()
- && !imageViewer.loadFile(commandLineParser.positionalArguments().constFirst())) {
- return -1;
- }
- imageViewer.show();
- return app.exec();
-}
diff --git a/examples/widgets/widgets/lineedits/CMakeLists.txt b/examples/widgets/widgets/lineedits/CMakeLists.txt
index 988e82a534..9cfaa784c8 100644
--- a/examples/widgets/widgets/lineedits/CMakeLists.txt
+++ b/examples/widgets/widgets/lineedits/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(lineedits LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/lineedits")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(lineedits
main.cpp
window.cpp window.h
@@ -24,14 +18,21 @@ set_target_properties(lineedits PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(lineedits PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(lineedits PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS lineedits
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET lineedits
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/widgets/mousebuttons/CMakeLists.txt b/examples/widgets/widgets/mousebuttons/CMakeLists.txt
deleted file mode 100644
index 79e7048eed..0000000000
--- a/examples/widgets/widgets/mousebuttons/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(mousebuttons LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/mousebuttons")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(mousebuttons
- buttontester.cpp buttontester.h
- main.cpp
-)
-
-set_target_properties(mousebuttons PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(mousebuttons PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS mousebuttons
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/mousebuttons/buttontester.cpp b/examples/widgets/widgets/mousebuttons/buttontester.cpp
deleted file mode 100644
index f2cbd4ea06..0000000000
--- a/examples/widgets/widgets/mousebuttons/buttontester.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// Copyright (C) 2016 Rick Stockton <rickstockton@reno-computerhelp.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "buttontester.h"
-
-#include <QDebug>
-
-void ButtonTester::mousePressEvent(QMouseEvent *e)
-{
- int j = ButtonTester::buttonByNumber (e->button());
- QString result = "Mouse Press: raw button=" + QString::number(j)
- + " Qt=" + enumNameFromValue(e->button());
- QString buttonsString = ButtonTester::enumNamesFromMouseButtons(e->buttons());
- result += "\n heldbuttons " + buttonsString;
- qDebug() << result;
- this->setText(result);
- this->repaint();
-}
-
-void ButtonTester::mouseReleaseEvent(QMouseEvent *e)
-{
- int j = ButtonTester::buttonByNumber (e->button());
- QString result = "Mouse Release: raw button=" + QString::number(j)
- + " Qt=" + enumNameFromValue(e->button());
- QString buttonsString = ButtonTester::enumNamesFromMouseButtons(e->buttons());
- result += "\n heldbuttons " + buttonsString;
- qDebug() << result;
- this->setText(result);
- this->repaint();
-
-}
-
-void ButtonTester::mouseDoubleClickEvent(QMouseEvent *e)
-{
- int j = ButtonTester::buttonByNumber (e->button());
- QString result = "Mouse DoubleClick: raw button=" + QString::number(j)
- + " Qt=" + enumNameFromValue(e->button());
- QString buttonsString = ButtonTester::enumNamesFromMouseButtons(e->buttons());
- result += "\n heldbuttons" + buttonsString;
- qDebug() << result;
- this->setText(result);
-}
-
-#if QT_CONFIG(wheelevent)
-void ButtonTester::wheelEvent (QWheelEvent *e)
-{
- QString result;
- const bool vertical = qAbs(e->angleDelta().y()) >= qAbs(e->angleDelta().x());
- const int delta = vertical ? e->angleDelta().y() : e->angleDelta().x();
- if (delta > 0) {
- if (vertical) {
- result = "Mouse Wheel Event: UP";
- } else {
- result = "Mouse Wheel Event: LEFT";
- }
- } else if (delta < 0) {
- if (vertical) {
- result = "Mouse Wheel Event: DOWN";
- } else {
- result = "Mouse Wheel Event: RIGHT";
- }
- }
- qDebug() << result;
- this->setText(result);
-}
-#endif
-
-int ButtonTester::buttonByNumber(const Qt::MouseButton button)
-{
- if (button == Qt::NoButton) return 0;
- if (button == Qt::LeftButton) return 1;
- if (button == Qt::RightButton) return 2;
- if (button == Qt::MiddleButton) return 3;
-
-/* Please note that Qt Button #4 corresponds to button #8 on all
- * platforms which EMULATE wheel events by creating button events
- * (Button #4 = Scroll Up; Button #5 = Scroll Down; Button #6 = Scroll
- * Left; and Button #7 = Scroll Right.) This includes X11, with both
- * Xlib and XCB. So, the "raw button" for "Qt::BackButton" is
- * usually described as "Button #8".
-
- * If your platform supports "smooth scrolling", then, for the cases of
- * Qt::BackButton and higher, this program will show "raw button" with a
- * value which is too large. Subtract 4 to get the correct button ID for
- * your platform.
- */
-
- if (button == Qt::BackButton) return 8;
- if (button == Qt::ForwardButton) return 9;
- if (button == Qt::TaskButton) return 10;
- if (button == Qt::ExtraButton4) return 11;
- if (button == Qt::ExtraButton5) return 12;
- if (button == Qt::ExtraButton6) return 13;
- if (button == Qt::ExtraButton7) return 14;
- if (button == Qt::ExtraButton8) return 15;
- if (button == Qt::ExtraButton9) return 16;
- if (button == Qt::ExtraButton10) return 17;
- if (button == Qt::ExtraButton11) return 18;
- if (button == Qt::ExtraButton12) return 19;
- if (button == Qt::ExtraButton13) return 20;
- if (button == Qt::ExtraButton14) return 21;
- if (button == Qt::ExtraButton15) return 22;
- if (button == Qt::ExtraButton16) return 23;
- if (button == Qt::ExtraButton17) return 24;
- if (button == Qt::ExtraButton18) return 25;
- if (button == Qt::ExtraButton19) return 26;
- if (button == Qt::ExtraButton20) return 27;
- if (button == Qt::ExtraButton21) return 28;
- if (button == Qt::ExtraButton22) return 29;
- if (button == Qt::ExtraButton23) return 30;
- if (button == Qt::ExtraButton24) return 31;
- qDebug("QMouseShortcutEntry::addShortcut contained Invalid Qt::MouseButton value");
- return 0;
-}
-
-QString ButtonTester::enumNameFromValue(const Qt::MouseButton button)
-{
- if (button == Qt::NoButton) return "NoButton";
- if (button == Qt::LeftButton) return "LeftButton";
- if (button == Qt::RightButton) return "RightButton";
- if (button == Qt::MiddleButton) return "MiddleButton";
- if (button == Qt::BackButton) return "BackButton";
- if (button == Qt::ForwardButton) return "ForwardButton";
- if (button == Qt::TaskButton) return "TaskButton";
- if (button == Qt::ExtraButton4) return "ExtraButton4";
- if (button == Qt::ExtraButton5) return "ExtraButton5";
- if (button == Qt::ExtraButton6) return "ExtraButton6";
- if (button == Qt::ExtraButton7) return "ExtraButton7";
- if (button == Qt::ExtraButton8) return "ExtraButton8";
- if (button == Qt::ExtraButton9) return "ExtraButton9";
- if (button == Qt::ExtraButton10) return "ExtraButton10";
- if (button == Qt::ExtraButton11) return "ExtraButton11";
- if (button == Qt::ExtraButton12) return "ExtraButton12";
- if (button == Qt::ExtraButton13) return "ExtraButton13";
- if (button == Qt::ExtraButton14) return "ExtraButton14";
- if (button == Qt::ExtraButton15) return "ExtraButton15";
- if (button == Qt::ExtraButton16) return "ExtraButton16";
- if (button == Qt::ExtraButton17) return "ExtraButton17";
- if (button == Qt::ExtraButton18) return "ExtraButton18";
- if (button == Qt::ExtraButton19) return "ExtraButton19";
- if (button == Qt::ExtraButton20) return "ExtraButton20";
- if (button == Qt::ExtraButton21) return "ExtraButton21";
- if (button == Qt::ExtraButton22) return "ExtraButton22";
- if (button == Qt::ExtraButton23) return "ExtraButton23";
- if (button == Qt::ExtraButton24) return "ExtraButton24";
- qDebug("QMouseShortcutEntry::addShortcut contained Invalid Qt::MouseButton value");
- return "NoButton";
-}
-
-QString ButtonTester::enumNamesFromMouseButtons(const Qt::MouseButtons buttons)
-{
- QString returnText = "";
- if (buttons == Qt::NoButton) return "NoButton";
- if (buttons & Qt::LeftButton) returnText += "LeftButton ";
- if (buttons & Qt::RightButton) returnText += "RightButton ";
- if (buttons & Qt::MiddleButton) returnText += "MiddleButton ";
- if (buttons & Qt::BackButton) returnText += "BackButton ";
- if (buttons & Qt::ForwardButton) returnText += "ForwardButton ";
- if (buttons & Qt::TaskButton) returnText += "TaskButton ";
- if (buttons & Qt::ExtraButton4) returnText += "ExtraButton4 ";
- if (buttons & Qt::ExtraButton5) returnText += "ExtraButton5 ";
- if (buttons & Qt::ExtraButton6) returnText += "ExtraButton6 ";
- if (buttons & Qt::ExtraButton7) returnText += "ExtraButton7 ";
- if (buttons & Qt::ExtraButton8) returnText += "ExtraButton8 ";
- if (buttons & Qt::ExtraButton9) returnText += "ExtraButton9 ";
- if (buttons & Qt::ExtraButton10) returnText += "ExtraButton10 ";
- if (buttons & Qt::ExtraButton11) returnText += "ExtraButton11 ";
- if (buttons & Qt::ExtraButton12) returnText += "ExtraButton12 ";
- if (buttons & Qt::ExtraButton13) returnText += "ExtraButton13 ";
- if (buttons & Qt::ExtraButton14) returnText += "ExtraButton14 ";
- if (buttons & Qt::ExtraButton15) returnText += "ExtraButton15 ";
- if (buttons & Qt::ExtraButton16) returnText += "ExtraButton16 ";
- if (buttons & Qt::ExtraButton17) returnText += "ExtraButton17 ";
- if (buttons & Qt::ExtraButton18) returnText += "ExtraButton18 ";
- if (buttons & Qt::ExtraButton19) returnText += "ExtraButton19 ";
- if (buttons & Qt::ExtraButton20) returnText += "ExtraButton20 ";
- if (buttons & Qt::ExtraButton21) returnText += "ExtraButton21 ";
- if (buttons & Qt::ExtraButton22) returnText += "ExtraButton22 ";
- if (buttons & Qt::ExtraButton23) returnText += "ExtraButton23 ";
- if (buttons & Qt::ExtraButton24) returnText += "ExtraButton24 ";
- return returnText;
-}
-
diff --git a/examples/widgets/widgets/mousebuttons/buttontester.h b/examples/widgets/widgets/mousebuttons/buttontester.h
deleted file mode 100644
index b2670c773a..0000000000
--- a/examples/widgets/widgets/mousebuttons/buttontester.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// Copyright (C) 2016 Rick Stockton <rickstockton@reno-computerhelp.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#ifndef BUTTONTESTER_H
-#define BUTTONTESTER_H
-
-#include <QTextEdit>
-#include <QString>
-#include <QMouseEvent>
-#include <QWheelEvent>
-
-class ButtonTester : public QTextEdit
-{
- Q_OBJECT
-public:
- using QTextEdit::QTextEdit;
-protected:
- void mousePressEvent(QMouseEvent *event) override;
- void mouseReleaseEvent(QMouseEvent *event) override;
- void mouseDoubleClickEvent(QMouseEvent *event) override;
-#if QT_CONFIG(wheelevent)
- void wheelEvent(QWheelEvent *event) override;
-#endif
- int buttonByNumber(const Qt::MouseButton button);
- QString enumNameFromValue(const Qt::MouseButton button);
- QString enumNamesFromMouseButtons(const Qt::MouseButtons buttons);
-};
-
-#endif // BUTTONTESTER_H
diff --git a/examples/widgets/widgets/mousebuttons/main.cpp b/examples/widgets/widgets/mousebuttons/main.cpp
deleted file mode 100644
index 850e0c7999..0000000000
--- a/examples/widgets/widgets/mousebuttons/main.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// Copyright (C) 2016 Rick Stockton <rickstockton@reno-computerhelp.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "buttontester.h"
-
-#include <QApplication>
-#include <QPushButton>
-#include <QVBoxLayout>
-
-int main(int argv, char **args)
-{
- QApplication app(argv, args);
-
- ButtonTester *testArea = new ButtonTester;
- testArea->setMinimumSize(500, 350);
-
-// For this test, Qt::RightButton behaves like any other button.
- testArea->setContextMenuPolicy(Qt::NoContextMenu);
- testArea->setTextInteractionFlags(Qt::TextSelectableByMouse);
- testArea->setText("To test your mouse with Qt, press buttons in this area.\nYou may also scroll or tilt your mouse wheel.");
- QPushButton *quitButton = new QPushButton("Quit");
-
- QObject::connect(quitButton, &QPushButton::clicked, qApp, &QCoreApplication::quit);
-
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(testArea);
- layout->addWidget(quitButton);
-
- QWidget window;
- window.setLayout(layout);
- window.setWindowTitle("Mouse Button Tester");
- window.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/widgets/mousebuttons/mousebuttons.pro b/examples/widgets/widgets/mousebuttons/mousebuttons.pro
deleted file mode 100644
index e1f4b9527d..0000000000
--- a/examples/widgets/widgets/mousebuttons/mousebuttons.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TEMPLATE = app
-
-TARGET = mousebuttons
-TEMPLATE = app
-
-SOURCES += \
- main.cpp\
- buttontester.cpp \
-
-HEADERS += \
- buttontester.h \
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/mousebuttons
-INSTALLS += target
-QT += core widgets
diff --git a/examples/widgets/widgets/movie/CMakeLists.txt b/examples/widgets/widgets/movie/CMakeLists.txt
deleted file mode 100644
index 89e2adb7da..0000000000
--- a/examples/widgets/widgets/movie/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(movie LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/movie")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(movie
- main.cpp
- movieplayer.cpp movieplayer.h
-)
-
-set_target_properties(movie PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(movie PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS movie
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/movie/animation.gif b/examples/widgets/widgets/movie/animation.gif
deleted file mode 100644
index f674369efc..0000000000
--- a/examples/widgets/widgets/movie/animation.gif
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/movie/main.cpp b/examples/widgets/widgets/movie/main.cpp
deleted file mode 100644
index e5d4d3f040..0000000000
--- a/examples/widgets/widgets/movie/main.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "movieplayer.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- MoviePlayer player;
- player.show();
- player.show();
- return app.exec();
-}
diff --git a/examples/widgets/widgets/movie/movie.pro b/examples/widgets/widgets/movie/movie.pro
deleted file mode 100644
index f9f89109e4..0000000000
--- a/examples/widgets/widgets/movie/movie.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-QT += widgets
-requires(qtConfig(filedialog))
-
-HEADERS = movieplayer.h
-SOURCES = main.cpp \
- movieplayer.cpp
-
-EXAMPLE_FILES = animation.gif
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/movie
-INSTALLS += target
diff --git a/examples/widgets/widgets/movie/movieplayer.cpp b/examples/widgets/widgets/movie/movieplayer.cpp
deleted file mode 100644
index 6f6ec14bb1..0000000000
--- a/examples/widgets/widgets/movie/movieplayer.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "movieplayer.h"
-
-#include <QCheckBox>
-#include <QFileDialog>
-#include <QLabel>
-#include <QMovie>
-#include <QSlider>
-#include <QSpinBox>
-#include <QStyle>
-#include <QToolButton>
-#include <QVBoxLayout>
-
-MoviePlayer::MoviePlayer(QWidget *parent)
- : QWidget(parent)
-{
- movie = new QMovie(this);
- movie->setCacheMode(QMovie::CacheAll);
-
- movieLabel = new QLabel(tr("No movie loaded"));
- movieLabel->setAlignment(Qt::AlignCenter);
- movieLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
- movieLabel->setBackgroundRole(QPalette::Dark);
- movieLabel->setAutoFillBackground(true);
-
- currentMovieDirectory = "movies";
-
- createControls();
- createButtons();
-
- connect(movie, &QMovie::frameChanged, this, &MoviePlayer::updateFrameSlider);
- connect(movie, &QMovie::stateChanged, this, &MoviePlayer::updateButtons);
- connect(fitCheckBox, &QCheckBox::clicked, this, &MoviePlayer::fitToWindow);
- connect(frameSlider, &QSlider::valueChanged, this, &MoviePlayer::goToFrame);
- connect(speedSpinBox, &QSpinBox::valueChanged,
- movie, &QMovie::setSpeed);
-
- mainLayout = new QVBoxLayout;
- mainLayout->addWidget(movieLabel);
- mainLayout->addLayout(controlsLayout);
- mainLayout->addLayout(buttonsLayout);
- setLayout(mainLayout);
-
- updateFrameSlider();
- updateButtons();
-
- setWindowTitle(tr("Movie Player"));
- resize(400, 400);
-}
-
-void MoviePlayer::open()
-{
- QString fileName = QFileDialog::getOpenFileName(this, tr("Open a Movie"),
- currentMovieDirectory);
- if (!fileName.isEmpty())
- openFile(fileName);
-}
-
-void MoviePlayer::openFile(const QString &fileName)
-{
- currentMovieDirectory = QFileInfo(fileName).path();
-
- movie->stop();
- movieLabel->setMovie(movie);
- movie->setFileName(fileName);
- movie->start();
-
- updateFrameSlider();
- updateButtons();
-}
-
-void MoviePlayer::goToFrame(int frame)
-{
- movie->jumpToFrame(frame);
-}
-
-void MoviePlayer::fitToWindow()
-{
- movieLabel->setScaledContents(fitCheckBox->isChecked());
-}
-
-void MoviePlayer::updateFrameSlider()
-{
- bool hasFrames = (movie->currentFrameNumber() >= 0);
-
- if (hasFrames) {
- if (movie->frameCount() > 0) {
- frameSlider->setMaximum(movie->frameCount() - 1);
- } else {
- if (movie->currentFrameNumber() > frameSlider->maximum())
- frameSlider->setMaximum(movie->currentFrameNumber());
- }
- frameSlider->setValue(movie->currentFrameNumber());
- } else {
- frameSlider->setMaximum(0);
- }
- frameLabel->setEnabled(hasFrames);
- frameSlider->setEnabled(hasFrames);
-}
-
-void MoviePlayer::updateButtons()
-{
- playButton->setEnabled(movie->isValid() && movie->frameCount() != 1
- && movie->state() == QMovie::NotRunning);
- pauseButton->setEnabled(movie->state() != QMovie::NotRunning);
- pauseButton->setChecked(movie->state() == QMovie::Paused);
- stopButton->setEnabled(movie->state() != QMovie::NotRunning);
-}
-
-void MoviePlayer::createControls()
-{
- fitCheckBox = new QCheckBox(tr("Fit to Window"));
-
- frameLabel = new QLabel(tr("Current frame:"));
-
- frameSlider = new QSlider(Qt::Horizontal);
- frameSlider->setTickPosition(QSlider::TicksBelow);
- frameSlider->setTickInterval(10);
-
- speedLabel = new QLabel(tr("Speed:"));
-
- speedSpinBox = new QSpinBox;
- speedSpinBox->setRange(1, 9999);
- speedSpinBox->setValue(100);
- speedSpinBox->setSuffix(tr("%"));
-
- controlsLayout = new QGridLayout;
- controlsLayout->addWidget(fitCheckBox, 0, 0, 1, 2);
- controlsLayout->addWidget(frameLabel, 1, 0);
- controlsLayout->addWidget(frameSlider, 1, 1, 1, 2);
- controlsLayout->addWidget(speedLabel, 2, 0);
- controlsLayout->addWidget(speedSpinBox, 2, 1);
-}
-
-void MoviePlayer::createButtons()
-{
- QSize iconSize(36, 36);
-
- openButton = new QToolButton;
- openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton));
- openButton->setIconSize(iconSize);
- openButton->setToolTip(tr("Open File"));
- connect(openButton, &QToolButton::clicked, this, &MoviePlayer::open);
-
- playButton = new QToolButton;
- playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
- playButton->setIconSize(iconSize);
- playButton->setToolTip(tr("Play"));
- connect(playButton, &QToolButton::clicked, movie, &QMovie::start);
-
- pauseButton = new QToolButton;
- pauseButton->setCheckable(true);
- pauseButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
- pauseButton->setIconSize(iconSize);
- pauseButton->setToolTip(tr("Pause"));
- connect(pauseButton, &QToolButton::clicked, movie, &QMovie::setPaused);
-
- stopButton = new QToolButton;
- stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
- stopButton->setIconSize(iconSize);
- stopButton->setToolTip(tr("Stop"));
- connect(stopButton, &QToolButton::clicked, movie, &QMovie::stop);
-
- quitButton = new QToolButton;
- quitButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
- quitButton->setIconSize(iconSize);
- quitButton->setToolTip(tr("Quit"));
- connect(quitButton, &QToolButton::clicked, this, &MoviePlayer::close);
-
- buttonsLayout = new QHBoxLayout;
- buttonsLayout->addStretch();
- buttonsLayout->addWidget(openButton);
- buttonsLayout->addWidget(playButton);
- buttonsLayout->addWidget(pauseButton);
- buttonsLayout->addWidget(stopButton);
- buttonsLayout->addWidget(quitButton);
- buttonsLayout->addStretch();
-}
diff --git a/examples/widgets/widgets/movie/movieplayer.h b/examples/widgets/widgets/movie/movieplayer.h
deleted file mode 100644
index 362fd50535..0000000000
--- a/examples/widgets/widgets/movie/movieplayer.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MOVIEPLAYER_H
-#define MOVIEPLAYER_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QCheckBox;
-class QGridLayout;
-class QHBoxLayout;
-class QLabel;
-class QMovie;
-class QSlider;
-class QSpinBox;
-class QToolButton;
-class QVBoxLayout;
-QT_END_NAMESPACE
-
-class MoviePlayer : public QWidget
-{
- Q_OBJECT
-
-public:
- MoviePlayer(QWidget *parent = nullptr);
- void openFile(const QString &fileName);
-
-private slots:
- void open();
- void goToFrame(int frame);
- void fitToWindow();
- void updateButtons();
- void updateFrameSlider();
-
-private:
- void createControls();
- void createButtons();
-
- QString currentMovieDirectory;
- QLabel *movieLabel;
- QMovie *movie;
- QToolButton *openButton;
- QToolButton *playButton;
- QToolButton *pauseButton;
- QToolButton *stopButton;
- QToolButton *quitButton;
- QCheckBox *fitCheckBox;
- QSlider *frameSlider;
- QSpinBox *speedSpinBox;
- QLabel *frameLabel;
- QLabel *speedLabel;
-
- QGridLayout *controlsLayout;
- QHBoxLayout *buttonsLayout;
- QVBoxLayout *mainLayout;
-};
-
-#endif
diff --git a/examples/widgets/widgets/scribble/CMakeLists.txt b/examples/widgets/widgets/scribble/CMakeLists.txt
index 4efce5a0c1..ec78b1ece8 100644
--- a/examples/widgets/widgets/scribble/CMakeLists.txt
+++ b/examples/widgets/widgets/scribble/CMakeLists.txt
@@ -1,22 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(scribble LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/scribble")
-
find_package(Qt6
REQUIRED COMPONENTS Core Gui Widgets
OPTIONAL_COMPONENTS PrintSupport
)
+qt_standard_project_setup()
+
qt_add_executable(scribble
main.cpp
mainwindow.cpp mainwindow.h
@@ -28,24 +22,25 @@ set_target_properties(scribble PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(scribble PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(scribble PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
-if (TARGET Qt::PrintSupport)
- target_link_libraries(scribble PUBLIC Qt::PrintSupport)
-endif()
-
-if(TARGET Qt::PrintSupport)
- target_link_libraries(scribble PUBLIC
- Qt::PrintSupport
- )
+if (TARGET Qt6::PrintSupport)
+ target_link_libraries(scribble PRIVATE Qt6::PrintSupport)
endif()
install(TARGETS scribble
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET scribble
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/widgets/scribble/mainwindow.cpp b/examples/widgets/widgets/scribble/mainwindow.cpp
index b7e08598f7..0a0a658265 100644
--- a/examples/widgets/widgets/scribble/mainwindow.cpp
+++ b/examples/widgets/widgets/scribble/mainwindow.cpp
@@ -153,7 +153,7 @@ void MainWindow::createMenus()
//! [15] //! [16]
{
saveAsMenu = new QMenu(tr("&Save As"), this);
- for (QAction *action : qAsConst(saveAsActs))
+ for (QAction *action : std::as_const(saveAsActs))
saveAsMenu->addAction(action);
fileMenu = new QMenu(tr("&File"), this);
diff --git a/examples/widgets/widgets/shapedclock/CMakeLists.txt b/examples/widgets/widgets/shapedclock/CMakeLists.txt
index c0cd5eac8c..dd8dc217ef 100644
--- a/examples/widgets/widgets/shapedclock/CMakeLists.txt
+++ b/examples/widgets/widgets/shapedclock/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(shapedclock LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/shapedclock")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(shapedclock
main.cpp
shapedclock.cpp shapedclock.h
@@ -24,14 +18,21 @@ set_target_properties(shapedclock PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(shapedclock PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(shapedclock PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS shapedclock
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET shapedclock
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/widgets/shapedclock/shapedclock.cpp b/examples/widgets/widgets/shapedclock/shapedclock.cpp
index 5cc4a54016..106b3454a6 100644
--- a/examples/widgets/widgets/shapedclock/shapedclock.cpp
+++ b/examples/widgets/widgets/shapedclock/shapedclock.cpp
@@ -54,23 +54,30 @@ void ShapedClock::mouseMoveEvent(QMouseEvent *event)
//! [3]
void ShapedClock::paintEvent(QPaintEvent *)
{
- static const QPoint hourHand[3] = {
- QPoint(7, 8),
- QPoint(-7, 8),
- QPoint(0, -40)
+ static const QPoint hourHand[4] = {
+ QPoint(5, 14),
+ QPoint(-5, 14),
+ QPoint(-4, -71),
+ QPoint(4, -71)
};
- static const QPoint minuteHand[3] = {
- QPoint(7, 8),
- QPoint(-7, 8),
- QPoint(0, -70)
+ static const QPoint minuteHand[4] = {
+ QPoint(4, 14),
+ QPoint(-4, 14),
+ QPoint(-3, -89),
+ QPoint(3, -89)
+ };
+ static const QPoint secondsHand[4] = {
+ QPoint(1, 14),
+ QPoint(-1, 14),
+ QPoint(-1, -89),
+ QPoint(1, -89)
};
- QColor hourColor(127, 0, 127);
- QColor minuteColor(0, 127, 127, 191);
+ const QColor hourColor(palette().color(QPalette::Text));
+ const QColor minuteColor(palette().color(QPalette::Text));
+ const QColor secondsColor(palette().color(QPalette::Accent));
int side = qMin(width(), height());
- QTime time = QTime::currentTime();
-
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.translate(width() / 2, height() / 2);
@@ -78,54 +85,52 @@ void ShapedClock::paintEvent(QPaintEvent *)
painter.setPen(Qt::NoPen);
painter.setBrush(palette().window());
+ painter.setOpacity(0.9);
painter.drawEllipse(QPoint(0, 0), 98, 98);
+ painter.setOpacity(1.0);
+ QTime time = QTime::currentTime();
painter.setPen(Qt::NoPen);
painter.setBrush(hourColor);
painter.save();
painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0)));
- painter.drawConvexPolygon(hourHand, 3);
+ painter.drawConvexPolygon(hourHand, 4);
painter.restore();
- painter.setPen(hourColor);
-
for (int i = 0; i < 12; ++i) {
- painter.drawLine(88, 0, 96, 0);
+ painter.drawRect(73, -3, 16, 6);
painter.rotate(30.0);
}
- painter.setPen(Qt::NoPen);
painter.setBrush(minuteColor);
painter.save();
- painter.rotate(6.0 * (time.minute() + time.second() / 60.0));
- painter.drawConvexPolygon(minuteHand, 3);
+ painter.rotate(6.0 * time.minute());
+ painter.drawConvexPolygon(minuteHand, 4);
+ painter.restore();
+
+ painter.setBrush(secondsColor);
+
+ painter.save();
+ painter.rotate(6.0 * time.second());
+ painter.drawConvexPolygon(secondsHand, 4);
+ painter.drawEllipse(-3, -3, 6, 6);
+ painter.drawEllipse(-5, -68, 10, 10);
painter.restore();
painter.setPen(minuteColor);
for (int j = 0; j < 60; ++j) {
- if ((j % 5) != 0)
- painter.drawLine(92, 0, 96, 0);
+ painter.drawLine(92, 0, 96, 0);
painter.rotate(6.0);
}
}
//! [3]
//! [4]
-void ShapedClock::resizeEvent(QResizeEvent * /* event */)
-{
- int side = qMin(width(), height());
- QRegion maskedRegion(width() / 2 - side / 2, height() / 2 - side / 2, side,
- side, QRegion::Ellipse);
- setMask(maskedRegion);
-}
-//! [4]
-
-//! [5]
QSize ShapedClock::sizeHint() const
{
return QSize(200, 200);
}
-//! [5]
+//! [4]
diff --git a/examples/widgets/widgets/shapedclock/shapedclock.h b/examples/widgets/widgets/shapedclock/shapedclock.h
index c359a3a083..3dec93cc74 100644
--- a/examples/widgets/widgets/shapedclock/shapedclock.h
+++ b/examples/widgets/widgets/shapedclock/shapedclock.h
@@ -19,7 +19,6 @@ protected:
void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *event) override;
- void resizeEvent(QResizeEvent *event) override;
private:
QPoint dragPosition;
diff --git a/examples/widgets/widgets/shortcuteditor/CMakeLists.txt b/examples/widgets/widgets/shortcuteditor/CMakeLists.txt
new file mode 100644
index 0000000000..5d1c4a8dc1
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/CMakeLists.txt
@@ -0,0 +1,40 @@
+cmake_minimum_required(VERSION 3.16)
+project(shortcuteditor LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(shortcuteditor
+ actionmanager.cpp actionmanager.h
+ application.cpp application.h
+ main.cpp
+ mainwindow.cpp mainwindow.h
+ shortcuteditordelegate.cpp shortcuteditordelegate.h
+ shortcuteditormodel.cpp shortcuteditormodel.h
+ shortcuteditorwidget.cpp shortcuteditorwidget.h
+)
+
+set_target_properties(shortcuteditor PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(shortcuteditor PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+)
+
+install(TARGETS shortcuteditor
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET shortcuteditor
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/widgets/shortcuteditor/actionmanager.cpp b/examples/widgets/widgets/shortcuteditor/actionmanager.cpp
new file mode 100644
index 0000000000..cfe5f42674
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/actionmanager.cpp
@@ -0,0 +1,57 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "actionmanager.h"
+
+#include <QAction>
+#include <QApplication>
+#include <QString>
+#include <QVariant>
+
+static const char *kDefaultShortcutPropertyName = "defaultShortcuts";
+static const char *kIdPropertyName = "id";
+static const char *kAuthorName = "qt";
+
+struct ActionIdentifier {
+ QString author;
+ QString context;
+ QString category;
+ QString name;
+};
+
+QList<QAction *> ActionManager::registeredActions() const
+{
+ return m_actions;
+}
+
+void ActionManager::registerAction(QAction *action)
+{
+ action->setProperty(kDefaultShortcutPropertyName, QVariant::fromValue(action->shortcut()));
+ m_actions.append(action);
+}
+
+void ActionManager::registerAction(QAction *action, const QString &context, const QString &category)
+{
+ action->setProperty(kIdPropertyName, QVariant::fromValue(ActionIdentifier{
+ kAuthorName, context, category, action->text()
+ }));
+ registerAction(action);
+}
+
+QAction *ActionManager::registerAction(const QString &name, const QString &shortcut, const QString &context, const QString &category)
+{
+ QAction *action = new QAction(name, qApp);
+ action->setShortcut(QKeySequence(shortcut));
+ registerAction(action, context, category);
+ return action;
+}
+
+QString ActionManager::contextForAction(QAction *action)
+{
+ return action->property(kIdPropertyName).value<ActionIdentifier>().context;
+}
+
+QString ActionManager::categoryForAction(QAction *action)
+{
+ return action->property(kIdPropertyName).value<ActionIdentifier>().category;
+}
diff --git a/examples/widgets/widgets/shortcuteditor/actionmanager.h b/examples/widgets/widgets/shortcuteditor/actionmanager.h
new file mode 100644
index 0000000000..da20cd8840
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/actionmanager.h
@@ -0,0 +1,33 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef ACTIONMANAGER_H
+#define ACTIONMANAGER_H
+
+#include <QList>
+#include <QString>
+
+QT_BEGIN_NAMESPACE
+class QAction;
+QT_END_NAMESPACE
+
+class ActionManager
+{
+public:
+ ActionManager() = default;
+ ~ActionManager() = default;
+
+ QList<QAction*> registeredActions() const;
+
+ void registerAction(QAction *action);
+ void registerAction(QAction *action, const QString &context, const QString &category);
+ QAction *registerAction(const QString &name, const QString &shortcut, const QString &context, const QString &category);
+
+ QString contextForAction(QAction *action);
+ QString categoryForAction(QAction *action);
+
+private:
+ QList<QAction *> m_actions;
+};
+
+#endif
diff --git a/examples/widgets/widgets/shortcuteditor/application.cpp b/examples/widgets/widgets/shortcuteditor/application.cpp
new file mode 100644
index 0000000000..4ac76682d0
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/application.cpp
@@ -0,0 +1,15 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "application.h"
+
+Application::Application(int &argc, char **argv)
+ : QApplication(argc, argv)
+{
+ m_actionManager = std::make_unique<ActionManager>();
+}
+
+ActionManager *Application::actionManager() const
+{
+ return m_actionManager.get();
+}
diff --git a/examples/widgets/widgets/shortcuteditor/application.h b/examples/widgets/widgets/shortcuteditor/application.h
new file mode 100644
index 0000000000..38808c3ad2
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/application.h
@@ -0,0 +1,27 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef APPLICATION_H
+#define APPLICATION_H
+
+#include "actionmanager.h"
+
+#include <QApplication>
+
+#include <memory>
+
+class Application : public QApplication
+{
+ Q_OBJECT
+
+public:
+ Application(int &argc, char **argv);
+ ~Application() override = default;
+
+ ActionManager *actionManager() const;
+
+private:
+ std::unique_ptr<ActionManager> m_actionManager;
+};
+
+#endif
diff --git a/examples/widgets/widgets/charactermap/main.cpp b/examples/widgets/widgets/shortcuteditor/main.cpp
index 7d7cf3e573..029f7a351a 100644
--- a/examples/widgets/widgets/charactermap/main.cpp
+++ b/examples/widgets/widgets/shortcuteditor/main.cpp
@@ -1,13 +1,12 @@
-// Copyright (C) 2016 The Qt Company Ltd.
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include <QApplication>
-
+#include "application.h"
#include "mainwindow.h"
int main(int argc, char *argv[])
{
- QApplication app(argc, argv);
+ Application app(argc, argv);
MainWindow window;
window.show();
return app.exec();
diff --git a/examples/widgets/widgets/shortcuteditor/mainwindow.cpp b/examples/widgets/widgets/shortcuteditor/mainwindow.cpp
new file mode 100644
index 0000000000..587dbbc5b5
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/mainwindow.cpp
@@ -0,0 +1,46 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "mainwindow.h"
+
+#include "actionmanager.h"
+#include "application.h"
+#include "shortcuteditorwidget.h"
+
+#include <QAction>
+#include <QHBoxLayout>
+#include <QPushButton>
+#include <QVBoxLayout>
+
+MainWindow::MainWindow()
+{
+ QPushButton *topPushButton = new QPushButton("Left");
+ QPushButton *bottomPushButton = new QPushButton("Right");
+ for (auto nameShortcut : std::vector<std::vector<const char *>>{{"red", "r", "shift+r"}, {"green", "g", "shift+g"}, {"blue", "b", "shift+b"}}) {
+ Application *application = static_cast<Application *>(QCoreApplication::instance());
+ ActionManager *actionManager = application->actionManager();
+ QAction *action = actionManager->registerAction(nameShortcut[0], nameShortcut[1], "top", "color");
+ topPushButton->addAction(action);
+ connect(action, &QAction::triggered, this, [topPushButton, nameShortcut]() {
+ topPushButton->setText(nameShortcut[0]);
+ });
+
+ action = actionManager->registerAction(nameShortcut[0], nameShortcut[2], "bottom", "color");
+ bottomPushButton->addAction(action);
+ connect(action, &QAction::triggered, this, [bottomPushButton, nameShortcut]() {
+ bottomPushButton->setText(nameShortcut[0]);
+ });
+ }
+
+ QVBoxLayout *vBoxLayout = new QVBoxLayout;
+ vBoxLayout->addWidget(topPushButton);
+ vBoxLayout->addWidget(bottomPushButton);
+
+ QHBoxLayout *hBoxLayout = new QHBoxLayout;
+ hBoxLayout->addWidget(new ShortcutEditorWidget);
+ hBoxLayout->addLayout(vBoxLayout);
+
+ QWidget *centralWidget = new QWidget;
+ centralWidget->setLayout(hBoxLayout);
+ setCentralWidget(centralWidget);
+}
diff --git a/examples/widgets/widgets/shortcuteditor/mainwindow.h b/examples/widgets/widgets/shortcuteditor/mainwindow.h
new file mode 100644
index 0000000000..702b3f2d87
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/mainwindow.h
@@ -0,0 +1,22 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+QT_BEGIN_NAMESPACE
+class QPushButton;
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+ ~MainWindow() override = default;
+};
+
+#endif
diff --git a/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.cpp b/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.cpp
new file mode 100644
index 0000000000..a8b32bc06a
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.cpp
@@ -0,0 +1,71 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "shortcuteditordelegate.h"
+
+#include <QAbstractItemModel>
+#include <QKeySequenceEdit>
+
+//! [0]
+ShortcutEditorDelegate::ShortcutEditorDelegate(QObject *parent)
+ : QStyledItemDelegate(parent)
+{
+}
+//! [0]
+
+//! [1]
+QWidget *ShortcutEditorDelegate::createEditor(QWidget *parent,
+ const QStyleOptionViewItem &/*option*/,
+ const QModelIndex &/*index*/) const
+{
+ QKeySequenceEdit *editor = new QKeySequenceEdit(parent);
+ connect(editor, &QKeySequenceEdit::editingFinished, this, &ShortcutEditorDelegate::commitAndCloseEditor);
+ return editor;
+}
+//! [1]
+
+//! [2]
+void ShortcutEditorDelegate::commitAndCloseEditor()
+{
+ QKeySequenceEdit *editor = static_cast<QKeySequenceEdit *>(sender());
+ Q_EMIT commitData(editor);
+ Q_EMIT closeEditor(editor);
+}
+//! [2]
+
+//! [3]
+void ShortcutEditorDelegate::setEditorData(QWidget *editor,
+ const QModelIndex &index) const
+{
+ if (!editor || !index.isValid())
+ return;
+
+ QString value = index.model()->data(index, Qt::EditRole).toString();
+
+ QKeySequenceEdit *keySequenceEdit = static_cast<QKeySequenceEdit *>(editor);
+ keySequenceEdit->setKeySequence(value);
+}
+//! [3]
+
+//! [4]
+void ShortcutEditorDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
+ const QModelIndex &index) const
+{
+ if (!editor || !model || !index.isValid())
+ return;
+
+ const QKeySequenceEdit *keySequenceEdit = static_cast<QKeySequenceEdit *>(editor);
+ const QKeySequence keySequence = keySequenceEdit->keySequence();
+ QString keySequenceString = keySequence.toString(QKeySequence::NativeText);
+ model->setData(index, keySequenceString);
+}
+//! [4]
+
+//! [5]
+void ShortcutEditorDelegate::updateEditorGeometry(QWidget *editor,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &/*index*/) const
+{
+ editor->setGeometry(option.rect);
+}
+//! [5]
diff --git a/examples/widgets/itemviews/spinboxdelegate/delegate.h b/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h
index 8f1130a1d2..2818438db3 100644
--- a/examples/widgets/itemviews/spinboxdelegate/delegate.h
+++ b/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h
@@ -1,19 +1,21 @@
-// Copyright (C) 2016 The Qt Company Ltd.
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#ifndef DELEGATE_H
-#define DELEGATE_H
+#ifndef SHORTCUTEDITORDELEGATE_H
+#define SHORTCUTEDITORDELEGATE_H
#include <QStyledItemDelegate>
//! [0]
-class SpinBoxDelegate : public QStyledItemDelegate
+class ShortcutEditorDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
- SpinBoxDelegate(QObject *parent = nullptr);
+ explicit ShortcutEditorDelegate(QObject *parent = nullptr);
+ ~ShortcutEditorDelegate() override = default;
+protected:
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
@@ -23,6 +25,9 @@ public:
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
+
+private:
+ void commitAndCloseEditor();
};
//! [0]
diff --git a/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.cpp b/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.cpp
new file mode 100644
index 0000000000..612f1fb726
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.cpp
@@ -0,0 +1,273 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "shortcuteditormodel.h"
+
+#include "actionmanager.h"
+#include "application.h"
+
+#include <QAction>
+#include <QModelIndex>
+
+// List of actions for all categories
+using CategoryActionsMap = QMap<QString, QList<QAction *>>;
+
+// List of categories for all contexts
+using ActionsMap = QMap<QString, CategoryActionsMap>;
+
+
+ShortcutEditorModel::ShortcutEditorModelItem::ShortcutEditorModelItem(const QList<QVariant> &data, ShortcutEditorModelItem *parent)
+ : m_itemData(data)
+ , m_parentItem(parent)
+{
+}
+
+ShortcutEditorModel::ShortcutEditorModelItem::~ShortcutEditorModelItem()
+{
+ qDeleteAll(m_childItems);
+}
+
+void ShortcutEditorModel::ShortcutEditorModelItem::appendChild(ShortcutEditorModelItem *item)
+{
+ m_childItems.push_back(item);
+}
+
+ShortcutEditorModel::ShortcutEditorModelItem *ShortcutEditorModel::ShortcutEditorModelItem::child(int row) const
+{
+ if (row < 0 || row >= m_childItems.size())
+ return nullptr;
+
+ return m_childItems.at(row);
+}
+
+int ShortcutEditorModel::ShortcutEditorModelItem::childCount() const
+{
+ return m_childItems.count();
+}
+
+int ShortcutEditorModel::ShortcutEditorModelItem::columnCount() const
+{
+ return m_itemData.count();
+}
+
+QVariant ShortcutEditorModel::ShortcutEditorModelItem::data(int column) const
+{
+ if (column < 0 || column >= m_itemData.size())
+ return QVariant();
+
+ QVariant columnVariant = m_itemData.at(column);
+ if (column != static_cast<int>(Column::Shortcut) || columnVariant.canConvert<QString>())
+ return columnVariant;
+
+ QAction *action = static_cast<QAction *>(columnVariant.value<void *>());
+ if (!action)
+ return QVariant();
+
+ QKeySequence keySequence = action->shortcut();
+ QString keySequenceString = keySequence.toString(QKeySequence::NativeText);
+ return keySequenceString;
+}
+
+ShortcutEditorModel::ShortcutEditorModelItem *ShortcutEditorModel::ShortcutEditorModelItem::parentItem() const
+{
+ return m_parentItem;
+}
+
+int ShortcutEditorModel::ShortcutEditorModelItem::row() const
+{
+ if (m_parentItem)
+ return m_parentItem->m_childItems.indexOf(const_cast<ShortcutEditorModelItem*>(this));
+
+ return 0;
+}
+
+QAction *ShortcutEditorModel::ShortcutEditorModelItem::action() const
+{
+ QVariant actionVariant = m_itemData.at(static_cast<int>(Column::Shortcut));
+ return static_cast<QAction*>(actionVariant.value<void *>());
+}
+
+
+//! [0]
+ShortcutEditorModel::ShortcutEditorModel(QObject *parent)
+ : QAbstractItemModel(parent)
+{
+ m_rootItem = new ShortcutEditorModelItem({tr("Name"), tr("Shortcut")});
+}
+//! [0]
+
+//! [1]
+ShortcutEditorModel::~ShortcutEditorModel()
+{
+ delete m_rootItem;
+}
+//! [1]
+
+//! [2]
+void ShortcutEditorModel::setActions()
+{
+ beginResetModel();
+ setupModelData(m_rootItem);
+ endResetModel();
+}
+//! [2]
+
+//! [3]
+QModelIndex ShortcutEditorModel::index(int row, int column, const QModelIndex &parent) const
+{
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
+
+ ShortcutEditorModelItem *parentItem;
+ if (!parent.isValid())
+ parentItem = m_rootItem;
+ else
+ parentItem = static_cast<ShortcutEditorModelItem*>(parent.internalPointer());
+
+ ShortcutEditorModelItem *childItem = parentItem->child(row);
+ if (childItem)
+ return createIndex(row, column, childItem);
+
+ return QModelIndex();
+}
+//! [3]
+
+//! [4]
+QModelIndex ShortcutEditorModel::parent(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return QModelIndex();
+
+ ShortcutEditorModelItem *childItem = static_cast<ShortcutEditorModelItem*>(index.internalPointer());
+ ShortcutEditorModelItem *parentItem = childItem->parentItem();
+
+ if (parentItem == m_rootItem)
+ return QModelIndex();
+
+ return createIndex(parentItem->row(), 0, parentItem);
+}
+//! [4]
+
+//! [5]
+int ShortcutEditorModel::rowCount(const QModelIndex &parent) const
+{
+ ShortcutEditorModelItem *parentItem;
+ if (parent.column() > 0)
+ return 0;
+
+ if (!parent.isValid())
+ parentItem = m_rootItem;
+ else
+ parentItem = static_cast<ShortcutEditorModelItem*>(parent.internalPointer());
+
+ return parentItem->childCount();
+}
+//! [5]
+
+//! [6]
+int ShortcutEditorModel::columnCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return static_cast<ShortcutEditorModelItem*>(parent.internalPointer())->columnCount();
+
+ return m_rootItem->columnCount();
+}
+//! [6]
+
+//! [7]
+QVariant ShortcutEditorModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (role != Qt::DisplayRole && role != Qt::EditRole)
+ return QVariant();
+
+ ShortcutEditorModelItem *item = static_cast<ShortcutEditorModelItem*>(index.internalPointer());
+ return item->data(index.column());
+}
+//! [7]
+
+//! [8]
+Qt::ItemFlags ShortcutEditorModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::NoItemFlags;
+
+ Qt::ItemFlags modelFlags = QAbstractItemModel::flags(index);
+ if (index.column() == static_cast<int>(Column::Shortcut))
+ modelFlags |= Qt::ItemIsEditable;
+
+ return modelFlags;
+}
+//! [8]
+
+//! [9]
+QVariant ShortcutEditorModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ return m_rootItem->data(section);
+ }
+
+ return QVariant();
+}
+//! [9]
+
+//! [10]
+void ShortcutEditorModel::setupModelData(ShortcutEditorModelItem *parent)
+{
+ ActionsMap actionsMap;
+ Application *application = static_cast<Application *>(QCoreApplication::instance());
+ ActionManager *actionManager = application->actionManager();
+ const QList<QAction *> registeredActions = actionManager->registeredActions();
+ for (QAction *action : registeredActions) {
+ QString context = actionManager->contextForAction(action);
+ QString category = actionManager->categoryForAction(action);
+ actionsMap[context][category].append(action);
+ }
+
+ QAction *nullAction = nullptr;
+ const QString contextIdPrefix = "root";
+ // Go through each context, one context - many categories each iteration
+ for (const auto &contextLevel : actionsMap.keys()) {
+ ShortcutEditorModelItem *contextLevelItem = new ShortcutEditorModelItem({contextLevel, QVariant::fromValue(nullAction)}, parent);
+ parent->appendChild(contextLevelItem);
+
+ // Go through each category, one category - many actions each iteration
+ for (const auto &categoryLevel : actionsMap[contextLevel].keys()) {
+ ShortcutEditorModelItem *categoryLevelItem = new ShortcutEditorModelItem({categoryLevel, QVariant::fromValue(nullAction)}, contextLevelItem);
+ contextLevelItem->appendChild(categoryLevelItem);
+ for (QAction *action : actionsMap[contextLevel][categoryLevel]) {
+ QString name = action->text();
+ if (name.isEmpty() || !action)
+ continue;
+
+ ShortcutEditorModelItem *actionLevelItem = new ShortcutEditorModelItem({name, QVariant::fromValue(reinterpret_cast<void *>(action))}, categoryLevelItem);
+ categoryLevelItem->appendChild(actionLevelItem);
+ }
+ }
+ }
+}
+//! [10]
+
+//! [11]
+bool ShortcutEditorModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (role == Qt::EditRole && index.column() == static_cast<int>(Column::Shortcut)) {
+ QString keySequenceString = value.toString();
+ ShortcutEditorModelItem *item = static_cast<ShortcutEditorModelItem *>(index.internalPointer());
+ QAction *itemAction = item->action();
+ if (itemAction) {
+ if (keySequenceString == itemAction->shortcut().toString(QKeySequence::NativeText))
+ return true;
+ itemAction->setShortcut(keySequenceString);
+ }
+ Q_EMIT dataChanged(index, index);
+
+ if (keySequenceString.isEmpty())
+ return true;
+ }
+
+ return QAbstractItemModel::setData(index, value, role);
+}
+//! [11]
diff --git a/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.h b/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.h
new file mode 100644
index 0000000000..c687bb4129
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.h
@@ -0,0 +1,71 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SHORTCUTEDITORMODEL_H
+#define SHORTCUTEDITORMODEL_H
+
+#include <QAbstractItemModel>
+#include <QList>
+#include <QVariant>
+
+QT_BEGIN_NAMESPACE
+class QAction;
+QT_END_NAMESPACE
+
+enum class Column : uint8_t {
+ Name,
+ Shortcut
+};
+
+//! [0]
+class ShortcutEditorModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+ class ShortcutEditorModelItem
+ {
+ public:
+ explicit ShortcutEditorModelItem(const QList<QVariant> &data,
+ ShortcutEditorModelItem *parentItem = nullptr);
+ ~ShortcutEditorModelItem();
+
+ void appendChild(ShortcutEditorModelItem *child);
+
+ ShortcutEditorModelItem *child(int row) const;
+ int childCount() const;
+ int columnCount() const;
+ QVariant data(int column) const;
+ int row() const;
+ ShortcutEditorModelItem *parentItem() const;
+ QAction *action() const;
+
+ private:
+ QList<ShortcutEditorModelItem *> m_childItems;
+ QList<QVariant> m_itemData;
+ ShortcutEditorModelItem *m_parentItem;
+ };
+
+public:
+ explicit ShortcutEditorModel(QObject *parent = nullptr);
+ ~ShortcutEditorModel() override;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
+ QModelIndex parent(const QModelIndex &index) const override;
+ int rowCount(const QModelIndex &index = QModelIndex()) const override;
+ int columnCount(const QModelIndex &index = QModelIndex()) const override;
+
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
+
+ void setActions();
+
+private:
+ void setupModelData(ShortcutEditorModelItem *parent);
+
+ ShortcutEditorModelItem *m_rootItem;
+};
+//! [0]
+
+#endif
diff --git a/examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.cpp b/examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.cpp
new file mode 100644
index 0000000000..3e8a027f38
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.cpp
@@ -0,0 +1,33 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "shortcuteditorwidget.h"
+
+#include "shortcuteditordelegate.h"
+#include "shortcuteditormodel.h"
+
+#include <QHeaderView>
+#include <QTreeView>
+#include <QVBoxLayout>
+
+//! [0]
+ShortcutEditorWidget::ShortcutEditorWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ m_model = new ShortcutEditorModel(this);
+ m_delegate = new ShortcutEditorDelegate(this);
+ m_view = new QTreeView(this);
+ m_view->setModel(m_model);
+ m_view->setItemDelegateForColumn(static_cast<int>(Column::Shortcut), m_delegate);
+ m_view->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
+ m_view->setAllColumnsShowFocus(true);
+ m_view->header()->resizeSection(0, 250);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addWidget(m_view);
+ setLayout(layout);
+
+ m_model->setActions();
+}
+//! [0]
diff --git a/examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.h b/examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.h
new file mode 100644
index 0000000000..44735e65e2
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.h
@@ -0,0 +1,32 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SHORTCUTEDITORWIDGET_H
+#define SHORTCUTEDITORWIDGET_H
+
+#include <QWidget>
+
+class ShortcutEditorDelegate;
+class ShortcutEditorModel;
+
+QT_BEGIN_NAMESPACE
+class QTreeView;
+QT_END_NAMESPACE
+
+//! [0]
+class ShortcutEditorWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit ShortcutEditorWidget(QWidget *parent = nullptr);
+ ~ShortcutEditorWidget() override = default;
+
+private:
+ ShortcutEditorDelegate *m_delegate;
+ ShortcutEditorModel *m_model;
+ QTreeView *m_view;
+};
+//! [0]
+
+#endif
diff --git a/examples/widgets/widgets/sliders/CMakeLists.txt b/examples/widgets/widgets/sliders/CMakeLists.txt
index 4a1dea7496..c4c9d11e03 100644
--- a/examples/widgets/widgets/sliders/CMakeLists.txt
+++ b/examples/widgets/widgets/sliders/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(sliders LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/sliders")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(sliders
main.cpp
slidersgroup.cpp slidersgroup.h
@@ -25,14 +19,21 @@ set_target_properties(sliders PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(sliders PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(sliders PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS sliders
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET sliders
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/widgets/sliders/slidersgroup.cpp b/examples/widgets/widgets/sliders/slidersgroup.cpp
index c5d01cdb37..87841c43f9 100644
--- a/examples/widgets/widgets/sliders/slidersgroup.cpp
+++ b/examples/widgets/widgets/sliders/slidersgroup.cpp
@@ -9,39 +9,28 @@
#include <QSlider>
//! [0]
-SlidersGroup::SlidersGroup(Qt::Orientation orientation, const QString &title,
- QWidget *parent)
+SlidersGroup::SlidersGroup(const QString &title, QWidget *parent)
: QGroupBox(title, parent)
{
- slider = new QSlider(orientation);
+ slider = new QSlider;
slider->setFocusPolicy(Qt::StrongFocus);
slider->setTickPosition(QSlider::TicksBothSides);
slider->setTickInterval(10);
slider->setSingleStep(1);
- scrollBar = new QScrollBar(orientation);
+ scrollBar = new QScrollBar;
scrollBar->setFocusPolicy(Qt::StrongFocus);
dial = new QDial;
dial->setFocusPolicy(Qt::StrongFocus);
+//! [0] //! [1]
connect(slider, &QSlider::valueChanged, scrollBar, &QScrollBar::setValue);
connect(scrollBar, &QScrollBar::valueChanged, dial, &QDial::setValue);
connect(dial, &QDial::valueChanged, slider, &QSlider::setValue);
-//! [0] //! [1]
connect(dial, &QDial::valueChanged, this, &SlidersGroup::valueChanged);
-//! [1] //! [2]
-
-//! [2] //! [3]
- QBoxLayout::Direction direction;
-//! [3] //! [4]
-
- if (orientation == Qt::Horizontal)
- direction = QBoxLayout::TopToBottom;
- else
- direction = QBoxLayout::LeftToRight;
-
- QBoxLayout *slidersLayout = new QBoxLayout(direction);
+//! [1] //! [4]
+ slidersLayout = new QBoxLayout(QBoxLayout::LeftToRight);
slidersLayout->addWidget(slider);
slidersLayout->addWidget(scrollBar);
slidersLayout->addWidget(dial);
@@ -96,3 +85,14 @@ void SlidersGroup::invertKeyBindings(bool invert)
dial->setInvertedControls(invert);
}
//! [14]
+
+//! [15]
+void SlidersGroup::setOrientation(Qt::Orientation orientation)
+{
+ slidersLayout->setDirection(orientation == Qt::Horizontal
+ ? QBoxLayout::TopToBottom
+ : QBoxLayout::LeftToRight);
+ scrollBar->setOrientation(orientation);
+ slider->setOrientation(orientation);
+}
+//! [15]
diff --git a/examples/widgets/widgets/sliders/slidersgroup.h b/examples/widgets/widgets/sliders/slidersgroup.h
index 66821ca558..7e7d887018 100644
--- a/examples/widgets/widgets/sliders/slidersgroup.h
+++ b/examples/widgets/widgets/sliders/slidersgroup.h
@@ -10,6 +10,7 @@ QT_BEGIN_NAMESPACE
class QDial;
class QScrollBar;
class QSlider;
+class QBoxLayout;
QT_END_NAMESPACE
//! [0]
@@ -18,8 +19,7 @@ class SlidersGroup : public QGroupBox
Q_OBJECT
public:
- SlidersGroup(Qt::Orientation orientation, const QString &title,
- QWidget *parent = nullptr);
+ SlidersGroup(const QString &title, QWidget *parent = nullptr);
signals:
void valueChanged(int value);
@@ -30,11 +30,13 @@ public slots:
void setMaximum(int value);
void invertAppearance(bool invert);
void invertKeyBindings(bool invert);
+ void setOrientation(Qt::Orientation orientation);
private:
QSlider *slider;
QScrollBar *scrollBar;
QDial *dial;
+ QBoxLayout *slidersLayout;
};
//! [0]
diff --git a/examples/widgets/widgets/sliders/window.cpp b/examples/widgets/widgets/sliders/window.cpp
index 4a3520716d..c62c3b83f5 100644
--- a/examples/widgets/widgets/sliders/window.cpp
+++ b/examples/widgets/widgets/sliders/window.cpp
@@ -13,29 +13,15 @@
Window::Window(QWidget *parent)
: QWidget(parent)
{
- horizontalSliders = new SlidersGroup(Qt::Horizontal, tr("Horizontal"));
- verticalSliders = new SlidersGroup(Qt::Vertical, tr("Vertical"));
-
- stackedWidget = new QStackedWidget;
- stackedWidget->addWidget(horizontalSliders);
- stackedWidget->addWidget(verticalSliders);
+ slidersGroup = new SlidersGroup(tr("Sliders"));
createControls(tr("Controls"));
//! [0]
//! [1]
- connect(horizontalSliders, &SlidersGroup::valueChanged,
-//! [1] //! [2]
- verticalSliders, &SlidersGroup::setValue);
- connect(verticalSliders, &SlidersGroup::valueChanged,
- valueSpinBox, &QSpinBox::setValue);
- connect(valueSpinBox, &QSpinBox::valueChanged,
- horizontalSliders, &SlidersGroup::setValue);
-
- layout = new QGridLayout;
- layout->addWidget(stackedWidget, 0, 1);
- layout->addWidget(controlsGroup, 0, 0);
-
+ layout = new QBoxLayout(QBoxLayout::LeftToRight);
+ layout->addWidget(controlsGroup);
+ layout->addWidget(slidersGroup);
setLayout(layout);
minimumSpinBox->setValue(0);
@@ -44,11 +30,11 @@ Window::Window(QWidget *parent)
setWindowTitle(tr("Sliders"));
}
-//! [2]
+//! [1]
-//! [3]
+//! [2]
void Window::createControls(const QString &title)
-//! [3] //! [4]
+//! [2] //! [3]
{
controlsGroup = new QGroupBox(title);
@@ -59,9 +45,9 @@ void Window::createControls(const QString &title)
invertedAppearance = new QCheckBox(tr("Inverted appearance"));
invertedKeyBindings = new QCheckBox(tr("Inverted key bindings"));
-//! [4] //! [5]
+//! [3] //! [4]
minimumSpinBox = new QSpinBox;
-//! [5] //! [6]
+//! [4] //! [5]
minimumSpinBox->setRange(-100, 100);
minimumSpinBox->setSingleStep(1);
@@ -73,30 +59,19 @@ void Window::createControls(const QString &title)
valueSpinBox->setRange(-100, 100);
valueSpinBox->setSingleStep(1);
- orientationCombo = new QComboBox;
- orientationCombo->addItem(tr("Horizontal slider-like widgets"));
- orientationCombo->addItem(tr("Vertical slider-like widgets"));
-
-//! [6] //! [7]
- connect(orientationCombo, &QComboBox::activated,
-//! [7] //! [8]
- stackedWidget, &QStackedWidget::setCurrentIndex);
- connect(minimumSpinBox, &QSpinBox::valueChanged,
- horizontalSliders, &SlidersGroup::setMinimum);
+//! [5] //! [6]
+ connect(slidersGroup, &SlidersGroup::valueChanged,
+ valueSpinBox, &QSpinBox::setValue);
+ connect(valueSpinBox, &QSpinBox::valueChanged,
+ slidersGroup, &SlidersGroup::setValue);
connect(minimumSpinBox, &QSpinBox::valueChanged,
- verticalSliders, &SlidersGroup::setMinimum);
- connect(maximumSpinBox, &QSpinBox::valueChanged,
- horizontalSliders, &SlidersGroup::setMaximum);
+ slidersGroup, &SlidersGroup::setMinimum);
connect(maximumSpinBox, &QSpinBox::valueChanged,
- verticalSliders, &SlidersGroup::setMaximum);
+ slidersGroup, &SlidersGroup::setMaximum);
connect(invertedAppearance, &QCheckBox::toggled,
- horizontalSliders, &SlidersGroup::invertAppearance);
- connect(invertedAppearance, &QCheckBox::toggled,
- verticalSliders, &SlidersGroup::invertAppearance);
- connect(invertedKeyBindings, &QCheckBox::toggled,
- horizontalSliders, &SlidersGroup::invertKeyBindings);
+ slidersGroup, &SlidersGroup::invertAppearance);
connect(invertedKeyBindings, &QCheckBox::toggled,
- verticalSliders, &SlidersGroup::invertKeyBindings);
+ slidersGroup, &SlidersGroup::invertKeyBindings);
QGridLayout *controlsLayout = new QGridLayout;
controlsLayout->addWidget(minimumLabel, 0, 0);
@@ -107,39 +82,26 @@ void Window::createControls(const QString &title)
controlsLayout->addWidget(valueSpinBox, 2, 1);
controlsLayout->addWidget(invertedAppearance, 0, 2);
controlsLayout->addWidget(invertedKeyBindings, 1, 2);
- controlsLayout->addWidget(orientationCombo, 3, 0, 1, 3);
controlsGroup->setLayout(controlsLayout);
}
-//! [8]
+//! [6]
-void Window::resizeEvent(QResizeEvent *e)
+//! [7]
+void Window::resizeEvent(QResizeEvent *)
{
if (width() == 0 || height() == 0)
return;
- const double aspectRatio = double(width()) / double(height());
-
- if ((aspectRatio < 1.0) && (oldAspectRatio > 1.0)) {
- layout->removeWidget(controlsGroup);
- layout->removeWidget(stackedWidget);
+ const double aspectRatio = double(width()) / double(height());
- layout->addWidget(stackedWidget, 1, 0);
- layout->addWidget(controlsGroup, 0, 0);
-
- oldAspectRatio = aspectRatio;
- }
- else if ((aspectRatio > 1.0) && (oldAspectRatio < 1.0)) {
- layout->removeWidget(controlsGroup);
- layout->removeWidget(stackedWidget);
-
- layout->addWidget(stackedWidget, 0, 1);
- layout->addWidget(controlsGroup, 0, 0);
-
- oldAspectRatio = aspectRatio;
+ if (aspectRatio < 1.0) {
+ layout->setDirection(QBoxLayout::TopToBottom);
+ slidersGroup->setOrientation(Qt::Horizontal);
+ } else if (aspectRatio > 1.0) {
+ layout->setDirection(QBoxLayout::LeftToRight);
+ slidersGroup->setOrientation(Qt::Vertical);
}
}
-
-
-
+//! [7]
diff --git a/examples/widgets/widgets/sliders/window.h b/examples/widgets/widgets/sliders/window.h
index fa627eabd3..8d7338f27c 100644
--- a/examples/widgets/widgets/sliders/window.h
+++ b/examples/widgets/widgets/sliders/window.h
@@ -29,9 +29,7 @@ private:
void createControls(const QString &title);
void resizeEvent(QResizeEvent *e);
- SlidersGroup *horizontalSliders;
- SlidersGroup *verticalSliders;
- QStackedWidget *stackedWidget;
+ SlidersGroup *slidersGroup;
QGroupBox *controlsGroup;
QLabel *minimumLabel;
@@ -42,9 +40,7 @@ private:
QSpinBox *minimumSpinBox;
QSpinBox *maximumSpinBox;
QSpinBox *valueSpinBox;
- QComboBox *orientationCombo;
- QGridLayout *layout;
- double oldAspectRatio;
+ QBoxLayout *layout;
};
//! [0]
diff --git a/examples/widgets/widgets/spinboxes/CMakeLists.txt b/examples/widgets/widgets/spinboxes/CMakeLists.txt
index add7c5ea2f..83e54166bb 100644
--- a/examples/widgets/widgets/spinboxes/CMakeLists.txt
+++ b/examples/widgets/widgets/spinboxes/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(spinboxes LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/spinboxes")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(spinboxes
main.cpp
window.cpp window.h
@@ -24,14 +18,21 @@ set_target_properties(spinboxes PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(spinboxes PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(spinboxes PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS spinboxes
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET spinboxes
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/widgets/styles/CMakeLists.txt b/examples/widgets/widgets/styles/CMakeLists.txt
deleted file mode 100644
index 502e5b8672..0000000000
--- a/examples/widgets/widgets/styles/CMakeLists.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(styles LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/styles")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(styles
- main.cpp
- norwegianwoodstyle.cpp norwegianwoodstyle.h
- widgetgallery.cpp widgetgallery.h
-)
-
-set_target_properties(styles PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(styles PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(styles_resource_files
- "images/woodbackground.png"
- "images/woodbutton.png"
-)
-
-qt_add_resources(styles "styles"
- PREFIX
- "/"
- FILES
- ${styles_resource_files}
-)
-
-install(TARGETS styles
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/styles/images/woodbackground.png b/examples/widgets/widgets/styles/images/woodbackground.png
deleted file mode 100644
index 8be3366bb4..0000000000
--- a/examples/widgets/widgets/styles/images/woodbackground.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/styles/images/woodbutton.png b/examples/widgets/widgets/styles/images/woodbutton.png
deleted file mode 100644
index adb59ef633..0000000000
--- a/examples/widgets/widgets/styles/images/woodbutton.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/styles/main.cpp b/examples/widgets/widgets/styles/main.cpp
deleted file mode 100644
index 936e01e77f..0000000000
--- a/examples/widgets/widgets/styles/main.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "norwegianwoodstyle.h"
-#include "widgetgallery.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(styles);
-
- QApplication::setStyle(new NorwegianWoodStyle);
-
- QApplication app(argc, argv);
- WidgetGallery gallery;
- gallery.show();
- return app.exec();
-}
diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp
deleted file mode 100644
index a8969dfd54..0000000000
--- a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp
+++ /dev/null
@@ -1,310 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "norwegianwoodstyle.h"
-
-#include <QComboBox>
-#include <QPainter>
-#include <QPainterPath>
-#include <QPushButton>
-#include <QStyleFactory>
-
-NorwegianWoodStyle::NorwegianWoodStyle() :
- QProxyStyle(QStyleFactory::create("windows"))
-{
- setObjectName("NorwegianWood");
-}
-
-//! [0]
-QPalette NorwegianWoodStyle::standardPalette() const
-{
- if (!m_standardPalette.isBrushSet(QPalette::Disabled, QPalette::Mid)) {
- QColor brown(212, 140, 95);
- QColor beige(236, 182, 120);
- QColor slightlyOpaqueBlack(0, 0, 0, 63);
-
- QImage backgroundImage(":/images/woodbackground.png");
- QImage buttonImage(":/images/woodbutton.png");
- QImage midImage = buttonImage.convertToFormat(QImage::Format_RGB32);
-
- QPainter painter;
- painter.begin(&midImage);
- painter.setPen(Qt::NoPen);
- painter.fillRect(midImage.rect(), slightlyOpaqueBlack);
- painter.end();
- //! [0]
-
- //! [1]
- QPalette palette(brown);
-
- palette.setBrush(QPalette::BrightText, Qt::white);
- palette.setBrush(QPalette::Base, beige);
- palette.setBrush(QPalette::Highlight, Qt::darkGreen);
- setTexture(palette, QPalette::Button, buttonImage);
- setTexture(palette, QPalette::Mid, midImage);
- setTexture(palette, QPalette::Window, backgroundImage);
-
- QBrush brush = palette.window();
- brush.setColor(brush.color().darker());
-
- palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush);
- palette.setBrush(QPalette::Disabled, QPalette::Text, brush);
- palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush);
- palette.setBrush(QPalette::Disabled, QPalette::Base, brush);
- palette.setBrush(QPalette::Disabled, QPalette::Button, brush);
- palette.setBrush(QPalette::Disabled, QPalette::Mid, brush);
-
- m_standardPalette = palette;
- }
-
- return m_standardPalette;
-}
-//! [1]
-
-//! [3]
-void NorwegianWoodStyle::polish(QWidget *widget)
-//! [3] //! [4]
-{
- if (qobject_cast<QPushButton *>(widget)
- || qobject_cast<QComboBox *>(widget))
- widget->setAttribute(Qt::WA_Hover, true);
-}
-//! [4]
-
-//! [5]
-void NorwegianWoodStyle::unpolish(QWidget *widget)
-//! [5] //! [6]
-{
- if (qobject_cast<QPushButton *>(widget)
- || qobject_cast<QComboBox *>(widget))
- widget->setAttribute(Qt::WA_Hover, false);
-}
-//! [6]
-
-//! [7]
-int NorwegianWoodStyle::pixelMetric(PixelMetric metric,
-//! [7] //! [8]
- const QStyleOption *option,
- const QWidget *widget) const
-{
- switch (metric) {
- case PM_ComboBoxFrameWidth:
- return 8;
- case PM_ScrollBarExtent:
- return QProxyStyle::pixelMetric(metric, option, widget) + 4;
- default:
- return QProxyStyle::pixelMetric(metric, option, widget);
- }
-}
-//! [8]
-
-//! [9]
-int NorwegianWoodStyle::styleHint(StyleHint hint, const QStyleOption *option,
-//! [9] //! [10]
- const QWidget *widget,
- QStyleHintReturn *returnData) const
-{
- switch (hint) {
- case SH_DitherDisabledText:
- return int(false);
- case SH_EtchDisabledText:
- return int(true);
- default:
- return QProxyStyle::styleHint(hint, option, widget, returnData);
- }
-}
-//! [10]
-
-//! [11]
-void NorwegianWoodStyle::drawPrimitive(PrimitiveElement element,
-//! [11] //! [12]
- const QStyleOption *option,
- QPainter *painter,
- const QWidget *widget) const
-{
- switch (element) {
- case PE_PanelButtonCommand:
- {
- int delta = (option->state & State_MouseOver) ? 64 : 0;
- QColor slightlyOpaqueBlack(0, 0, 0, 63);
- QColor semiTransparentWhite(255, 255, 255, 127 + delta);
- QColor semiTransparentBlack(0, 0, 0, 127 - delta);
-
- int x, y, width, height;
- option->rect.getRect(&x, &y, &width, &height);
-//! [12]
-
-//! [13]
- QPainterPath roundRect = roundRectPath(option->rect);
-//! [13] //! [14]
- int radius = qMin(width, height) / 2;
-//! [14]
-
-//! [15]
- QBrush brush;
-//! [15] //! [16]
- bool darker;
-
- const QStyleOptionButton *buttonOption =
- qstyleoption_cast<const QStyleOptionButton *>(option);
- if (buttonOption
- && (buttonOption->features & QStyleOptionButton::Flat)) {
- brush = option->palette.window();
- darker = (option->state & (State_Sunken | State_On));
- } else {
- if (option->state & (State_Sunken | State_On)) {
- brush = option->palette.mid();
- darker = !(option->state & State_Sunken);
- } else {
- brush = option->palette.button();
- darker = false;
-//! [16] //! [17]
- }
-//! [17] //! [18]
- }
-//! [18]
-
-//! [19]
- painter->save();
-//! [19] //! [20]
- painter->setRenderHint(QPainter::Antialiasing, true);
-//! [20] //! [21]
- painter->fillPath(roundRect, brush);
-//! [21] //! [22]
- if (darker)
-//! [22] //! [23]
- painter->fillPath(roundRect, slightlyOpaqueBlack);
-//! [23]
-
-//! [24]
- int penWidth;
-//! [24] //! [25]
- if (radius < 10)
- penWidth = 3;
- else if (radius < 20)
- penWidth = 5;
- else
- penWidth = 7;
-
- QPen topPen(semiTransparentWhite, penWidth);
- QPen bottomPen(semiTransparentBlack, penWidth);
-
- if (option->state & (State_Sunken | State_On))
- qSwap(topPen, bottomPen);
-//! [25]
-
-//! [26]
- int x1 = x;
- int x2 = x + radius;
- int x3 = x + width - radius;
- int x4 = x + width;
-
- if (option->direction == Qt::RightToLeft) {
- qSwap(x1, x4);
- qSwap(x2, x3);
- }
-
- QPolygon topHalf;
- topHalf << QPoint(x1, y)
- << QPoint(x4, y)
- << QPoint(x3, y + radius)
- << QPoint(x2, y + height - radius)
- << QPoint(x1, y + height);
-
- painter->setClipPath(roundRect);
- painter->setClipRegion(topHalf, Qt::IntersectClip);
- painter->setPen(topPen);
- painter->drawPath(roundRect);
-//! [26] //! [32]
-
- QPolygon bottomHalf = topHalf;
- bottomHalf[0] = QPoint(x4, y + height);
-
- painter->setClipPath(roundRect);
- painter->setClipRegion(bottomHalf, Qt::IntersectClip);
- painter->setPen(bottomPen);
- painter->drawPath(roundRect);
-
- painter->setPen(option->palette.windowText().color());
- painter->setClipping(false);
- painter->drawPath(roundRect);
-
- painter->restore();
- }
- break;
-//! [32] //! [33]
- default:
-//! [33] //! [34]
- QProxyStyle::drawPrimitive(element, option, painter, widget);
- }
-}
-//! [34]
-
-//! [35]
-void NorwegianWoodStyle::drawControl(ControlElement element,
-//! [35] //! [36]
- const QStyleOption *option,
- QPainter *painter,
- const QWidget *widget) const
-{
- switch (element) {
- case CE_PushButtonLabel:
- {
- QStyleOptionButton myButtonOption;
- const QStyleOptionButton *buttonOption =
- qstyleoption_cast<const QStyleOptionButton *>(option);
- if (buttonOption) {
- myButtonOption = *buttonOption;
- if (myButtonOption.palette.currentColorGroup()
- != QPalette::Disabled) {
- if (myButtonOption.state & (State_Sunken | State_On)) {
- myButtonOption.palette.setBrush(QPalette::ButtonText,
- myButtonOption.palette.brightText());
- }
- }
- }
- QProxyStyle::drawControl(element, &myButtonOption, painter, widget);
- }
- break;
- default:
- QProxyStyle::drawControl(element, option, painter, widget);
- }
-}
-//! [36]
-
-//! [37]
-void NorwegianWoodStyle::setTexture(QPalette &palette, QPalette::ColorRole role,
-//! [37] //! [38]
- const QImage &image)
-{
- for (int i = 0; i < QPalette::NColorGroups; ++i) {
- QBrush brush(image);
- brush.setColor(palette.brush(QPalette::ColorGroup(i), role).color());
- palette.setBrush(QPalette::ColorGroup(i), role, brush);
- }
-}
-//! [38]
-
-//! [39]
-QPainterPath NorwegianWoodStyle::roundRectPath(const QRect &rect)
-//! [39] //! [40]
-{
- int radius = qMin(rect.width(), rect.height()) / 2;
- int diam = 2 * radius;
-
- int x1, y1, x2, y2;
- rect.getCoords(&x1, &y1, &x2, &y2);
-
- QPainterPath path;
- path.moveTo(x2, y1 + radius);
- path.arcTo(QRect(x2 - diam, y1, diam, diam), 0.0, +90.0);
- path.lineTo(x1 + radius, y1);
- path.arcTo(QRect(x1, y1, diam, diam), 90.0, +90.0);
- path.lineTo(x1, y2 - radius);
- path.arcTo(QRect(x1, y2 - diam, diam, diam), 180.0, +90.0);
- path.lineTo(x1 + radius, y2);
- path.arcTo(QRect(x2 - diam, y2 - diam, diam, diam), 270.0, +90.0);
- path.closeSubpath();
- return path;
-}
-//! [40]
diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.h b/examples/widgets/widgets/styles/norwegianwoodstyle.h
deleted file mode 100644
index 5af2171f35..0000000000
--- a/examples/widgets/widgets/styles/norwegianwoodstyle.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef NORWEGIANWOODSTYLE_H
-#define NORWEGIANWOODSTYLE_H
-
-#include <QProxyStyle>
-#include <QPalette>
-
-QT_BEGIN_NAMESPACE
-class QPainterPath;
-QT_END_NAMESPACE
-
-//! [0]
-class NorwegianWoodStyle : public QProxyStyle
-{
- Q_OBJECT
-
-public:
- NorwegianWoodStyle();
-
- QPalette standardPalette() const override;
-
- void polish(QWidget *widget) override;
- void unpolish(QWidget *widget) override;
- int pixelMetric(PixelMetric metric, const QStyleOption *option,
- const QWidget *widget) const override;
- int styleHint(StyleHint hint, const QStyleOption *option,
- const QWidget *widget, QStyleHintReturn *returnData) const override;
- void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const override;
- void drawControl(ControlElement control, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const override;
-
-private:
- static void setTexture(QPalette &palette, QPalette::ColorRole role,
- const QImage &image);
- static QPainterPath roundRectPath(const QRect &rect);
- mutable QPalette m_standardPalette;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/styles/styles.pro b/examples/widgets/widgets/styles/styles.pro
deleted file mode 100644
index 87dee7e04c..0000000000
--- a/examples/widgets/widgets/styles/styles.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-QT += widgets
-requires(qtConfig(combobox))
-
-HEADERS = norwegianwoodstyle.h \
- widgetgallery.h
-SOURCES = main.cpp \
- norwegianwoodstyle.cpp \
- widgetgallery.cpp
-RESOURCES = styles.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/styles
-INSTALLS += target
diff --git a/examples/widgets/widgets/styles/styles.qrc b/examples/widgets/widgets/styles/styles.qrc
deleted file mode 100644
index 4fdad8d914..0000000000
--- a/examples/widgets/widgets/styles/styles.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/woodbutton.png</file>
- <file>images/woodbackground.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/widgets/styles/widgetgallery.cpp b/examples/widgets/widgets/styles/widgetgallery.cpp
deleted file mode 100644
index 83cb99a52c..0000000000
--- a/examples/widgets/widgets/styles/widgetgallery.cpp
+++ /dev/null
@@ -1,277 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "widgetgallery.h"
-#include "norwegianwoodstyle.h"
-
-#include <QApplication>
-#include <QCheckBox>
-#include <QComboBox>
-#include <QDateTimeEdit>
-#include <QDial>
-#include <QGridLayout>
-#include <QGroupBox>
-#include <QLabel>
-#include <QLineEdit>
-#include <QProgressBar>
-#include <QPushButton>
-#include <QRadioButton>
-#include <QScrollBar>
-#include <QSpinBox>
-#include <QStyle>
-#include <QStyleFactory>
-#include <QTableWidget>
-#include <QTextEdit>
-#include <QTimer>
-
-//! [0]
-WidgetGallery::WidgetGallery(QWidget *parent)
- : QDialog(parent)
-{
- styleComboBox = new QComboBox;
- const QString defaultStyleName = QApplication::style()->objectName();
- QStringList styleNames = QStyleFactory::keys();
- styleNames.append("NorwegianWood");
- for (int i = 1, size = styleNames.size(); i < size; ++i) {
- if (defaultStyleName.compare(styleNames.at(i), Qt::CaseInsensitive) == 0) {
- styleNames.swapItemsAt(0, i);
- break;
- }
- }
- styleComboBox->addItems(styleNames);
-
- styleLabel = new QLabel(tr("&Style:"));
- styleLabel->setBuddy(styleComboBox);
-
- useStylePaletteCheckBox = new QCheckBox(tr("&Use style's standard palette"));
- useStylePaletteCheckBox->setChecked(true);
-
- disableWidgetsCheckBox = new QCheckBox(tr("&Disable widgets"));
-
- createTopLeftGroupBox();
- createTopRightGroupBox();
- createBottomLeftTabWidget();
- createBottomRightGroupBox();
- createProgressBar();
-//! [0]
-
-//! [1]
- connect(styleComboBox, &QComboBox::textActivated,
-//! [1] //! [2]
- this, &WidgetGallery::changeStyle);
- connect(useStylePaletteCheckBox, &QCheckBox::toggled,
- this, &WidgetGallery::changePalette);
- connect(disableWidgetsCheckBox, &QCheckBox::toggled,
- topLeftGroupBox, &QGroupBox::setDisabled);
- connect(disableWidgetsCheckBox, &QCheckBox::toggled,
- topRightGroupBox, &QGroupBox::setDisabled);
- connect(disableWidgetsCheckBox, &QCheckBox::toggled,
- bottomLeftTabWidget, &QGroupBox::setDisabled);
- connect(disableWidgetsCheckBox, &QCheckBox::toggled,
- bottomRightGroupBox, &QGroupBox::setDisabled);
-//! [2]
-
-//! [3]
- QHBoxLayout *topLayout = new QHBoxLayout;
-//! [3] //! [4]
- topLayout->addWidget(styleLabel);
- topLayout->addWidget(styleComboBox);
- topLayout->addStretch(1);
- topLayout->addWidget(useStylePaletteCheckBox);
- topLayout->addWidget(disableWidgetsCheckBox);
-
- QGridLayout *mainLayout = new QGridLayout;
- mainLayout->addLayout(topLayout, 0, 0, 1, 2);
- mainLayout->addWidget(topLeftGroupBox, 1, 0);
- mainLayout->addWidget(topRightGroupBox, 1, 1);
- mainLayout->addWidget(bottomLeftTabWidget, 2, 0);
- mainLayout->addWidget(bottomRightGroupBox, 2, 1);
- mainLayout->addWidget(progressBar, 3, 0, 1, 2);
- mainLayout->setRowStretch(1, 1);
- mainLayout->setRowStretch(2, 1);
- mainLayout->setColumnStretch(0, 1);
- mainLayout->setColumnStretch(1, 1);
- setLayout(mainLayout);
-
- setWindowTitle(tr("Styles"));
- styleChanged();
-}
-//! [4]
-
-//! [5]
-void WidgetGallery::changeStyle(const QString &styleName)
-//! [5] //! [6]
-{
- if (styleName == "NorwegianWood")
- QApplication::setStyle(new NorwegianWoodStyle);
- else
- QApplication::setStyle(QStyleFactory::create(styleName));
-}
-//! [6]
-
-//! [7]
-void WidgetGallery::changePalette()
-//! [7] //! [8]
-{
- QApplication::setPalette(useStylePaletteCheckBox->isChecked() ?
- QApplication::style()->standardPalette() : QPalette());
-}
-//! [8]
-
-void WidgetGallery::changeEvent(QEvent *event)
-{
- if (event->type() == QEvent::StyleChange)
- styleChanged();
-}
-
-void WidgetGallery::styleChanged()
-{
- auto styleName = QApplication::style()->objectName();
- for (int i = 0; i < styleComboBox->count(); ++i) {
- if (QString::compare(styleComboBox->itemText(i), styleName, Qt::CaseInsensitive) == 0) {
- styleComboBox->setCurrentIndex(i);
- break;
- }
- }
-
- changePalette();
-}
-
-//! [9]
-void WidgetGallery::advanceProgressBar()
-//! [9] //! [10]
-{
- int curVal = progressBar->value();
- int maxVal = progressBar->maximum();
- progressBar->setValue(curVal + (maxVal - curVal) / 100);
-}
-//! [10]
-
-//! [11]
-void WidgetGallery::createTopLeftGroupBox()
-//! [11] //! [12]
-{
- topLeftGroupBox = new QGroupBox(tr("Group 1"));
-
- radioButton1 = new QRadioButton(tr("Radio button 1"));
- radioButton2 = new QRadioButton(tr("Radio button 2"));
- radioButton3 = new QRadioButton(tr("Radio button 3"));
- radioButton1->setChecked(true);
-
- checkBox = new QCheckBox(tr("Tri-state check box"));
- checkBox->setTristate(true);
- checkBox->setCheckState(Qt::PartiallyChecked);
-
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(radioButton1);
- layout->addWidget(radioButton2);
- layout->addWidget(radioButton3);
- layout->addWidget(checkBox);
- layout->addStretch(1);
- topLeftGroupBox->setLayout(layout);
-}
-//! [12]
-
-void WidgetGallery::createTopRightGroupBox()
-{
- topRightGroupBox = new QGroupBox(tr("Group 2"));
-
- defaultPushButton = new QPushButton(tr("Default Push Button"));
- defaultPushButton->setDefault(true);
-
- togglePushButton = new QPushButton(tr("Toggle Push Button"));
- togglePushButton->setCheckable(true);
- togglePushButton->setChecked(true);
-
- flatPushButton = new QPushButton(tr("Flat Push Button"));
- flatPushButton->setFlat(true);
-
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(defaultPushButton);
- layout->addWidget(togglePushButton);
- layout->addWidget(flatPushButton);
- layout->addStretch(1);
- topRightGroupBox->setLayout(layout);
-}
-
-void WidgetGallery::createBottomLeftTabWidget()
-{
- bottomLeftTabWidget = new QTabWidget;
- bottomLeftTabWidget->setSizePolicy(QSizePolicy::Preferred,
- QSizePolicy::Ignored);
-
- QWidget *tab1 = new QWidget;
- tableWidget = new QTableWidget(10, 10);
-
- QHBoxLayout *tab1hbox = new QHBoxLayout;
- tab1hbox->setContentsMargins(5,5, 5, 5);
- tab1hbox->addWidget(tableWidget);
- tab1->setLayout(tab1hbox);
-
- QWidget *tab2 = new QWidget;
- textEdit = new QTextEdit;
-
- textEdit->setPlainText(tr("Twinkle, twinkle, little star,\n"
- "How I wonder what you are.\n"
- "Up above the world so high,\n"
- "Like a diamond in the sky.\n"
- "Twinkle, twinkle, little star,\n"
- "How I wonder what you are!\n"));
-
- QHBoxLayout *tab2hbox = new QHBoxLayout;
- tab2hbox->setContentsMargins(5, 5, 5, 5);
- tab2hbox->addWidget(textEdit);
- tab2->setLayout(tab2hbox);
-
- bottomLeftTabWidget->addTab(tab1, tr("&Table"));
- bottomLeftTabWidget->addTab(tab2, tr("Text &Edit"));
-}
-
-void WidgetGallery::createBottomRightGroupBox()
-{
- bottomRightGroupBox = new QGroupBox(tr("Group 3"));
- bottomRightGroupBox->setCheckable(true);
- bottomRightGroupBox->setChecked(true);
-
- lineEdit = new QLineEdit("s3cRe7");
- lineEdit->setEchoMode(QLineEdit::Password);
-
- spinBox = new QSpinBox(bottomRightGroupBox);
- spinBox->setValue(50);
-
- dateTimeEdit = new QDateTimeEdit(bottomRightGroupBox);
- dateTimeEdit->setDateTime(QDateTime::currentDateTime());
-
- slider = new QSlider(Qt::Horizontal, bottomRightGroupBox);
- slider->setValue(40);
-
- scrollBar = new QScrollBar(Qt::Horizontal, bottomRightGroupBox);
- scrollBar->setValue(60);
-
- dial = new QDial(bottomRightGroupBox);
- dial->setValue(30);
- dial->setNotchesVisible(true);
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(lineEdit, 0, 0, 1, 2);
- layout->addWidget(spinBox, 1, 0, 1, 2);
- layout->addWidget(dateTimeEdit, 2, 0, 1, 2);
- layout->addWidget(slider, 3, 0);
- layout->addWidget(scrollBar, 4, 0);
- layout->addWidget(dial, 3, 1, 2, 1);
- layout->setRowStretch(5, 1);
- bottomRightGroupBox->setLayout(layout);
-}
-
-//! [13]
-void WidgetGallery::createProgressBar()
-{
- progressBar = new QProgressBar;
- progressBar->setRange(0, 10000);
- progressBar->setValue(0);
-
- QTimer *timer = new QTimer(this);
- connect(timer, &QTimer::timeout, this, &WidgetGallery::advanceProgressBar);
- timer->start(1000);
-}
-//! [13]
diff --git a/examples/widgets/widgets/styles/widgetgallery.h b/examples/widgets/widgets/styles/widgetgallery.h
deleted file mode 100644
index f4c43e7b4f..0000000000
--- a/examples/widgets/widgets/styles/widgetgallery.h
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef WIDGETGALLERY_H
-#define WIDGETGALLERY_H
-
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-class QCheckBox;
-class QComboBox;
-class QDateTimeEdit;
-class QDial;
-class QGroupBox;
-class QLabel;
-class QLineEdit;
-class QProgressBar;
-class QPushButton;
-class QRadioButton;
-class QScrollBar;
-class QSlider;
-class QSpinBox;
-class QTabWidget;
-class QTableWidget;
-class QTextEdit;
-QT_END_NAMESPACE
-
-//! [0]
-class WidgetGallery : public QDialog
-{
- Q_OBJECT
-
-public:
- WidgetGallery(QWidget *parent = nullptr);
-
-protected:
- void changeEvent(QEvent *) override;
-
-private slots:
- void changeStyle(const QString &styleName);
- void styleChanged();
- void changePalette();
- void advanceProgressBar();
-
-private:
- void createTopLeftGroupBox();
- void createTopRightGroupBox();
- void createBottomLeftTabWidget();
- void createBottomRightGroupBox();
- void createProgressBar();
-
- QLabel *styleLabel;
- QComboBox *styleComboBox;
- QCheckBox *useStylePaletteCheckBox;
- QCheckBox *disableWidgetsCheckBox;
-//! [0]
-
- QGroupBox *topLeftGroupBox;
- QRadioButton *radioButton1;
- QRadioButton *radioButton2;
- QRadioButton *radioButton3;
- QCheckBox *checkBox;
-
- QGroupBox *topRightGroupBox;
- QPushButton *defaultPushButton;
- QPushButton *togglePushButton;
- QPushButton *flatPushButton;
-
- QTabWidget *bottomLeftTabWidget;
- QTableWidget *tableWidget;
- QTextEdit *textEdit;
-
- QGroupBox *bottomRightGroupBox;
- QLineEdit *lineEdit;
- QSpinBox *spinBox;
- QDateTimeEdit *dateTimeEdit;
- QSlider *slider;
- QScrollBar *scrollBar;
- QDial *dial;
-
- QProgressBar *progressBar;
-//! [1]
-};
-//! [1]
-
-#endif
diff --git a/examples/widgets/widgets/stylesheet/CMakeLists.txt b/examples/widgets/widgets/stylesheet/CMakeLists.txt
deleted file mode 100644
index f75e5a4a52..0000000000
--- a/examples/widgets/widgets/stylesheet/CMakeLists.txt
+++ /dev/null
@@ -1,85 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(stylesheet LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/stylesheet")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(stylesheet
- main.cpp
- mainwindow.cpp mainwindow.h mainwindow.ui
- stylesheeteditor.cpp stylesheeteditor.h stylesheeteditor.ui
-)
-
-set_target_properties(stylesheet PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(stylesheet PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(stylesheet_resource_files
- "images/checkbox_checked.png"
- "images/checkbox_checked_hover.png"
- "images/checkbox_checked_pressed.png"
- "images/checkbox_unchecked.png"
- "images/checkbox_unchecked_hover.png"
- "images/checkbox_unchecked_pressed.png"
- "images/down_arrow.png"
- "images/down_arrow_disabled.png"
- "images/frame.png"
- "images/pagefold.png"
- "images/pushbutton.png"
- "images/pushbutton_hover.png"
- "images/pushbutton_pressed.png"
- "images/radiobutton_checked.png"
- "images/radiobutton_checked_hover.png"
- "images/radiobutton_checked_pressed.png"
- "images/radiobutton_unchecked.png"
- "images/radiobutton_unchecked_hover.png"
- "images/radiobutton_unchecked_pressed.png"
- "images/sizegrip.png"
- "images/spindown.png"
- "images/spindown_hover.png"
- "images/spindown_off.png"
- "images/spindown_pressed.png"
- "images/spinup.png"
- "images/spinup_hover.png"
- "images/spinup_off.png"
- "images/spinup_pressed.png"
- "images/up_arrow.png"
- "images/up_arrow_disabled.png"
- "layouts/default.ui"
- "layouts/pagefold.ui"
- "qss/coffee.qss"
- "qss/default.qss"
- "qss/pagefold.qss"
-)
-
-qt_add_resources(stylesheet "stylesheet"
- PREFIX
- "/"
- FILES
- ${stylesheet_resource_files}
-)
-
-install(TARGETS stylesheet
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/stylesheet/images/checkbox_checked.png b/examples/widgets/widgets/stylesheet/images/checkbox_checked.png
deleted file mode 100644
index cbf06f6513..0000000000
--- a/examples/widgets/widgets/stylesheet/images/checkbox_checked.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/checkbox_checked_hover.png b/examples/widgets/widgets/stylesheet/images/checkbox_checked_hover.png
deleted file mode 100644
index fb4d4d3fdb..0000000000
--- a/examples/widgets/widgets/stylesheet/images/checkbox_checked_hover.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/checkbox_checked_pressed.png b/examples/widgets/widgets/stylesheet/images/checkbox_checked_pressed.png
deleted file mode 100644
index 852fcc0306..0000000000
--- a/examples/widgets/widgets/stylesheet/images/checkbox_checked_pressed.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/checkbox_unchecked.png b/examples/widgets/widgets/stylesheet/images/checkbox_unchecked.png
deleted file mode 100644
index 5f5465582a..0000000000
--- a/examples/widgets/widgets/stylesheet/images/checkbox_unchecked.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/checkbox_unchecked_hover.png b/examples/widgets/widgets/stylesheet/images/checkbox_unchecked_hover.png
deleted file mode 100644
index 687364497e..0000000000
--- a/examples/widgets/widgets/stylesheet/images/checkbox_unchecked_hover.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/checkbox_unchecked_pressed.png b/examples/widgets/widgets/stylesheet/images/checkbox_unchecked_pressed.png
deleted file mode 100644
index 6a768c44de..0000000000
--- a/examples/widgets/widgets/stylesheet/images/checkbox_unchecked_pressed.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/down_arrow.png b/examples/widgets/widgets/stylesheet/images/down_arrow.png
deleted file mode 100644
index 85004aeaf6..0000000000
--- a/examples/widgets/widgets/stylesheet/images/down_arrow.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/down_arrow_disabled.png b/examples/widgets/widgets/stylesheet/images/down_arrow_disabled.png
deleted file mode 100644
index d9eefed4c8..0000000000
--- a/examples/widgets/widgets/stylesheet/images/down_arrow_disabled.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/frame.png b/examples/widgets/widgets/stylesheet/images/frame.png
deleted file mode 100644
index 05a600502e..0000000000
--- a/examples/widgets/widgets/stylesheet/images/frame.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/pagefold.png b/examples/widgets/widgets/stylesheet/images/pagefold.png
deleted file mode 100644
index 69be8f2a38..0000000000
--- a/examples/widgets/widgets/stylesheet/images/pagefold.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/pushbutton.png b/examples/widgets/widgets/stylesheet/images/pushbutton.png
deleted file mode 100644
index c7529ba02d..0000000000
--- a/examples/widgets/widgets/stylesheet/images/pushbutton.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/pushbutton_hover.png b/examples/widgets/widgets/stylesheet/images/pushbutton_hover.png
deleted file mode 100644
index af0ef9d561..0000000000
--- a/examples/widgets/widgets/stylesheet/images/pushbutton_hover.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/pushbutton_pressed.png b/examples/widgets/widgets/stylesheet/images/pushbutton_pressed.png
deleted file mode 100644
index f7381f752a..0000000000
--- a/examples/widgets/widgets/stylesheet/images/pushbutton_pressed.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/radiobutton_checked.png b/examples/widgets/widgets/stylesheet/images/radiobutton_checked.png
deleted file mode 100644
index 8ab9157578..0000000000
--- a/examples/widgets/widgets/stylesheet/images/radiobutton_checked.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/radiobutton_checked_hover.png b/examples/widgets/widgets/stylesheet/images/radiobutton_checked_hover.png
deleted file mode 100644
index d68cb009a7..0000000000
--- a/examples/widgets/widgets/stylesheet/images/radiobutton_checked_hover.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/radiobutton_checked_pressed.png b/examples/widgets/widgets/stylesheet/images/radiobutton_checked_pressed.png
deleted file mode 100644
index e3cd5a59e4..0000000000
--- a/examples/widgets/widgets/stylesheet/images/radiobutton_checked_pressed.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked.png b/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked.png
deleted file mode 100644
index 321a9a1558..0000000000
--- a/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_hover.png b/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_hover.png
deleted file mode 100644
index 666a3b0bdd..0000000000
--- a/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_hover.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_pressed.png b/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_pressed.png
deleted file mode 100644
index c4b0567aa9..0000000000
--- a/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_pressed.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/sizegrip.png b/examples/widgets/widgets/stylesheet/images/sizegrip.png
deleted file mode 100644
index 350583aaac..0000000000
--- a/examples/widgets/widgets/stylesheet/images/sizegrip.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/spindown.png b/examples/widgets/widgets/stylesheet/images/spindown.png
deleted file mode 100644
index 7ff3c64926..0000000000
--- a/examples/widgets/widgets/stylesheet/images/spindown.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/spindown_hover.png b/examples/widgets/widgets/stylesheet/images/spindown_hover.png
deleted file mode 100644
index 1486c4dfe4..0000000000
--- a/examples/widgets/widgets/stylesheet/images/spindown_hover.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/spindown_off.png b/examples/widgets/widgets/stylesheet/images/spindown_off.png
deleted file mode 100644
index a90ab3f038..0000000000
--- a/examples/widgets/widgets/stylesheet/images/spindown_off.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/spindown_pressed.png b/examples/widgets/widgets/stylesheet/images/spindown_pressed.png
deleted file mode 100644
index f6271cbde2..0000000000
--- a/examples/widgets/widgets/stylesheet/images/spindown_pressed.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/spinup.png b/examples/widgets/widgets/stylesheet/images/spinup.png
deleted file mode 100644
index 1069dd00df..0000000000
--- a/examples/widgets/widgets/stylesheet/images/spinup.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/spinup_hover.png b/examples/widgets/widgets/stylesheet/images/spinup_hover.png
deleted file mode 100644
index 884c8d77c5..0000000000
--- a/examples/widgets/widgets/stylesheet/images/spinup_hover.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/spinup_off.png b/examples/widgets/widgets/stylesheet/images/spinup_off.png
deleted file mode 100644
index 02dad1fb29..0000000000
--- a/examples/widgets/widgets/stylesheet/images/spinup_off.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/spinup_pressed.png b/examples/widgets/widgets/stylesheet/images/spinup_pressed.png
deleted file mode 100644
index b1843e2a1f..0000000000
--- a/examples/widgets/widgets/stylesheet/images/spinup_pressed.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/up_arrow.png b/examples/widgets/widgets/stylesheet/images/up_arrow.png
deleted file mode 100644
index e7f7ddb3a6..0000000000
--- a/examples/widgets/widgets/stylesheet/images/up_arrow.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/images/up_arrow_disabled.png b/examples/widgets/widgets/stylesheet/images/up_arrow_disabled.png
deleted file mode 100644
index 4d2c27770f..0000000000
--- a/examples/widgets/widgets/stylesheet/images/up_arrow_disabled.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/stylesheet/layouts/default.ui b/examples/widgets/widgets/stylesheet/layouts/default.ui
deleted file mode 100644
index 431a40956e..0000000000
--- a/examples/widgets/widgets/stylesheet/layouts/default.ui
+++ /dev/null
@@ -1,329 +0,0 @@
-<ui version="4.0" >
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>388</width>
- <height>413</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>MainWindow</string>
- </property>
- <widget class="QWidget" name="centralwidget" >
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="0" column="0" >
- <widget class="QLabel" name="nameLabel" >
- <property name="text" >
- <string>&amp;Name:</string>
- </property>
- <property name="buddy" >
- <cstring>nameCombo</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1" colspan="3" >
- <widget class="QComboBox" name="nameCombo" >
- <property name="toolTip" >
- <string>Specify your name</string>
- </property>
- <property name="editable" >
- <bool>true</bool>
- </property>
- <property name="currentIndex" >
- <number>-1</number>
- </property>
- <item>
- <property name="text" >
- <string>Girish</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Jasmin</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Simon</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Zack</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="3" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="2" >
- <widget class="QRadioButton" name="femaleRadioButton" >
- <property name="toolTip" >
- <string>Check this if you are female</string>
- </property>
- <property name="text" >
- <string>&amp;Female</string>
- </property>
- </widget>
- </item>
- <item row="6" column="0" colspan="4" >
- <widget class="QCheckBox" name="agreeCheckBox" >
- <property name="toolTip" >
- <string>Please read the license before checking this</string>
- </property>
- <property name="text" >
- <string>I &amp;accept the terms and conditions</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QRadioButton" name="maleRadioButton" >
- <property name="toolTip" >
- <string>Check this if you are male</string>
- </property>
- <property name="text" >
- <string>&amp;Male</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QLabel" name="genderLabel" >
- <property name="text" >
- <string>Gender:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1" colspan="3" >
- <widget class="QSpinBox" name="ageSpinBox" >
- <property name="toolTip" >
- <string>Specify your age</string>
- </property>
- <property name="statusTip" >
- <string>Specify your age here</string>
- </property>
- <property name="minimum" >
- <number>12</number>
- </property>
- <property name="value" >
- <number>22</number>
- </property>
- </widget>
- </item>
- <item row="7" column="2" colspan="2" >
- <widget class="QDialogButtonBox" name="buttonBox" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons" >
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- <item row="2" column="0" >
- <widget class="QLabel" name="ageLabel" >
- <property name="text" >
- <string>&amp;Age:</string>
- </property>
- <property name="buddy" >
- <cstring>ageSpinBox</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="0" >
- <widget class="QLabel" name="passwordLabel" >
- <property name="text" >
- <string>&amp;Password:</string>
- </property>
- <property name="buddy" >
- <cstring>passwordEdit</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="1" colspan="3" >
- <widget class="QLineEdit" name="passwordEdit" >
- <property name="toolTip" >
- <string>Specify your password</string>
- </property>
- <property name="statusTip" >
- <string>Specify your password here</string>
- </property>
- <property name="text" >
- <string>Password</string>
- </property>
- <property name="echoMode" >
- <enum>QLineEdit::Password</enum>
- </property>
- </widget>
- </item>
- <item row="5" column="0" >
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>Profession</string>
- </property>
- <property name="buddy" >
- <cstring>professionList</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="0" >
- <widget class="QLabel" name="countryLabel" >
- <property name="text" >
- <string>&amp;Country</string>
- </property>
- <property name="buddy" >
- <cstring>professionList</cstring>
- </property>
- </widget>
- </item>
- <item row="5" column="1" colspan="3" >
- <widget class="QListWidget" name="professionList" >
- <property name="toolTip" >
- <string>Select your profession</string>
- </property>
- <property name="statusTip" >
- <string>Select your profession</string>
- </property>
- <property name="whatsThis" >
- <string>Select your profession</string>
- </property>
- <property name="currentRow" >
- <number>1</number>
- </property>
- <item>
- <property name="text" >
- <string>Developer</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Student</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Fisherman</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="4" column="1" colspan="3" >
- <widget class="QComboBox" name="countryCombo" >
- <property name="toolTip" >
- <string>Specify your country</string>
- </property>
- <property name="statusTip" >
- <string>Specify your country here</string>
- </property>
- <property name="currentIndex" >
- <number>2</number>
- </property>
- <item>
- <property name="text" >
- <string>Germany</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>India</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Norway</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>United States Of America</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>United Kingdom</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QMenuBar" name="menubar" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>388</width>
- <height>21</height>
- </rect>
- </property>
- <widget class="QMenu" name="menu_File" >
- <property name="title" >
- <string>&amp;File</string>
- </property>
- <addaction name="editStyleAction" />
- <addaction name="separator" />
- <addaction name="exitAction" />
- </widget>
- <widget class="QMenu" name="menu_Help" >
- <property name="title" >
- <string>&amp;Help</string>
- </property>
- <addaction name="aboutAction" />
- <addaction name="separator" />
- <addaction name="aboutQtAction" />
- </widget>
- <addaction name="menu_File" />
- <addaction name="menu_Help" />
- </widget>
- <widget class="QStatusBar" name="statusbar" />
- <action name="exitAction" >
- <property name="text" >
- <string>&amp;Exit</string>
- </property>
- </action>
- <action name="aboutQtAction" >
- <property name="text" >
- <string>About Qt</string>
- </property>
- </action>
- <action name="editStyleAction" >
- <property name="text" >
- <string>Edit &amp;Style</string>
- </property>
- </action>
- <action name="aboutAction" >
- <property name="text" >
- <string>About</string>
- </property>
- </action>
- </widget>
- <tabstops>
- <tabstop>maleRadioButton</tabstop>
- <tabstop>femaleRadioButton</tabstop>
- <tabstop>ageSpinBox</tabstop>
- <tabstop>passwordEdit</tabstop>
- <tabstop>professionList</tabstop>
- <tabstop>agreeCheckBox</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/widgets/widgets/stylesheet/layouts/pagefold.ui b/examples/widgets/widgets/stylesheet/layouts/pagefold.ui
deleted file mode 100644
index 7ae313c331..0000000000
--- a/examples/widgets/widgets/stylesheet/layouts/pagefold.ui
+++ /dev/null
@@ -1,349 +0,0 @@
-<ui version="4.0" >
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>392</width>
- <height>412</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>MainWindow</string>
- </property>
- <widget class="QWidget" name="centralwidget" >
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <widget class="QFrame" name="mainFrame" >
- <property name="frameShape" >
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow" >
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="0" column="1" colspan="3" >
- <widget class="QComboBox" name="nameCombo" >
- <property name="toolTip" >
- <string>Specify your name</string>
- </property>
- <property name="editable" >
- <bool>true</bool>
- </property>
- <property name="currentIndex" >
- <number>-1</number>
- </property>
- <item>
- <property name="text" >
- <string>Girish</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Jasmin</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Simon</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Zack</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="3" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="2" >
- <widget class="QRadioButton" name="femaleRadioButton" >
- <property name="styleSheet" >
- <string>Check this if you are female</string>
- </property>
- <property name="text" >
- <string>&amp;Female</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QLabel" name="genderLabel" >
- <property name="text" >
- <string>Gender:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" >
- <widget class="QLabel" name="ageLabel" >
- <property name="text" >
- <string>&amp;Age:</string>
- </property>
- <property name="buddy" >
- <cstring>ageSpinBox</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QRadioButton" name="maleRadioButton" >
- <property name="toolTip" >
- <string>Check this if you are male</string>
- </property>
- <property name="text" >
- <string>&amp;Male</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0" >
- <widget class="QLabel" name="nameLabel" >
- <property name="text" >
- <string>&amp;Name:</string>
- </property>
- <property name="buddy" >
- <cstring>nameCombo</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="0" >
- <widget class="QLabel" name="passwordLabel" >
- <property name="text" >
- <string>&amp;Password:</string>
- </property>
- <property name="buddy" >
- <cstring>passwordEdit</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="1" colspan="3" >
- <widget class="QSpinBox" name="ageSpinBox" >
- <property name="toolTip" >
- <string>Specify your age</string>
- </property>
- <property name="statusTip" >
- <string>Specify your age</string>
- </property>
- <property name="minimum" >
- <number>12</number>
- </property>
- <property name="value" >
- <number>22</number>
- </property>
- </widget>
- </item>
- <item row="7" column="2" colspan="2" >
- <widget class="QDialogButtonBox" name="buttonBox" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons" >
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- <item row="6" column="0" colspan="4" >
- <widget class="QCheckBox" name="agreeCheckBox" >
- <property name="toolTip" >
- <string>Please read the LICENSE file before checking</string>
- </property>
- <property name="text" >
- <string>I &amp;accept the terms and &amp;conditions</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1" colspan="3" >
- <widget class="QLineEdit" name="passwordEdit" >
- <property name="toolTip" >
- <string>Specify your password</string>
- </property>
- <property name="statusTip" >
- <string>Specify your password</string>
- </property>
- <property name="text" >
- <string>Password</string>
- </property>
- <property name="echoMode" >
- <enum>QLineEdit::Password</enum>
- </property>
- </widget>
- </item>
- <item row="5" column="1" colspan="3" >
- <widget class="QListWidget" name="professionList" >
- <property name="toolTip" >
- <string>Select your profession</string>
- </property>
- <property name="statusTip" >
- <string>Specify your name here</string>
- </property>
- <property name="whatsThis" >
- <string>Specify your name here</string>
- </property>
- <property name="currentRow" >
- <number>0</number>
- </property>
- <item>
- <property name="text" >
- <string>Developer</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Student</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Fisherman</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="5" column="0" >
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>Profession:</string>
- </property>
- <property name="buddy" >
- <cstring>professionList</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="1" colspan="3" >
- <widget class="QComboBox" name="countryCombo" >
- <property name="toolTip" >
- <string>Specify country of origin</string>
- </property>
- <property name="statusTip" >
- <string>Specify country of origin</string>
- </property>
- <property name="currentIndex" >
- <number>6</number>
- </property>
- <item>
- <property name="text" >
- <string>Egypt</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>France</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Germany</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>India</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Italy</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Korea</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Norway</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="4" column="0" >
- <widget class="QLabel" name="countryLabel" >
- <property name="text" >
- <string>Pro&amp;fession</string>
- </property>
- <property name="buddy" >
- <cstring>professionList</cstring>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QMenuBar" name="menubar" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>392</width>
- <height>25</height>
- </rect>
- </property>
- <widget class="QMenu" name="menu_File" >
- <property name="title" >
- <string>&amp;File</string>
- </property>
- <addaction name="editStyleAction" />
- <addaction name="separator" />
- <addaction name="exitAction" />
- </widget>
- <widget class="QMenu" name="menu_Help" >
- <property name="title" >
- <string>&amp;Help</string>
- </property>
- <addaction name="aboutAction" />
- <addaction name="separator" />
- <addaction name="aboutQtAction" />
- </widget>
- <addaction name="menu_File" />
- <addaction name="menu_Help" />
- </widget>
- <widget class="QStatusBar" name="statusbar" />
- <action name="exitAction" >
- <property name="text" >
- <string>&amp;Exit</string>
- </property>
- </action>
- <action name="aboutQtAction" >
- <property name="text" >
- <string>About Qt</string>
- </property>
- </action>
- <action name="editStyleAction" >
- <property name="text" >
- <string>Edit &amp;Style</string>
- </property>
- </action>
- <action name="aboutAction" >
- <property name="text" >
- <string>About</string>
- </property>
- </action>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/widgets/widgets/stylesheet/main.cpp b/examples/widgets/widgets/stylesheet/main.cpp
deleted file mode 100644
index 9afdefc939..0000000000
--- a/examples/widgets/widgets/stylesheet/main.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(stylesheet);
-
- QApplication app(argc, argv);
- MainWindow window;
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/widgets/stylesheet/mainwindow.cpp b/examples/widgets/widgets/stylesheet/mainwindow.cpp
deleted file mode 100644
index a2f477c83d..0000000000
--- a/examples/widgets/widgets/stylesheet/mainwindow.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "mainwindow.h"
-#include "stylesheeteditor.h"
-
-#include <QMessageBox>
-
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
-{
- ui.setupUi(this);
-
- ui.nameLabel->setProperty("class", "mandatory QLabel");
-
- styleSheetEditor = new StyleSheetEditor(this);
-
- statusBar()->addWidget(new QLabel(tr("Ready")));
-
- connect(ui.exitAction, &QAction::triggered, qApp, &QApplication::quit);
- connect(ui.aboutQtAction, &QAction::triggered, qApp, &QApplication::aboutQt);
-}
-
-void MainWindow::on_editStyleAction_triggered()
-{
- styleSheetEditor->show();
- styleSheetEditor->activateWindow();
-}
-
-void MainWindow::on_aboutAction_triggered()
-{
- const QString url = QStringLiteral("http://doc.qt.io/qt-%1/stylesheet.html")
- .arg(QT_VERSION_MAJOR);
- QMessageBox::about(this, tr("About Style sheet"),
- tr("The <b>Style Sheet</b> example shows how widgets can be styled "
- "using <a href=\"%1\">Qt "
- "Style Sheets</a>. Click <b>File|Edit Style Sheet</b> to pop up the "
- "style editor, and either choose an existing style sheet or design "
- "your own.").arg(url));
-}
diff --git a/examples/widgets/widgets/stylesheet/mainwindow.h b/examples/widgets/widgets/stylesheet/mainwindow.h
deleted file mode 100644
index 877636bddf..0000000000
--- a/examples/widgets/widgets/stylesheet/mainwindow.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-
-#include "ui_mainwindow.h"
-
-class StyleSheetEditor;
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow(QWidget *parent = nullptr);
-
-private slots:
- void on_editStyleAction_triggered();
- void on_aboutAction_triggered();
-
-private:
- StyleSheetEditor *styleSheetEditor;
- Ui::MainWindow ui;
-};
-
-#endif
diff --git a/examples/widgets/widgets/stylesheet/mainwindow.ui b/examples/widgets/widgets/stylesheet/mainwindow.ui
deleted file mode 100644
index cc29257afb..0000000000
--- a/examples/widgets/widgets/stylesheet/mainwindow.ui
+++ /dev/null
@@ -1,356 +0,0 @@
-<ui version="4.0" >
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>413</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Style Sheet</string>
- </property>
- <widget class="QWidget" name="centralwidget" >
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <widget class="QFrame" name="mainFrame" >
- <property name="frameShape" >
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow" >
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="6" column="0" colspan="5" >
- <widget class="QCheckBox" name="agreeCheckBox" >
- <property name="toolTip" >
- <string>Please read the LICENSE file before checking</string>
- </property>
- <property name="text" >
- <string>I accept the terms and &amp;conditions</string>
- </property>
- </widget>
- </item>
- <item row="5" column="0" >
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>Profession:</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
- </property>
- <property name="buddy" >
- <cstring>professionList</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="0" >
- <widget class="QLabel" name="nameLabel" >
- <property name="text" >
- <string>&amp;Name:</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy" >
- <cstring>nameCombo</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QRadioButton" name="maleRadioButton" >
- <property name="toolTip" >
- <string>Check this if you are male</string>
- </property>
- <property name="text" >
- <string>&amp;Male</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0" >
- <widget class="QLabel" name="passwordLabel" >
- <property name="text" >
- <string>&amp;Password:</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy" >
- <cstring>passwordEdit</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="1" colspan="4" >
- <widget class="QComboBox" name="countryCombo" >
- <property name="toolTip" >
- <string>Specify country of origin</string>
- </property>
- <property name="statusTip" >
- <string>Specify country of origin</string>
- </property>
- <property name="currentIndex" >
- <number>6</number>
- </property>
- <item>
- <property name="text" >
- <string>Egypt</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>France</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Germany</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>India</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Italy</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Norway</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Pakistan</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="2" column="0" >
- <widget class="QLabel" name="ageLabel" >
- <property name="text" >
- <string>&amp;Age:</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy" >
- <cstring>ageSpinBox</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="0" >
- <widget class="QLabel" name="countryLabel" >
- <property name="text" >
- <string>Country:</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy" >
- <cstring>countryCombo</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QLabel" name="genderLabel" >
- <property name="text" >
- <string>Gender:</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="3" column="1" colspan="4" >
- <widget class="QLineEdit" name="passwordEdit" >
- <property name="toolTip" >
- <string>Specify your password</string>
- </property>
- <property name="statusTip" >
- <string>Specify your password</string>
- </property>
- <property name="text" >
- <string>Password</string>
- </property>
- <property name="echoMode" >
- <enum>QLineEdit::Password</enum>
- </property>
- </widget>
- </item>
- <item row="1" column="2" colspan="2" >
- <widget class="QRadioButton" name="femaleRadioButton" >
- <property name="toolTip">
- <string>Check this if you are female</string>
- </property>
- <property name="text" >
- <string>&amp;Female</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1" colspan="2" >
- <widget class="QSpinBox" name="ageSpinBox" >
- <property name="toolTip" >
- <string>Specify your age</string>
- </property>
- <property name="statusTip" >
- <string>Specify your age</string>
- </property>
- <property name="minimum" >
- <number>12</number>
- </property>
- <property name="value" >
- <number>22</number>
- </property>
- </widget>
- </item>
- <item row="0" column="1" colspan="4" >
- <widget class="QComboBox" name="nameCombo" >
- <property name="toolTip" >
- <string>Specify your name</string>
- </property>
- <property name="editable" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="4" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="3" colspan="2" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>61</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="7" column="3" colspan="2" >
- <widget class="QDialogButtonBox" name="buttonBox" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons" >
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- <item row="5" column="1" colspan="4" >
- <widget class="QListWidget" name="professionList" >
- <property name="toolTip" >
- <string>Select your profession</string>
- </property>
- <property name="statusTip" >
- <string>Specify your name here</string>
- </property>
- <property name="whatsThis" >
- <string>Specify your name here</string>
- </property>
- <property name="currentRow" >
- <number>0</number>
- </property>
- <item>
- <property name="text" >
- <string>Developer</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Student</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Fisherman</string>
- </property>
- </item>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QMenuBar" name="menubar" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>29</height>
- </rect>
- </property>
- <widget class="QMenu" name="menu_File" >
- <property name="title" >
- <string>&amp;File</string>
- </property>
- <addaction name="editStyleAction" />
- <addaction name="separator" />
- <addaction name="exitAction" />
- </widget>
- <widget class="QMenu" name="menu_Help" >
- <property name="title" >
- <string>&amp;Help</string>
- </property>
- <addaction name="aboutAction" />
- <addaction name="aboutQtAction" />
- </widget>
- <addaction name="menu_File" />
- <addaction name="menu_Help" />
- </widget>
- <widget class="QStatusBar" name="statusbar" />
- <action name="exitAction" >
- <property name="text" >
- <string>&amp;Exit</string>
- </property>
- </action>
- <action name="aboutQtAction" >
- <property name="text" >
- <string>About Qt</string>
- </property>
- </action>
- <action name="editStyleAction" >
- <property name="text" >
- <string>Edit &amp;Style...</string>
- </property>
- </action>
- <action name="aboutAction" >
- <property name="text" >
- <string>About</string>
- </property>
- </action>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/widgets/widgets/stylesheet/qss/coffee.qss b/examples/widgets/widgets/stylesheet/qss/coffee.qss
deleted file mode 100644
index 4571d42d7e..0000000000
--- a/examples/widgets/widgets/stylesheet/qss/coffee.qss
+++ /dev/null
@@ -1,112 +0,0 @@
-.QWidget {
- background-color: beige;
-}
-
-/* Nice Windows-XP-style password character. */
-QLineEdit[echoMode="2"] {
- lineedit-password-character: 9679;
-}
-
-/* We provide a min-width and min-height for push buttons
- so that they look elegant regardless of the width of the text. */
-QPushButton {
- background-color: palegoldenrod;
- border-width: 2px;
- border-color: darkkhaki;
- border-style: solid;
- border-radius: 5;
- padding: 3px;
- min-width: 9ex;
- min-height: 2.5ex;
-}
-
-QPushButton:hover {
- background-color: khaki;
-}
-
-/* Increase the padding, so the text is shifted when the button is
- pressed. */
-QPushButton:pressed {
- padding-left: 5px;
- padding-top: 5px;
- background-color: #d0d67c;
-}
-
-QLabel, QAbstractButton {
- font: bold;
-}
-
-/* Mark mandatory fields with a brownish color. */
-.mandatory {
- color: brown;
-}
-
-/* Bold text on status bar looks awful. */
-QStatusBar QLabel {
- font: normal;
-}
-
-QStatusBar::item {
- border-width: 1;
- border-color: darkkhaki;
- border-style: solid;
- border-radius: 2;
-}
-
-QComboBox, QLineEdit, QSpinBox, QTextEdit, QListView {
- background-color: cornsilk;
- selection-color: #0a214c;
- selection-background-color: #C19A6B;
-}
-
-QListView {
- show-decoration-selected: 1;
-}
-
-QListView::item:hover {
- background-color: wheat;
-}
-
-/* We reserve 1 pixel space in padding. When we get the focus,
- we kill the padding and enlarge the border. This makes the items
- glow. */
-QLineEdit, QFrame {
- border-width: 2px;
- padding: 1px;
- border-style: solid;
- border-color: darkkhaki;
- border-radius: 5px;
-}
-
-/* As mentioned above, eliminate the padding and increase the border. */
-QLineEdit:focus, QFrame:focus {
- border-width: 3px;
- padding: 0px;
-}
-
-/* A QLabel is a QFrame ... */
-QLabel {
- border: none;
- padding: 0;
- background: none;
-}
-
-/* A QToolTip is a QLabel ... */
-QToolTip {
- border: 2px solid darkkhaki;
- padding: 5px;
- border-radius: 3px;
- opacity: 200;
-}
-
-/* Nice to have the background color change when hovered. */
-QRadioButton:hover, QCheckBox:hover {
- background-color: wheat;
-}
-
-/* Force the dialog's buttons to follow the Windows guidelines. */
-QDialogButtonBox {
- button-layout: 0;
-}
-
-
diff --git a/examples/widgets/widgets/stylesheet/qss/default.qss b/examples/widgets/widgets/stylesheet/qss/default.qss
deleted file mode 100644
index 84eb5e0bc2..0000000000
--- a/examples/widgets/widgets/stylesheet/qss/default.qss
+++ /dev/null
@@ -1 +0,0 @@
-/* empty stylesheet */
diff --git a/examples/widgets/widgets/stylesheet/qss/pagefold.qss b/examples/widgets/widgets/stylesheet/qss/pagefold.qss
deleted file mode 100644
index 3701fc713c..0000000000
--- a/examples/widgets/widgets/stylesheet/qss/pagefold.qss
+++ /dev/null
@@ -1,299 +0,0 @@
-/* Customize any plain widget that is a child of a QMainWindow. */
-QMainWindow > .QWidget {
- background-color: gainsboro;
- background-image: url(:/images/pagefold.png);
- background-position: top right;
- background-repeat: no-repeat
-}
-
-/* Provide a padding for the layout inside the frame. The frame
- exists only to provide a padding for the top-right image, so we
- explicitly disable the border. */
-#mainFrame {
- padding-right: 30px;
- border-style: none;
- border-image: none; /* since we set a border-image below */
-}
-
-/* mainFrame won't have this border-image since we have
- explicitly set it to 'none' using a more specific selector. */
-QFrame, QLineEdit, QComboBox[editable="true"], QSpinBox {
- border-image: url(:/images/frame.png) 4;
- border-width: 3;
-}
-
-QLabel {
- border: none;
- border-image: none;
- padding: 0;
- background: none;
-}
-
-/* Make text in message boxes selectable. */
-QMessageBox {
- /* LinksAccessibleByMouse | TextSelectableByMouse */
- messagebox-text-interaction-flags: 5;
-}
-
-/* Set the selection colors for all widgets. */
-QWidget {
- selection-color: black;
- selection-background-color: Silver;
- color: black;
-}
-
-/* Make the entire row selected in item views. */
-QAbstractItemView {
- show-decoration-selected: 1;
-}
-
-/* Nice WindowsXP-style password character for password line edits. */
-QLineEdit[echoMode="2"] {
- lineedit-password-character: 9679;
-}
-
-/* Customize tooltips. */
-QToolTip {
- background-color: rgb(200,200,255);
- border-color: darkslategray;
- border-width: 1px;
- border-style: solid;
- padding: 3px;
- font: bold;
- border-radius: 3px;
- opacity: 200;
-}
-
-/* Customize radio buttons. */
-
-QRadioButton {
- spacing: 5px;
-}
-
-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);
-}
-
-/* Customize arrows. */
-
-*::down-arrow, *::menu-indicator {
- image: url(:/images/down_arrow.png);
- width: 7px;
- height: 7px;
-}
-
-*::down-arrow:disabled, *::down-arrow:off {
- image: url(:/images/down_arrow_disabled.png);
-}
-
-*::up-arrow {
- image: url(:/images/up_arrow.png);
- width: 7px;
- height: 7px;
-}
-
-*::up-arrow:disabled, *::up-arrow:off {
- image: url(:/images/up_arrow_disabled.png);
-}
-
-/* Customize push buttons and comboboxes. Our read-only combobox
- is very similar to a push button, so they share the same border image. */
-
-QPushButton {
- min-width: 4em;
-}
-
-QPushButton, QComboBox[editable="false"],
-QComboBox[editable="true"]::drop-down {
- border-image: url(:/images/pushbutton.png) 5;
- border-width: 5;
-}
-
-QPushButton:hover, QComboBox[editable="false"]:hover,
-QComboBox[editable="true"]::drop-down:hover, QMenuBar::item:hover {
- border-image: url(:/images/pushbutton_hover.png) 5;
- border-width: 5;
-}
-
-QPushButton:pressed, QComboBox[editable="false"]:on,
-QComboBox[editable="true"]::drop-down:on, QMenuBar::item:on {
- border-image: url(:/images/pushbutton_pressed.png) 5;
- border-width: 5;
-}
-
-/* Customize read-only comboboxes. */
-
-QComboBox[editable="false"] {
- padding-left: 3px;
- padding-right: 20px; /* space for the arrow */
-}
-
-QComboBox[editable="false"]::drop-down {
- subcontrol-origin: padding;
- subcontrol-position: top right;
- width: 15px;
- border-left-style: solid;
- border-left-color: darkgray;
- border-left-width: 1px;
-}
-
-QComboBox[editable="false"]::down-arrow {
- subcontrol-origin: content;
- subcontrol-position: center;
- position: relative;
- left: 1px; /* 1 pixel dropdown border */
-}
-
-/* The combobox arrow is on when the popup is open. */
-QComboBox[editable="false"]::down-arrow:on {
- position: relative;
- top: 1px;
- left: 2px;
-}
-
-/* Customize editable comboboxes. */
-
-QComboBox[editable="true"] {
- padding-right: 16px;
-}
-
-QComboBox[editable="true"]::drop-down {
- subcontrol-origin: border;
- subcontrol-position: top right;
- width: 13px;
- position: absolute;
- top: 2px;
- bottom: 2px;
- right: 2px;
-}
-
-QComboBox[editable="true"]::drop-down,
-QComboBox[editable="true"]::drop-down:hover,
-QComboBox[editable="true"]::drop-down:on {
- border-width: 0px;
- border-left-width: 3px; /* we need only left and center part */
-}
-
-/* Shift the arrow when it's open. */
-QComboBox[editable="true"]::down-arrow:on {
- position: relative;
- top: 1px;
- left: 1px;
-}
-
-/* Customize check boxes. */
-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);
-}
-
-/* Customize the size grip. */
-QSizeGrip {
- image: url(:/images/sizegrip.png);
- width: 16px;
- height: 16px;
-}
-
-/* Customize the menu bar. */
-QMenuBar {
- border-image: none;
- border-style: none;
- border-width: 1px;
- border-bottom-style: solid;
- border-bottom-color: darkslategray;
- padding: 2px;
-}
-
-/* Customize spin boxes. */
-
-QSpinBox {
- padding-right: 15px;
-}
-
-QSpinBox::up-button {
- subcontrol-origin: border;
- subcontrol-position: top right;
-
- 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::down-button {
- subcontrol-origin: border;
- subcontrol-position: bottom right;
-
- 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;
-}
diff --git a/examples/widgets/widgets/stylesheet/stylesheet.pro b/examples/widgets/widgets/stylesheet/stylesheet.pro
deleted file mode 100644
index 0fe3187f63..0000000000
--- a/examples/widgets/widgets/stylesheet/stylesheet.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-QT += widgets
-requires(qtConfig(combobox))
-
-HEADERS = mainwindow.h \
- stylesheeteditor.h
-FORMS = mainwindow.ui \
- stylesheeteditor.ui
-RESOURCES = stylesheet.qrc
-SOURCES = main.cpp \
- mainwindow.cpp \
- stylesheeteditor.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/stylesheet
-INSTALLS += target
diff --git a/examples/widgets/widgets/stylesheet/stylesheet.qrc b/examples/widgets/widgets/stylesheet/stylesheet.qrc
deleted file mode 100644
index e1e61a920a..0000000000
--- a/examples/widgets/widgets/stylesheet/stylesheet.qrc
+++ /dev/null
@@ -1,39 +0,0 @@
-<RCC>
-<qresource prefix="/">
- <file>layouts/default.ui</file>
- <file>layouts/pagefold.ui</file>
- <file>qss/coffee.qss</file>
- <file>qss/default.qss</file>
- <file>qss/pagefold.qss</file>
- <file>images/pagefold.png</file>
- <file>images/frame.png</file>
- <file>images/radiobutton_unchecked.png</file>
- <file>images/radiobutton_unchecked_pressed.png</file>
- <file>images/radiobutton_unchecked_hover.png</file>
- <file>images/radiobutton_checked.png</file>
- <file>images/radiobutton_checked_pressed.png</file>
- <file>images/radiobutton_checked_hover.png</file>
- <file>images/pushbutton.png</file>
- <file>images/pushbutton_hover.png</file>
- <file>images/pushbutton_pressed.png</file>
- <file>images/checkbox_unchecked.png</file>
- <file>images/checkbox_unchecked_pressed.png</file>
- <file>images/checkbox_unchecked_hover.png</file>
- <file>images/checkbox_checked.png</file>
- <file>images/checkbox_checked_pressed.png</file>
- <file>images/checkbox_checked_hover.png</file>
- <file>images/down_arrow.png</file>
- <file>images/down_arrow_disabled.png</file>
- <file>images/up_arrow.png</file>
- <file>images/up_arrow_disabled.png</file>
- <file>images/sizegrip.png</file>
- <file>images/spinup.png</file>
- <file>images/spinup_off.png</file>
- <file>images/spinup_hover.png</file>
- <file>images/spinup_pressed.png</file>
- <file>images/spindown.png</file>
- <file>images/spindown_off.png</file>
- <file>images/spindown_hover.png</file>
- <file>images/spindown_pressed.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp b/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp
deleted file mode 100644
index 84fda79a16..0000000000
--- a/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "stylesheeteditor.h"
-
-#include <QFile>
-#include <QRegularExpression>
-#include <QStyleFactory>
-
-StyleSheetEditor::StyleSheetEditor(QWidget *parent)
- : QDialog(parent)
-{
- ui.setupUi(this);
-
- connect(ui.styleCombo, &QComboBox::textActivated, this, &StyleSheetEditor::setStyleName);
- connect(ui.styleSheetCombo, &QComboBox::textActivated, this, &StyleSheetEditor::setStyleSheetName);
- connect(ui.styleTextEdit, &QTextEdit::textChanged, this, &StyleSheetEditor::setModified);
- connect(ui.applyButton, &QAbstractButton::clicked, this, &StyleSheetEditor::apply);
-
- QRegularExpression regExp("^.(.*)\\+?Style$");
- QString defaultStyle = QApplication::style()->metaObject()->className();
- QRegularExpressionMatch match = regExp.match(defaultStyle);
-
- if (match.hasMatch())
- defaultStyle = match.captured(1);
-
- ui.styleCombo->addItems(QStyleFactory::keys());
- ui.styleCombo->setCurrentIndex(ui.styleCombo->findText(defaultStyle, Qt::MatchContains));
- ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText("Coffee"));
- loadStyleSheet("Coffee");
-}
-
-void StyleSheetEditor::setStyleName(const QString &styleName)
-{
- qApp->setStyle(styleName);
- ui.applyButton->setEnabled(false);
-}
-
-void StyleSheetEditor::setStyleSheetName(const QString &sheetName)
-{
- loadStyleSheet(sheetName);
-}
-
-void StyleSheetEditor::setModified()
-{
- ui.applyButton->setEnabled(true);
-}
-
-void StyleSheetEditor::apply()
-{
- qApp->setStyleSheet(ui.styleTextEdit->toPlainText());
- ui.applyButton->setEnabled(false);
-}
-
-void StyleSheetEditor::loadStyleSheet(const QString &sheetName)
-{
- QFile file(":/qss/" + sheetName.toLower() + ".qss");
- file.open(QFile::ReadOnly);
- QString styleSheet = QString::fromLatin1(file.readAll());
-
- ui.styleTextEdit->setPlainText(styleSheet);
- qApp->setStyleSheet(styleSheet);
- ui.applyButton->setEnabled(false);
-}
diff --git a/examples/widgets/widgets/stylesheet/stylesheeteditor.h b/examples/widgets/widgets/stylesheet/stylesheeteditor.h
deleted file mode 100644
index e61534a4f9..0000000000
--- a/examples/widgets/widgets/stylesheet/stylesheeteditor.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef STYLESHEETEDITOR_H
-#define STYLESHEETEDITOR_H
-
-#include <QDialog>
-
-#include "ui_stylesheeteditor.h"
-
-class StyleSheetEditor : public QDialog
-{
- Q_OBJECT
-
-public:
- StyleSheetEditor(QWidget *parent = nullptr);
-
-private slots:
- void setStyleName(const QString &styleName);
- void setStyleSheetName(const QString &styleSheetName);
- void setModified();
- void apply();
-
-private:
- void loadStyleSheet(const QString &sheetName);
-
- Ui::StyleSheetEditor ui;
-};
-
-#endif
diff --git a/examples/widgets/widgets/stylesheet/stylesheeteditor.ui b/examples/widgets/widgets/stylesheet/stylesheeteditor.ui
deleted file mode 100644
index 34cd7f6d04..0000000000
--- a/examples/widgets/widgets/stylesheet/stylesheeteditor.ui
+++ /dev/null
@@ -1,171 +0,0 @@
-<ui version="4.0" >
- <class>StyleSheetEditor</class>
- <widget class="QWidget" name="StyleSheetEditor" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>445</width>
- <height>289</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Style Editor</string>
- </property>
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="0" column="6" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::MinimumExpanding</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>32</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="0" column="0" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::MinimumExpanding</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>32</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="0" column="5" >
- <widget class="QComboBox" name="styleSheetCombo" >
- <item>
- <property name="text" >
- <string>Default</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Coffee</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Pagefold</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="0" column="3" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>10</width>
- <height>16</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="0" column="2" >
- <widget class="QComboBox" name="styleCombo" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QLabel" name="label_7" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>5</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>Style:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="7" >
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>321</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="applyButton" >
- <property name="enabled" >
- <bool>false</bool>
- </property>
- <property name="text" >
- <string>&amp;Apply</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0" colspan="7" >
- <widget class="QTextEdit" name="styleTextEdit" />
- </item>
- <item row="0" column="4" >
- <widget class="QLabel" name="label_8" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>5</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>Style Sheet:</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/widgets/widgets/tablet/CMakeLists.txt b/examples/widgets/widgets/tablet/CMakeLists.txt
index bb1d76f2fb..caf9922741 100644
--- a/examples/widgets/widgets/tablet/CMakeLists.txt
+++ b/examples/widgets/widgets/tablet/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(qttablet LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/tablet")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(qttablet
main.cpp
mainwindow.cpp mainwindow.h
@@ -26,10 +20,10 @@ set_target_properties(qttablet PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(qttablet PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(qttablet PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
# Resources:
@@ -48,7 +42,14 @@ qt_add_resources(qttablet "images"
)
install(TARGETS qttablet
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET qttablet
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/widgets/tetrix/CMakeLists.txt b/examples/widgets/widgets/tetrix/CMakeLists.txt
deleted file mode 100644
index 4320cef400..0000000000
--- a/examples/widgets/widgets/tetrix/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(tetrix LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/tetrix")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(tetrix
- main.cpp
- tetrixboard.cpp tetrixboard.h
- tetrixpiece.cpp tetrixpiece.h
- tetrixwindow.cpp tetrixwindow.h
-)
-
-set_target_properties(tetrix PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(tetrix PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS tetrix
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/tetrix/main.cpp b/examples/widgets/widgets/tetrix/main.cpp
deleted file mode 100644
index 24791bde26..0000000000
--- a/examples/widgets/widgets/tetrix/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "tetrixwindow.h"
-
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- TetrixWindow window;
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/widgets/tetrix/tetrix.pro b/examples/widgets/widgets/tetrix/tetrix.pro
deleted file mode 100644
index bb9f855fb0..0000000000
--- a/examples/widgets/widgets/tetrix/tetrix.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-QT += widgets
-
-HEADERS = tetrixboard.h \
- tetrixpiece.h \
- tetrixwindow.h
-SOURCES = main.cpp \
- tetrixboard.cpp \
- tetrixpiece.cpp \
- tetrixwindow.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/tetrix
-INSTALLS += target
diff --git a/examples/widgets/widgets/tetrix/tetrixboard.cpp b/examples/widgets/widgets/tetrix/tetrixboard.cpp
deleted file mode 100644
index 0c5771ad89..0000000000
--- a/examples/widgets/widgets/tetrix/tetrixboard.cpp
+++ /dev/null
@@ -1,371 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "tetrixboard.h"
-
-#include <QKeyEvent>
-#include <QLabel>
-#include <QPainter>
-
-//! [0]
-TetrixBoard::TetrixBoard(QWidget *parent)
- : QFrame(parent), isStarted(false), isPaused(false)
-{
- setFrameStyle(QFrame::Panel | QFrame::Sunken);
- setFocusPolicy(Qt::StrongFocus);
- clearBoard();
-
- nextPiece.setRandomShape();
-}
-//! [0]
-
-//! [1]
-void TetrixBoard::setNextPieceLabel(QLabel *label)
-{
- nextPieceLabel = label;
-}
-//! [1]
-
-//! [2]
-QSize TetrixBoard::sizeHint() const
-{
- return QSize(BoardWidth * 15 + frameWidth() * 2,
- BoardHeight * 15 + frameWidth() * 2);
-}
-
-QSize TetrixBoard::minimumSizeHint() const
-//! [2] //! [3]
-{
- return QSize(BoardWidth * 5 + frameWidth() * 2,
- BoardHeight * 5 + frameWidth() * 2);
-}
-//! [3]
-
-//! [4]
-void TetrixBoard::start()
-{
- if (isPaused)
- return;
-
- isStarted = true;
- isWaitingAfterLine = false;
- numLinesRemoved = 0;
- numPiecesDropped = 0;
- score = 0;
- level = 1;
- clearBoard();
-
- emit linesRemovedChanged(numLinesRemoved);
- emit scoreChanged(score);
- emit levelChanged(level);
-
- newPiece();
- timer.start(timeoutTime(), this);
-}
-//! [4]
-
-//! [5]
-void TetrixBoard::pause()
-{
- if (!isStarted)
- return;
-
- isPaused = !isPaused;
- if (isPaused) {
- timer.stop();
- } else {
- timer.start(timeoutTime(), this);
- }
- update();
-//! [5] //! [6]
-}
-//! [6]
-
-//! [7]
-void TetrixBoard::paintEvent(QPaintEvent *event)
-{
- QFrame::paintEvent(event);
-
- QPainter painter(this);
- QRect rect = contentsRect();
-//! [7]
-
- if (isPaused) {
- painter.drawText(rect, Qt::AlignCenter, tr("Pause"));
- return;
- }
-
-//! [8]
- int boardTop = rect.bottom() - BoardHeight*squareHeight();
-
- for (int i = 0; i < BoardHeight; ++i) {
- for (int j = 0; j < BoardWidth; ++j) {
- TetrixShape shape = shapeAt(j, BoardHeight - i - 1);
- if (shape != NoShape)
- drawSquare(painter, rect.left() + j * squareWidth(),
- boardTop + i * squareHeight(), shape);
- }
-//! [8] //! [9]
- }
-//! [9]
-
-//! [10]
- if (curPiece.shape() != NoShape) {
- for (int i = 0; i < 4; ++i) {
- int x = curX + curPiece.x(i);
- int y = curY - curPiece.y(i);
- drawSquare(painter, rect.left() + x * squareWidth(),
- boardTop + (BoardHeight - y - 1) * squareHeight(),
- curPiece.shape());
- }
-//! [10] //! [11]
- }
-//! [11] //! [12]
-}
-//! [12]
-
-//! [13]
-void TetrixBoard::keyPressEvent(QKeyEvent *event)
-{
- if (!isStarted || isPaused || curPiece.shape() == NoShape) {
- QFrame::keyPressEvent(event);
- return;
- }
-//! [13]
-
-//! [14]
- switch (event->key()) {
- case Qt::Key_Left:
- tryMove(curPiece, curX - 1, curY);
- break;
- case Qt::Key_Right:
- tryMove(curPiece, curX + 1, curY);
- break;
- case Qt::Key_Down:
- tryMove(curPiece.rotatedRight(), curX, curY);
- break;
- case Qt::Key_Up:
- tryMove(curPiece.rotatedLeft(), curX, curY);
- break;
- case Qt::Key_Space:
- dropDown();
- break;
- case Qt::Key_D:
- oneLineDown();
- break;
- default:
- QFrame::keyPressEvent(event);
- }
-//! [14]
-}
-
-//! [15]
-void TetrixBoard::timerEvent(QTimerEvent *event)
-{
- if (event->timerId() == timer.timerId()) {
- if (isWaitingAfterLine) {
- isWaitingAfterLine = false;
- newPiece();
- timer.start(timeoutTime(), this);
- } else {
- oneLineDown();
- }
- } else {
- QFrame::timerEvent(event);
-//! [15] //! [16]
- }
-//! [16] //! [17]
-}
-//! [17]
-
-//! [18]
-void TetrixBoard::clearBoard()
-{
- for (int i = 0; i < BoardHeight * BoardWidth; ++i)
- board[i] = NoShape;
-}
-//! [18]
-
-//! [19]
-void TetrixBoard::dropDown()
-{
- int dropHeight = 0;
- int newY = curY;
- while (newY > 0) {
- if (!tryMove(curPiece, curX, newY - 1))
- break;
- --newY;
- ++dropHeight;
- }
- pieceDropped(dropHeight);
-//! [19] //! [20]
-}
-//! [20]
-
-//! [21]
-void TetrixBoard::oneLineDown()
-{
- if (!tryMove(curPiece, curX, curY - 1))
- pieceDropped(0);
-}
-//! [21]
-
-//! [22]
-void TetrixBoard::pieceDropped(int dropHeight)
-{
- for (int i = 0; i < 4; ++i) {
- int x = curX + curPiece.x(i);
- int y = curY - curPiece.y(i);
- shapeAt(x, y) = curPiece.shape();
- }
-
- ++numPiecesDropped;
- if (numPiecesDropped % 25 == 0) {
- ++level;
- timer.start(timeoutTime(), this);
- emit levelChanged(level);
- }
-
- score += dropHeight + 7;
- emit scoreChanged(score);
- removeFullLines();
-
- if (!isWaitingAfterLine)
- newPiece();
-//! [22] //! [23]
-}
-//! [23]
-
-//! [24]
-void TetrixBoard::removeFullLines()
-{
- int numFullLines = 0;
-
- for (int i = BoardHeight - 1; i >= 0; --i) {
- bool lineIsFull = true;
-
- for (int j = 0; j < BoardWidth; ++j) {
- if (shapeAt(j, i) == NoShape) {
- lineIsFull = false;
- break;
- }
- }
-
- if (lineIsFull) {
-//! [24] //! [25]
- ++numFullLines;
- for (int k = i; k < BoardHeight - 1; ++k) {
- for (int j = 0; j < BoardWidth; ++j)
- shapeAt(j, k) = shapeAt(j, k + 1);
- }
-//! [25] //! [26]
- for (int j = 0; j < BoardWidth; ++j)
- shapeAt(j, BoardHeight - 1) = NoShape;
- }
-//! [26] //! [27]
- }
-//! [27]
-
-//! [28]
- if (numFullLines > 0) {
- numLinesRemoved += numFullLines;
- score += 10 * numFullLines;
- emit linesRemovedChanged(numLinesRemoved);
- emit scoreChanged(score);
-
- timer.start(500, this);
- isWaitingAfterLine = true;
- curPiece.setShape(NoShape);
- update();
- }
-//! [28] //! [29]
-}
-//! [29]
-
-//! [30]
-void TetrixBoard::newPiece()
-{
- curPiece = nextPiece;
- nextPiece.setRandomShape();
- showNextPiece();
- curX = BoardWidth / 2 + 1;
- curY = BoardHeight - 1 + curPiece.minY();
-
- if (!tryMove(curPiece, curX, curY)) {
- curPiece.setShape(NoShape);
- timer.stop();
- isStarted = false;
- }
-//! [30] //! [31]
-}
-//! [31]
-
-//! [32]
-void TetrixBoard::showNextPiece()
-{
- if (!nextPieceLabel)
- return;
-
- int dx = nextPiece.maxX() - nextPiece.minX() + 1;
- int dy = nextPiece.maxY() - nextPiece.minY() + 1;
-
- QPixmap pixmap(dx * squareWidth(), dy * squareHeight());
- QPainter painter(&pixmap);
- painter.fillRect(pixmap.rect(), nextPieceLabel->palette().window());
-
- for (int i = 0; i < 4; ++i) {
- int x = nextPiece.x(i) - nextPiece.minX();
- int y = nextPiece.y(i) - nextPiece.minY();
- drawSquare(painter, x * squareWidth(), y * squareHeight(),
- nextPiece.shape());
- }
- nextPieceLabel->setPixmap(pixmap);
-//! [32] //! [33]
-}
-//! [33]
-
-//! [34]
-bool TetrixBoard::tryMove(const TetrixPiece &newPiece, int newX, int newY)
-{
- for (int i = 0; i < 4; ++i) {
- int x = newX + newPiece.x(i);
- int y = newY - newPiece.y(i);
- if (x < 0 || x >= BoardWidth || y < 0 || y >= BoardHeight)
- return false;
- if (shapeAt(x, y) != NoShape)
- return false;
- }
-//! [34]
-
-//! [35]
- curPiece = newPiece;
- curX = newX;
- curY = newY;
- update();
- return true;
-}
-//! [35]
-
-//! [36]
-void TetrixBoard::drawSquare(QPainter &painter, int x, int y, TetrixShape shape)
-{
- static constexpr QRgb colorTable[8] = {
- 0x000000, 0xCC6666, 0x66CC66, 0x6666CC,
- 0xCCCC66, 0xCC66CC, 0x66CCCC, 0xDAAA00
- };
-
- QColor color = colorTable[int(shape)];
- painter.fillRect(x + 1, y + 1, squareWidth() - 2, squareHeight() - 2,
- color);
-
- painter.setPen(color.lighter());
- painter.drawLine(x, y + squareHeight() - 1, x, y);
- painter.drawLine(x, y, x + squareWidth() - 1, y);
-
- painter.setPen(color.darker());
- painter.drawLine(x + 1, y + squareHeight() - 1,
- x + squareWidth() - 1, y + squareHeight() - 1);
- painter.drawLine(x + squareWidth() - 1, y + squareHeight() - 1,
- x + squareWidth() - 1, y + 1);
-}
-//! [36]
diff --git a/examples/widgets/widgets/tetrix/tetrixboard.h b/examples/widgets/widgets/tetrix/tetrixboard.h
deleted file mode 100644
index c2fe3fd01e..0000000000
--- a/examples/widgets/widgets/tetrix/tetrixboard.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef TETRIXBOARD_H
-#define TETRIXBOARD_H
-
-#include <QBasicTimer>
-#include <QFrame>
-#include <QPointer>
-
-#include "tetrixpiece.h"
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-QT_END_NAMESPACE
-
-//! [0]
-class TetrixBoard : public QFrame
-{
- Q_OBJECT
-
-public:
- TetrixBoard(QWidget *parent = nullptr);
-
- void setNextPieceLabel(QLabel *label);
- QSize sizeHint() const override;
- QSize minimumSizeHint() const override;
-
-public slots:
- void start();
- void pause();
-
-signals:
- void scoreChanged(int score);
- void levelChanged(int level);
- void linesRemovedChanged(int numLines);
-
-protected:
- void paintEvent(QPaintEvent *event) override;
- void keyPressEvent(QKeyEvent *event) override;
- void timerEvent(QTimerEvent *event) override;
-//! [0]
-
-//! [1]
-private:
- enum { BoardWidth = 10, BoardHeight = 22 };
-
- TetrixShape &shapeAt(int x, int y) { return board[(y * BoardWidth) + x]; }
- int timeoutTime() { return 1000 / (1 + level); }
- int squareWidth() { return contentsRect().width() / BoardWidth; }
- int squareHeight() { return contentsRect().height() / BoardHeight; }
- void clearBoard();
- void dropDown();
- void oneLineDown();
- void pieceDropped(int dropHeight);
- void removeFullLines();
- void newPiece();
- void showNextPiece();
- bool tryMove(const TetrixPiece &newPiece, int newX, int newY);
- void drawSquare(QPainter &painter, int x, int y, TetrixShape shape);
-
- QBasicTimer timer;
- QPointer<QLabel> nextPieceLabel;
- bool isStarted;
- bool isPaused;
- bool isWaitingAfterLine;
- TetrixPiece curPiece;
- TetrixPiece nextPiece;
- int curX;
- int curY;
- int numLinesRemoved;
- int numPiecesDropped;
- int score;
- int level;
- TetrixShape board[BoardWidth * BoardHeight];
-};
-//! [1]
-
-#endif
diff --git a/examples/widgets/widgets/tetrix/tetrixpiece.cpp b/examples/widgets/widgets/tetrix/tetrixpiece.cpp
deleted file mode 100644
index 5dc9e11c49..0000000000
--- a/examples/widgets/widgets/tetrix/tetrixpiece.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "tetrixpiece.h"
-
-#include <QtCore>
-
-//! [0]
-void TetrixPiece::setRandomShape()
-{
- setShape(TetrixShape(QRandomGenerator::global()->bounded(7) + 1));
-}
-//! [0]
-
-//! [1]
-void TetrixPiece::setShape(TetrixShape shape)
-{
- static constexpr int coordsTable[8][4][2] = {
- { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
- { { 0, -1 }, { 0, 0 }, { -1, 0 }, { -1, 1 } },
- { { 0, -1 }, { 0, 0 }, { 1, 0 }, { 1, 1 } },
- { { 0, -1 }, { 0, 0 }, { 0, 1 }, { 0, 2 } },
- { { -1, 0 }, { 0, 0 }, { 1, 0 }, { 0, 1 } },
- { { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } },
- { { -1, -1 }, { 0, -1 }, { 0, 0 }, { 0, 1 } },
- { { 1, -1 }, { 0, -1 }, { 0, 0 }, { 0, 1 } }
- };
-
- for (int i = 0; i < 4 ; i++) {
- for (int j = 0; j < 2; ++j)
- coords[i][j] = coordsTable[shape][i][j];
- }
- pieceShape = shape;
-//! [1] //! [2]
-}
-//! [2]
-
-//! [3]
-int TetrixPiece::minX() const
-{
- int min = coords[0][0];
- for (int i = 1; i < 4; ++i)
- min = qMin(min, coords[i][0]);
- return min;
-}
-
-int TetrixPiece::maxX() const
-//! [3] //! [4]
-{
- int max = coords[0][0];
- for (int i = 1; i < 4; ++i)
- max = qMax(max, coords[i][0]);
- return max;
-}
-//! [4]
-
-//! [5]
-int TetrixPiece::minY() const
-{
- int min = coords[0][1];
- for (int i = 1; i < 4; ++i)
- min = qMin(min, coords[i][1]);
- return min;
-}
-
-int TetrixPiece::maxY() const
-//! [5] //! [6]
-{
- int max = coords[0][1];
- for (int i = 1; i < 4; ++i)
- max = qMax(max, coords[i][1]);
- return max;
-}
-//! [6]
-
-//! [7]
-TetrixPiece TetrixPiece::rotatedLeft() const
-{
- if (pieceShape == SquareShape)
- return *this;
-
- TetrixPiece result;
- result.pieceShape = pieceShape;
- for (int i = 0; i < 4; ++i) {
- result.setX(i, y(i));
- result.setY(i, -x(i));
- }
-//! [7]
- return result;
-}
-
-//! [9]
-TetrixPiece TetrixPiece::rotatedRight() const
-{
- if (pieceShape == SquareShape)
- return *this;
-
- TetrixPiece result;
- result.pieceShape = pieceShape;
- for (int i = 0; i < 4; ++i) {
- result.setX(i, -y(i));
- result.setY(i, x(i));
- }
-//! [9]
- return result;
-}
diff --git a/examples/widgets/widgets/tetrix/tetrixpiece.h b/examples/widgets/widgets/tetrix/tetrixpiece.h
deleted file mode 100644
index 86a513a76e..0000000000
--- a/examples/widgets/widgets/tetrix/tetrixpiece.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef TETRIXPIECE_H
-#define TETRIXPIECE_H
-
-enum TetrixShape { NoShape, ZShape, SShape, LineShape, TShape, SquareShape,
- LShape, MirroredLShape };
-
-//! [0]
-class TetrixPiece
-{
-public:
- TetrixPiece() { setShape(NoShape); }
-
- void setRandomShape();
- void setShape(TetrixShape shape);
-
- TetrixShape shape() const { return pieceShape; }
- int x(int index) const { return coords[index][0]; }
- int y(int index) const { return coords[index][1]; }
- int minX() const;
- int maxX() const;
- int minY() const;
- int maxY() const;
- TetrixPiece rotatedLeft() const;
- TetrixPiece rotatedRight() const;
-
-private:
- void setX(int index, int x) { coords[index][0] = x; }
- void setY(int index, int y) { coords[index][1] = y; }
-
- TetrixShape pieceShape;
- int coords[4][2];
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/tetrix/tetrixwindow.cpp b/examples/widgets/widgets/tetrix/tetrixwindow.cpp
deleted file mode 100644
index ae10a778e7..0000000000
--- a/examples/widgets/widgets/tetrix/tetrixwindow.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "tetrixboard.h"
-#include "tetrixwindow.h"
-
-#include <QCoreApplication>
-#include <QGridLayout>
-#include <QLabel>
-#include <QLCDNumber>
-#include <QPushButton>
-
-//! [0]
-TetrixWindow::TetrixWindow(QWidget *parent)
- : QWidget(parent), board(new TetrixBoard)
-{
-//! [0]
- nextPieceLabel = new QLabel;
- nextPieceLabel->setFrameStyle(QFrame::Box | QFrame::Raised);
- nextPieceLabel->setAlignment(Qt::AlignCenter);
- board->setNextPieceLabel(nextPieceLabel);
-//! [1]
- scoreLcd = new QLCDNumber(5);
- scoreLcd->setSegmentStyle(QLCDNumber::Filled);
-//! [1]
- levelLcd = new QLCDNumber(2);
- levelLcd->setSegmentStyle(QLCDNumber::Filled);
- linesLcd = new QLCDNumber(5);
- linesLcd->setSegmentStyle(QLCDNumber::Filled);
-
-//! [2]
- startButton = new QPushButton(tr("&Start"));
- startButton->setFocusPolicy(Qt::NoFocus);
- quitButton = new QPushButton(tr("&Quit"));
- quitButton->setFocusPolicy(Qt::NoFocus);
- pauseButton = new QPushButton(tr("&Pause"));
-//! [2] //! [3]
- pauseButton->setFocusPolicy(Qt::NoFocus);
-//! [3] //! [4]
-
- connect(startButton, &QPushButton::clicked, board, &TetrixBoard::start);
-//! [4] //! [5]
- connect(quitButton , &QPushButton::clicked, qApp, &QCoreApplication::quit);
- connect(pauseButton, &QPushButton::clicked, board, &TetrixBoard::pause);
- connect(board, &TetrixBoard::scoreChanged,
- scoreLcd, qOverload<int>(&QLCDNumber::display));
- connect(board, &TetrixBoard::levelChanged,
- levelLcd, qOverload<int>(&QLCDNumber::display));
- connect(board, &TetrixBoard::linesRemovedChanged,
- linesLcd, qOverload<int>(&QLCDNumber::display));
-//! [5]
-
-//! [6]
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(createLabel(tr("NEXT")), 0, 0);
- layout->addWidget(nextPieceLabel, 1, 0);
- layout->addWidget(createLabel(tr("LEVEL")), 2, 0);
- layout->addWidget(levelLcd, 3, 0);
- layout->addWidget(startButton, 4, 0);
- layout->addWidget(board, 0, 1, 6, 1);
- layout->addWidget(createLabel(tr("SCORE")), 0, 2);
- layout->addWidget(scoreLcd, 1, 2);
- layout->addWidget(createLabel(tr("LINES REMOVED")), 2, 2);
- layout->addWidget(linesLcd, 3, 2);
- layout->addWidget(quitButton, 4, 2);
- layout->addWidget(pauseButton, 5, 2);
- setLayout(layout);
-
- setWindowTitle(tr("Tetrix"));
- resize(550, 370);
-}
-//! [6]
-
-//! [7]
-QLabel *TetrixWindow::createLabel(const QString &text)
-{
- QLabel *label = new QLabel(text);
- label->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
- return label;
-}
-//! [7]
-
diff --git a/examples/widgets/widgets/tetrix/tetrixwindow.h b/examples/widgets/widgets/tetrix/tetrixwindow.h
deleted file mode 100644
index 2ed468717d..0000000000
--- a/examples/widgets/widgets/tetrix/tetrixwindow.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef TETRIXWINDOW_H
-#define TETRIXWINDOW_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QLCDNumber;
-class QLabel;
-class QPushButton;
-QT_END_NAMESPACE
-class TetrixBoard;
-
-//! [0]
-class TetrixWindow : public QWidget
-{
- Q_OBJECT
-
-public:
- TetrixWindow(QWidget *parent = nullptr);
-
-private:
- QLabel *createLabel(const QString &text);
-
- TetrixBoard *board;
- QLabel *nextPieceLabel;
- QLCDNumber *scoreLcd;
- QLCDNumber *levelLcd;
- QLCDNumber *linesLcd;
- QPushButton *startButton;
- QPushButton *quitButton;
- QPushButton *pauseButton;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/tooltips/CMakeLists.txt b/examples/widgets/widgets/tooltips/CMakeLists.txt
deleted file mode 100644
index 7e1e0fbf1c..0000000000
--- a/examples/widgets/widgets/tooltips/CMakeLists.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(tooltips LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/tooltips")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(tooltips
- main.cpp
- shapeitem.cpp shapeitem.h
- sortingbox.cpp sortingbox.h
-)
-
-set_target_properties(tooltips PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(tooltips PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(tooltips_resource_files
- "images/circle.png"
- "images/square.png"
- "images/triangle.png"
-)
-
-qt_add_resources(tooltips "tooltips"
- PREFIX
- "/"
- FILES
- ${tooltips_resource_files}
-)
-
-install(TARGETS tooltips
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/tooltips/images/circle.png b/examples/widgets/widgets/tooltips/images/circle.png
deleted file mode 100644
index dc392cb3f7..0000000000
--- a/examples/widgets/widgets/tooltips/images/circle.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/tooltips/images/square.png b/examples/widgets/widgets/tooltips/images/square.png
deleted file mode 100644
index c0fd2d540a..0000000000
--- a/examples/widgets/widgets/tooltips/images/square.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/tooltips/images/triangle.png b/examples/widgets/widgets/tooltips/images/triangle.png
deleted file mode 100644
index 2ee15f8f1f..0000000000
--- a/examples/widgets/widgets/tooltips/images/triangle.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/tooltips/main.cpp b/examples/widgets/widgets/tooltips/main.cpp
deleted file mode 100644
index 677d9ecd15..0000000000
--- a/examples/widgets/widgets/tooltips/main.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QApplication>
-
-#include "sortingbox.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(tooltips);
-
- QApplication app(argc, argv);
- SortingBox sortingBox;
- sortingBox.show();
- return app.exec();
-}
diff --git a/examples/widgets/widgets/tooltips/shapeitem.cpp b/examples/widgets/widgets/tooltips/shapeitem.cpp
deleted file mode 100644
index c66c7ab958..0000000000
--- a/examples/widgets/widgets/tooltips/shapeitem.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "shapeitem.h"
-
-//! [0]
-QPainterPath ShapeItem::path() const
-{
- return myPath;
-}
-//! [0]
-
-//! [1]
-QPoint ShapeItem::position() const
-{
- return myPosition;
-}
-//! [1]
-
-//! [2]
-QColor ShapeItem::color() const
-{
- return myColor;
-}
-//! [2]
-
-//! [3]
-QString ShapeItem::toolTip() const
-{
- return myToolTip;
-}
-//! [3]
-
-//! [4]
-void ShapeItem::setPath(const QPainterPath &path)
-{
- myPath = path;
-}
-//! [4]
-
-//! [5]
-void ShapeItem::setToolTip(const QString &toolTip)
-{
- myToolTip = toolTip;
-}
-//! [5]
-
-//! [6]
-void ShapeItem::setPosition(const QPoint &position)
-{
- myPosition = position;
-}
-//! [6]
-
-//! [7]
-void ShapeItem::setColor(const QColor &color)
-{
- myColor = color;
-}
-//! [7]
diff --git a/examples/widgets/widgets/tooltips/shapeitem.h b/examples/widgets/widgets/tooltips/shapeitem.h
deleted file mode 100644
index 6c0643fa89..0000000000
--- a/examples/widgets/widgets/tooltips/shapeitem.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef SHAPEITEM_H
-#define SHAPEITEM_H
-
-#include <QColor>
-#include <QPainterPath>
-#include <QPoint>
-
-//! [0]
-class ShapeItem
-{
-public:
- void setPath(const QPainterPath &path);
- void setToolTip(const QString &toolTip);
- void setPosition(const QPoint &position);
- void setColor(const QColor &color);
-
- QPainterPath path() const;
- QPoint position() const;
- QColor color() const;
- QString toolTip() const;
-
-private:
- QPainterPath myPath;
- QPoint myPosition;
- QColor myColor;
- QString myToolTip;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/tooltips/sortingbox.cpp b/examples/widgets/widgets/tooltips/sortingbox.cpp
deleted file mode 100644
index 2b9127f5bd..0000000000
--- a/examples/widgets/widgets/tooltips/sortingbox.cpp
+++ /dev/null
@@ -1,269 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "sortingbox.h"
-
-#include <QMouseEvent>
-#include <QIcon>
-#include <QPainter>
-#include <QRandomGenerator>
-#include <QStyle>
-#include <QToolButton>
-#include <QToolTip>
-
-//! [0]
-SortingBox::SortingBox(QWidget *parent)
- : QWidget(parent)
-{
-//! [0] //! [1]
- setMouseTracking(true);
-//! [1] //! [2]
- setBackgroundRole(QPalette::Base);
-//! [2]
-
- itemInMotion = nullptr;
-
-//! [3]
- newCircleButton = createToolButton(tr("New Circle"),
- QIcon(":/images/circle.png"),
- SLOT(createNewCircle()));
-
- newSquareButton = createToolButton(tr("New Square"),
- QIcon(":/images/square.png"),
- SLOT(createNewSquare()));
-
- newTriangleButton = createToolButton(tr("New Triangle"),
- QIcon(":/images/triangle.png"),
- SLOT(createNewTriangle()));
-
- circlePath.addEllipse(QRect(0, 0, 100, 100));
- squarePath.addRect(QRect(0, 0, 100, 100));
-
- qreal x = trianglePath.currentPosition().x();
- qreal y = trianglePath.currentPosition().y();
- trianglePath.moveTo(x + 120 / 2, y);
- trianglePath.lineTo(0, 100);
- trianglePath.lineTo(120, 100);
- trianglePath.lineTo(x + 120 / 2, y);
-
-//! [3] //! [4]
- setWindowTitle(tr("Tool Tips"));
- resize(500, 300);
-
- createShapeItem(circlePath, tr("Circle"), initialItemPosition(circlePath),
- initialItemColor());
- createShapeItem(squarePath, tr("Square"), initialItemPosition(squarePath),
- initialItemColor());
- createShapeItem(trianglePath, tr("Triangle"),
- initialItemPosition(trianglePath), initialItemColor());
-}
-//! [4]
-
-//! [5]
-bool SortingBox::event(QEvent *event)
-{
-//! [5] //! [6]
- if (event->type() == QEvent::ToolTip) {
- QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
- int index = itemAt(helpEvent->pos());
- if (index != -1) {
- QToolTip::showText(helpEvent->globalPos(), shapeItems[index].toolTip());
- } else {
- QToolTip::hideText();
- event->ignore();
- }
-
- return true;
- }
- return QWidget::event(event);
-}
-//! [6]
-
-//! [7]
-void SortingBox::resizeEvent(QResizeEvent * /* event */)
-{
- int margin = style()->pixelMetric(QStyle::PM_LayoutTopMargin);
- int x = width() - margin;
- int y = height() - margin;
-
- y = updateButtonGeometry(newCircleButton, x, y);
- y = updateButtonGeometry(newSquareButton, x, y);
- updateButtonGeometry(newTriangleButton, x, y);
-}
-//! [7]
-
-//! [8]
-void SortingBox::paintEvent(QPaintEvent * /* event */)
-{
- QPainter painter(this);
- painter.setRenderHint(QPainter::Antialiasing);
- for (const ShapeItem &shapeItem : qAsConst(shapeItems)) {
-//! [8] //! [9]
- painter.translate(shapeItem.position());
-//! [9] //! [10]
- painter.setBrush(shapeItem.color());
- painter.drawPath(shapeItem.path());
- painter.translate(-shapeItem.position());
- }
-}
-//! [10]
-
-//! [11]
-void SortingBox::mousePressEvent(QMouseEvent *event)
-{
- if (event->button() == Qt::LeftButton) {
- int index = itemAt(event->position().toPoint());
- if (index != -1) {
- itemInMotion = &shapeItems[index];
- previousPosition = event->position().toPoint();
- shapeItems.move(index, shapeItems.size() - 1);
- update();
- }
- }
-}
-//! [11]
-
-//! [12]
-void SortingBox::mouseMoveEvent(QMouseEvent *event)
-{
- if ((event->buttons() & Qt::LeftButton) && itemInMotion)
- moveItemTo(event->position().toPoint());
-}
-//! [12]
-
-//! [13]
-void SortingBox::mouseReleaseEvent(QMouseEvent *event)
-{
- if (event->button() == Qt::LeftButton && itemInMotion) {
- moveItemTo(event->position().toPoint());
- itemInMotion = nullptr;
- }
-}
-//! [13]
-
-//! [14]
-void SortingBox::createNewCircle()
-{
- static int count = 1;
- createShapeItem(circlePath, tr("Circle <%1>").arg(++count),
- randomItemPosition(), randomItemColor());
-}
-//! [14]
-
-//! [15]
-void SortingBox::createNewSquare()
-{
- static int count = 1;
- createShapeItem(squarePath, tr("Square <%1>").arg(++count),
- randomItemPosition(), randomItemColor());
-}
-//! [15]
-
-//! [16]
-void SortingBox::createNewTriangle()
-{
- static int count = 1;
- createShapeItem(trianglePath, tr("Triangle <%1>").arg(++count),
- randomItemPosition(), randomItemColor());
-}
-//! [16]
-
-//! [17]
-int SortingBox::itemAt(const QPoint &pos)
-{
- for (int i = shapeItems.size() - 1; i >= 0; --i) {
- const ShapeItem &item = shapeItems[i];
- if (item.path().contains(pos - item.position()))
- return i;
- }
- return -1;
-}
-//! [17]
-
-//! [18]
-void SortingBox::moveItemTo(const QPoint &pos)
-{
- QPoint offset = pos - previousPosition;
- itemInMotion->setPosition(itemInMotion->position() + offset);
-//! [18] //! [19]
- previousPosition = pos;
- update();
-}
-//! [19]
-
-//! [20]
-int SortingBox::updateButtonGeometry(QToolButton *button, int x, int y)
-{
- QSize size = button->sizeHint();
- button->setGeometry(x - size.rwidth(), y - size.rheight(),
- size.rwidth(), size.rheight());
-
- return y - size.rheight()
- - style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing);
-}
-//! [20]
-
-//! [21]
-void SortingBox::createShapeItem(const QPainterPath &path,
- const QString &toolTip, const QPoint &pos,
- const QColor &color)
-{
- ShapeItem shapeItem;
- shapeItem.setPath(path);
- shapeItem.setToolTip(toolTip);
- shapeItem.setPosition(pos);
- shapeItem.setColor(color);
- shapeItems.append(shapeItem);
- update();
-}
-//! [21]
-
-//! [22]
-QToolButton *SortingBox::createToolButton(const QString &toolTip,
- const QIcon &icon, const char *member)
-{
- QToolButton *button = new QToolButton(this);
- button->setToolTip(toolTip);
- button->setIcon(icon);
- button->setIconSize(QSize(32, 32));
- connect(button, SIGNAL(clicked()), this, member);
-
- return button;
-}
-//! [22]
-
-//! [23]
-QPoint SortingBox::initialItemPosition(const QPainterPath &path)
-{
- int x;
- int y = (height() - qRound(path.controlPointRect().height()) / 2);
- if (shapeItems.size() == 0)
- x = ((3 * width()) / 2 - qRound(path.controlPointRect().width())) / 2;
- else
- x = (width() / shapeItems.size()
- - qRound(path.controlPointRect().width())) / 2;
-
- return QPoint(x, y);
-}
-//! [23]
-
-//! [24]
-QPoint SortingBox::randomItemPosition()
-{
- return QPoint(QRandomGenerator::global()->bounded(width() - 120), QRandomGenerator::global()->bounded(height() - 120));
-}
-//! [24]
-
-//! [25]
-QColor SortingBox::initialItemColor()
-{
- return QColor::fromHsv(((shapeItems.size() + 1) * 85) % 256, 255, 190);
-}
-//! [25]
-
-//! [26]
-QColor SortingBox::randomItemColor()
-{
- return QColor::fromHsv(QRandomGenerator::global()->bounded(256), 255, 190);
-}
-//! [26]
diff --git a/examples/widgets/widgets/tooltips/sortingbox.h b/examples/widgets/widgets/tooltips/sortingbox.h
deleted file mode 100644
index 4fa9b4d36c..0000000000
--- a/examples/widgets/widgets/tooltips/sortingbox.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef SORTINGBOX_H
-#define SORTINGBOX_H
-
-#include "shapeitem.h"
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QPoint;
-class QToolButton;
-QT_END_NAMESPACE
-
-//! [0]
-class SortingBox : public QWidget
-{
- Q_OBJECT
-
-public:
- SortingBox(QWidget *parent = nullptr);
-
-protected:
- bool event(QEvent *event) override;
- void resizeEvent(QResizeEvent *event) override;
- void paintEvent(QPaintEvent *event) override;
- void mousePressEvent(QMouseEvent *event) override;
- void mouseMoveEvent(QMouseEvent *event) override;
- void mouseReleaseEvent(QMouseEvent *event) override;
-
-private slots:
- void createNewCircle();
- void createNewSquare();
- void createNewTriangle();
-//! [0]
-
-//! [1]
-private:
- int updateButtonGeometry(QToolButton *button, int x, int y);
- void createShapeItem(const QPainterPath &path, const QString &toolTip,
- const QPoint &pos, const QColor &color);
- int itemAt(const QPoint &pos);
- void moveItemTo(const QPoint &pos);
- QPoint initialItemPosition(const QPainterPath &path);
- QPoint randomItemPosition();
- QColor initialItemColor();
- QColor randomItemColor();
- QToolButton *createToolButton(const QString &toolTip, const QIcon &icon,
-//! [1]
- const char *member);
-
-//! [2]
- QList<ShapeItem> shapeItems;
- QPainterPath circlePath;
- QPainterPath squarePath;
- QPainterPath trianglePath;
-
- QPoint previousPosition;
- ShapeItem *itemInMotion;
-
- QToolButton *newCircleButton;
- QToolButton *newSquareButton;
- QToolButton *newTriangleButton;
-};
-//! [2]
-
-#endif
diff --git a/examples/widgets/widgets/tooltips/tooltips.pro b/examples/widgets/widgets/tooltips/tooltips.pro
deleted file mode 100644
index d14b8295ba..0000000000
--- a/examples/widgets/widgets/tooltips/tooltips.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-QT += widgets
-
-HEADERS = shapeitem.h \
- sortingbox.h
-SOURCES = main.cpp \
- shapeitem.cpp \
- sortingbox.cpp
-RESOURCES = tooltips.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/tooltips
-INSTALLS += target
diff --git a/examples/widgets/widgets/tooltips/tooltips.qrc b/examples/widgets/widgets/tooltips/tooltips.qrc
deleted file mode 100644
index dabc894e9b..0000000000
--- a/examples/widgets/widgets/tooltips/tooltips.qrc
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/circle.png</file>
- <file>images/square.png</file>
- <file>images/triangle.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/widgets/validators/CMakeLists.txt b/examples/widgets/widgets/validators/CMakeLists.txt
deleted file mode 100644
index ca034a8709..0000000000
--- a/examples/widgets/widgets/validators/CMakeLists.txt
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(validators LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/validators")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(validators
- ledwidget.cpp ledwidget.h
- localeselector.cpp localeselector.h
- main.cpp
- validators.ui
- validatorwidget.cpp validatorwidget.h
-)
-
-set_target_properties(validators PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(validators PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-# Resources:
-set(validators_resource_files
- "ledoff.png"
- "ledon.png"
-)
-
-qt_add_resources(validators "validators"
- PREFIX
- "/"
- FILES
- ${validators_resource_files}
-)
-
-install(TARGETS validators
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/validators/ledoff.png b/examples/widgets/widgets/validators/ledoff.png
deleted file mode 100644
index 8b1f2ed123..0000000000
--- a/examples/widgets/widgets/validators/ledoff.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/validators/ledon.png b/examples/widgets/widgets/validators/ledon.png
deleted file mode 100644
index 601c34d5a8..0000000000
--- a/examples/widgets/widgets/validators/ledon.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/widgets/validators/ledwidget.cpp b/examples/widgets/widgets/validators/ledwidget.cpp
deleted file mode 100644
index 5b95595a75..0000000000
--- a/examples/widgets/widgets/validators/ledwidget.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "ledwidget.h"
-
-LEDWidget::LEDWidget(QWidget *parent)
- : QLabel(parent), onPixmap(":/ledon.png"), offPixmap(":/ledoff.png")
-{
- setPixmap(offPixmap);
- flashTimer.setInterval(200);
- flashTimer.setSingleShot(true);
- connect(&flashTimer, &QTimer::timeout, this, &LEDWidget::extinguish);
-};
-
-void LEDWidget::extinguish()
-{
- setPixmap(offPixmap);
-}
-
-void LEDWidget::flash()
-{
- setPixmap(onPixmap);
- flashTimer.start();
-}
-
diff --git a/examples/widgets/widgets/validators/ledwidget.h b/examples/widgets/widgets/validators/ledwidget.h
deleted file mode 100644
index 81215b668f..0000000000
--- a/examples/widgets/widgets/validators/ledwidget.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef LEDWIDGET_H
-#define LEDWIDGET_H
-
-#include <QLabel>
-#include <QPixmap>
-#include <QTimer>
-
-class LEDWidget : public QLabel
-{
- Q_OBJECT
-public:
- LEDWidget(QWidget *parent = nullptr);
-public slots:
- void flash();
-
-private slots:
- void extinguish();
-
-private:
- QPixmap onPixmap, offPixmap;
- QTimer flashTimer;
-};
-
-#endif // LEDWIDGET_H
diff --git a/examples/widgets/widgets/validators/localeselector.cpp b/examples/widgets/widgets/validators/localeselector.cpp
deleted file mode 100644
index c74faa8c9d..0000000000
--- a/examples/widgets/widgets/validators/localeselector.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "localeselector.h"
-
-#include <QLocale>
-
-LocaleSelector::LocaleSelector(QWidget *parent)
- : QComboBox(parent)
-{
- int curIndex = -1;
- int index = 0;
- for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) {
- QLocale::Language lang = static_cast<QLocale::Language>(_lang);
- const QList<QLocale> locales =
- QLocale::matchingLocales(lang, QLocale::AnyScript, QLocale::AnyTerritory);
- for (const QLocale &l : locales) {
- QString label = QLocale::languageToString(l.language());
- label += QLatin1Char('/');
- label += QLocale::territoryToString(l.territory());
- // distinguish locales by script, if there are more than one script for a language/territory pair
- if (QLocale::matchingLocales(l.language(), QLocale::AnyScript, l.territory()).size() > 1)
- label += QLatin1String(" (") + QLocale::scriptToString(l.script()) + QLatin1Char(')');
-
- addItem(label, QVariant::fromValue(l));
-
- if (l.language() == locale().language() && l.territory() == locale().territory()
- && (locale().script() == QLocale::AnyScript || l.script() == locale().script())) {
- curIndex = index;
- }
- ++index;
- }
- }
- if (curIndex != -1)
- setCurrentIndex(curIndex);
-
- connect(this, QOverload<int>::of(&LocaleSelector::activated),
- this, &LocaleSelector::emitLocaleSelected);
-}
-
-void LocaleSelector::emitLocaleSelected(int index)
-{
- QVariant v = itemData(index);
- if (!v.isValid())
- return;
- const QLocale l = qvariant_cast<QLocale>(v);
- emit localeSelected(l);
-}
diff --git a/examples/widgets/widgets/validators/localeselector.h b/examples/widgets/widgets/validators/localeselector.h
deleted file mode 100644
index c684e18d40..0000000000
--- a/examples/widgets/widgets/validators/localeselector.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef LOCALESELECTOR_H
-#define LOCALESELECTOR_H
-
-#include <QComboBox>
-
-class LocaleSelector : public QComboBox
-{
- Q_OBJECT
-
-public:
- LocaleSelector(QWidget *parent = nullptr);
-
-signals:
- void localeSelected(const QLocale &locale);
-
-private slots:
- void emitLocaleSelected(int index);
-};
-
-#endif //LOCALESELECTOR_H
diff --git a/examples/widgets/widgets/validators/main.cpp b/examples/widgets/widgets/validators/main.cpp
deleted file mode 100644
index b5a685e850..0000000000
--- a/examples/widgets/widgets/validators/main.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "validatorwidget.h"
-
-#include <QApplication>
-
-int main(int argc, char **argv)
-{
- Q_INIT_RESOURCE(validators);
-
- QApplication app(argc, argv);
-
- ValidatorWidget w;
- w.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/widgets/validators/validators.pro b/examples/widgets/widgets/validators/validators.pro
deleted file mode 100644
index 029cf95aca..0000000000
--- a/examples/widgets/widgets/validators/validators.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-QT += widgets
-requires(qtConfig(combobox))
-
-FORMS += validators.ui
-RESOURCES += validators.qrc
-
-SOURCES += main.cpp ledwidget.cpp localeselector.cpp validatorwidget.cpp
-HEADERS += ledwidget.h localeselector.h validatorwidget.h
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/validators
-INSTALLS += target
diff --git a/examples/widgets/widgets/validators/validators.qrc b/examples/widgets/widgets/validators/validators.qrc
deleted file mode 100644
index 94874317a8..0000000000
--- a/examples/widgets/widgets/validators/validators.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource prefix="/" >
- <file>ledoff.png</file>
- <file>ledon.png</file>
- </qresource>
-</RCC>
diff --git a/examples/widgets/widgets/validators/validators.ui b/examples/widgets/widgets/validators/validators.ui
deleted file mode 100644
index cd984e6b97..0000000000
--- a/examples/widgets/widgets/validators/validators.ui
+++ /dev/null
@@ -1,468 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ValidatorsForm</class>
- <widget class="QWidget" name="ValidatorsForm">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>526</width>
- <height>443</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Validators</string>
- </property>
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>9</number>
- </property>
- <item>
- <layout class="QHBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <widget class="LocaleSelector" name="localeSelector"/>
- </item>
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>QIntValidator</string>
- </property>
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>9</number>
- </property>
- <item>
- <layout class="QHBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <layout class="QGridLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Min:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QSpinBox" name="minVal">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimum">
- <number>-1000000</number>
- </property>
- <property name="maximum">
- <number>1000000</number>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Max:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QSpinBox" name="maxVal">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimum">
- <number>-1000000</number>
- </property>
- <property name="maximum">
- <number>1000000</number>
- </property>
- <property name="value">
- <number>1000</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QFrame" name="frame">
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Sunken</enum>
- </property>
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>9</number>
- </property>
- <item>
- <widget class="LEDWidget" name="ledWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="pixmap">
- <pixmap resource="validators.qrc">:/ledoff.png</pixmap>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="label_7">
- <property name="text">
- <string>editingFinished()</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLineEdit" name="editor"/>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox_2">
- <property name="title">
- <string>QDoubleValidator</string>
- </property>
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>9</number>
- </property>
- <item>
- <layout class="QHBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <layout class="QGridLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Min:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QDoubleSpinBox" name="doubleMinVal">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimum">
- <double>-100000.000000000000000</double>
- </property>
- <property name="maximum">
- <double>100000.000000000000000</double>
- </property>
- <property name="value">
- <double>0.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Format:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="0" column="3">
- <widget class="QComboBox" name="doubleFormat">
- <item>
- <property name="text">
- <string>Standard</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Scientific</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Max:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QDoubleSpinBox" name="doubleMaxVal">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimum">
- <double>-100000.000000000000000</double>
- </property>
- <property name="maximum">
- <double>100000.000000000000000</double>
- </property>
- <property name="value">
- <double>1000.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="QLabel" name="label_6">
- <property name="text">
- <string>Decimals:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="1" column="3">
- <widget class="QSpinBox" name="doubleDecimals">
- <property name="value">
- <number>2</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QFrame" name="frame_2">
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Sunken</enum>
- </property>
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>9</number>
- </property>
- <item>
- <widget class="LEDWidget" name="doubleLedWidget">
- <property name="text">
- <string/>
- </property>
- <property name="pixmap">
- <pixmap resource="validators.qrc">:/ledoff.png</pixmap>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="label_8">
- <property name="text">
- <string>editingFinished()</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLineEdit" name="doubleEditor"/>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>111</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <layout class="QHBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="pushButton">
- <property name="text">
- <string>Quit</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>LEDWidget</class>
- <extends>QLabel</extends>
- <header>ledwidget.h</header>
- </customwidget>
- <customwidget>
- <class>LocaleSelector</class>
- <extends>QComboBox</extends>
- <header>localeselector.h</header>
- </customwidget>
- </customwidgets>
- <resources>
- <include location="validators.qrc"/>
- </resources>
- <connections>
- <connection>
- <sender>pushButton</sender>
- <signal>clicked()</signal>
- <receiver>ValidatorsForm</receiver>
- <slot>close()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>94</x>
- <y>274</y>
- </hint>
- <hint type="destinationlabel">
- <x>131</x>
- <y>260</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/examples/widgets/widgets/validators/validatorwidget.cpp b/examples/widgets/widgets/validators/validatorwidget.cpp
deleted file mode 100644
index 7782342221..0000000000
--- a/examples/widgets/widgets/validators/validatorwidget.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "validatorwidget.h"
-
-#include <QIntValidator>
-
-ValidatorWidget::ValidatorWidget(QWidget *parent)
- : QWidget(parent)
-{
- setupUi(this);
-
- connect(localeSelector, &LocaleSelector::localeSelected,
- this, &ValidatorWidget::setLocale);
- connect(localeSelector, &LocaleSelector::localeSelected,
- this, &ValidatorWidget::updateValidator);
- connect(localeSelector, &LocaleSelector::localeSelected,
- this, &ValidatorWidget::updateDoubleValidator);
-
- connect(minVal, &QSpinBox::editingFinished,
- this, &ValidatorWidget::updateValidator);
- connect(maxVal, &QSpinBox::editingFinished,
- this, &ValidatorWidget::updateValidator);
- connect(editor, &QLineEdit::editingFinished,
- ledWidget, &LEDWidget::flash);
-
- connect(doubleMaxVal, &QDoubleSpinBox::editingFinished,
- this, &ValidatorWidget::updateDoubleValidator);
- connect(doubleMinVal, &QDoubleSpinBox::editingFinished,
- this, &ValidatorWidget::updateDoubleValidator);
- connect(doubleDecimals, &QSpinBox::valueChanged,
- this, &ValidatorWidget::updateDoubleValidator);
- connect(doubleFormat, &QComboBox::activated,
- this, &ValidatorWidget::updateDoubleValidator);
- connect(doubleEditor, &QLineEdit::editingFinished,
- doubleLedWidget, &LEDWidget::flash);
-
- updateValidator();
- updateDoubleValidator();
-}
-
-void ValidatorWidget::updateValidator()
-{
- QIntValidator *v = new QIntValidator(minVal->value(), maxVal->value(), this);
- v->setLocale(locale());
- delete editor->validator();
- editor->setValidator(v);
-
- QString s = editor->text();
- int i = 0;
- if (v->validate(s, i) == QValidator::Invalid) {
- editor->clear();
- } else {
- editor->setText(s);
- }
-}
-
-void ValidatorWidget::updateDoubleValidator()
-{
- QDoubleValidator *v
- = new QDoubleValidator(doubleMinVal->value(), doubleMaxVal->value(),
- doubleDecimals->value(), this);
- v->setNotation(static_cast<QDoubleValidator::Notation>(doubleFormat->currentIndex()));
- v->setLocale(locale());
- delete doubleEditor->validator();
- doubleEditor->setValidator(v);
-
- QString s = doubleEditor->text();
- int i = 0;
- if (v->validate(s, i) == QValidator::Invalid) {
- doubleEditor->clear();
- } else {
- doubleEditor->setText(s);
- }
-}
diff --git a/examples/widgets/widgets/validators/validatorwidget.h b/examples/widgets/widgets/validators/validatorwidget.h
deleted file mode 100644
index 635257f16b..0000000000
--- a/examples/widgets/widgets/validators/validatorwidget.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QWidget>
-
-#include "ui_validators.h"
-
-class ValidatorWidget : public QWidget, public Ui::ValidatorsForm
-{
- Q_OBJECT
-public:
- ValidatorWidget(QWidget *parent = nullptr);
-
-private slots:
- void updateValidator();
- void updateDoubleValidator();
-};
diff --git a/examples/widgets/widgets/widgets.pro b/examples/widgets/widgets/widgets.pro
index fe3e289944..9fe06d4d80 100644
--- a/examples/widgets/widgets/widgets.pro
+++ b/examples/widgets/widgets/widgets.pro
@@ -2,25 +2,11 @@ TEMPLATE = subdirs
SUBDIRS = analogclock \
calculator \
calendarwidget \
- charactermap \
- codeeditor \
- digitalclock \
- elidedlabel \
groupbox \
- icons \
- imageviewer \
lineedits \
- movie \
- mousebuttons \
scribble \
shapedclock \
sliders \
spinboxes \
- styles \
- stylesheet \
tablet \
- tetrix \
- tooltips \
- validators \
- wiggly \
windowflags
diff --git a/examples/widgets/widgets/wiggly/CMakeLists.txt b/examples/widgets/widgets/wiggly/CMakeLists.txt
deleted file mode 100644
index 1f39e94cb1..0000000000
--- a/examples/widgets/widgets/wiggly/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(wiggly LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/wiggly")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-
-qt_add_executable(wiggly
- dialog.cpp dialog.h
- main.cpp
- wigglywidget.cpp wigglywidget.h
-)
-
-set_target_properties(wiggly PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(wiggly PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS wiggly
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/wiggly/dialog.cpp b/examples/widgets/widgets/wiggly/dialog.cpp
deleted file mode 100644
index 08a240af56..0000000000
--- a/examples/widgets/widgets/wiggly/dialog.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "dialog.h"
-#include "wigglywidget.h"
-
-#include <QLineEdit>
-#include <QVBoxLayout>
-
-//! [0]
-Dialog::Dialog(QWidget *parent)
- : QDialog(parent)
-{
- WigglyWidget *wigglyWidget = new WigglyWidget;
- QLineEdit *lineEdit = new QLineEdit;
-
- QVBoxLayout *layout = new QVBoxLayout(this);
- layout->addWidget(wigglyWidget);
- layout->addWidget(lineEdit);
-
- connect(lineEdit, &QLineEdit::textChanged, wigglyWidget, &WigglyWidget::setText);
- lineEdit->setText(tr("Hello world!"));
-
- setWindowTitle(tr("Wiggly"));
- resize(360, 145);
-}
-//! [0]
diff --git a/examples/widgets/widgets/wiggly/dialog.h b/examples/widgets/widgets/wiggly/dialog.h
deleted file mode 100644
index 1f27668f4a..0000000000
--- a/examples/widgets/widgets/wiggly/dialog.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef DIALOG_H
-#define DIALOG_H
-
-#include <QDialog>
-
-//! [0]
-class Dialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit Dialog(QWidget *parent = nullptr);
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/wiggly/main.cpp b/examples/widgets/widgets/wiggly/main.cpp
deleted file mode 100644
index e7df19b6a0..0000000000
--- a/examples/widgets/widgets/wiggly/main.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "dialog.h"
-
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- Dialog dialog;
- dialog.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/widgets/wiggly/wiggly.pro b/examples/widgets/widgets/wiggly/wiggly.pro
deleted file mode 100644
index 0e39f18add..0000000000
--- a/examples/widgets/widgets/wiggly/wiggly.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += widgets
-
-HEADERS = wigglywidget.h \
- dialog.h
-SOURCES = wigglywidget.cpp \
- dialog.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/wiggly
-INSTALLS += target
diff --git a/examples/widgets/widgets/wiggly/wigglywidget.cpp b/examples/widgets/widgets/wiggly/wigglywidget.cpp
deleted file mode 100644
index d7890ef2b7..0000000000
--- a/examples/widgets/widgets/wiggly/wigglywidget.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "wigglywidget.h"
-
-#include <QFontMetrics>
-#include <QPainter>
-#include <QTimerEvent>
-
-//! [0]
-WigglyWidget::WigglyWidget(QWidget *parent)
- : QWidget(parent), step(0)
-{
- setBackgroundRole(QPalette::Midlight);
- setAutoFillBackground(true);
-
- QFont newFont = font();
- newFont.setPointSize(newFont.pointSize() + 20);
- setFont(newFont);
-
- timer.start(60, this);
-}
-//! [0]
-
-//! [1]
-void WigglyWidget::paintEvent(QPaintEvent * /* event */)
-//! [1] //! [2]
-{
- static constexpr int sineTable[16] = {
- 0, 38, 71, 92, 100, 92, 71, 38, 0, -38, -71, -92, -100, -92, -71, -38
- };
-
- QFontMetrics metrics(font());
- int x = (width() - metrics.horizontalAdvance(text)) / 2;
- int y = (height() + metrics.ascent() - metrics.descent()) / 2;
- QColor color;
-//! [2]
-
-//! [3]
- QPainter painter(this);
-//! [3] //! [4]
- for (int i = 0; i < text.size(); ++i) {
- int index = (step + i) % 16;
- color.setHsv((15 - index) * 16, 255, 191);
- painter.setPen(color);
- painter.drawText(x, y - ((sineTable[index] * metrics.height()) / 400),
- QString(text[i]));
- x += metrics.horizontalAdvance(text[i]);
- }
-}
-//! [4]
-
-//! [5]
-void WigglyWidget::timerEvent(QTimerEvent *event)
-//! [5] //! [6]
-{
- if (event->timerId() == timer.timerId()) {
- ++step;
- update();
- } else {
- QWidget::timerEvent(event);
- }
-//! [6]
-}
diff --git a/examples/widgets/widgets/wiggly/wigglywidget.h b/examples/widgets/widgets/wiggly/wigglywidget.h
deleted file mode 100644
index 1c21e52234..0000000000
--- a/examples/widgets/widgets/wiggly/wigglywidget.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef WIGGLYWIDGET_H
-#define WIGGLYWIDGET_H
-
-#include <QBasicTimer>
-#include <QWidget>
-
-//! [0]
-class WigglyWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- WigglyWidget(QWidget *parent = nullptr);
-
-public slots:
- void setText(const QString &newText) { text = newText; }
-
-protected:
- void paintEvent(QPaintEvent *event) override;
- void timerEvent(QTimerEvent *event) override;
-
-private:
- QBasicTimer timer;
- QString text;
- int step;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/windowflags/CMakeLists.txt b/examples/widgets/widgets/windowflags/CMakeLists.txt
index 379270ef87..fbc1bf217b 100644
--- a/examples/widgets/widgets/windowflags/CMakeLists.txt
+++ b/examples/widgets/widgets/windowflags/CMakeLists.txt
@@ -1,19 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(windowflags LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/windowflags")
-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+qt_standard_project_setup()
+
qt_add_executable(windowflags
controllerwindow.cpp controllerwindow.h
main.cpp
@@ -25,14 +19,21 @@ set_target_properties(windowflags PROPERTIES
MACOSX_BUNDLE TRUE
)
-target_link_libraries(windowflags PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+target_link_libraries(windowflags PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS windowflags
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET windowflags
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/windowcontainer/CMakeLists.txt b/examples/widgets/windowcontainer/CMakeLists.txt
deleted file mode 100644
index 90bdc67a62..0000000000
--- a/examples/widgets/windowcontainer/CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(windowcontainer LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/windowcontainer")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL Widgets)
-
-qt_add_executable(windowcontainer
- ../../opengl/openglwindow/openglwindow.cpp ../../opengl/openglwindow/openglwindow.h
- windowcontainer.cpp
-)
-
-set_target_properties(windowcontainer PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_include_directories(windowcontainer PUBLIC
- ../../opengl/openglwindow
-)
-
-target_link_libraries(windowcontainer PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
- Qt::Widgets
-)
-
-install(TARGETS windowcontainer
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/windowcontainer/windowcontainer.cpp b/examples/widgets/windowcontainer/windowcontainer.cpp
deleted file mode 100644
index fa66684294..0000000000
--- a/examples/widgets/windowcontainer/windowcontainer.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "openglwindow.h"
-
-#include <QApplication>
-#include <QFocusEvent>
-#include <QHBoxLayout>
-#include <QKeyEvent>
-#include <QLineEdit>
-#include <QMouseEvent>
-#include <QPainter>
-#include <QWidget>
-
-
-// Making use of the class from the openglwindow example
-class Window : public OpenGLWindow
-{
- Q_OBJECT
-public:
- using OpenGLWindow::OpenGLWindow;
-
- void render(QPainter *p) override
- {
- QLinearGradient g(0, 0, 0, height());
- g.setColorAt(0, QColor("lightsteelblue"));
- g.setColorAt(1, Qt::black);
- p->fillRect(0, 0, width(), height(), g);
-
- p->setPen(Qt::white);
-
- p->drawText(20, 30, QLatin1String("This is an OpenGL based QWindow"));
-
- if (m_key.trimmed().length() > 0) {
- QRect bounds = p->boundingRect(QRect(0, 0, width(), height()), Qt::AlignTop | Qt::AlignLeft, m_key);
- p->save();
- p->translate(width() / 2.0, height() / 2.0);
- p->scale(10, 10);
- p->translate(-bounds.width() / 2.0, -bounds.height() / 2.0);
- p->drawText(bounds, Qt::AlignCenter, m_key);
- p->restore();
- }
-
- if (m_focus)
- p->drawText(20, height() - 20, QLatin1String("Window has focus!"));
-
- p->setRenderHint(QPainter::Antialiasing);
- p->drawPolyline(m_polygon);
- }
-
- void mousePressEvent(QMouseEvent *e) override
- {
- if (!m_mouseDown) {
- m_mouseDown = true;
- m_polygon.clear();
- m_polygon.append(e->position().toPoint());
- renderLater();
- }
- }
-
- void mouseMoveEvent(QMouseEvent *e) override
- {
- if (m_mouseDown) {
- m_polygon.append(e->position().toPoint());
- renderLater();
- }
- }
-
- void mouseReleaseEvent(QMouseEvent *e) override
- {
- if (m_mouseDown) {
- m_mouseDown = false;
- m_polygon.append(e->position().toPoint());
- renderLater();
- }
- }
-
- void focusInEvent(QFocusEvent *) override
- {
- m_focus = true;
- renderLater();
- }
-
- void focusOutEvent(QFocusEvent *) override
- {
- m_focus = false;
- m_polygon.clear();
- renderLater();
- }
-
- void keyPressEvent(QKeyEvent *e) override
- {
- m_key = e->text();
- renderLater();
- }
-
- void keyReleaseEvent(QKeyEvent *) override
- {
- m_key = QString();
- renderLater();
- }
-private:
- QPolygon m_polygon;
- QString m_key;
- bool m_mouseDown = false;
- bool m_focus = false;
-};
-
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QWidget *widget = new QWidget;
- QHBoxLayout *layout = new QHBoxLayout(widget);
-
- Window *window = new Window;
-
- QWidget *container = QWidget::createWindowContainer(window);
- container->setMinimumSize(300, 300);
- container->setMaximumSize(600, 600);
- container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- container->setFocusPolicy(Qt::StrongFocus);
-
- window->setGeometry(100, 100, 300, 200);
-
- layout->addWidget(new QLineEdit(QLatin1String("A QLineEdit")));
- layout->addWidget(container);
- layout->addWidget(new QLineEdit(QLatin1String("A QLabel")));
-
- widget->show();
-
- return app.exec();
-}
-
-#include "windowcontainer.moc"
diff --git a/examples/widgets/windowcontainer/windowcontainer.pro b/examples/widgets/windowcontainer/windowcontainer.pro
deleted file mode 100644
index 664ac938a2..0000000000
--- a/examples/widgets/windowcontainer/windowcontainer.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-SOURCES = windowcontainer.cpp
-
-QT += widgets
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/windowcontainer
-INSTALLS += target
-
-include(../../opengl/openglwindow/openglwindow.pri)