summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt40
-rw-r--r--examples/corelib/CMakeLists.txt7
-rw-r--r--examples/corelib/bindableproperties/CMakeLists.txt33
-rw-r--r--examples/corelib/bindableproperties/bindableproperties.pro4
-rw-r--r--examples/corelib/bindableproperties/bindablesubscription/CMakeLists.txt15
-rw-r--r--examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.cpp51
-rw-r--r--examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.h44
-rw-r--r--examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.pro22
-rw-r--r--examples/corelib/bindableproperties/bindablesubscription/bindableuser.cpp18
-rw-r--r--examples/corelib/bindableproperties/bindablesubscription/bindableuser.h37
-rw-r--r--examples/corelib/bindableproperties/bindablesubscription/main.cpp77
-rw-r--r--examples/corelib/bindableproperties/doc/images/bindable_properties_example.pngbin0 -> 18831 bytes
-rw-r--r--examples/corelib/bindableproperties/doc/src/bindableproperties.qdoc179
-rw-r--r--examples/corelib/bindableproperties/shared/CMakeLists.txt23
-rw-r--r--examples/corelib/bindableproperties/shared/countries.qrc7
-rw-r--r--examples/corelib/bindableproperties/shared/finland.pngbin0 -> 1062 bytes
-rw-r--r--examples/corelib/bindableproperties/shared/germany.pngbin0 -> 483 bytes
-rw-r--r--examples/corelib/bindableproperties/shared/norway.pngbin0 -> 5190 bytes
-rw-r--r--examples/corelib/bindableproperties/shared/subscriptionwindow.cpp16
-rw-r--r--examples/corelib/bindableproperties/shared/subscriptionwindow.h29
-rw-r--r--examples/corelib/bindableproperties/shared/subscriptionwindow.ui280
-rw-r--r--examples/corelib/bindableproperties/subscription/CMakeLists.txt12
-rw-r--r--examples/corelib/bindableproperties/subscription/main.cpp95
-rw-r--r--examples/corelib/bindableproperties/subscription/subscription.cpp79
-rw-r--r--examples/corelib/bindableproperties/subscription/subscription.h48
-rw-r--r--examples/corelib/bindableproperties/subscription/subscription.pro22
-rw-r--r--examples/corelib/bindableproperties/subscription/user.cpp24
-rw-r--r--examples/corelib/bindableproperties/subscription/user.h36
-rw-r--r--examples/corelib/corelib.pro3
-rw-r--r--examples/corelib/ipc/CMakeLists.txt15
-rw-r--r--examples/corelib/ipc/doc/images/localfortuneserver-example.pngbin5715 -> 14948 bytes
-rw-r--r--examples/corelib/ipc/doc/src/localfortuneclient.qdoc36
-rw-r--r--examples/corelib/ipc/doc/src/localfortuneserver.qdoc33
-rw-r--r--examples/corelib/ipc/doc/src/sharedmemory.qdoc35
-rw-r--r--examples/corelib/ipc/localfortuneclient/CMakeLists.txt47
-rw-r--r--examples/corelib/ipc/localfortuneclient/client.cpp80
-rw-r--r--examples/corelib/ipc/localfortuneclient/client.h62
-rw-r--r--examples/corelib/ipc/localfortuneclient/main.cpp55
-rw-r--r--examples/corelib/ipc/localfortuneserver/CMakeLists.txt47
-rw-r--r--examples/corelib/ipc/localfortuneserver/main.cpp55
-rw-r--r--examples/corelib/ipc/localfortuneserver/server.cpp149
-rw-r--r--examples/corelib/ipc/localfortuneserver/server.h75
-rw-r--r--examples/corelib/ipc/sharedmemory/CMakeLists.txt44
-rw-r--r--examples/corelib/ipc/sharedmemory/dialog.cpp69
-rw-r--r--examples/corelib/ipc/sharedmemory/dialog.h62
-rw-r--r--examples/corelib/ipc/sharedmemory/main.cpp54
-rw-r--r--examples/corelib/mimetypes/CMakeLists.txt7
-rw-r--r--examples/corelib/mimetypes/doc/src/mimetypebrowser.qdoc31
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/CMakeLists.txt44
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/main.cpp55
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp78
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/mainwindow.h58
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp51
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h59
-rw-r--r--examples/corelib/platform/CMakeLists.txt6
-rw-r--r--examples/corelib/platform/androidnotifier/CMakeLists.txt57
-rw-r--r--examples/corelib/platform/androidnotifier/android/AndroidManifest.xml47
-rw-r--r--examples/corelib/platform/androidnotifier/android/res/drawable-hdpi/icon.pngbin0 -> 3654 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/android/res/drawable-ldpi/icon.pngbin0 -> 1432 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/android/res/drawable-mdpi/icon.pngbin0 -> 1998 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/android/res/drawable-xhdpi/icon.pngbin0 -> 4549 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/android/res/drawable-xxhdpi/icon.pngbin0 -> 9275 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/android/res/drawable-xxxhdpi/icon.pngbin0 -> 12866 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java46
-rw-r--r--examples/corelib/platform/androidnotifier/androidnotifier.pro21
-rw-r--r--examples/corelib/platform/androidnotifier/doc/images/androidnotifier.pngbin0 -> 48263 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/doc/src/androidnotifier-example.qdoc62
-rw-r--r--examples/corelib/platform/androidnotifier/images/happy.pngbin0 -> 42346 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/images/sad.pngbin0 -> 41223 bytes
-rw-r--r--examples/corelib/platform/androidnotifier/main.cpp56
-rw-r--r--examples/corelib/platform/androidnotifier/main.qrc6
-rw-r--r--examples/corelib/platform/androidnotifier/notificationclient.cpp55
-rw-r--r--examples/corelib/platform/androidnotifier/notificationclient.h29
-rw-r--r--examples/corelib/platform/platform.pro4
-rw-r--r--examples/corelib/serialization/CMakeLists.txt14
-rw-r--r--examples/corelib/serialization/cbordump/CMakeLists.txt41
-rwxr-xr-xexamples/corelib/serialization/cbordump/cbortag.py188
-rw-r--r--examples/corelib/serialization/cbordump/doc/images/cbordump.pngbin0 -> 9556 bytes
-rw-r--r--examples/corelib/serialization/cbordump/doc/src/cbordump.qdoc55
-rw-r--r--examples/corelib/serialization/cbordump/main.cpp289
-rw-r--r--examples/corelib/serialization/cbordump/tag-transform.xslt25
-rw-r--r--examples/corelib/serialization/convert/CMakeLists.txt45
-rw-r--r--examples/corelib/serialization/convert/cborconverter.cpp148
-rw-r--r--examples/corelib/serialization/convert/cborconverter.h79
-rw-r--r--examples/corelib/serialization/convert/convert.pro16
-rw-r--r--examples/corelib/serialization/convert/converter.cpp44
-rw-r--r--examples/corelib/serialization/convert/converter.h100
-rw-r--r--examples/corelib/serialization/convert/datastreamconverter.cpp188
-rw-r--r--examples/corelib/serialization/convert/datastreamconverter.h79
-rw-r--r--examples/corelib/serialization/convert/debugtextdumper.cpp74
-rw-r--r--examples/corelib/serialization/convert/debugtextdumper.h20
-rw-r--r--examples/corelib/serialization/convert/doc/images/convert.pngbin0 -> 7707 bytes
-rw-r--r--examples/corelib/serialization/convert/doc/src/convert.qdoc156
-rw-r--r--examples/corelib/serialization/convert/jsonconverter.cpp107
-rw-r--r--examples/corelib/serialization/convert/jsonconverter.h68
-rw-r--r--examples/corelib/serialization/convert/main.cpp257
-rw-r--r--examples/corelib/serialization/convert/nullconverter.cpp92
-rw-r--r--examples/corelib/serialization/convert/nullconverter.h63
-rw-r--r--examples/corelib/serialization/convert/textconverter.cpp103
-rw-r--r--examples/corelib/serialization/convert/textconverter.h65
-rw-r--r--examples/corelib/serialization/convert/variantorderedmap.h24
-rw-r--r--examples/corelib/serialization/convert/xmlconverter.cpp214
-rw-r--r--examples/corelib/serialization/convert/xmlconverter.h66
-rw-r--r--examples/corelib/serialization/savegame/CMakeLists.txt41
-rw-r--r--examples/corelib/serialization/savegame/character.cpp104
-rw-r--r--examples/corelib/serialization/savegame/character.h70
-rw-r--r--examples/corelib/serialization/savegame/doc/src/savegame.qdoc182
-rw-r--r--examples/corelib/serialization/savegame/game.cpp181
-rw-r--r--examples/corelib/serialization/savegame/game.h66
-rw-r--r--examples/corelib/serialization/savegame/level.cpp106
-rw-r--r--examples/corelib/serialization/savegame/level.h64
-rw-r--r--examples/corelib/serialization/savegame/main.cpp78
-rw-r--r--examples/corelib/serialization/serialization.pro4
-rw-r--r--examples/corelib/serialization/streambookmarks/CMakeLists.txt40
-rw-r--r--examples/corelib/serialization/streambookmarks/doc/images/filemenu.pngbin0 -> 3728 bytes
-rw-r--r--examples/corelib/serialization/streambookmarks/doc/images/helpmenu.pngbin0 -> 2099 bytes
-rw-r--r--examples/corelib/serialization/streambookmarks/doc/images/screenshot.pngbin0 -> 66567 bytes
-rw-r--r--examples/corelib/serialization/streambookmarks/doc/src/qxmlstreambookmarks.qdoc223
-rw-r--r--examples/corelib/serialization/streambookmarks/jennifer.xbel69
-rw-r--r--examples/corelib/serialization/streambookmarks/main.cpp17
-rw-r--r--examples/corelib/serialization/streambookmarks/mainwindow.cpp151
-rw-r--r--examples/corelib/serialization/streambookmarks/mainwindow.h35
-rw-r--r--examples/corelib/serialization/streambookmarks/streambookmarks.pro15
-rw-r--r--examples/corelib/serialization/streambookmarks/xbelreader.cpp140
-rw-r--r--examples/corelib/serialization/streambookmarks/xbelreader.h45
-rw-r--r--examples/corelib/serialization/streambookmarks/xbelwriter.cpp56
-rw-r--r--examples/corelib/serialization/streambookmarks/xbelwriter.h28
-rw-r--r--examples/corelib/threads/CMakeLists.txt15
-rw-r--r--examples/corelib/threads/doc/src/mandelbrot.qdoc52
-rw-r--r--examples/corelib/threads/doc/src/queuedcustomtype.qdoc53
-rw-r--r--examples/corelib/threads/doc/src/semaphores.qdoc42
-rw-r--r--examples/corelib/threads/doc/src/waitconditions.qdoc42
-rw-r--r--examples/corelib/threads/mandelbrot/CMakeLists.txt50
-rw-r--r--examples/corelib/threads/mandelbrot/main.cpp78
-rw-r--r--examples/corelib/threads/mandelbrot/mandelbrot.pro2
-rw-r--r--examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp148
-rw-r--r--examples/corelib/threads/mandelbrot/mandelbrotwidget.h73
-rw-r--r--examples/corelib/threads/mandelbrot/renderthread.cpp82
-rw-r--r--examples/corelib/threads/mandelbrot/renderthread.h58
-rw-r--r--examples/corelib/threads/queuedcustomtype/CMakeLists.txt44
-rw-r--r--examples/corelib/threads/queuedcustomtype/block.cpp51
-rw-r--r--examples/corelib/threads/queuedcustomtype/block.h51
-rw-r--r--examples/corelib/threads/queuedcustomtype/main.cpp66
-rw-r--r--examples/corelib/threads/queuedcustomtype/renderthread.cpp82
-rw-r--r--examples/corelib/threads/queuedcustomtype/renderthread.h60
-rw-r--r--examples/corelib/threads/queuedcustomtype/window.cpp70
-rw-r--r--examples/corelib/threads/queuedcustomtype/window.h62
-rw-r--r--examples/corelib/threads/semaphores/CMakeLists.txt41
-rw-r--r--examples/corelib/threads/semaphores/semaphores.cpp58
-rw-r--r--examples/corelib/threads/waitconditions/CMakeLists.txt41
-rw-r--r--examples/corelib/threads/waitconditions/waitconditions.cpp119
-rw-r--r--examples/corelib/tools/CMakeLists.txt9
-rw-r--r--examples/corelib/tools/contiguouscache/CMakeLists.txt44
-rw-r--r--examples/corelib/tools/contiguouscache/main.cpp51
-rw-r--r--examples/corelib/tools/contiguouscache/randomlistmodel.cpp71
-rw-r--r--examples/corelib/tools/contiguouscache/randomlistmodel.h52
-rw-r--r--examples/corelib/tools/customtype/CMakeLists.txt40
-rw-r--r--examples/corelib/tools/customtype/customtype.pro8
-rw-r--r--examples/corelib/tools/customtype/main.cpp84
-rw-r--r--examples/corelib/tools/customtype/message.cpp84
-rw-r--r--examples/corelib/tools/customtype/message.h85
-rw-r--r--examples/corelib/tools/customtypesending/CMakeLists.txt41
-rw-r--r--examples/corelib/tools/customtypesending/customtypesending.pro10
-rw-r--r--examples/corelib/tools/customtypesending/main.cpp78
-rw-r--r--examples/corelib/tools/customtypesending/message.cpp66
-rw-r--r--examples/corelib/tools/customtypesending/message.h81
-rw-r--r--examples/corelib/tools/customtypesending/window.cpp90
-rw-r--r--examples/corelib/tools/customtypesending/window.h82
-rw-r--r--examples/corelib/tools/doc/src/contiguouscache.qdoc31
-rw-r--r--examples/corelib/tools/doc/src/customtype.qdoc135
-rw-r--r--examples/corelib/tools/tools.pro4
-rw-r--r--examples/dbus/CMakeLists.txt20
-rw-r--r--examples/dbus/chat/.prev_CMakeLists.txt43
-rw-r--r--examples/dbus/chat/CMakeLists.txt56
-rw-r--r--examples/dbus/chat/chat.cpp170
-rw-r--r--examples/dbus/chat/chat.h71
-rw-r--r--examples/dbus/chat/chat.pro4
-rw-r--r--examples/dbus/chat/chatsetnickname.ui149
-rw-r--r--examples/dbus/complexpingpong/CMakeLists.txt83
-rw-r--r--examples/dbus/complexpingpong/complexping.cpp91
-rw-r--r--examples/dbus/complexpingpong/complexping.h60
-rw-r--r--examples/dbus/complexpingpong/complexpong.cpp71
-rw-r--r--examples/dbus/complexpingpong/complexpong.h62
-rw-r--r--examples/dbus/complexpingpong/ping-common.h51
-rw-r--r--examples/dbus/dbus.pro3
-rw-r--r--examples/dbus/doc/images/dbus-chat-example.pngbin38530 -> 0 bytes
-rw-r--r--examples/dbus/doc/images/dbus-chat-example.webpbin0 -> 17556 bytes
-rw-r--r--examples/dbus/doc/src/chat.qdoc35
-rw-r--r--examples/dbus/doc/src/complexpingpong.qdoc33
-rw-r--r--examples/dbus/doc/src/listnames.qdoc39
-rw-r--r--examples/dbus/doc/src/pingpong.qdoc31
-rw-r--r--examples/dbus/listnames/CMakeLists.txt43
-rw-r--r--examples/dbus/listnames/listnames.cpp105
-rw-r--r--examples/dbus/listnames/listnames.pro8
-rw-r--r--examples/dbus/pingpong/CMakeLists.txt85
-rw-r--r--examples/dbus/pingpong/ping-common.h51
-rw-r--r--examples/dbus/pingpong/ping.cpp72
-rw-r--r--examples/dbus/pingpong/pong.cpp83
-rw-r--r--examples/dbus/pingpong/pong.h63
-rw-r--r--examples/dbus/pingpong/pong.pro2
-rw-r--r--examples/dbus/remotecontrolledcar/CMakeLists.txt10
-rw-r--r--examples/dbus/remotecontrolledcar/car/.prev_CMakeLists.txt42
-rw-r--r--examples/dbus/remotecontrolledcar/car/CMakeLists.txt55
-rw-r--r--examples/dbus/remotecontrolledcar/car/car.cpp79
-rw-r--r--examples/dbus/remotecontrolledcar/car/car.h69
-rw-r--r--examples/dbus/remotecontrolledcar/car/car.pro4
-rw-r--r--examples/dbus/remotecontrolledcar/car/car.xml11
-rw-r--r--examples/dbus/remotecontrolledcar/car/main.cpp57
-rw-r--r--examples/dbus/remotecontrolledcar/common/car.xml10
-rw-r--r--examples/dbus/remotecontrolledcar/controller/.prev_CMakeLists.txt42
-rw-r--r--examples/dbus/remotecontrolledcar/controller/CMakeLists.txt69
-rw-r--r--examples/dbus/remotecontrolledcar/controller/car.xml11
-rw-r--r--examples/dbus/remotecontrolledcar/controller/connected.svg4
-rw-r--r--examples/dbus/remotecontrolledcar/controller/connecting.svg4
-rw-r--r--examples/dbus/remotecontrolledcar/controller/controller.cpp126
-rw-r--r--examples/dbus/remotecontrolledcar/controller/controller.h73
-rw-r--r--examples/dbus/remotecontrolledcar/controller/controller.pro4
-rw-r--r--examples/dbus/remotecontrolledcar/controller/controller.ui64
-rw-r--r--examples/dbus/remotecontrolledcar/controller/down.svg3
-rw-r--r--examples/dbus/remotecontrolledcar/controller/icons.qrc10
-rw-r--r--examples/dbus/remotecontrolledcar/controller/left.svg3
-rw-r--r--examples/dbus/remotecontrolledcar/controller/main.cpp51
-rw-r--r--examples/dbus/remotecontrolledcar/controller/right.svg3
-rw-r--r--examples/dbus/remotecontrolledcar/controller/up.svg3
-rw-r--r--examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.pngbin8833 -> 0 bytes
-rw-r--r--examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.webpbin0 -> 8346 bytes
-rw-r--r--examples/dbus/remotecontrolledcar/doc/src/dbus-remotecontrolledcar.qdoc33
-rw-r--r--examples/dbus/remotecontrolledcar/remotecontrolledcar.pro2
-rw-r--r--examples/embedded/CMakeLists.txt11
-rw-r--r--examples/embedded/digiflip/CMakeLists.txt39
-rw-r--r--examples/embedded/digiflip/digiflip.cpp418
-rw-r--r--examples/embedded/digiflip/digiflip.pro6
-rw-r--r--examples/embedded/embedded.pro7
-rw-r--r--examples/embedded/flickable/CMakeLists.txt40
-rw-r--r--examples/embedded/flickable/flickable.cpp293
-rw-r--r--examples/embedded/flickable/flickable.h87
-rw-r--r--examples/embedded/flickable/flickable.pro7
-rw-r--r--examples/embedded/flickable/main.cpp237
-rw-r--r--examples/embedded/flightinfo/.prev_CMakeLists.txt47
-rw-r--r--examples/embedded/flightinfo/CMakeLists.txt55
-rw-r--r--examples/embedded/flightinfo/aircraft.pngbin20200 -> 0 bytes
-rw-r--r--examples/embedded/flightinfo/flightinfo.cpp401
-rw-r--r--examples/embedded/flightinfo/flightinfo.pro9
-rw-r--r--examples/embedded/flightinfo/flightinfo.qrc5
-rw-r--r--examples/embedded/flightinfo/form.ui226
-rw-r--r--examples/embedded/lightmaps/CMakeLists.txt44
-rw-r--r--examples/embedded/lightmaps/lightmaps.cpp285
-rw-r--r--examples/embedded/lightmaps/lightmaps.h97
-rw-r--r--examples/embedded/lightmaps/lightmaps.pro12
-rw-r--r--examples/embedded/lightmaps/main.cpp65
-rw-r--r--examples/embedded/lightmaps/mapzoom.cpp105
-rw-r--r--examples/embedded/lightmaps/mapzoom.h75
-rw-r--r--examples/embedded/lightmaps/slippymap.cpp211
-rw-r--r--examples/embedded/lightmaps/slippymap.h99
-rw-r--r--examples/embedded/raycasting/CMakeLists.txt52
-rw-r--r--examples/embedded/raycasting/raycasting.cpp383
-rw-r--r--examples/embedded/raycasting/raycasting.pro7
-rw-r--r--examples/embedded/raycasting/raycasting.qrc5
-rw-r--r--examples/embedded/raycasting/textures.pngbin17669 -> 0 bytes
-rw-r--r--examples/embedded/styleexample/.prev_CMakeLists.txt52
-rw-r--r--examples/embedded/styleexample/CMakeLists.txt60
-rw-r--r--examples/embedded/styleexample/files/add.pngbin1474 -> 0 bytes
-rw-r--r--examples/embedded/styleexample/files/application.qss125
-rw-r--r--examples/embedded/styleexample/files/blue.qss38
-rw-r--r--examples/embedded/styleexample/files/khaki.qss99
-rw-r--r--examples/embedded/styleexample/files/nature_1.jpgbin167443 -> 0 bytes
-rw-r--r--examples/embedded/styleexample/files/nostyle.qss0
-rw-r--r--examples/embedded/styleexample/files/remove.pngbin865 -> 0 bytes
-rw-r--r--examples/embedded/styleexample/files/transparent.qss139
-rw-r--r--examples/embedded/styleexample/main.cpp68
-rw-r--r--examples/embedded/styleexample/styleexample.pro9
-rw-r--r--examples/embedded/styleexample/styleexample.qrc13
-rw-r--r--examples/embedded/styleexample/stylewidget.cpp121
-rw-r--r--examples/embedded/styleexample/stylewidget.h74
-rw-r--r--examples/embedded/styleexample/stylewidget.ui417
-rw-r--r--examples/examples.pro8
-rw-r--r--examples/gui/CMakeLists.txt9
-rw-r--r--examples/gui/analogclock/.prev_CMakeLists.txt42
-rw-r--r--examples/gui/analogclock/CMakeLists.txt49
-rw-r--r--examples/gui/analogclock/analogclock.pro10
-rw-r--r--examples/gui/analogclock/main.cpp170
-rw-r--r--examples/gui/doc/images/analogclock-window-example.pngbin14556 -> 0 bytes
-rw-r--r--examples/gui/doc/images/analogclockwindow-viewport.pngbin29668 -> 0 bytes
-rw-r--r--examples/gui/doc/images/rhiwindow_example.jpgbin0 -> 47775 bytes
-rw-r--r--examples/gui/doc/src/analogclockwindow.qdoc138
-rw-r--r--examples/gui/doc/src/rasterwindow.qdoc29
-rw-r--r--examples/gui/doc/src/rhiwindow.qdoc445
-rw-r--r--examples/gui/gui.pro4
-rw-r--r--examples/gui/rasterwindow/.prev_CMakeLists.txt42
-rw-r--r--examples/gui/rasterwindow/CMakeLists.txt46
-rw-r--r--examples/gui/rasterwindow/main.cpp51
-rw-r--r--examples/gui/rasterwindow/rasterwindow.cpp51
-rw-r--r--examples/gui/rasterwindow/rasterwindow.h54
-rw-r--r--examples/gui/rhiwindow/CMakeLists.txt60
-rw-r--r--examples/gui/rhiwindow/main.cpp110
-rw-r--r--examples/gui/rhiwindow/rhiwindow.cpp436
-rw-r--r--examples/gui/rhiwindow/rhiwindow.h78
-rw-r--r--examples/gui/rhiwindow/rhiwindow.pri4
-rw-r--r--examples/gui/rhiwindow/rhiwindow.pro9
-rw-r--r--examples/gui/rhiwindow/rhiwindow.qrc8
-rw-r--r--examples/gui/rhiwindow/shaders/color.frag15
-rw-r--r--examples/gui/rhiwindow/shaders/color.vert17
-rw-r--r--examples/gui/rhiwindow/shaders/prebuilt/color.frag.qsbbin0 -> 1035 bytes
-rw-r--r--examples/gui/rhiwindow/shaders/prebuilt/color.vert.qsbbin0 -> 1131 bytes
-rw-r--r--examples/gui/rhiwindow/shaders/prebuilt/quad.frag.qsbbin0 -> 1023 bytes
-rw-r--r--examples/gui/rhiwindow/shaders/prebuilt/quad.vert.qsbbin0 -> 982 bytes
-rw-r--r--examples/gui/rhiwindow/shaders/quad.frag11
-rw-r--r--examples/gui/rhiwindow/shaders/quad.vert10
-rw-r--r--examples/network/.prev_CMakeLists.txt38
-rw-r--r--examples/network/CMakeLists.txt56
-rw-r--r--examples/network/blockingfortuneclient/CMakeLists.txt47
-rw-r--r--examples/network/blockingfortuneclient/blockingclient.cpp60
-rw-r--r--examples/network/blockingfortuneclient/blockingclient.h51
-rw-r--r--examples/network/blockingfortuneclient/fortunethread.cpp53
-rw-r--r--examples/network/blockingfortuneclient/fortunethread.h51
-rw-r--r--examples/network/blockingfortuneclient/main.cpp51
-rw-r--r--examples/network/broadcastreceiver/CMakeLists.txt47
-rw-r--r--examples/network/broadcastreceiver/main.cpp51
-rw-r--r--examples/network/broadcastreceiver/receiver.cpp54
-rw-r--r--examples/network/broadcastreceiver/receiver.h51
-rw-r--r--examples/network/broadcastsender/CMakeLists.txt47
-rw-r--r--examples/network/broadcastsender/main.cpp51
-rw-r--r--examples/network/broadcastsender/sender.cpp53
-rw-r--r--examples/network/broadcastsender/sender.h51
-rw-r--r--examples/network/dnslookup/CMakeLists.txt44
-rw-r--r--examples/network/dnslookup/dnslookup.cpp214
-rw-r--r--examples/network/dnslookup/dnslookup.h51
-rw-r--r--examples/network/doc/images/blockingfortuneclient-example.pngbin9199 -> 7013 bytes
-rw-r--r--examples/network/doc/images/dnslookup-example.webpbin0 -> 7532 bytes
-rw-r--r--examples/network/doc/images/fortuneclient-example.pngbin8282 -> 7814 bytes
-rw-r--r--examples/network/doc/images/fortuneserver-example.pngbin7883 -> 6167 bytes
-rw-r--r--examples/network/doc/images/googlesuggest-example.pngbin21272 -> 0 bytes
-rw-r--r--examples/network/doc/images/http-example.pngbin8099 -> 0 bytes
-rw-r--r--examples/network/doc/images/http-example.webpbin0 -> 8250 bytes
-rw-r--r--examples/network/doc/images/loopback-example.pngbin6195 -> 0 bytes
-rw-r--r--examples/network/doc/images/multi-stream-client-example.webpbin0 -> 27060 bytes
-rw-r--r--examples/network/doc/images/multi-stream-server-example.webpbin0 -> 19164 bytes
-rw-r--r--examples/network/doc/images/multicastreceiver-example.pngbin13042 -> 0 bytes
-rw-r--r--examples/network/doc/images/multicastreceiver-example.webpbin0 -> 3280 bytes
-rw-r--r--examples/network/doc/images/multicastsender-example.pngbin21092 -> 0 bytes
-rw-r--r--examples/network/doc/images/multicastsender-example.webpbin0 -> 3502 bytes
-rw-r--r--examples/network/doc/images/network-chat-example.pngbin17453 -> 0 bytes
-rw-r--r--examples/network/doc/images/network-chat-example.webpbin0 -> 11864 bytes
-rw-r--r--examples/network/doc/images/rsslisting.pngbin0 -> 19739 bytes
-rw-r--r--examples/network/doc/images/securesocketclient-example.webpbin0 -> 86522 bytes
-rw-r--r--examples/network/doc/images/securesocketclient.pngbin12056 -> 0 bytes
-rw-r--r--examples/network/doc/images/securesocketclient2.pngbin15532 -> 0 bytes
-rw-r--r--examples/network/doc/images/threadedfortuneserver-example.pngbin16232 -> 5558 bytes
-rw-r--r--examples/network/doc/images/torrent-example.pngbin18915 -> 11343 bytes
-rw-r--r--examples/network/doc/src/blockingfortuneclient.qdoc40
-rw-r--r--examples/network/doc/src/broadcastreceiver.qdoc32
-rw-r--r--examples/network/doc/src/broadcastsender.qdoc32
-rw-r--r--examples/network/doc/src/dnslookup.qdoc17
-rw-r--r--examples/network/doc/src/fortuneclient.qdoc38
-rw-r--r--examples/network/doc/src/fortuneserver.qdoc38
-rw-r--r--examples/network/doc/src/googlesuggest.qdoc177
-rw-r--r--examples/network/doc/src/http.qdoc35
-rw-r--r--examples/network/doc/src/loopback.qdoc38
-rw-r--r--examples/network/doc/src/multicastreceiver.qdoc36
-rw-r--r--examples/network/doc/src/multicastsender.qdoc34
-rw-r--r--examples/network/doc/src/multistreamclient.qdoc15
-rw-r--r--examples/network/doc/src/multistreamserver.qdoc16
-rw-r--r--examples/network/doc/src/network-chat.qdoc34
-rw-r--r--examples/network/doc/src/network-download.qdoc41
-rw-r--r--examples/network/doc/src/network-downloadmanager.qdoc41
-rw-r--r--examples/network/doc/src/rsslisting.qdoc129
-rw-r--r--examples/network/doc/src/securesocketclient.qdoc35
-rw-r--r--examples/network/doc/src/secureudpclient.qdoc29
-rw-r--r--examples/network/doc/src/secureudpserver.qdoc29
-rw-r--r--examples/network/doc/src/threadedfortuneserver.qdoc35
-rw-r--r--examples/network/doc/src/torrent.qdoc29
-rw-r--r--examples/network/download/CMakeLists.txt37
-rw-r--r--examples/network/download/download.pro8
-rw-r--r--examples/network/download/main.cpp213
-rw-r--r--examples/network/downloadmanager/CMakeLists.txt39
-rw-r--r--examples/network/downloadmanager/downloadmanager.cpp212
-rw-r--r--examples/network/downloadmanager/downloadmanager.h93
-rw-r--r--examples/network/downloadmanager/downloadmanager.pro17
-rw-r--r--examples/network/downloadmanager/main.cpp82
-rw-r--r--examples/network/downloadmanager/textprogressbar.cpp107
-rw-r--r--examples/network/downloadmanager/textprogressbar.h71
-rw-r--r--examples/network/fortuneclient/CMakeLists.txt47
-rw-r--r--examples/network/fortuneclient/client.cpp68
-rw-r--r--examples/network/fortuneclient/client.h51
-rw-r--r--examples/network/fortuneclient/main.cpp51
-rw-r--r--examples/network/fortuneserver/CMakeLists.txt47
-rw-r--r--examples/network/fortuneserver/main.cpp51
-rw-r--r--examples/network/fortuneserver/server.cpp65
-rw-r--r--examples/network/fortuneserver/server.h51
-rw-r--r--examples/network/googlesuggest/CMakeLists.txt43
-rw-r--r--examples/network/googlesuggest/googlesuggest.cpp231
-rw-r--r--examples/network/googlesuggest/googlesuggest.h84
-rw-r--r--examples/network/googlesuggest/googlesuggest.pro8
-rw-r--r--examples/network/googlesuggest/main.cpp61
-rw-r--r--examples/network/googlesuggest/searchbox.cpp82
-rw-r--r--examples/network/googlesuggest/searchbox.h75
-rw-r--r--examples/network/http/CMakeLists.txt57
-rw-r--r--examples/network/http/http.pro4
-rw-r--r--examples/network/http/httpwindow.cpp111
-rw-r--r--examples/network/http/httpwindow.h57
-rw-r--r--examples/network/http/main.cpp75
-rw-r--r--examples/network/loopback/CMakeLists.txt42
-rw-r--r--examples/network/loopback/dialog.cpp202
-rw-r--r--examples/network/loopback/dialog.h98
-rw-r--r--examples/network/loopback/loopback.pro9
-rw-r--r--examples/network/loopback/main.cpp61
-rw-r--r--examples/network/multicastreceiver/CMakeLists.txt47
-rw-r--r--examples/network/multicastreceiver/main.cpp51
-rw-r--r--examples/network/multicastreceiver/receiver.cpp55
-rw-r--r--examples/network/multicastreceiver/receiver.h51
-rw-r--r--examples/network/multicastsender/CMakeLists.txt47
-rw-r--r--examples/network/multicastsender/main.cpp51
-rw-r--r--examples/network/multicastsender/sender.cpp51
-rw-r--r--examples/network/multicastsender/sender.h51
-rw-r--r--examples/network/multistreamclient/CMakeLists.txt47
-rw-r--r--examples/network/multistreamclient/chatconsumer.cpp51
-rw-r--r--examples/network/multistreamclient/chatconsumer.h51
-rw-r--r--examples/network/multistreamclient/client.cpp51
-rw-r--r--examples/network/multistreamclient/client.h51
-rw-r--r--examples/network/multistreamclient/consumer.h51
-rw-r--r--examples/network/multistreamclient/main.cpp51
-rw-r--r--examples/network/multistreamclient/movieconsumer.cpp51
-rw-r--r--examples/network/multistreamclient/movieconsumer.h51
-rw-r--r--examples/network/multistreamclient/timeconsumer.cpp53
-rw-r--r--examples/network/multistreamclient/timeconsumer.h51
-rw-r--r--examples/network/multistreamserver/CMakeLists.txt47
-rw-r--r--examples/network/multistreamserver/chatprovider.cpp51
-rw-r--r--examples/network/multistreamserver/chatprovider.h51
-rw-r--r--examples/network/multistreamserver/main.cpp51
-rw-r--r--examples/network/multistreamserver/movieprovider.cpp51
-rw-r--r--examples/network/multistreamserver/movieprovider.h51
-rw-r--r--examples/network/multistreamserver/provider.h51
-rw-r--r--examples/network/multistreamserver/server.cpp51
-rw-r--r--examples/network/multistreamserver/server.h51
-rw-r--r--examples/network/multistreamserver/timeprovider.cpp53
-rw-r--r--examples/network/multistreamserver/timeprovider.h51
-rw-r--r--examples/network/network-chat/CMakeLists.txt51
-rw-r--r--examples/network/network-chat/chatdialog.cpp61
-rw-r--r--examples/network/network-chat/chatdialog.h53
-rw-r--r--examples/network/network-chat/client.cpp103
-rw-r--r--examples/network/network-chat/client.h59
-rw-r--r--examples/network/network-chat/connection.cpp110
-rw-r--r--examples/network/network-chat/connection.h76
-rw-r--r--examples/network/network-chat/main.cpp55
-rw-r--r--examples/network/network-chat/network-chat.pro1
-rw-r--r--examples/network/network-chat/peermanager.cpp99
-rw-r--r--examples/network/network-chat/peermanager.h59
-rw-r--r--examples/network/network-chat/server.cpp53
-rw-r--r--examples/network/network-chat/server.h53
-rw-r--r--examples/network/network.pro19
-rw-r--r--examples/network/rsslisting/CMakeLists.txt39
-rw-r--r--examples/network/rsslisting/main.cpp16
-rw-r--r--examples/network/rsslisting/rsslisting.cpp126
-rw-r--r--examples/network/rsslisting/rsslisting.h54
-rw-r--r--examples/network/rsslisting/rsslisting.pro8
-rw-r--r--examples/network/securesocketclient/CMakeLists.txt50
-rw-r--r--examples/network/securesocketclient/certificateinfo.cpp75
-rw-r--r--examples/network/securesocketclient/certificateinfo.h51
-rw-r--r--examples/network/securesocketclient/main.cpp53
-rw-r--r--examples/network/securesocketclient/sslclient.cpp53
-rw-r--r--examples/network/securesocketclient/sslclient.h51
-rw-r--r--examples/network/secureudpclient/CMakeLists.txt47
-rw-r--r--examples/network/secureudpclient/addressdialog.cpp51
-rw-r--r--examples/network/secureudpclient/addressdialog.h57
-rw-r--r--examples/network/secureudpclient/association.cpp55
-rw-r--r--examples/network/secureudpclient/association.h55
-rw-r--r--examples/network/secureudpclient/main.cpp53
-rw-r--r--examples/network/secureudpclient/mainwindow.cpp53
-rw-r--r--examples/network/secureudpclient/mainwindow.h59
-rw-r--r--examples/network/secureudpserver/CMakeLists.txt47
-rw-r--r--examples/network/secureudpserver/main.cpp53
-rw-r--r--examples/network/secureudpserver/mainwindow.cpp51
-rw-r--r--examples/network/secureudpserver/mainwindow.h55
-rw-r--r--examples/network/secureudpserver/nicselector.cpp51
-rw-r--r--examples/network/secureudpserver/nicselector.h55
-rw-r--r--examples/network/secureudpserver/server.cpp63
-rw-r--r--examples/network/secureudpserver/server.h55
-rw-r--r--examples/network/shared/sctpchannels.h51
-rw-r--r--examples/network/threadedfortuneserver/CMakeLists.txt47
-rw-r--r--examples/network/threadedfortuneserver/dialog.cpp61
-rw-r--r--examples/network/threadedfortuneserver/dialog.h51
-rw-r--r--examples/network/threadedfortuneserver/fortuneserver.cpp53
-rw-r--r--examples/network/threadedfortuneserver/fortuneserver.h51
-rw-r--r--examples/network/threadedfortuneserver/fortunethread.cpp55
-rw-r--r--examples/network/threadedfortuneserver/fortunethread.h55
-rw-r--r--examples/network/threadedfortuneserver/main.cpp51
-rw-r--r--examples/network/torrent/.prev_CMakeLists.txt73
-rw-r--r--examples/network/torrent/CMakeLists.txt70
-rw-r--r--examples/network/torrent/addtorrentdialog.cpp51
-rw-r--r--examples/network/torrent/addtorrentdialog.h51
-rw-r--r--examples/network/torrent/addtorrentform.ui (renamed from examples/network/torrent/forms/addtorrentform.ui)0
-rw-r--r--examples/network/torrent/bencodeparser.cpp51
-rw-r--r--examples/network/torrent/bencodeparser.h51
-rw-r--r--examples/network/torrent/connectionmanager.cpp51
-rw-r--r--examples/network/torrent/connectionmanager.h51
-rw-r--r--examples/network/torrent/filemanager.cpp73
-rw-r--r--examples/network/torrent/filemanager.h83
-rw-r--r--examples/network/torrent/icons.qrc23
-rw-r--r--examples/network/torrent/icons/1downarrow.pngbin895 -> 0 bytes
-rw-r--r--examples/network/torrent/icons/1downarrow.svg3
-rw-r--r--examples/network/torrent/icons/1uparrow.pngbin822 -> 0 bytes
-rw-r--r--examples/network/torrent/icons/1uparrow.svg3
-rw-r--r--examples/network/torrent/icons/about.svg4
-rw-r--r--examples/network/torrent/icons/bottom.pngbin1632 -> 0 bytes
-rw-r--r--examples/network/torrent/icons/bottom.svg6
-rw-r--r--examples/network/torrent/icons/edit_add.pngbin394 -> 0 bytes
-rw-r--r--examples/network/torrent/icons/edit_add.svg4
-rw-r--r--examples/network/torrent/icons/edit_remove.pngbin368 -> 0 bytes
-rw-r--r--examples/network/torrent/icons/edit_remove.svg3
-rw-r--r--examples/network/torrent/icons/exit.pngbin1426 -> 0 bytes
-rw-r--r--examples/network/torrent/icons/exit.svg4
-rw-r--r--examples/network/torrent/icons/peertopeer.pngbin10072 -> 0 bytes
-rw-r--r--examples/network/torrent/icons/peertopeer.svg62
-rw-r--r--examples/network/torrent/icons/player_pause.pngbin690 -> 0 bytes
-rw-r--r--examples/network/torrent/icons/player_pause.svg6
-rw-r--r--examples/network/torrent/icons/player_play.pngbin900 -> 0 bytes
-rw-r--r--examples/network/torrent/icons/player_play.svg3
-rw-r--r--examples/network/torrent/icons/player_stop.pngbin627 -> 0 bytes
-rw-r--r--examples/network/torrent/icons/player_stop.svg5
-rw-r--r--examples/network/torrent/icons/stop.pngbin1252 -> 0 bytes
-rw-r--r--examples/network/torrent/main.cpp53
-rw-r--r--examples/network/torrent/mainwindow.cpp102
-rw-r--r--examples/network/torrent/mainwindow.h51
-rw-r--r--examples/network/torrent/metainfo.cpp51
-rw-r--r--examples/network/torrent/metainfo.h53
-rw-r--r--examples/network/torrent/peerwireclient.cpp152
-rw-r--r--examples/network/torrent/peerwireclient.h59
-rw-r--r--examples/network/torrent/ratecontroller.cpp57
-rw-r--r--examples/network/torrent/ratecontroller.h51
-rw-r--r--examples/network/torrent/torrent.pro2
-rw-r--r--examples/network/torrent/torrentclient.cpp157
-rw-r--r--examples/network/torrent/torrentclient.h54
-rw-r--r--examples/network/torrent/torrentserver.cpp53
-rw-r--r--examples/network/torrent/torrentserver.h51
-rw-r--r--examples/network/torrent/trackerclient.cpp65
-rw-r--r--examples/network/torrent/trackerclient.h52
-rw-r--r--examples/opengl/2dpainting/CMakeLists.txt50
-rw-r--r--examples/opengl/2dpainting/glwidget.cpp51
-rw-r--r--examples/opengl/2dpainting/glwidget.h51
-rw-r--r--examples/opengl/2dpainting/helper.cpp51
-rw-r--r--examples/opengl/2dpainting/helper.h51
-rw-r--r--examples/opengl/2dpainting/main.cpp51
-rw-r--r--examples/opengl/2dpainting/widget.cpp51
-rw-r--r--examples/opengl/2dpainting/widget.h51
-rw-r--r--examples/opengl/2dpainting/window.cpp51
-rw-r--r--examples/opengl/2dpainting/window.h51
-rw-r--r--examples/opengl/CMakeLists.txt25
-rw-r--r--examples/opengl/computegles31/CMakeLists.txt53
-rw-r--r--examples/opengl/computegles31/Qt-logo-medium.pngbin24817 -> 0 bytes
-rw-r--r--examples/opengl/computegles31/computegles31.pro11
-rw-r--r--examples/opengl/computegles31/computegles31.qrc5
-rw-r--r--examples/opengl/computegles31/glwindow.cpp419
-rw-r--r--examples/opengl/computegles31/glwindow.h110
-rw-r--r--examples/opengl/computegles31/main.cpp148
-rw-r--r--examples/opengl/contextinfo/CMakeLists.txt43
-rw-r--r--examples/opengl/contextinfo/contextinfo.pro14
-rw-r--r--examples/opengl/contextinfo/main.cpp72
-rw-r--r--examples/opengl/contextinfo/renderwindow.cpp238
-rw-r--r--examples/opengl/contextinfo/renderwindow.h95
-rw-r--r--examples/opengl/contextinfo/widget.cpp403
-rw-r--r--examples/opengl/contextinfo/widget.h93
-rw-r--r--examples/opengl/cube/CMakeLists.txt52
-rw-r--r--examples/opengl/cube/cube.pngbin30341 -> 88913 bytes
-rw-r--r--examples/opengl/cube/geometryengine.cpp51
-rw-r--r--examples/opengl/cube/geometryengine.h51
-rw-r--r--examples/opengl/cube/main.cpp51
-rw-r--r--examples/opengl/cube/mainwidget.cpp68
-rw-r--r--examples/opengl/cube/mainwidget.h51
-rw-r--r--examples/opengl/doc/images/hellogles3-example.png (renamed from examples/opengl/hellogles3/doc/images/hellogles3-example.png)bin61792 -> 61792 bytes
-rw-r--r--examples/opengl/doc/images/stereoexample-leftbuffer.pngbin0 -> 9987 bytes
-rw-r--r--examples/opengl/doc/images/stereoexample-rightbuffer.pngbin0 -> 10002 bytes
-rw-r--r--examples/opengl/doc/src/2dpainting.qdoc29
-rw-r--r--examples/opengl/doc/src/cube.qdoc39
-rw-r--r--examples/opengl/doc/src/hellogl2.qdoc29
-rw-r--r--examples/opengl/doc/src/hellogles3.qdoc149
-rw-r--r--examples/opengl/doc/src/openglwindow.qdoc32
-rw-r--r--examples/opengl/doc/src/stereoqopenglwidget.qdoc46
-rw-r--r--examples/opengl/doc/src/textures.qdoc28
-rw-r--r--examples/opengl/hellogl2/CMakeLists.txt50
-rw-r--r--examples/opengl/hellogl2/glwidget.cpp52
-rw-r--r--examples/opengl/hellogl2/glwidget.h51
-rw-r--r--examples/opengl/hellogl2/logo.cpp51
-rw-r--r--examples/opengl/hellogl2/logo.h51
-rw-r--r--examples/opengl/hellogl2/main.cpp51
-rw-r--r--examples/opengl/hellogl2/mainwindow.cpp69
-rw-r--r--examples/opengl/hellogl2/mainwindow.h51
-rw-r--r--examples/opengl/hellogl2/window.cpp131
-rw-r--r--examples/opengl/hellogl2/window.h63
-rw-r--r--examples/opengl/hellogles3/CMakeLists.txt47
-rw-r--r--examples/opengl/hellogles3/doc/src/hellogles3.qdoc46
-rw-r--r--examples/opengl/hellogles3/glwindow.cpp51
-rw-r--r--examples/opengl/hellogles3/glwindow.h63
-rw-r--r--examples/opengl/hellogles3/main.cpp51
-rw-r--r--examples/opengl/hellowindow/CMakeLists.txt42
-rw-r--r--examples/opengl/hellowindow/hellowindow.cpp352
-rw-r--r--examples/opengl/hellowindow/hellowindow.h119
-rw-r--r--examples/opengl/hellowindow/hellowindow.pro9
-rw-r--r--examples/opengl/hellowindow/main.cpp172
-rw-r--r--examples/opengl/opengl.pro14
-rw-r--r--examples/opengl/openglwindow/.prev_CMakeLists.txt36
-rw-r--r--examples/opengl/openglwindow/CMakeLists.txt46
-rw-r--r--examples/opengl/openglwindow/main.cpp132
-rw-r--r--examples/opengl/openglwindow/openglwindow.cpp51
-rw-r--r--examples/opengl/openglwindow/openglwindow.h63
-rw-r--r--examples/opengl/paintedwindow/CMakeLists.txt40
-rw-r--r--examples/opengl/paintedwindow/main.cpp65
-rw-r--r--examples/opengl/paintedwindow/paintedwindow.cpp232
-rw-r--r--examples/opengl/paintedwindow/paintedwindow.h104
-rw-r--r--examples/opengl/paintedwindow/paintedwindow.pro8
-rw-r--r--examples/opengl/qopenglwidget/CMakeLists.txt59
-rw-r--r--examples/opengl/qopenglwidget/bubble.cpp146
-rw-r--r--examples/opengl/qopenglwidget/bubble.h86
-rw-r--r--examples/opengl/qopenglwidget/glwidget.cpp560
-rw-r--r--examples/opengl/qopenglwidget/glwidget.h133
-rw-r--r--examples/opengl/qopenglwidget/main.cpp89
-rw-r--r--examples/opengl/qopenglwidget/mainwindow.cpp187
-rw-r--r--examples/opengl/qopenglwidget/mainwindow.h83
-rw-r--r--examples/opengl/qopenglwidget/qopenglwidget.pro15
-rw-r--r--examples/opengl/qopenglwidget/qt.pngbin2991 -> 0 bytes
-rw-r--r--examples/opengl/qopenglwidget/texture.qrc5
-rw-r--r--examples/opengl/qopenglwindow/CMakeLists.txt57
-rw-r--r--examples/opengl/qopenglwindow/background.frag30
-rw-r--r--examples/opengl/qopenglwindow/background_renderer.cpp214
-rw-r--r--examples/opengl/qopenglwindow/background_renderer.h93
-rw-r--r--examples/opengl/qopenglwindow/main.cpp201
-rw-r--r--examples/opengl/qopenglwindow/qopenglwindow.pro16
-rw-r--r--examples/opengl/qopenglwindow/shaders.qrc5
-rw-r--r--examples/opengl/stereoqopenglwidget/CMakeLists.txt42
-rw-r--r--examples/opengl/stereoqopenglwidget/glwidget.cpp277
-rw-r--r--examples/opengl/stereoqopenglwidget/glwidget.h53
-rw-r--r--examples/opengl/stereoqopenglwidget/main.cpp31
-rw-r--r--examples/opengl/stereoqopenglwidget/mainwindow.cpp25
-rw-r--r--examples/opengl/stereoqopenglwidget/mainwindow.h21
-rw-r--r--examples/opengl/stereoqopenglwidget/stereoqopenglwidget.pro11
-rw-r--r--examples/opengl/textures/CMakeLists.txt51
-rw-r--r--examples/opengl/textures/glwidget.cpp59
-rw-r--r--examples/opengl/textures/glwidget.h51
-rw-r--r--examples/opengl/textures/main.cpp53
-rw-r--r--examples/opengl/textures/window.cpp51
-rw-r--r--examples/opengl/textures/window.h51
-rw-r--r--examples/opengl/threadedqopenglwidget/CMakeLists.txt45
-rw-r--r--examples/opengl/threadedqopenglwidget/glwidget.cpp367
-rw-r--r--examples/opengl/threadedqopenglwidget/glwidget.h136
-rw-r--r--examples/opengl/threadedqopenglwidget/main.cpp131
-rw-r--r--examples/opengl/threadedqopenglwidget/mainwindow.cpp63
-rw-r--r--examples/opengl/threadedqopenglwidget/mainwindow.h64
-rw-r--r--examples/opengl/threadedqopenglwidget/threadedqopenglwidget.pro11
-rw-r--r--examples/qmake/precompile/main.cpp54
-rw-r--r--examples/qmake/precompile/mydialog.cpp51
-rw-r--r--examples/qmake/precompile/mydialog.h51
-rw-r--r--examples/qmake/precompile/myobject.cpp51
-rw-r--r--examples/qmake/precompile/myobject.h51
-rw-r--r--examples/qmake/precompile/stable.h51
-rw-r--r--examples/qmake/precompile/util.cpp51
-rw-r--r--examples/qmake/tutorial/hello.cpp51
-rw-r--r--examples/qmake/tutorial/hello.h51
-rw-r--r--examples/qmake/tutorial/hellounix.cpp51
-rw-r--r--examples/qmake/tutorial/hellowin.cpp51
-rw-r--r--examples/qmake/tutorial/main.cpp51
-rw-r--r--examples/qpa/CMakeLists.txt7
-rw-r--r--examples/qpa/qpa.pro5
-rw-r--r--examples/qpa/qrasterwindow/.prev_CMakeLists.txt29
-rw-r--r--examples/qpa/qrasterwindow/CMakeLists.txt37
-rw-r--r--examples/qpa/qrasterwindow/main.cpp138
-rw-r--r--examples/qpa/qrasterwindow/qrasterwindow.pro4
-rw-r--r--examples/qpa/windows/CMakeLists.txt40
-rw-r--r--examples/qpa/windows/main.cpp97
-rw-r--r--examples/qpa/windows/window.cpp211
-rw-r--r--examples/qpa/windows/window.h83
-rw-r--r--examples/qpa/windows/windows.pro9
-rw-r--r--examples/qtconcurrent/CMakeLists.txt17
-rw-r--r--examples/qtconcurrent/imagescaling/CMakeLists.txt50
-rw-r--r--examples/qtconcurrent/imagescaling/doc/images/imagescaling.webpbin0 -> 46826 bytes
-rw-r--r--examples/qtconcurrent/imagescaling/doc/images/imagescaling_example.pngbin21049 -> 0 bytes
-rw-r--r--examples/qtconcurrent/imagescaling/doc/src/qtconcurrent-imagescaling.qdoc142
-rw-r--r--examples/qtconcurrent/imagescaling/downloaddialog.cpp51
-rw-r--r--examples/qtconcurrent/imagescaling/downloaddialog.h51
-rw-r--r--examples/qtconcurrent/imagescaling/imagescaling.cpp150
-rw-r--r--examples/qtconcurrent/imagescaling/imagescaling.h62
-rw-r--r--examples/qtconcurrent/imagescaling/main.cpp58
-rw-r--r--examples/qtconcurrent/map/.prev_CMakeLists.txt39
-rw-r--r--examples/qtconcurrent/map/CMakeLists.txt38
-rw-r--r--examples/qtconcurrent/map/doc/src/qtconcurrent-map.qdoc38
-rw-r--r--examples/qtconcurrent/map/main.cpp82
-rw-r--r--examples/qtconcurrent/map/map.pro9
-rw-r--r--examples/qtconcurrent/primecounter/CMakeLists.txt41
-rw-r--r--examples/qtconcurrent/primecounter/doc/images/primecounter.pngbin0 -> 9732 bytes
-rw-r--r--examples/qtconcurrent/primecounter/doc/src/qtconcurrent-primecounter.qdoc89
-rw-r--r--examples/qtconcurrent/primecounter/main.cpp18
-rw-r--r--examples/qtconcurrent/primecounter/primecounter.cpp139
-rw-r--r--examples/qtconcurrent/primecounter/primecounter.h49
-rw-r--r--examples/qtconcurrent/primecounter/primecounter.pro9
-rw-r--r--examples/qtconcurrent/primecounter/primecounter.ui177
-rw-r--r--examples/qtconcurrent/progressdialog/CMakeLists.txt41
-rw-r--r--examples/qtconcurrent/progressdialog/doc/images/qtconcurrent-progressdialog.pngbin4608 -> 0 bytes
-rw-r--r--examples/qtconcurrent/progressdialog/doc/src/qtconcurrent-progressdialog.qdoc38
-rw-r--r--examples/qtconcurrent/progressdialog/main.cpp100
-rw-r--r--examples/qtconcurrent/progressdialog/progressdialog.pro7
-rw-r--r--examples/qtconcurrent/qtconcurrent.pro13
-rw-r--r--examples/qtconcurrent/runfunction/CMakeLists.txt41
-rw-r--r--examples/qtconcurrent/runfunction/doc/src/qtconcurrent-runfunction.qdoc39
-rw-r--r--examples/qtconcurrent/runfunction/main.cpp71
-rw-r--r--examples/qtconcurrent/runfunction/runfunction.pro7
-rw-r--r--examples/qtconcurrent/wordcount/CMakeLists.txt50
-rw-r--r--examples/qtconcurrent/wordcount/doc/src/qtconcurrent-wordcount.qdoc70
-rw-r--r--examples/qtconcurrent/wordcount/main.cpp195
-rw-r--r--examples/qtestlib/CMakeLists.txt15
-rw-r--r--examples/qtestlib/tutorial1/CMakeLists.txt47
-rw-r--r--examples/qtestlib/tutorial1/testqstring.cpp51
-rw-r--r--examples/qtestlib/tutorial2/CMakeLists.txt47
-rw-r--r--examples/qtestlib/tutorial2/testqstring.cpp55
-rw-r--r--examples/qtestlib/tutorial3/CMakeLists.txt47
-rw-r--r--examples/qtestlib/tutorial3/testgui.cpp51
-rw-r--r--examples/qtestlib/tutorial4/CMakeLists.txt47
-rw-r--r--examples/qtestlib/tutorial4/testgui.cpp53
-rw-r--r--examples/qtestlib/tutorial5/CMakeLists.txt47
-rw-r--r--examples/qtestlib/tutorial5/benchmarking.cpp60
-rw-r--r--examples/sql/.prev_CMakeLists.txt18
-rw-r--r--examples/sql/CMakeLists.txt27
-rw-r--r--examples/sql/books/CMakeLists.txt57
-rw-r--r--examples/sql/books/bookdelegate.cpp101
-rw-r--r--examples/sql/books/bookdelegate.h57
-rw-r--r--examples/sql/books/books.pro1
-rw-r--r--examples/sql/books/books.qrc3
-rw-r--r--examples/sql/books/bookwindow.cpp258
-rw-r--r--examples/sql/books/bookwindow.h89
-rw-r--r--examples/sql/books/bookwindow.ui164
-rw-r--r--examples/sql/books/images/star-filled.svg1
-rw-r--r--examples/sql/books/images/star.pngbin782 -> 0 bytes
-rw-r--r--examples/sql/books/images/star.svg1
-rw-r--r--examples/sql/books/initdb.h55
-rw-r--r--examples/sql/books/main.cpp55
-rw-r--r--examples/sql/cachedtable/CMakeLists.txt47
-rw-r--r--examples/sql/cachedtable/main.cpp51
-rw-r--r--examples/sql/cachedtable/tableeditor.cpp62
-rw-r--r--examples/sql/cachedtable/tableeditor.h59
-rw-r--r--examples/sql/connection.h51
-rw-r--r--examples/sql/doc/images/books-demo.pngbin14782 -> 13975 bytes
-rw-r--r--examples/sql/doc/images/drilldown-example.pngbin6612 -> 10335 bytes
-rw-r--r--examples/sql/doc/src/books.qdoc29
-rw-r--r--examples/sql/doc/src/cachedtable.qdoc35
-rw-r--r--examples/sql/doc/src/drilldown.qdoc39
-rw-r--r--examples/sql/doc/src/masterdetail.qdoc29
-rw-r--r--examples/sql/doc/src/querymodel.qdoc29
-rw-r--r--examples/sql/doc/src/relationaltablemodel.qdoc29
-rw-r--r--examples/sql/doc/src/sqlbrowser.qdoc29
-rw-r--r--examples/sql/doc/src/sqlwidgetmapper.qdoc40
-rw-r--r--examples/sql/doc/src/tablemodel.qdoc29
-rw-r--r--examples/sql/drilldown/CMakeLists.txt50
-rw-r--r--examples/sql/drilldown/imageitem.cpp57
-rw-r--r--examples/sql/drilldown/imageitem.h54
-rw-r--r--examples/sql/drilldown/images/qt-creator.pngbin6655 -> 8355 bytes
-rw-r--r--examples/sql/drilldown/images/qt-logo.pngbin5527 -> 6650 bytes
-rw-r--r--examples/sql/drilldown/images/qt-project.pngbin16832 -> 8376 bytes
-rw-r--r--examples/sql/drilldown/images/qt-quick.pngbin26635 -> 8029 bytes
-rw-r--r--examples/sql/drilldown/informationwindow.cpp65
-rw-r--r--examples/sql/drilldown/informationwindow.h59
-rw-r--r--examples/sql/drilldown/main.cpp53
-rw-r--r--examples/sql/drilldown/view.cpp55
-rw-r--r--examples/sql/drilldown/view.h54
-rw-r--r--examples/sql/masterdetail/CMakeLists.txt53
-rw-r--r--examples/sql/masterdetail/database.h51
-rw-r--r--examples/sql/masterdetail/dialog.cpp90
-rw-r--r--examples/sql/masterdetail/dialog.h78
-rw-r--r--examples/sql/masterdetail/main.cpp55
-rw-r--r--examples/sql/masterdetail/mainwindow.cpp112
-rw-r--r--examples/sql/masterdetail/mainwindow.h80
-rw-r--r--examples/sql/querymodel/CMakeLists.txt47
-rw-r--r--examples/sql/querymodel/customsqlmodel.cpp55
-rw-r--r--examples/sql/querymodel/customsqlmodel.h51
-rw-r--r--examples/sql/querymodel/editablesqlmodel.cpp63
-rw-r--r--examples/sql/querymodel/editablesqlmodel.h51
-rw-r--r--examples/sql/querymodel/main.cpp53
-rw-r--r--examples/sql/relationaltablemodel/CMakeLists.txt47
-rw-r--r--examples/sql/relationaltablemodel/relationaltablemodel.cpp51
-rw-r--r--examples/sql/sqlbrowser/CMakeLists.txt45
-rw-r--r--examples/sql/sqlbrowser/browser.cpp265
-rw-r--r--examples/sql/sqlbrowser/browser.h117
-rw-r--r--examples/sql/sqlbrowser/connectionwidget.cpp114
-rw-r--r--examples/sql/sqlbrowser/connectionwidget.h60
-rw-r--r--examples/sql/sqlbrowser/main.cpp91
-rw-r--r--examples/sql/sqlbrowser/qsqlconnectiondialog.cpp96
-rw-r--r--examples/sql/sqlbrowser/qsqlconnectiondialog.h68
-rw-r--r--examples/sql/sqlwidgetmapper/CMakeLists.txt47
-rw-r--r--examples/sql/sqlwidgetmapper/main.cpp51
-rw-r--r--examples/sql/sqlwidgetmapper/window.cpp66
-rw-r--r--examples/sql/sqlwidgetmapper/window.h73
-rw-r--r--examples/sql/tablemodel/CMakeLists.txt47
-rw-r--r--examples/sql/tablemodel/tablemodel.cpp53
-rw-r--r--examples/vulkan/CMakeLists.txt15
-rw-r--r--examples/vulkan/doc/images/hellovulkantexture.pngbin10259 -> 0 bytes
-rw-r--r--examples/vulkan/doc/images/hellovulkanwindow.pngbin2736 -> 0 bytes
-rw-r--r--examples/vulkan/doc/src/hellovulkancubes.qdoc29
-rw-r--r--examples/vulkan/doc/src/hellovulkantexture.qdoc42
-rw-r--r--examples/vulkan/doc/src/hellovulkantriangle.qdoc77
-rw-r--r--examples/vulkan/doc/src/hellovulkanwidget.qdoc29
-rw-r--r--examples/vulkan/doc/src/hellovulkanwindow.qdoc102
-rw-r--r--examples/vulkan/hellovulkancubes/CMakeLists.txt50
-rw-r--r--examples/vulkan/hellovulkancubes/camera.cpp51
-rw-r--r--examples/vulkan/hellovulkancubes/camera.h51
-rw-r--r--examples/vulkan/hellovulkancubes/main.cpp65
-rw-r--r--examples/vulkan/hellovulkancubes/mainwindow.cpp53
-rw-r--r--examples/vulkan/hellovulkancubes/mainwindow.h61
-rw-r--r--examples/vulkan/hellovulkancubes/mesh.cpp51
-rw-r--r--examples/vulkan/hellovulkancubes/mesh.h51
-rw-r--r--examples/vulkan/hellovulkancubes/renderer.cpp53
-rw-r--r--examples/vulkan/hellovulkancubes/renderer.h51
-rw-r--r--examples/vulkan/hellovulkancubes/shader.cpp51
-rw-r--r--examples/vulkan/hellovulkancubes/shader.h51
-rw-r--r--examples/vulkan/hellovulkancubes/vulkanwindow.cpp51
-rw-r--r--examples/vulkan/hellovulkancubes/vulkanwindow.h51
-rw-r--r--examples/vulkan/hellovulkantexture/CMakeLists.txt53
-rw-r--r--examples/vulkan/hellovulkantexture/hellovulkantexture.cpp839
-rw-r--r--examples/vulkan/hellovulkantexture/hellovulkantexture.h108
-rw-r--r--examples/vulkan/hellovulkantexture/hellovulkantexture.pro7
-rw-r--r--examples/vulkan/hellovulkantexture/hellovulkantexture.qrc7
-rw-r--r--examples/vulkan/hellovulkantexture/main.cpp91
-rw-r--r--examples/vulkan/hellovulkantexture/qt256.pngbin6208 -> 0 bytes
-rw-r--r--examples/vulkan/hellovulkantexture/texture.frag12
-rw-r--r--examples/vulkan/hellovulkantexture/texture.vert18
-rw-r--r--examples/vulkan/hellovulkantexture/texture_frag.spvbin556 -> 0 bytes
-rw-r--r--examples/vulkan/hellovulkantexture/texture_vert.spvbin968 -> 0 bytes
-rw-r--r--examples/vulkan/hellovulkantriangle/CMakeLists.txt46
-rw-r--r--examples/vulkan/hellovulkantriangle/main.cpp72
-rw-r--r--examples/vulkan/hellovulkanwidget/CMakeLists.txt49
-rw-r--r--examples/vulkan/hellovulkanwidget/hellovulkanwidget.cpp51
-rw-r--r--examples/vulkan/hellovulkanwidget/hellovulkanwidget.h66
-rw-r--r--examples/vulkan/hellovulkanwidget/main.cpp65
-rw-r--r--examples/vulkan/hellovulkanwindow/CMakeLists.txt38
-rw-r--r--examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp128
-rw-r--r--examples/vulkan/hellovulkanwindow/hellovulkanwindow.h77
-rw-r--r--examples/vulkan/hellovulkanwindow/hellovulkanwindow.pro6
-rw-r--r--examples/vulkan/hellovulkanwindow/main.cpp93
-rw-r--r--examples/vulkan/shared/objconvert.js51
-rw-r--r--examples/vulkan/shared/trianglerenderer.cpp51
-rw-r--r--examples/vulkan/shared/trianglerenderer.h56
-rw-r--r--examples/vulkan/vulkan.pro4
-rw-r--r--examples/widgets/.prev_CMakeLists.txt32
-rw-r--r--examples/widgets/CMakeLists.txt15
-rw-r--r--examples/widgets/animation/CMakeLists.txt4
-rw-r--r--examples/widgets/animation/easing/CMakeLists.txt47
-rw-r--r--examples/widgets/animation/easing/animation.h55
-rw-r--r--examples/widgets/animation/easing/main.cpp52
-rw-r--r--examples/widgets/animation/easing/window.cpp69
-rw-r--r--examples/widgets/animation/easing/window.h56
-rw-r--r--examples/widgets/desktop/CMakeLists.txt6
-rw-r--r--examples/widgets/desktop/screenshot/CMakeLists.txt44
-rw-r--r--examples/widgets/desktop/screenshot/main.cpp51
-rw-r--r--examples/widgets/desktop/screenshot/screenshot.cpp53
-rw-r--r--examples/widgets/desktop/screenshot/screenshot.h51
-rw-r--r--examples/widgets/desktop/systray/CMakeLists.txt47
-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.qdoc37
-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.cpp53
-rw-r--r--examples/widgets/desktop/systray/window.cpp56
-rw-r--r--examples/widgets/desktop/systray/window.h51
-rw-r--r--examples/widgets/dialogs/.prev_CMakeLists.txt13
-rw-r--r--examples/widgets/dialogs/CMakeLists.txt18
-rw-r--r--examples/widgets/dialogs/classwizard/CMakeLists.txt59
-rw-r--r--examples/widgets/dialogs/classwizard/classwizard.cpp441
-rw-r--r--examples/widgets/dialogs/classwizard/classwizard.h166
-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.cpp75
-rw-r--r--examples/widgets/dialogs/dialogs.pro5
-rw-r--r--examples/widgets/dialogs/extension/CMakeLists.txt40
-rw-r--r--examples/widgets/dialogs/extension/extension.pro9
-rw-r--r--examples/widgets/dialogs/extension/finddialog.cpp124
-rw-r--r--examples/widgets/dialogs/extension/finddialog.h88
-rw-r--r--examples/widgets/dialogs/extension/main.cpp63
-rw-r--r--examples/widgets/dialogs/findfiles/CMakeLists.txt40
-rw-r--r--examples/widgets/dialogs/findfiles/findfiles.pro10
-rw-r--r--examples/widgets/dialogs/findfiles/main.cpp61
-rw-r--r--examples/widgets/dialogs/findfiles/window.cpp311
-rw-r--r--examples/widgets/dialogs/findfiles/window.h97
-rw-r--r--examples/widgets/dialogs/licensewizard/CMakeLists.txt50
-rw-r--r--examples/widgets/dialogs/licensewizard/licensewizard.cpp56
-rw-r--r--examples/widgets/dialogs/licensewizard/licensewizard.h51
-rw-r--r--examples/widgets/dialogs/licensewizard/main.cpp53
-rw-r--r--examples/widgets/dialogs/standarddialogs/CMakeLists.txt44
-rw-r--r--examples/widgets/dialogs/standarddialogs/dialog.cpp140
-rw-r--r--examples/widgets/dialogs/standarddialogs/dialog.h52
-rw-r--r--examples/widgets/dialogs/standarddialogs/main.cpp68
-rw-r--r--examples/widgets/dialogs/standarddialogs/main.mm47
-rw-r--r--examples/widgets/dialogs/tabdialog/CMakeLists.txt44
-rw-r--r--examples/widgets/dialogs/tabdialog/main.cpp51
-rw-r--r--examples/widgets/dialogs/tabdialog/tabdialog.cpp51
-rw-r--r--examples/widgets/dialogs/tabdialog/tabdialog.h51
-rw-r--r--examples/widgets/dialogs/trivialwizard/CMakeLists.txt44
-rw-r--r--examples/widgets/dialogs/trivialwizard/trivialwizard.cpp53
-rw-r--r--examples/widgets/doc/dropsite.qdoc33
-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/notepad1.pngbin12418 -> 11747 bytes
-rw-r--r--examples/widgets/doc/images/notepad2.pngbin22700 -> 26246 bytes
-rw-r--r--examples/widgets/doc/images/notepad3.pngbin40584 -> 21002 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/regularexpression-example.pngbin78860 -> 75203 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.qdoc94
-rw-r--r--examples/widgets/doc/src/addressbook-tutorial.qdoc972
-rw-r--r--examples/widgets/doc/src/addressbook.qdoc47
-rw-r--r--examples/widgets/doc/src/affine.qdoc31
-rw-r--r--examples/widgets/doc/src/analogclock.qdoc113
-rw-r--r--examples/widgets/doc/src/application.qdoc395
-rw-r--r--examples/widgets/doc/src/basicdrawing.qdoc29
-rw-r--r--examples/widgets/doc/src/basicgraphicslayouts.qdoc29
-rw-r--r--examples/widgets/doc/src/basiclayouts.qdoc29
-rw-r--r--examples/widgets/doc/src/basicsortfiltermodel.qdoc29
-rw-r--r--examples/widgets/doc/src/blurpicker.qdoc44
-rw-r--r--examples/widgets/doc/src/borderlayout.qdoc70
-rw-r--r--examples/widgets/doc/src/calculator.qdoc29
-rw-r--r--examples/widgets/doc/src/calendar.qdoc226
-rw-r--r--examples/widgets/doc/src/calendarwidget.qdoc29
-rw-r--r--examples/widgets/doc/src/charactermap.qdoc275
-rw-r--r--examples/widgets/doc/src/chart.qdoc82
-rw-r--r--examples/widgets/doc/src/chip.qdoc29
-rw-r--r--examples/widgets/doc/src/classwizard.qdoc191
-rw-r--r--examples/widgets/doc/src/codeeditor.qdoc197
-rw-r--r--examples/widgets/doc/src/collidingmice-example.qdoc31
-rw-r--r--examples/widgets/doc/src/coloreditorfactory.qdoc155
-rw-r--r--examples/widgets/doc/src/combowidgetmapper.qdoc49
-rw-r--r--examples/widgets/doc/src/completer.qdoc33
-rw-r--r--examples/widgets/doc/src/composition.qdoc31
-rw-r--r--examples/widgets/doc/src/concentriccircles.qdoc233
-rw-r--r--examples/widgets/doc/src/cuberhiwidget.qdoc170
-rw-r--r--examples/widgets/doc/src/customsortfiltermodel.qdoc29
-rw-r--r--examples/widgets/doc/src/deform.qdoc29
-rw-r--r--examples/widgets/doc/src/diagramscene.qdoc37
-rw-r--r--examples/widgets/doc/src/digitalclock.qdoc75
-rw-r--r--examples/widgets/doc/src/dirview.qdoc73
-rw-r--r--examples/widgets/doc/src/dockwidgets.qdoc164
-rw-r--r--examples/widgets/doc/src/draganddroppuzzle.qdoc42
-rw-r--r--examples/widgets/doc/src/dragdroprobot.qdoc31
-rw-r--r--examples/widgets/doc/src/draggableicons.qdoc29
-rw-r--r--examples/widgets/doc/src/draggabletext.qdoc29
-rw-r--r--examples/widgets/doc/src/dynamiclayouts.qdoc115
-rw-r--r--examples/widgets/doc/src/easing.qdoc29
-rw-r--r--examples/widgets/doc/src/echoplugin.qdoc205
-rw-r--r--examples/widgets/doc/src/editabletreemodel.qdoc82
-rw-r--r--examples/widgets/doc/src/elasticnodes.qdoc33
-rw-r--r--examples/widgets/doc/src/elidedlabel.qdoc155
-rw-r--r--examples/widgets/doc/src/embeddeddialogs.qdoc39
-rw-r--r--examples/widgets/doc/src/extension.qdoc145
-rw-r--r--examples/widgets/doc/src/fademessage.qdoc39
-rw-r--r--examples/widgets/doc/src/fetchmore.qdoc46
-rw-r--r--examples/widgets/doc/src/findfiles.qdoc293
-rw-r--r--examples/widgets/doc/src/flowlayout.qdoc29
-rw-r--r--examples/widgets/doc/src/fontsampler.qdoc37
-rw-r--r--examples/widgets/doc/src/fridgemagnets.qdoc362
-rw-r--r--examples/widgets/doc/src/frozencolumn.qdoc31
-rw-r--r--examples/widgets/doc/src/gallery.qdoc29
-rw-r--r--examples/widgets/doc/src/gradients.qdoc29
-rw-r--r--examples/widgets/doc/src/graphicsview-anchorlayout.qdoc81
-rw-r--r--examples/widgets/doc/src/graphicsview-flowlayout.qdoc52
-rw-r--r--examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc31
-rw-r--r--examples/widgets/doc/src/graphicsview-weatheranchorlayout.qdoc38
-rw-r--r--examples/widgets/doc/src/groupbox.qdoc140
-rw-r--r--examples/widgets/doc/src/i18n.qdoc40
-rw-r--r--examples/widgets/doc/src/icons.qdoc829
-rw-r--r--examples/widgets/doc/src/imagecomposition.qdoc29
-rw-r--r--examples/widgets/doc/src/imageviewer.qdoc344
-rw-r--r--examples/widgets/doc/src/interview.qdoc39
-rw-r--r--examples/widgets/doc/src/itemviewspuzzle.qdoc43
-rw-r--r--examples/widgets/doc/src/licensewizard.qdoc33
-rw-r--r--examples/widgets/doc/src/lineedits.qdoc29
-rw-r--r--examples/widgets/doc/src/mainwindow.qdoc37
-rw-r--r--examples/widgets/doc/src/mdi.qdoc38
-rw-r--r--examples/widgets/doc/src/menus.qdoc32
-rw-r--r--examples/widgets/doc/src/movie.qdoc40
-rw-r--r--examples/widgets/doc/src/orderform.qdoc29
-rw-r--r--examples/widgets/doc/src/painterpaths.qdoc40
-rw-r--r--examples/widgets/doc/src/pathstroke.qdoc29
-rw-r--r--examples/widgets/doc/src/pixelator.qdoc255
-rw-r--r--examples/widgets/doc/src/plugandpaint.qdoc551
-rw-r--r--examples/widgets/doc/src/regularexpression.qdoc29
-rw-r--r--examples/widgets/doc/src/screenshot.qdoc31
-rw-r--r--examples/widgets/doc/src/scribble.qdoc29
-rw-r--r--examples/widgets/doc/src/sdi.qdoc37
-rw-r--r--examples/widgets/doc/src/settingseditor.qdoc38
-rw-r--r--examples/widgets/doc/src/shapedclock.qdoc104
-rw-r--r--examples/widgets/doc/src/shortcuteditor.qdoc231
-rw-r--r--examples/widgets/doc/src/simpledommodel.qdoc280
-rw-r--r--examples/widgets/doc/src/simplerhiwidget.qdoc204
-rw-r--r--examples/widgets/doc/src/simpletreemodel.qdoc79
-rw-r--r--examples/widgets/doc/src/simplewidgetmapper.qdoc125
-rw-r--r--examples/widgets/doc/src/sliders.qdoc117
-rw-r--r--examples/widgets/doc/src/spinboxdelegate.qdoc141
-rw-r--r--examples/widgets/doc/src/spinboxes.qdoc29
-rw-r--r--examples/widgets/doc/src/spreadsheet.qdoc29
-rw-r--r--examples/widgets/doc/src/standarddialogs.qdoc29
-rw-r--r--examples/widgets/doc/src/stardelegate.qdoc29
-rw-r--r--examples/widgets/doc/src/styleplugin.qdoc138
-rw-r--r--examples/widgets/doc/src/styles.qdoc472
-rw-r--r--examples/widgets/doc/src/stylesheet.qdoc88
-rw-r--r--examples/widgets/doc/src/syntaxhighlighter.qdoc35
-rw-r--r--examples/widgets/doc/src/tabdialog.qdoc29
-rw-r--r--examples/widgets/doc/src/tablet.qdoc37
-rw-r--r--examples/widgets/doc/src/tetrix.qdoc431
-rw-r--r--examples/widgets/doc/src/textedit.qdoc39
-rw-r--r--examples/widgets/doc/src/tooltips.qdoc394
-rw-r--r--examples/widgets/doc/src/transformations.qdoc43
-rw-r--r--examples/widgets/doc/src/treemodelcompleter.qdoc29
-rw-r--r--examples/widgets/doc/src/trivialwizard.qdoc31
-rw-r--r--examples/widgets/doc/src/undo.qdoc44
-rw-r--r--examples/widgets/doc/src/undoframework.qdoc70
-rw-r--r--examples/widgets/doc/src/validators.qdoc35
-rw-r--r--examples/widgets/doc/src/wiggly.qdoc168
-rw-r--r--examples/widgets/doc/src/windowflags.qdoc29
-rw-r--r--examples/widgets/draganddrop/CMakeLists.txt11
-rw-r--r--examples/widgets/draganddrop/draganddrop.pro4
-rw-r--r--examples/widgets/draganddrop/draggableicons/CMakeLists.txt50
-rw-r--r--examples/widgets/draganddrop/draggableicons/draggableicons.pro4
-rw-r--r--examples/widgets/draganddrop/draggableicons/dragwidget.cpp53
-rw-r--r--examples/widgets/draganddrop/draggableicons/dragwidget.h51
-rw-r--r--examples/widgets/draganddrop/draggableicons/main.cpp53
-rw-r--r--examples/widgets/draganddrop/draggabletext/CMakeLists.txt49
-rw-r--r--examples/widgets/draganddrop/draggabletext/draggabletext.pro3
-rw-r--r--examples/widgets/draganddrop/draggabletext/dragwidget.cpp51
-rw-r--r--examples/widgets/draganddrop/draggabletext/dragwidget.h51
-rw-r--r--examples/widgets/draganddrop/draggabletext/main.cpp53
-rw-r--r--examples/widgets/draganddrop/draggabletext/words.txt64
-rw-r--r--examples/widgets/draganddrop/dropsite/CMakeLists.txt44
-rw-r--r--examples/widgets/draganddrop/dropsite/droparea.cpp61
-rw-r--r--examples/widgets/draganddrop/dropsite/droparea.h54
-rw-r--r--examples/widgets/draganddrop/dropsite/dropsitewindow.cpp93
-rw-r--r--examples/widgets/draganddrop/dropsite/dropsitewindow.h51
-rw-r--r--examples/widgets/draganddrop/dropsite/main.cpp51
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/CMakeLists.txt54
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/draglabel.cpp98
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/draglabel.h74
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp223
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/dragwidget.h75
-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.cpp72
-rw-r--r--examples/widgets/draganddrop/fridgemagnets/words.txt48
-rw-r--r--examples/widgets/draganddrop/puzzle/.prev_CMakeLists.txt55
-rw-r--r--examples/widgets/draganddrop/puzzle/CMakeLists.txt55
-rw-r--r--examples/widgets/draganddrop/puzzle/example.jpgbin42654 -> 0 bytes
-rw-r--r--examples/widgets/draganddrop/puzzle/main.cpp64
-rw-r--r--examples/widgets/draganddrop/puzzle/mainwindow.cpp165
-rw-r--r--examples/widgets/draganddrop/puzzle/mainwindow.h87
-rw-r--r--examples/widgets/draganddrop/puzzle/pieceslist.cpp134
-rw-r--r--examples/widgets/draganddrop/puzzle/pieceslist.h75
-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.cpp214
-rw-r--r--examples/widgets/draganddrop/puzzle/puzzlewidget.h103
-rw-r--r--examples/widgets/effects/CMakeLists.txt4
-rw-r--r--examples/widgets/effects/blurpicker/CMakeLists.txt62
-rw-r--r--examples/widgets/effects/blurpicker/blureffect.cpp78
-rw-r--r--examples/widgets/effects/blurpicker/blureffect.h76
-rw-r--r--examples/widgets/effects/blurpicker/blurpicker.cpp169
-rw-r--r--examples/widgets/effects/blurpicker/blurpicker.h85
-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.cpp65
-rw-r--r--examples/widgets/effects/effects.pro5
-rw-r--r--examples/widgets/effects/fademessage/CMakeLists.txt53
-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.cpp138
-rw-r--r--examples/widgets/effects/fademessage/fademessage.h80
-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.cpp65
-rw-r--r--examples/widgets/gallery/CMakeLists.txt44
-rw-r--r--examples/widgets/gallery/main.cpp51
-rw-r--r--examples/widgets/gallery/widgetgallery.cpp51
-rw-r--r--examples/widgets/gallery/widgetgallery.h51
-rw-r--r--examples/widgets/gestures/CMakeLists.txt7
-rw-r--r--examples/widgets/gestures/imagegestures/CMakeLists.txt44
-rw-r--r--examples/widgets/gestures/imagegestures/doc/src/imagegestures.qdoc31
-rw-r--r--examples/widgets/gestures/imagegestures/imagewidget.cpp89
-rw-r--r--examples/widgets/gestures/imagegestures/imagewidget.h58
-rw-r--r--examples/widgets/gestures/imagegestures/main.cpp51
-rw-r--r--examples/widgets/gestures/imagegestures/mainwidget.cpp51
-rw-r--r--examples/widgets/gestures/imagegestures/mainwidget.h51
-rw-r--r--examples/widgets/graphicsview/CMakeLists.txt21
-rw-r--r--examples/widgets/graphicsview/anchorlayout/CMakeLists.txt39
-rw-r--r--examples/widgets/graphicsview/anchorlayout/anchorlayout.pro9
-rw-r--r--examples/widgets/graphicsview/anchorlayout/main.cpp136
-rw-r--r--examples/widgets/graphicsview/basicgraphicslayouts/CMakeLists.txt47
-rw-r--r--examples/widgets/graphicsview/basicgraphicslayouts/layoutitem.cpp51
-rw-r--r--examples/widgets/graphicsview/basicgraphicslayouts/layoutitem.h51
-rw-r--r--examples/widgets/graphicsview/basicgraphicslayouts/main.cpp51
-rw-r--r--examples/widgets/graphicsview/basicgraphicslayouts/window.cpp51
-rw-r--r--examples/widgets/graphicsview/basicgraphicslayouts/window.h51
-rw-r--r--examples/widgets/graphicsview/chip/.prev_CMakeLists.txt66
-rw-r--r--examples/widgets/graphicsview/chip/CMakeLists.txt58
-rw-r--r--examples/widgets/graphicsview/chip/chip.cpp51
-rw-r--r--examples/widgets/graphicsview/chip/chip.h51
-rw-r--r--examples/widgets/graphicsview/chip/main.cpp53
-rw-r--r--examples/widgets/graphicsview/chip/mainwindow.cpp54
-rw-r--r--examples/widgets/graphicsview/chip/mainwindow.h51
-rw-r--r--examples/widgets/graphicsview/chip/view.cpp69
-rw-r--r--examples/widgets/graphicsview/chip/view.h57
-rw-r--r--examples/widgets/graphicsview/collidingmice/CMakeLists.txt47
-rw-r--r--examples/widgets/graphicsview/collidingmice/main.cpp51
-rw-r--r--examples/widgets/graphicsview/collidingmice/mouse.cpp51
-rw-r--r--examples/widgets/graphicsview/collidingmice/mouse.h51
-rw-r--r--examples/widgets/graphicsview/diagramscene/CMakeLists.txt47
-rw-r--r--examples/widgets/graphicsview/diagramscene/arrow.cpp51
-rw-r--r--examples/widgets/graphicsview/diagramscene/arrow.h51
-rw-r--r--examples/widgets/graphicsview/diagramscene/diagramitem.cpp55
-rw-r--r--examples/widgets/graphicsview/diagramscene/diagramitem.h51
-rw-r--r--examples/widgets/graphicsview/diagramscene/diagramscene.cpp51
-rw-r--r--examples/widgets/graphicsview/diagramscene/diagramscene.h51
-rw-r--r--examples/widgets/graphicsview/diagramscene/diagramtextitem.cpp51
-rw-r--r--examples/widgets/graphicsview/diagramscene/diagramtextitem.h51
-rw-r--r--examples/widgets/graphicsview/diagramscene/main.cpp53
-rw-r--r--examples/widgets/graphicsview/diagramscene/mainwindow.cpp66
-rw-r--r--examples/widgets/graphicsview/diagramscene/mainwindow.h55
-rw-r--r--examples/widgets/graphicsview/dragdroprobot/CMakeLists.txt47
-rw-r--r--examples/widgets/graphicsview/dragdroprobot/coloritem.cpp51
-rw-r--r--examples/widgets/graphicsview/dragdroprobot/coloritem.h51
-rw-r--r--examples/widgets/graphicsview/dragdroprobot/main.cpp51
-rw-r--r--examples/widgets/graphicsview/dragdroprobot/robot.cpp51
-rw-r--r--examples/widgets/graphicsview/dragdroprobot/robot.h51
-rw-r--r--examples/widgets/graphicsview/elasticnodes/CMakeLists.txt44
-rw-r--r--examples/widgets/graphicsview/elasticnodes/edge.cpp51
-rw-r--r--examples/widgets/graphicsview/elasticnodes/edge.h51
-rw-r--r--examples/widgets/graphicsview/elasticnodes/graphwidget.cpp55
-rw-r--r--examples/widgets/graphicsview/elasticnodes/graphwidget.h51
-rw-r--r--examples/widgets/graphicsview/elasticnodes/main.cpp51
-rw-r--r--examples/widgets/graphicsview/elasticnodes/node.cpp55
-rw-r--r--examples/widgets/graphicsview/elasticnodes/node.h51
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/CMakeLists.txt54
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/No-Ones-Laughing-3.jpgbin30730 -> 0 bytes
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/customproxy.cpp180
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/customproxy.h86
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.cpp117
-rw-r--r--examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.h80
-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.cpp90
-rw-r--r--examples/widgets/graphicsview/flowlayout/.prev_CMakeLists.txt41
-rw-r--r--examples/widgets/graphicsview/flowlayout/CMakeLists.txt41
-rw-r--r--examples/widgets/graphicsview/flowlayout/flowlayout.cpp217
-rw-r--r--examples/widgets/graphicsview/flowlayout/flowlayout.h86
-rw-r--r--examples/widgets/graphicsview/flowlayout/flowlayout.pro10
-rw-r--r--examples/widgets/graphicsview/flowlayout/main.cpp71
-rw-r--r--examples/widgets/graphicsview/flowlayout/window.cpp71
-rw-r--r--examples/widgets/graphicsview/flowlayout/window.h58
-rw-r--r--examples/widgets/graphicsview/graphicsview.pro6
-rw-r--r--examples/widgets/graphicsview/simpleanchorlayout/CMakeLists.txt44
-rw-r--r--examples/widgets/graphicsview/simpleanchorlayout/main.cpp51
-rw-r--r--examples/widgets/graphicsview/weatheranchorlayout/CMakeLists.txt57
-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.cpp286
-rw-r--r--examples/widgets/graphicsview/weatheranchorlayout/weatheranchorlayout.pro8
-rw-r--r--examples/widgets/graphicsview/weatheranchorlayout/weatheranchorlayout.qrc10
-rw-r--r--examples/widgets/itemviews/.prev_CMakeLists.txt27
-rw-r--r--examples/widgets/itemviews/CMakeLists.txt37
-rw-r--r--examples/widgets/itemviews/addressbook/CMakeLists.txt44
-rw-r--r--examples/widgets/itemviews/addressbook/adddialog.cpp51
-rw-r--r--examples/widgets/itemviews/addressbook/adddialog.h51
-rw-r--r--examples/widgets/itemviews/addressbook/addresswidget.cpp70
-rw-r--r--examples/widgets/itemviews/addressbook/addresswidget.h59
-rw-r--r--examples/widgets/itemviews/addressbook/main.cpp51
-rw-r--r--examples/widgets/itemviews/addressbook/mainwindow.cpp61
-rw-r--r--examples/widgets/itemviews/addressbook/mainwindow.h51
-rw-r--r--examples/widgets/itemviews/addressbook/newaddresstab.cpp51
-rw-r--r--examples/widgets/itemviews/addressbook/newaddresstab.h51
-rw-r--r--examples/widgets/itemviews/addressbook/tablemodel.cpp51
-rw-r--r--examples/widgets/itemviews/addressbook/tablemodel.h51
-rw-r--r--examples/widgets/itemviews/basicsortfiltermodel/CMakeLists.txt44
-rw-r--r--examples/widgets/itemviews/basicsortfiltermodel/main.cpp51
-rw-r--r--examples/widgets/itemviews/basicsortfiltermodel/window.cpp51
-rw-r--r--examples/widgets/itemviews/basicsortfiltermodel/window.h51
-rw-r--r--examples/widgets/itemviews/chart/CMakeLists.txt60
-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.cpp63
-rw-r--r--examples/widgets/itemviews/chart/mainwindow.cpp183
-rw-r--r--examples/widgets/itemviews/chart/mainwindow.h81
-rw-r--r--examples/widgets/itemviews/chart/pieview.cpp557
-rw-r--r--examples/widgets/itemviews/chart/pieview.h113
-rw-r--r--examples/widgets/itemviews/chart/qtdata.cht14
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/CMakeLists.txt41
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/coloreditorfactory.pro12
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/colorlisteditor.cpp86
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/colorlisteditor.h79
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/main.cpp63
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/window.cpp102
-rw-r--r--examples/widgets/itemviews/coloreditorfactory/window.h67
-rw-r--r--examples/widgets/itemviews/combowidgetmapper/CMakeLists.txt44
-rw-r--r--examples/widgets/itemviews/combowidgetmapper/main.cpp51
-rw-r--r--examples/widgets/itemviews/combowidgetmapper/window.cpp51
-rw-r--r--examples/widgets/itemviews/combowidgetmapper/window.h51
-rw-r--r--examples/widgets/itemviews/customsortfiltermodel/CMakeLists.txt47
-rw-r--r--examples/widgets/itemviews/customsortfiltermodel/filterwidget.cpp51
-rw-r--r--examples/widgets/itemviews/customsortfiltermodel/filterwidget.h51
-rw-r--r--examples/widgets/itemviews/customsortfiltermodel/main.cpp51
-rw-r--r--examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp51
-rw-r--r--examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h51
-rw-r--r--examples/widgets/itemviews/customsortfiltermodel/window.cpp51
-rw-r--r--examples/widgets/itemviews/customsortfiltermodel/window.h51
-rw-r--r--examples/widgets/itemviews/dirview/CMakeLists.txt39
-rw-r--r--examples/widgets/itemviews/dirview/dirview.pro8
-rw-r--r--examples/widgets/itemviews/dirview/main.cpp107
-rw-r--r--examples/widgets/itemviews/editabletreemodel/CMakeLists.txt79
-rw-r--r--examples/widgets/itemviews/editabletreemodel/main.cpp58
-rw-r--r--examples/widgets/itemviews/editabletreemodel/mainwindow.cpp60
-rw-r--r--examples/widgets/itemviews/editabletreemodel/mainwindow.h51
-rw-r--r--examples/widgets/itemviews/editabletreemodel/test.cpp37
-rw-r--r--examples/widgets/itemviews/editabletreemodel/treeitem.cpp135
-rw-r--r--examples/widgets/itemviews/editabletreemodel/treeitem.h62
-rw-r--r--examples/widgets/itemviews/editabletreemodel/treemodel.cpp162
-rw-r--r--examples/widgets/itemviews/editabletreemodel/treemodel.h73
-rw-r--r--examples/widgets/itemviews/fetchmore/CMakeLists.txt44
-rw-r--r--examples/widgets/itemviews/fetchmore/filelistmodel.cpp104
-rw-r--r--examples/widgets/itemviews/fetchmore/filelistmodel.h64
-rw-r--r--examples/widgets/itemviews/fetchmore/main.cpp51
-rw-r--r--examples/widgets/itemviews/fetchmore/window.cpp99
-rw-r--r--examples/widgets/itemviews/fetchmore/window.h64
-rw-r--r--examples/widgets/itemviews/flattreeview/CMakeLists.txt39
-rw-r--r--examples/widgets/itemviews/flattreeview/flattreeview.pro7
-rw-r--r--examples/widgets/itemviews/flattreeview/main.cpp84
-rw-r--r--examples/widgets/itemviews/frozencolumn/CMakeLists.txt47
-rw-r--r--examples/widgets/itemviews/frozencolumn/freezetablewidget.cpp51
-rw-r--r--examples/widgets/itemviews/frozencolumn/freezetablewidget.h51
-rw-r--r--examples/widgets/itemviews/frozencolumn/main.cpp54
-rw-r--r--examples/widgets/itemviews/interview/CMakeLists.txt55
-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.cpp104
-rw-r--r--examples/widgets/itemviews/interview/model.cpp157
-rw-r--r--examples/widgets/itemviews/interview/model.h100
-rw-r--r--examples/widgets/itemviews/itemviews.pro15
-rw-r--r--examples/widgets/itemviews/pixelator/.prev_CMakeLists.txt61
-rw-r--r--examples/widgets/itemviews/pixelator/CMakeLists.txt62
-rw-r--r--examples/widgets/itemviews/pixelator/imagemodel.cpp100
-rw-r--r--examples/widgets/itemviews/pixelator/imagemodel.h78
-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.cpp64
-rw-r--r--examples/widgets/itemviews/pixelator/mainwindow.cpp261
-rw-r--r--examples/widgets/itemviews/pixelator/mainwindow.h84
-rw-r--r--examples/widgets/itemviews/pixelator/pixelator.pro16
-rw-r--r--examples/widgets/itemviews/pixelator/pixeldelegate.cpp115
-rw-r--r--examples/widgets/itemviews/pixelator/pixeldelegate.h88
-rw-r--r--examples/widgets/itemviews/puzzle/.prev_CMakeLists.txt55
-rw-r--r--examples/widgets/itemviews/puzzle/CMakeLists.txt55
-rw-r--r--examples/widgets/itemviews/puzzle/example.jpgbin42654 -> 0 bytes
-rw-r--r--examples/widgets/itemviews/puzzle/main.cpp64
-rw-r--r--examples/widgets/itemviews/puzzle/mainwindow.cpp162
-rw-r--r--examples/widgets/itemviews/puzzle/mainwindow.h88
-rw-r--r--examples/widgets/itemviews/puzzle/piecesmodel.cpp215
-rw-r--r--examples/widgets/itemviews/puzzle/piecesmodel.h92
-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.cpp210
-rw-r--r--examples/widgets/itemviews/puzzle/puzzlewidget.h103
-rw-r--r--examples/widgets/itemviews/simpledommodel/CMakeLists.txt44
-rw-r--r--examples/widgets/itemviews/simpledommodel/domitem.cpp109
-rw-r--r--examples/widgets/itemviews/simpledommodel/domitem.h76
-rw-r--r--examples/widgets/itemviews/simpledommodel/dommodel.cpp200
-rw-r--r--examples/widgets/itemviews/simpledommodel/dommodel.h85
-rw-r--r--examples/widgets/itemviews/simpledommodel/main.cpp62
-rw-r--r--examples/widgets/itemviews/simpledommodel/mainwindow.cpp94
-rw-r--r--examples/widgets/itemviews/simpledommodel/mainwindow.h80
-rw-r--r--examples/widgets/itemviews/simpledommodel/simpledommodel.pro14
-rw-r--r--examples/widgets/itemviews/simpletreemodel/CMakeLists.txt79
-rw-r--r--examples/widgets/itemviews/simpletreemodel/main.cpp71
-rw-r--r--examples/widgets/itemviews/simpletreemodel/test.cpp35
-rw-r--r--examples/widgets/itemviews/simpletreemodel/treeitem.cpp105
-rw-r--r--examples/widgets/itemviews/simpletreemodel/treeitem.h60
-rw-r--r--examples/widgets/itemviews/simpletreemodel/treemodel.cpp176
-rw-r--r--examples/widgets/itemviews/simpletreemodel/treemodel.h65
-rw-r--r--examples/widgets/itemviews/simplewidgetmapper/CMakeLists.txt40
-rw-r--r--examples/widgets/itemviews/simplewidgetmapper/main.cpp61
-rw-r--r--examples/widgets/itemviews/simplewidgetmapper/simplewidgetmapper.pro10
-rw-r--r--examples/widgets/itemviews/simplewidgetmapper/window.cpp140
-rw-r--r--examples/widgets/itemviews/simplewidgetmapper/window.h94
-rw-r--r--examples/widgets/itemviews/spinboxdelegate/CMakeLists.txt40
-rw-r--r--examples/widgets/itemviews/spinboxdelegate/delegate.cpp113
-rw-r--r--examples/widgets/itemviews/spinboxdelegate/delegate.h76
-rw-r--r--examples/widgets/itemviews/spinboxdelegate/main.cpp95
-rw-r--r--examples/widgets/itemviews/spinboxdelegate/spinboxdelegate.pro10
-rw-r--r--examples/widgets/itemviews/spreadsheet/.prev_CMakeLists.txt62
-rw-r--r--examples/widgets/itemviews/spreadsheet/CMakeLists.txt64
-rw-r--r--examples/widgets/itemviews/spreadsheet/main.cpp55
-rw-r--r--examples/widgets/itemviews/spreadsheet/printview.cpp51
-rw-r--r--examples/widgets/itemviews/spreadsheet/printview.h53
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheet.cpp53
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheet.h51
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp51
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.h51
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheetitem.cpp51
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheetitem.h51
-rw-r--r--examples/widgets/itemviews/stardelegate/CMakeLists.txt44
-rw-r--r--examples/widgets/itemviews/stardelegate/main.cpp51
-rw-r--r--examples/widgets/itemviews/stardelegate/stardelegate.cpp51
-rw-r--r--examples/widgets/itemviews/stardelegate/stardelegate.h51
-rw-r--r--examples/widgets/itemviews/stardelegate/stareditor.cpp51
-rw-r--r--examples/widgets/itemviews/stardelegate/stareditor.h51
-rw-r--r--examples/widgets/itemviews/stardelegate/starrating.cpp51
-rw-r--r--examples/widgets/itemviews/stardelegate/starrating.h51
-rw-r--r--examples/widgets/itemviews/storageview/CMakeLists.txt40
-rw-r--r--examples/widgets/itemviews/storageview/main.cpp79
-rw-r--r--examples/widgets/itemviews/storageview/storagemodel.cpp211
-rw-r--r--examples/widgets/itemviews/storageview/storagemodel.h93
-rw-r--r--examples/widgets/itemviews/storageview/storageview.pro12
-rw-r--r--examples/widgets/layouts/CMakeLists.txt9
-rw-r--r--examples/widgets/layouts/basiclayouts/CMakeLists.txt44
-rw-r--r--examples/widgets/layouts/basiclayouts/dialog.cpp70
-rw-r--r--examples/widgets/layouts/basiclayouts/dialog.h51
-rw-r--r--examples/widgets/layouts/basiclayouts/main.cpp55
-rw-r--r--examples/widgets/layouts/borderlayout/CMakeLists.txt41
-rw-r--r--examples/widgets/layouts/borderlayout/borderlayout.cpp218
-rw-r--r--examples/widgets/layouts/borderlayout/borderlayout.h97
-rw-r--r--examples/widgets/layouts/borderlayout/borderlayout.pro11
-rw-r--r--examples/widgets/layouts/borderlayout/main.cpp61
-rw-r--r--examples/widgets/layouts/borderlayout/window.cpp78
-rw-r--r--examples/widgets/layouts/borderlayout/window.h71
-rw-r--r--examples/widgets/layouts/dynamiclayouts/CMakeLists.txt40
-rw-r--r--examples/widgets/layouts/dynamiclayouts/dialog.cpp183
-rw-r--r--examples/widgets/layouts/dynamiclayouts/dialog.h100
-rw-r--r--examples/widgets/layouts/dynamiclayouts/dynamiclayouts.pro10
-rw-r--r--examples/widgets/layouts/dynamiclayouts/main.cpp66
-rw-r--r--examples/widgets/layouts/flowlayout/CMakeLists.txt44
-rw-r--r--examples/widgets/layouts/flowlayout/flowlayout.cpp55
-rw-r--r--examples/widgets/layouts/flowlayout/flowlayout.h51
-rw-r--r--examples/widgets/layouts/flowlayout/main.cpp51
-rw-r--r--examples/widgets/layouts/flowlayout/window.cpp51
-rw-r--r--examples/widgets/layouts/flowlayout/window.h51
-rw-r--r--examples/widgets/layouts/layouts.pro2
-rw-r--r--examples/widgets/mainwindows/CMakeLists.txt10
-rw-r--r--examples/widgets/mainwindows/application/CMakeLists.txt58
-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.cpp79
-rw-r--r--examples/widgets/mainwindows/application/mainwindow.cpp417
-rw-r--r--examples/widgets/mainwindows/application/mainwindow.h102
-rw-r--r--examples/widgets/mainwindows/dockwidgets/.prev_CMakeLists.txt62
-rw-r--r--examples/widgets/mainwindows/dockwidgets/CMakeLists.txt68
-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.cpp62
-rw-r--r--examples/widgets/mainwindows/dockwidgets/mainwindow.cpp345
-rw-r--r--examples/widgets/mainwindows/dockwidgets/mainwindow.h93
-rw-r--r--examples/widgets/mainwindows/mainwindow/CMakeLists.txt58
-rw-r--r--examples/widgets/mainwindows/mainwindow/colorswatch.cpp732
-rw-r--r--examples/widgets/mainwindows/mainwindow/colorswatch.h149
-rw-r--r--examples/widgets/mainwindows/mainwindow/main.cpp194
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.cpp491
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.h94
-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.cpp363
-rw-r--r--examples/widgets/mainwindows/mainwindow/toolbar.h119
-rw-r--r--examples/widgets/mainwindows/mainwindows.pro7
-rw-r--r--examples/widgets/mainwindows/mdi/CMakeLists.txt59
-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.cpp78
-rw-r--r--examples/widgets/mainwindows/mdi/mainwindow.cpp508
-rw-r--r--examples/widgets/mainwindows/mdi/mainwindow.h131
-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.cpp197
-rw-r--r--examples/widgets/mainwindows/mdi/mdichild.h86
-rw-r--r--examples/widgets/mainwindows/menus/CMakeLists.txt44
-rw-r--r--examples/widgets/mainwindows/menus/main.cpp51
-rw-r--r--examples/widgets/mainwindows/menus/mainwindow.cpp102
-rw-r--r--examples/widgets/mainwindows/menus/mainwindow.h51
-rw-r--r--examples/widgets/mainwindows/sdi/CMakeLists.txt58
-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.cpp84
-rw-r--r--examples/widgets/mainwindows/sdi/mainwindow.cpp492
-rw-r--r--examples/widgets/mainwindows/sdi/mainwindow.h117
-rw-r--r--examples/widgets/mainwindows/sdi/sdi.pro11
-rw-r--r--examples/widgets/mainwindows/sdi/sdi.qrc10
-rw-r--r--examples/widgets/painting/.prev_CMakeLists.txt13
-rw-r--r--examples/widgets/painting/CMakeLists.txt24
-rw-r--r--examples/widgets/painting/affine/.prev_CMakeLists.txt223
-rw-r--r--examples/widgets/painting/affine/CMakeLists.txt256
-rw-r--r--examples/widgets/painting/affine/main.cpp55
-rw-r--r--examples/widgets/painting/affine/xform.cpp156
-rw-r--r--examples/widgets/painting/affine/xform.h67
-rw-r--r--examples/widgets/painting/basicdrawing/CMakeLists.txt47
-rw-r--r--examples/widgets/painting/basicdrawing/main.cpp53
-rw-r--r--examples/widgets/painting/basicdrawing/renderarea.cpp51
-rw-r--r--examples/widgets/painting/basicdrawing/renderarea.h51
-rw-r--r--examples/widgets/painting/basicdrawing/window.cpp51
-rw-r--r--examples/widgets/painting/basicdrawing/window.h51
-rw-r--r--examples/widgets/painting/composition/.prev_CMakeLists.txt224
-rw-r--r--examples/widgets/painting/composition/CMakeLists.txt256
-rw-r--r--examples/widgets/painting/composition/composition.cpp164
-rw-r--r--examples/widgets/painting/composition/composition.h65
-rw-r--r--examples/widgets/painting/composition/main.cpp51
-rw-r--r--examples/widgets/painting/concentriccircles/CMakeLists.txt41
-rw-r--r--examples/widgets/painting/concentriccircles/circlewidget.cpp131
-rw-r--r--examples/widgets/painting/concentriccircles/circlewidget.h83
-rw-r--r--examples/widgets/painting/concentriccircles/concentriccircles.pro11
-rw-r--r--examples/widgets/painting/concentriccircles/main.cpp61
-rw-r--r--examples/widgets/painting/concentriccircles/window.cpp103
-rw-r--r--examples/widgets/painting/concentriccircles/window.h80
-rw-r--r--examples/widgets/painting/deform/.prev_CMakeLists.txt222
-rw-r--r--examples/widgets/painting/deform/CMakeLists.txt256
-rw-r--r--examples/widgets/painting/deform/main.cpp53
-rw-r--r--examples/widgets/painting/deform/pathdeform.cpp127
-rw-r--r--examples/widgets/painting/deform/pathdeform.h51
-rw-r--r--examples/widgets/painting/fontsampler/CMakeLists.txt47
-rw-r--r--examples/widgets/painting/fontsampler/fontsampler.pro12
-rw-r--r--examples/widgets/painting/fontsampler/main.cpp61
-rw-r--r--examples/widgets/painting/fontsampler/mainwindow.cpp361
-rw-r--r--examples/widgets/painting/fontsampler/mainwindow.h96
-rw-r--r--examples/widgets/painting/fontsampler/mainwindowbase.ui142
-rw-r--r--examples/widgets/painting/gradients/.prev_CMakeLists.txt222
-rw-r--r--examples/widgets/painting/gradients/CMakeLists.txt256
-rw-r--r--examples/widgets/painting/gradients/gradients.cpp69
-rw-r--r--examples/widgets/painting/gradients/gradients.h51
-rw-r--r--examples/widgets/painting/gradients/main.cpp56
-rw-r--r--examples/widgets/painting/imagecomposition/CMakeLists.txt47
-rw-r--r--examples/widgets/painting/imagecomposition/imagecomposer.cpp51
-rw-r--r--examples/widgets/painting/imagecomposition/imagecomposer.h51
-rw-r--r--examples/widgets/painting/imagecomposition/main.cpp53
-rw-r--r--examples/widgets/painting/painterpaths/CMakeLists.txt46
-rw-r--r--examples/widgets/painting/painterpaths/main.cpp51
-rw-r--r--examples/widgets/painting/painterpaths/renderarea.cpp51
-rw-r--r--examples/widgets/painting/painterpaths/renderarea.h51
-rw-r--r--examples/widgets/painting/painterpaths/window.cpp61
-rw-r--r--examples/widgets/painting/painterpaths/window.h51
-rw-r--r--examples/widgets/painting/painting.pro4
-rw-r--r--examples/widgets/painting/pathstroke/.prev_CMakeLists.txt222
-rw-r--r--examples/widgets/painting/pathstroke/CMakeLists.txt256
-rw-r--r--examples/widgets/painting/pathstroke/main.cpp56
-rw-r--r--examples/widgets/painting/pathstroke/pathstroke.cpp104
-rw-r--r--examples/widgets/painting/pathstroke/pathstroke.h51
-rw-r--r--examples/widgets/painting/shared/CMakeLists.txt27
-rw-r--r--examples/widgets/painting/shared/arthurstyle.cpp53
-rw-r--r--examples/widgets/painting/shared/arthurstyle.h51
-rw-r--r--examples/widgets/painting/shared/arthurwidgets.cpp161
-rw-r--r--examples/widgets/painting/shared/arthurwidgets.h78
-rw-r--r--examples/widgets/painting/shared/fbopaintdevice.cpp113
-rw-r--r--examples/widgets/painting/shared/fbopaintdevice.h91
-rw-r--r--examples/widgets/painting/shared/hoverpoints.cpp436
-rw-r--r--examples/widgets/painting/shared/hoverpoints.h79
-rw-r--r--examples/widgets/painting/shared/shared.pri6
-rw-r--r--examples/widgets/painting/shared/use_lib.cmake12
-rw-r--r--examples/widgets/painting/transformations/CMakeLists.txt44
-rw-r--r--examples/widgets/painting/transformations/main.cpp51
-rw-r--r--examples/widgets/painting/transformations/renderarea.cpp51
-rw-r--r--examples/widgets/painting/transformations/renderarea.h51
-rw-r--r--examples/widgets/painting/transformations/window.cpp51
-rw-r--r--examples/widgets/painting/transformations/window.h51
-rw-r--r--examples/widgets/qnx/foreignwindows/collector.cpp42
-rw-r--r--examples/widgets/qnx/foreignwindows/collector.h42
-rw-r--r--examples/widgets/qnx/foreignwindows/main.cpp40
-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.txt9
-rw-r--r--examples/widgets/richtext/calendar/CMakeLists.txt40
-rw-r--r--examples/widgets/richtext/calendar/calendar.pro10
-rw-r--r--examples/widgets/richtext/calendar/main.cpp62
-rw-r--r--examples/widgets/richtext/calendar/mainwindow.cpp226
-rw-r--r--examples/widgets/richtext/calendar/mainwindow.h83
-rw-r--r--examples/widgets/richtext/orderform/CMakeLists.txt50
-rw-r--r--examples/widgets/richtext/orderform/detailsdialog.cpp51
-rw-r--r--examples/widgets/richtext/orderform/detailsdialog.h51
-rw-r--r--examples/widgets/richtext/orderform/main.cpp51
-rw-r--r--examples/widgets/richtext/orderform/mainwindow.cpp51
-rw-r--r--examples/widgets/richtext/orderform/mainwindow.h51
-rw-r--r--examples/widgets/richtext/richtext.pro6
-rw-r--r--examples/widgets/richtext/syntaxhighlighter/CMakeLists.txt44
-rw-r--r--examples/widgets/richtext/syntaxhighlighter/highlighter.cpp53
-rw-r--r--examples/widgets/richtext/syntaxhighlighter/highlighter.h51
-rw-r--r--examples/widgets/richtext/syntaxhighlighter/main.cpp51
-rw-r--r--examples/widgets/richtext/syntaxhighlighter/mainwindow.cpp63
-rw-r--r--examples/widgets/richtext/syntaxhighlighter/mainwindow.h51
-rw-r--r--examples/widgets/richtext/textedit/.prev_CMakeLists.txt106
-rw-r--r--examples/widgets/richtext/textedit/CMakeLists.txt112
-rw-r--r--examples/widgets/richtext/textedit/example.html79
-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/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/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.cpp85
-rw-r--r--examples/widgets/richtext/textedit/textedit.cpp893
-rw-r--r--examples/widgets/richtext/textedit/textedit.h152
-rw-r--r--examples/widgets/richtext/textedit/textedit.pro22
-rw-r--r--examples/widgets/richtext/textedit/textedit.qdoc44
-rw-r--r--examples/widgets/richtext/textedit/textedit.qrc52
-rw-r--r--examples/widgets/scroller/CMakeLists.txt3
-rw-r--r--examples/widgets/scroller/graphicsview/CMakeLists.txt39
-rw-r--r--examples/widgets/scroller/graphicsview/graphicsview.pro8
-rw-r--r--examples/widgets/scroller/graphicsview/main.cpp302
-rw-r--r--examples/widgets/scroller/scroller.pro2
-rw-r--r--examples/widgets/tools/.prev_CMakeLists.txt17
-rw-r--r--examples/widgets/tools/CMakeLists.txt24
-rw-r--r--examples/widgets/tools/completer/CMakeLists.txt47
-rw-r--r--examples/widgets/tools/completer/fsmodel.cpp51
-rw-r--r--examples/widgets/tools/completer/fsmodel.h51
-rw-r--r--examples/widgets/tools/completer/main.cpp53
-rw-r--r--examples/widgets/tools/completer/mainwindow.cpp51
-rw-r--r--examples/widgets/tools/completer/mainwindow.h51
-rw-r--r--examples/widgets/tools/customcompleter/CMakeLists.txt47
-rw-r--r--examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc28
-rw-r--r--examples/widgets/tools/customcompleter/main.cpp53
-rw-r--r--examples/widgets/tools/customcompleter/mainwindow.cpp51
-rw-r--r--examples/widgets/tools/customcompleter/mainwindow.h51
-rw-r--r--examples/widgets/tools/customcompleter/textedit.cpp51
-rw-r--r--examples/widgets/tools/customcompleter/textedit.h51
-rw-r--r--examples/widgets/tools/echoplugin/CMakeLists.txt4
-rw-r--r--examples/widgets/tools/echoplugin/echoplugin.pro5
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/.prev_CMakeLists.txt41
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/CMakeLists.txt41
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/echointerface.h74
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/echowindow.cpp137
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/echowindow.h89
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/echowindow.pro21
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/main.cpp66
-rw-r--r--examples/widgets/tools/echoplugin/plugin/.prev_CMakeLists.txt35
-rw-r--r--examples/widgets/tools/echoplugin/plugin/CMakeLists.txt44
-rw-r--r--examples/widgets/tools/echoplugin/plugin/echoplugin.cpp58
-rw-r--r--examples/widgets/tools/echoplugin/plugin/echoplugin.h70
-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.txt67
-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.cpp186
-rw-r--r--examples/widgets/tools/i18n/languagechooser.h96
-rw-r--r--examples/widgets/tools/i18n/main.cpp64
-rw-r--r--examples/widgets/tools/i18n/mainwindow.cpp113
-rw-r--r--examples/widgets/tools/i18n/mainwindow.h86
-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.txt7
-rw-r--r--examples/widgets/tools/plugandpaint/app/.prev_CMakeLists.txt74
-rw-r--r--examples/widgets/tools/plugandpaint/app/CMakeLists.txt76
-rw-r--r--examples/widgets/tools/plugandpaint/app/app.pro33
-rw-r--r--examples/widgets/tools/plugandpaint/app/interfaces.h123
-rw-r--r--examples/widgets/tools/plugandpaint/app/main.cpp66
-rw-r--r--examples/widgets/tools/plugandpaint/app/mainwindow.cpp329
-rw-r--r--examples/widgets/tools/plugandpaint/app/mainwindow.h115
-rw-r--r--examples/widgets/tools/plugandpaint/app/paintarea.cpp199
-rw-r--r--examples/widgets/tools/plugandpaint/app/paintarea.h101
-rw-r--r--examples/widgets/tools/plugandpaint/app/plugindialog.cpp165
-rw-r--r--examples/widgets/tools/plugandpaint/app/plugindialog.h85
-rw-r--r--examples/widgets/tools/plugandpaint/plugandpaint.pro7
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt4
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/.prev_CMakeLists.txt36
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt44
-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.cpp197
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.h101
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/.prev_CMakeLists.txt36
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt44
-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.cpp129
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.h75
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/plugins.pro3
-rw-r--r--examples/widgets/tools/regularexpression/CMakeLists.txt47
-rw-r--r--examples/widgets/tools/regularexpression/main.cpp51
-rw-r--r--examples/widgets/tools/regularexpression/regularexpressiondialog.cpp169
-rw-r--r--examples/widgets/tools/regularexpression/regularexpressiondialog.h67
-rw-r--r--examples/widgets/tools/settingseditor/CMakeLists.txt43
-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.cpp240
-rw-r--r--examples/widgets/tools/settingseditor/locationdialog.h96
-rw-r--r--examples/widgets/tools/settingseditor/main.cpp64
-rw-r--r--examples/widgets/tools/settingseditor/mainwindow.cpp222
-rw-r--r--examples/widgets/tools/settingseditor/mainwindow.h91
-rw-r--r--examples/widgets/tools/settingseditor/settingseditor.pro18
-rw-r--r--examples/widgets/tools/settingseditor/settingstree.cpp278
-rw-r--r--examples/widgets/tools/settingseditor/settingstree.h108
-rw-r--r--examples/widgets/tools/settingseditor/variantdelegate.cpp424
-rw-r--r--examples/widgets/tools/settingseditor/variantdelegate.h100
-rw-r--r--examples/widgets/tools/styleplugin/.prev_CMakeLists.txt4
-rw-r--r--examples/widgets/tools/styleplugin/CMakeLists.txt19
-rw-r--r--examples/widgets/tools/styleplugin/plugin/.prev_CMakeLists.txt32
-rw-r--r--examples/widgets/tools/styleplugin/plugin/CMakeLists.txt41
-rw-r--r--examples/widgets/tools/styleplugin/plugin/plugin.pro24
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyle.cpp56
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyle.h66
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyle.json3
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyleplugin.cpp68
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h70
-rw-r--r--examples/widgets/tools/styleplugin/styleplugin.pro3
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/CMakeLists.txt40
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/main.cpp68
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/stylewindow.cpp72
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/stylewindow.h64
-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.txt47
-rw-r--r--examples/widgets/tools/treemodelcompleter/main.cpp53
-rw-r--r--examples/widgets/tools/treemodelcompleter/mainwindow.cpp56
-rw-r--r--examples/widgets/tools/treemodelcompleter/mainwindow.h51
-rw-r--r--examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp51
-rw-r--r--examples/widgets/tools/treemodelcompleter/treemodelcompleter.h51
-rw-r--r--examples/widgets/tools/undo/CMakeLists.txt70
-rw-r--r--examples/widgets/tools/undo/commands.cpp177
-rw-r--r--examples/widgets/tools/undo/commands.h123
-rw-r--r--examples/widgets/tools/undo/document.cpp448
-rw-r--r--examples/widgets/tools/undo/document.h133
-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.cpp65
-rw-r--r--examples/widgets/tools/undo/mainwindow.cpp457
-rw-r--r--examples/widgets/tools/undo/mainwindow.h96
-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.txt54
-rw-r--r--examples/widgets/tools/undoframework/commands.cpp51
-rw-r--r--examples/widgets/tools/undoframework/commands.h51
-rw-r--r--examples/widgets/tools/undoframework/diagramitem.cpp51
-rw-r--r--examples/widgets/tools/undoframework/diagramitem.h51
-rw-r--r--examples/widgets/tools/undoframework/diagramscene.cpp51
-rw-r--r--examples/widgets/tools/undoframework/diagramscene.h51
-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.cpp53
-rw-r--r--examples/widgets/tools/undoframework/mainwindow.cpp142
-rw-r--r--examples/widgets/tools/undoframework/mainwindow.h55
-rw-r--r--examples/widgets/tools/undoframework/undoframework.qrc8
-rw-r--r--examples/widgets/touch/CMakeLists.txt10
-rw-r--r--examples/widgets/touch/dials/CMakeLists.txt40
-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.qdoc38
-rw-r--r--examples/widgets/touch/dials/main.cpp68
-rw-r--r--examples/widgets/touch/fingerpaint/.prev_CMakeLists.txt47
-rw-r--r--examples/widgets/touch/fingerpaint/CMakeLists.txt53
-rw-r--r--examples/widgets/touch/fingerpaint/doc/src/fingerpaint.qdoc42
-rw-r--r--examples/widgets/touch/fingerpaint/fingerpaint.pro13
-rw-r--r--examples/widgets/touch/fingerpaint/main.cpp61
-rw-r--r--examples/widgets/touch/fingerpaint/mainwindow.cpp227
-rw-r--r--examples/widgets/touch/fingerpaint/mainwindow.h98
-rw-r--r--examples/widgets/touch/fingerpaint/scribblearea.cpp237
-rw-r--r--examples/widgets/touch/fingerpaint/scribblearea.h90
-rw-r--r--examples/widgets/touch/knobs/CMakeLists.txt44
-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.qdoc29
-rw-r--r--examples/widgets/touch/knobs/knob.cpp59
-rw-r--r--examples/widgets/touch/knobs/knob.h51
-rw-r--r--examples/widgets/touch/knobs/main.cpp52
-rw-r--r--examples/widgets/touch/pinchzoom/CMakeLists.txt54
-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.qdoc38
-rw-r--r--examples/widgets/touch/pinchzoom/graphicsview.cpp95
-rw-r--r--examples/widgets/touch/pinchzoom/graphicsview.h65
-rw-r--r--examples/widgets/touch/pinchzoom/images/cheese.jpgbin3029 -> 0 bytes
-rw-r--r--examples/widgets/touch/pinchzoom/main.cpp94
-rw-r--r--examples/widgets/touch/pinchzoom/mice.qrc5
-rw-r--r--examples/widgets/touch/pinchzoom/mouse.cpp205
-rw-r--r--examples/widgets/touch/pinchzoom/mouse.h80
-rw-r--r--examples/widgets/touch/pinchzoom/pinchzoom.pro16
-rw-r--r--examples/widgets/touch/touch.pro2
-rw-r--r--examples/widgets/tutorials/CMakeLists.txt7
-rw-r--r--examples/widgets/tutorials/addressbook/CMakeLists.txt9
-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.txt40
-rw-r--r--examples/widgets/tutorials/addressbook/part1/addressbook.cpp77
-rw-r--r--examples/widgets/tutorials/addressbook/part1/addressbook.h76
-rw-r--r--examples/widgets/tutorials/addressbook/part1/main.cpp64
-rw-r--r--examples/widgets/tutorials/addressbook/part1/part1.pro11
-rw-r--r--examples/widgets/tutorials/addressbook/part2/CMakeLists.txt40
-rw-r--r--examples/widgets/tutorials/addressbook/part2/addressbook.cpp170
-rw-r--r--examples/widgets/tutorials/addressbook/part2/addressbook.h94
-rw-r--r--examples/widgets/tutorials/addressbook/part2/main.cpp64
-rw-r--r--examples/widgets/tutorials/addressbook/part2/part2.pro11
-rw-r--r--examples/widgets/tutorials/addressbook/part3/CMakeLists.txt40
-rw-r--r--examples/widgets/tutorials/addressbook/part3/addressbook.cpp229
-rw-r--r--examples/widgets/tutorials/addressbook/part3/addressbook.h96
-rw-r--r--examples/widgets/tutorials/addressbook/part3/main.cpp62
-rw-r--r--examples/widgets/tutorials/addressbook/part3/part3.pro11
-rw-r--r--examples/widgets/tutorials/addressbook/part4/CMakeLists.txt40
-rw-r--r--examples/widgets/tutorials/addressbook/part4/addressbook.cpp305
-rw-r--r--examples/widgets/tutorials/addressbook/part4/addressbook.h109
-rw-r--r--examples/widgets/tutorials/addressbook/part4/main.cpp62
-rw-r--r--examples/widgets/tutorials/addressbook/part4/part4.pro11
-rw-r--r--examples/widgets/tutorials/addressbook/part5/CMakeLists.txt41
-rw-r--r--examples/widgets/tutorials/addressbook/part5/addressbook.cpp330
-rw-r--r--examples/widgets/tutorials/addressbook/part5/addressbook.h112
-rw-r--r--examples/widgets/tutorials/addressbook/part5/finddialog.cpp98
-rw-r--r--examples/widgets/tutorials/addressbook/part5/finddialog.h78
-rw-r--r--examples/widgets/tutorials/addressbook/part5/main.cpp62
-rw-r--r--examples/widgets/tutorials/addressbook/part5/part5.pro13
-rw-r--r--examples/widgets/tutorials/addressbook/part6/CMakeLists.txt41
-rw-r--r--examples/widgets/tutorials/addressbook/part6/addressbook.cpp413
-rw-r--r--examples/widgets/tutorials/addressbook/part6/addressbook.h113
-rw-r--r--examples/widgets/tutorials/addressbook/part6/finddialog.cpp94
-rw-r--r--examples/widgets/tutorials/addressbook/part6/finddialog.h78
-rw-r--r--examples/widgets/tutorials/addressbook/part6/main.cpp62
-rw-r--r--examples/widgets/tutorials/addressbook/part6/part6.pro14
-rw-r--r--examples/widgets/tutorials/addressbook/part7/CMakeLists.txt41
-rw-r--r--examples/widgets/tutorials/addressbook/part7/addressbook.cpp466
-rw-r--r--examples/widgets/tutorials/addressbook/part7/addressbook.h115
-rw-r--r--examples/widgets/tutorials/addressbook/part7/finddialog.cpp94
-rw-r--r--examples/widgets/tutorials/addressbook/part7/finddialog.h78
-rw-r--r--examples/widgets/tutorials/addressbook/part7/main.cpp62
-rw-r--r--examples/widgets/tutorials/addressbook/part7/part7.pro14
-rw-r--r--examples/widgets/tutorials/gettingStarted/CMakeLists.txt2
-rw-r--r--examples/widgets/tutorials/gettingStarted/gettingStarted.pro4
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt7
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/gsqt.pro7
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt39
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part1/main.cpp62
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part1/part1.pro8
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt39
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part2/main.cpp74
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part2/part2.pro8
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt39
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part3/main.cpp108
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part3/part3.pro8
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt39
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part4/main.cpp120
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part4/part4.pro8
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt39
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part5/main.cpp146
-rw-r--r--examples/widgets/tutorials/gettingStarted/gsQt/part5/part5.pro8
-rw-r--r--examples/widgets/tutorials/gettingstartedqt.qdoc559
-rw-r--r--examples/widgets/tutorials/modelview/1_readonly/CMakeLists.txt44
-rw-r--r--examples/widgets/tutorials/modelview/1_readonly/main.cpp51
-rw-r--r--examples/widgets/tutorials/modelview/1_readonly/mymodel.cpp51
-rw-r--r--examples/widgets/tutorials/modelview/1_readonly/mymodel.h54
-rw-r--r--examples/widgets/tutorials/modelview/2_formatting/CMakeLists.txt44
-rw-r--r--examples/widgets/tutorials/modelview/2_formatting/main.cpp51
-rw-r--r--examples/widgets/tutorials/modelview/2_formatting/mymodel.cpp59
-rw-r--r--examples/widgets/tutorials/modelview/2_formatting/mymodel.h54
-rw-r--r--examples/widgets/tutorials/modelview/3_changingmodel/CMakeLists.txt44
-rw-r--r--examples/widgets/tutorials/modelview/3_changingmodel/main.cpp51
-rw-r--r--examples/widgets/tutorials/modelview/3_changingmodel/mymodel.cpp55
-rw-r--r--examples/widgets/tutorials/modelview/3_changingmodel/mymodel.h60
-rw-r--r--examples/widgets/tutorials/modelview/4_headers/CMakeLists.txt44
-rw-r--r--examples/widgets/tutorials/modelview/4_headers/main.cpp51
-rw-r--r--examples/widgets/tutorials/modelview/4_headers/mymodel.cpp51
-rw-r--r--examples/widgets/tutorials/modelview/4_headers/mymodel.h54
-rw-r--r--examples/widgets/tutorials/modelview/5_edit/CMakeLists.txt44
-rw-r--r--examples/widgets/tutorials/modelview/5_edit/main.cpp51
-rw-r--r--examples/widgets/tutorials/modelview/5_edit/mainwindow.cpp62
-rw-r--r--examples/widgets/tutorials/modelview/5_edit/mainwindow.h60
-rw-r--r--examples/widgets/tutorials/modelview/5_edit/mymodel.cpp51
-rw-r--r--examples/widgets/tutorials/modelview/5_edit/mymodel.h51
-rw-r--r--examples/widgets/tutorials/modelview/6_treeview/CMakeLists.txt44
-rw-r--r--examples/widgets/tutorials/modelview/6_treeview/main.cpp51
-rw-r--r--examples/widgets/tutorials/modelview/6_treeview/mainwindow.cpp51
-rw-r--r--examples/widgets/tutorials/modelview/6_treeview/mainwindow.h63
-rw-r--r--examples/widgets/tutorials/modelview/7_selections/CMakeLists.txt44
-rw-r--r--examples/widgets/tutorials/modelview/7_selections/main.cpp51
-rw-r--r--examples/widgets/tutorials/modelview/7_selections/mainwindow.cpp83
-rw-r--r--examples/widgets/tutorials/modelview/7_selections/mainwindow.h63
-rw-r--r--examples/widgets/tutorials/modelview/CMakeLists.txt17
-rw-r--r--examples/widgets/tutorials/notepad/.prev_CMakeLists.txt76
-rw-r--r--examples/widgets/tutorials/notepad/CMakeLists.txt59
-rw-r--r--examples/widgets/tutorials/notepad/gettingstartedqt.qdoc501
-rw-r--r--examples/widgets/tutorials/notepad/main.cpp61
-rw-r--r--examples/widgets/tutorials/notepad/notepad.cpp119
-rw-r--r--examples/widgets/tutorials/notepad/notepad.h86
-rw-r--r--examples/widgets/tutorials/notepad/notepad.ui9
-rw-r--r--examples/widgets/tutorials/tutorials.pro2
-rw-r--r--examples/widgets/tutorials/widgets/CMakeLists.txt11
-rw-r--r--examples/widgets/tutorials/widgets/childwidget/CMakeLists.txt44
-rw-r--r--examples/widgets/tutorials/widgets/childwidget/main.cpp51
-rw-r--r--examples/widgets/tutorials/widgets/nestedlayouts/CMakeLists.txt44
-rw-r--r--examples/widgets/tutorials/widgets/nestedlayouts/main.cpp51
-rw-r--r--examples/widgets/tutorials/widgets/toplevel/CMakeLists.txt44
-rw-r--r--examples/widgets/tutorials/widgets/toplevel/main.cpp51
-rw-r--r--examples/widgets/tutorials/widgets/windowlayout/CMakeLists.txt44
-rw-r--r--examples/widgets/tutorials/widgets/windowlayout/main.cpp51
-rw-r--r--examples/widgets/widgets.pro6
-rw-r--r--examples/widgets/widgets/CMakeLists.txt39
-rw-r--r--examples/widgets/widgets/analogclock/CMakeLists.txt44
-rw-r--r--examples/widgets/widgets/analogclock/analogclock.cpp127
-rw-r--r--examples/widgets/widgets/analogclock/analogclock.h51
-rw-r--r--examples/widgets/widgets/analogclock/main.cpp51
-rw-r--r--examples/widgets/widgets/calculator/CMakeLists.txt44
-rw-r--r--examples/widgets/widgets/calculator/button.cpp51
-rw-r--r--examples/widgets/widgets/calculator/button.h51
-rw-r--r--examples/widgets/widgets/calculator/calculator.cpp92
-rw-r--r--examples/widgets/widgets/calculator/calculator.h54
-rw-r--r--examples/widgets/widgets/calculator/main.cpp51
-rw-r--r--examples/widgets/widgets/calendarwidget/CMakeLists.txt44
-rw-r--r--examples/widgets/widgets/calendarwidget/main.cpp51
-rw-r--r--examples/widgets/widgets/calendarwidget/window.cpp68
-rw-r--r--examples/widgets/widgets/calendarwidget/window.h51
-rw-r--r--examples/widgets/widgets/charactermap/CMakeLists.txt41
-rw-r--r--examples/widgets/widgets/charactermap/charactermap.pro12
-rw-r--r--examples/widgets/widgets/charactermap/characterwidget.cpp192
-rw-r--r--examples/widgets/widgets/charactermap/characterwidget.h97
-rw-r--r--examples/widgets/widgets/charactermap/main.cpp61
-rw-r--r--examples/widgets/widgets/charactermap/mainwindow.cpp311
-rw-r--r--examples/widgets/widgets/charactermap/mainwindow.h97
-rw-r--r--examples/widgets/widgets/codeeditor/CMakeLists.txt40
-rw-r--r--examples/widgets/widgets/codeeditor/codeeditor.cpp181
-rw-r--r--examples/widgets/widgets/codeeditor/codeeditor.h115
-rw-r--r--examples/widgets/widgets/codeeditor/codeeditor.pro8
-rw-r--r--examples/widgets/widgets/codeeditor/main.cpp65
-rw-r--r--examples/widgets/widgets/digitalclock/CMakeLists.txt40
-rw-r--r--examples/widgets/widgets/digitalclock/digitalclock.cpp83
-rw-r--r--examples/widgets/widgets/digitalclock/digitalclock.h69
-rw-r--r--examples/widgets/widgets/digitalclock/digitalclock.pro9
-rw-r--r--examples/widgets/widgets/digitalclock/main.cpp61
-rw-r--r--examples/widgets/widgets/elidedlabel/CMakeLists.txt41
-rw-r--r--examples/widgets/widgets/elidedlabel/elidedlabel.cpp121
-rw-r--r--examples/widgets/widgets/elidedlabel/elidedlabel.h83
-rw-r--r--examples/widgets/widgets/elidedlabel/elidedlabel.pro20
-rw-r--r--examples/widgets/widgets/elidedlabel/main.cpp63
-rw-r--r--examples/widgets/widgets/elidedlabel/testwidget.cpp166
-rw-r--r--examples/widgets/widgets/elidedlabel/testwidget.h85
-rw-r--r--examples/widgets/widgets/groupbox/CMakeLists.txt40
-rw-r--r--examples/widgets/widgets/groupbox/groupbox.pro9
-rw-r--r--examples/widgets/widgets/groupbox/main.cpp61
-rw-r--r--examples/widgets/widgets/groupbox/window.cpp204
-rw-r--r--examples/widgets/widgets/groupbox/window.h76
-rw-r--r--examples/widgets/widgets/icons/.prev_CMakeLists.txt47
-rw-r--r--examples/widgets/widgets/icons/CMakeLists.txt47
-rw-r--r--examples/widgets/widgets/icons/iconpreviewarea.cpp179
-rw-r--r--examples/widgets/widgets/icons/iconpreviewarea.h94
-rw-r--r--examples/widgets/widgets/icons/icons.pro20
-rw-r--r--examples/widgets/widgets/icons/iconsizespinbox.cpp80
-rw-r--r--examples/widgets/widgets/icons/iconsizespinbox.h69
-rw-r--r--examples/widgets/widgets/icons/imagedelegate.cpp111
-rw-r--r--examples/widgets/widgets/icons/imagedelegate.h78
-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.cpp81
-rw-r--r--examples/widgets/widgets/icons/mainwindow.cpp525
-rw-r--r--examples/widgets/widgets/icons/mainwindow.h121
-rw-r--r--examples/widgets/widgets/imageviewer/.prev_CMakeLists.txt46
-rw-r--r--examples/widgets/widgets/imageviewer/CMakeLists.txt52
-rw-r--r--examples/widgets/widgets/imageviewer/imageviewer.cpp406
-rw-r--r--examples/widgets/widgets/imageviewer/imageviewer.h121
-rw-r--r--examples/widgets/widgets/imageviewer/imageviewer.pro11
-rw-r--r--examples/widgets/widgets/imageviewer/main.cpp71
-rw-r--r--examples/widgets/widgets/lineedits/CMakeLists.txt44
-rw-r--r--examples/widgets/widgets/lineedits/main.cpp51
-rw-r--r--examples/widgets/widgets/lineedits/window.cpp51
-rw-r--r--examples/widgets/widgets/lineedits/window.h51
-rw-r--r--examples/widgets/widgets/mousebuttons/CMakeLists.txt40
-rw-r--r--examples/widgets/widgets/mousebuttons/buttontester.cpp231
-rw-r--r--examples/widgets/widgets/mousebuttons/buttontester.h76
-rw-r--r--examples/widgets/widgets/mousebuttons/main.cpp83
-rw-r--r--examples/widgets/widgets/mousebuttons/mousebuttons.pro16
-rw-r--r--examples/widgets/widgets/movie/CMakeLists.txt40
-rw-r--r--examples/widgets/widgets/movie/animation.gifbin42629 -> 0 bytes
-rw-r--r--examples/widgets/widgets/movie/main.cpp62
-rw-r--r--examples/widgets/widgets/movie/movie.pro12
-rw-r--r--examples/widgets/widgets/movie/movieplayer.cpp227
-rw-r--r--examples/widgets/widgets/movie/movieplayer.h106
-rw-r--r--examples/widgets/widgets/scribble/.prev_CMakeLists.txt47
-rw-r--r--examples/widgets/widgets/scribble/CMakeLists.txt59
-rw-r--r--examples/widgets/widgets/scribble/main.cpp51
-rw-r--r--examples/widgets/widgets/scribble/mainwindow.cpp53
-rw-r--r--examples/widgets/widgets/scribble/mainwindow.h51
-rw-r--r--examples/widgets/widgets/scribble/scribblearea.cpp51
-rw-r--r--examples/widgets/widgets/scribble/scribblearea.h51
-rw-r--r--examples/widgets/widgets/shapedclock/CMakeLists.txt44
-rw-r--r--examples/widgets/widgets/shapedclock/main.cpp51
-rw-r--r--examples/widgets/widgets/shapedclock/shapedclock.cpp120
-rw-r--r--examples/widgets/widgets/shapedclock/shapedclock.h52
-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.cpp13
-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.h34
-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.txt44
-rw-r--r--examples/widgets/widgets/sliders/main.cpp51
-rw-r--r--examples/widgets/widgets/sliders/slidersgroup.cpp85
-rw-r--r--examples/widgets/widgets/sliders/slidersgroup.h57
-rw-r--r--examples/widgets/widgets/sliders/window.cpp134
-rw-r--r--examples/widgets/widgets/sliders/window.h59
-rw-r--r--examples/widgets/widgets/spinboxes/CMakeLists.txt44
-rw-r--r--examples/widgets/widgets/spinboxes/main.cpp51
-rw-r--r--examples/widgets/widgets/spinboxes/window.cpp51
-rw-r--r--examples/widgets/widgets/spinboxes/window.h51
-rw-r--r--examples/widgets/widgets/styles/CMakeLists.txt55
-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.cpp66
-rw-r--r--examples/widgets/widgets/styles/norwegianwoodstyle.cpp357
-rw-r--r--examples/widgets/widgets/styles/norwegianwoodstyle.h90
-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.cpp324
-rw-r--r--examples/widgets/widgets/styles/widgetgallery.h133
-rw-r--r--examples/widgets/widgets/stylesheet/CMakeLists.txt88
-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.cpp63
-rw-r--r--examples/widgets/widgets/stylesheet/mainwindow.cpp85
-rw-r--r--examples/widgets/widgets/stylesheet/mainwindow.h76
-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.cpp111
-rw-r--r--examples/widgets/widgets/stylesheet/stylesheeteditor.h77
-rw-r--r--examples/widgets/widgets/stylesheet/stylesheeteditor.ui171
-rw-r--r--examples/widgets/widgets/tablet/CMakeLists.txt47
-rw-r--r--examples/widgets/widgets/tablet/main.cpp51
-rw-r--r--examples/widgets/widgets/tablet/mainwindow.cpp61
-rw-r--r--examples/widgets/widgets/tablet/mainwindow.h51
-rw-r--r--examples/widgets/widgets/tablet/tabletapplication.cpp51
-rw-r--r--examples/widgets/widgets/tablet/tabletapplication.h51
-rw-r--r--examples/widgets/widgets/tablet/tabletcanvas.cpp51
-rw-r--r--examples/widgets/widgets/tablet/tabletcanvas.h51
-rw-r--r--examples/widgets/widgets/tetrix/CMakeLists.txt42
-rw-r--r--examples/widgets/widgets/tetrix/main.cpp61
-rw-r--r--examples/widgets/widgets/tetrix/tetrix.pro13
-rw-r--r--examples/widgets/widgets/tetrix/tetrixboard.cpp418
-rw-r--r--examples/widgets/widgets/tetrix/tetrixboard.h126
-rw-r--r--examples/widgets/widgets/tetrix/tetrixpiece.cpp153
-rw-r--r--examples/widgets/widgets/tetrix/tetrixpiece.h85
-rw-r--r--examples/widgets/widgets/tetrix/tetrixwindow.cpp138
-rw-r--r--examples/widgets/widgets/tetrix/tetrixwindow.h85
-rw-r--r--examples/widgets/widgets/tooltips/CMakeLists.txt56
-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.cpp63
-rw-r--r--examples/widgets/widgets/tooltips/shapeitem.cpp107
-rw-r--r--examples/widgets/widgets/tooltips/shapeitem.h80
-rw-r--r--examples/widgets/widgets/tooltips/sortingbox.cpp316
-rw-r--r--examples/widgets/widgets/tooltips/sortingbox.h116
-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.txt57
-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.cpp72
-rw-r--r--examples/widgets/widgets/validators/ledwidget.h74
-rw-r--r--examples/widgets/widgets/validators/localeselector.cpp95
-rw-r--r--examples/widgets/widgets/validators/localeselector.h70
-rw-r--r--examples/widgets/widgets/validators/main.cpp65
-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.cpp122
-rw-r--r--examples/widgets/widgets/validators/validatorwidget.h64
-rw-r--r--examples/widgets/widgets/widgets.pro15
-rw-r--r--examples/widgets/widgets/wiggly/CMakeLists.txt41
-rw-r--r--examples/widgets/widgets/wiggly/dialog.cpp74
-rw-r--r--examples/widgets/widgets/wiggly/dialog.h66
-rw-r--r--examples/widgets/widgets/wiggly/main.cpp63
-rw-r--r--examples/widgets/widgets/wiggly/wiggly.pro11
-rw-r--r--examples/widgets/widgets/wiggly/wigglywidget.cpp111
-rw-r--r--examples/widgets/widgets/wiggly/wigglywidget.h79
-rw-r--r--examples/widgets/widgets/windowflags/CMakeLists.txt44
-rw-r--r--examples/widgets/widgets/windowflags/controllerwindow.cpp51
-rw-r--r--examples/widgets/widgets/windowflags/controllerwindow.h51
-rw-r--r--examples/widgets/widgets/windowflags/main.cpp51
-rw-r--r--examples/widgets/widgets/windowflags/previewwindow.cpp53
-rw-r--r--examples/widgets/widgets/windowflags/previewwindow.h51
-rw-r--r--examples/widgets/windowcontainer/CMakeLists.txt46
-rw-r--r--examples/widgets/windowcontainer/windowcontainer.cpp183
-rw-r--r--examples/widgets/windowcontainer/windowcontainer.pro9
-rw-r--r--examples/xml/CMakeLists.txt13
-rw-r--r--examples/xml/dombookmarks/CMakeLists.txt47
-rw-r--r--examples/xml/dombookmarks/doc/images/dombookmarks-example.pngbin19405 -> 0 bytes
-rw-r--r--examples/xml/dombookmarks/doc/images/screenshot.pngbin0 -> 67075 bytes
-rw-r--r--examples/xml/dombookmarks/doc/src/dombookmarks.qdoc117
-rw-r--r--examples/xml/dombookmarks/dombookmarks.pro2
-rw-r--r--examples/xml/dombookmarks/jennifer.xbel46
-rw-r--r--examples/xml/dombookmarks/main.cpp51
-rw-r--r--examples/xml/dombookmarks/mainwindow.cpp100
-rw-r--r--examples/xml/dombookmarks/mainwindow.h53
-rw-r--r--examples/xml/dombookmarks/xbeltree.cpp150
-rw-r--r--examples/xml/dombookmarks/xbeltree.h57
-rw-r--r--examples/xml/htmlinfo/.prev_CMakeLists.txt44
-rw-r--r--examples/xml/htmlinfo/CMakeLists.txt52
-rw-r--r--examples/xml/htmlinfo/apache_org.html281
-rw-r--r--examples/xml/htmlinfo/htmlinfo.pro10
-rw-r--r--examples/xml/htmlinfo/main.cpp129
-rw-r--r--examples/xml/htmlinfo/resources.qrc10
-rw-r--r--examples/xml/htmlinfo/simpleexample.html11
-rw-r--r--examples/xml/htmlinfo/trolltech_com.html955
-rw-r--r--examples/xml/htmlinfo/w3c_org.html507
-rw-r--r--examples/xml/htmlinfo/youtube_com.html1585
-rw-r--r--examples/xml/rsslisting/CMakeLists.txt44
-rw-r--r--examples/xml/rsslisting/main.cpp73
-rw-r--r--examples/xml/rsslisting/rsslisting.cpp258
-rw-r--r--examples/xml/rsslisting/rsslisting.h102
-rw-r--r--examples/xml/rsslisting/rsslisting.pro8
-rw-r--r--examples/xml/streambookmarks/CMakeLists.txt44
-rw-r--r--examples/xml/streambookmarks/doc/images/xmlstreamexample-filemenu.pngbin9380 -> 0 bytes
-rw-r--r--examples/xml/streambookmarks/doc/images/xmlstreamexample-helpmenu.pngbin10856 -> 0 bytes
-rw-r--r--examples/xml/streambookmarks/doc/images/xmlstreamexample-screenshot.pngbin22323 -> 0 bytes
-rw-r--r--examples/xml/streambookmarks/doc/src/qxmlstreambookmarks.qdoc194
-rw-r--r--examples/xml/streambookmarks/jennifer.xbel69
-rw-r--r--examples/xml/streambookmarks/main.cpp64
-rw-r--r--examples/xml/streambookmarks/mainwindow.cpp189
-rw-r--r--examples/xml/streambookmarks/mainwindow.h82
-rw-r--r--examples/xml/streambookmarks/streambookmarks.pro15
-rw-r--r--examples/xml/streambookmarks/xbelreader.cpp187
-rw-r--r--examples/xml/streambookmarks/xbelreader.h97
-rw-r--r--examples/xml/streambookmarks/xbelwriter.cpp107
-rw-r--r--examples/xml/streambookmarks/xbelwriter.h75
-rw-r--r--examples/xml/xml.pro8
-rw-r--r--examples/xml/xmlstreamlint/.prev_CMakeLists.txt35
-rw-r--r--examples/xml/xmlstreamlint/CMakeLists.txt36
-rw-r--r--examples/xml/xmlstreamlint/doc/src/xmlstreamlint.qdoc75
-rw-r--r--examples/xml/xmlstreamlint/main.cpp137
-rw-r--r--examples/xml/xmlstreamlint/xmlstreamlint.pro7
2240 files changed, 18730 insertions, 126459 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index a48879d447..d1b6b67aa0 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,38 +1,50 @@
-# Generated from examples.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-qt_examples_build_begin()
+if(QT_BUILD_STANDALONE_EXAMPLES)
+ # Needed for early feature values, despite it being found later on in qt_build_tests().
+ # Needs to be find_package, not qt_find_package, because qt_find_package doesn't handle finding
+ # component for a super-package that has already been found.
+ find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Core)
+
+ # Modify the optimization flags specifically for qtbase standalone examples. Other projects
+ # are handled by qt_enable_cmake_languages().
+ qt_internal_set_up_config_optimizations_like_in_qmake()
+endif()
+
+qt_examples_build_begin(EXTERNAL_BUILD)
+
+add_compile_definitions(QT_NO_CONTEXTLESS_CONNECT)
add_subdirectory(corelib)
-add_subdirectory(embedded)
-add_subdirectory(qpa)
-if(TARGET Qt::DBus)
+if(TARGET Qt6::DBus)
add_subdirectory(dbus)
endif()
-if(TARGET Qt::Network)
+if(TARGET Qt6::Network)
add_subdirectory(network)
endif()
-if(TARGET Qt::Test)
+if(TARGET Qt6::Test)
add_subdirectory(qtestlib)
endif()
-if(TARGET Qt::Concurrent)
+if(TARGET Qt6::Concurrent)
add_subdirectory(qtconcurrent)
endif()
-if(TARGET Qt::Sql)
+if(TARGET Qt6::Sql)
add_subdirectory(sql)
endif()
-if(TARGET Qt::Widgets)
+if(TARGET Qt6::Widgets)
add_subdirectory(widgets)
endif()
-if(TARGET Qt::Xml)
+if(TARGET Qt6::Xml)
add_subdirectory(xml)
endif()
-if(TARGET Qt::Gui)
+if(TARGET Qt6::Gui)
add_subdirectory(gui)
endif()
-if(QT_FEATURE_opengl AND TARGET Qt::Gui)
+if(QT_FEATURE_opengl AND TARGET Qt6::Gui)
add_subdirectory(opengl)
endif()
-if(QT_FEATURE_vulkan AND TARGET Qt::Gui)
+if(QT_FEATURE_vulkan AND TARGET Qt6::Gui)
add_subdirectory(vulkan)
endif()
diff --git a/examples/corelib/CMakeLists.txt b/examples/corelib/CMakeLists.txt
index 9ec9dcb156..38a883b4ea 100644
--- a/examples/corelib/CMakeLists.txt
+++ b/examples/corelib/CMakeLists.txt
@@ -1,9 +1,14 @@
-# Generated from corelib.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
add_subdirectory(ipc)
add_subdirectory(mimetypes)
add_subdirectory(serialization)
add_subdirectory(tools)
+add_subdirectory(platform)
if(QT_FEATURE_thread)
add_subdirectory(threads)
endif()
+if(QT_FEATURE_widgets)
+ qt_internal_add_example(bindableproperties)
+endif()
diff --git a/examples/corelib/bindableproperties/CMakeLists.txt b/examples/corelib/bindableproperties/CMakeLists.txt
new file mode 100644
index 0000000000..07a2b7a2cf
--- /dev/null
+++ b/examples/corelib/bindableproperties/CMakeLists.txt
@@ -0,0 +1,33 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(bindableproperties LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+
+qt_standard_project_setup()
+
+add_subdirectory(shared)
+add_subdirectory(subscription)
+add_subdirectory(bindablesubscription)
+
+install(TARGETS subscription bindablesubscription
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET subscription
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
+
+qt_generate_deploy_app_script(
+ TARGET bindablesubscription
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/bindableproperties/bindableproperties.pro b/examples/corelib/bindableproperties/bindableproperties.pro
new file mode 100644
index 0000000000..fab8d8107a
--- /dev/null
+++ b/examples/corelib/bindableproperties/bindableproperties.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+SUBDIRS = \
+ bindablesubscription \
+ subscription
diff --git a/examples/corelib/bindableproperties/bindablesubscription/CMakeLists.txt b/examples/corelib/bindableproperties/bindablesubscription/CMakeLists.txt
new file mode 100644
index 0000000000..2734f44a17
--- /dev/null
+++ b/examples/corelib/bindableproperties/bindablesubscription/CMakeLists.txt
@@ -0,0 +1,15 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+qt_add_executable(bindablesubscription
+ main.cpp
+ bindablesubscription.cpp
+ bindablesubscription.h
+ bindableuser.cpp
+ bindableuser.h
+)
+
+target_link_libraries(bindablesubscription PRIVATE
+ bindableproperties_shared
+)
+
diff --git a/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.cpp b/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.cpp
new file mode 100644
index 0000000000..32f4194635
--- /dev/null
+++ b/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.cpp
@@ -0,0 +1,51 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "bindablesubscription.h"
+#include "bindableuser.h"
+
+//! [binding-expressions]
+
+BindableSubscription::BindableSubscription(BindableUser *user) : m_user(user)
+{
+ Q_ASSERT(user);
+
+ m_price.setBinding(
+ [this] { return qRound(calculateDiscount() * int(m_duration) * basePrice()); });
+
+ m_isValid.setBinding([this] {
+ return m_user->country() != BindableUser::Country::AnyCountry && m_user->age() > 12;
+ });
+}
+
+//! [binding-expressions]
+
+//! [set-duration]
+
+void BindableSubscription::setDuration(Duration newDuration)
+{
+ m_duration = newDuration;
+}
+
+//! [set-duration]
+
+double BindableSubscription::calculateDiscount() const
+{
+ switch (m_duration) {
+ case Monthly:
+ return 1;
+ case Quarterly:
+ return 0.9;
+ case Yearly:
+ return 0.6;
+ }
+ Q_UNREACHABLE_RETURN(-1);
+}
+
+int BindableSubscription::basePrice() const
+{
+ if (m_user->country() == BindableUser::Country::AnyCountry)
+ return 0;
+
+ return (m_user->country() == BindableUser::Country::Norway) ? 100 : 80;
+}
diff --git a/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.h b/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.h
new file mode 100644
index 0000000000..03870d0617
--- /dev/null
+++ b/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.h
@@ -0,0 +1,44 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef BINDABLESUBSCRIPTION_H
+#define BINDABLESUBSCRIPTION_H
+
+#include <QBindable>
+#include <QProperty>
+
+class BindableUser;
+
+//! [bindable-subscription-class]
+
+class BindableSubscription
+{
+public:
+ enum Duration { Monthly = 1, Quarterly = 3, Yearly = 12 };
+
+ BindableSubscription(BindableUser *user);
+ BindableSubscription(const BindableSubscription &) = delete;
+
+ int price() const { return m_price; }
+ QBindable<int> bindablePrice() { return &m_price; }
+
+ Duration duration() const { return m_duration; }
+ void setDuration(Duration newDuration);
+ QBindable<Duration> bindableDuration() { return &m_duration; }
+
+ bool isValid() const { return m_isValid; }
+ QBindable<bool> bindableIsValid() { return &m_isValid; }
+
+private:
+ double calculateDiscount() const;
+ int basePrice() const;
+
+ BindableUser *m_user;
+ QProperty<Duration> m_duration { Monthly };
+ QProperty<int> m_price { 0 };
+ QProperty<bool> m_isValid { false };
+};
+
+//! [bindable-subscription-class]
+
+#endif // BNDABLESUBSCRIPTION_H
diff --git a/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.pro b/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.pro
new file mode 100644
index 0000000000..321a1226c4
--- /dev/null
+++ b/examples/corelib/bindableproperties/bindablesubscription/bindablesubscription.pro
@@ -0,0 +1,22 @@
+QT += widgets
+TARGET = bindablesubscription
+
+SOURCES += main.cpp \
+ bindablesubscription.cpp \
+ bindableuser.cpp \
+ ../shared/subscriptionwindow.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/corelib/bindableproperties/bindablesubscription
+INSTALLS += target
+
+FORMS += \
+ ../shared/subscriptionwindow.ui
+
+HEADERS += \
+ bindablesubscription.h \
+ bindableuser.h \
+ ../shared/subscriptionwindow.h
+
+RESOURCES += \
+ ../shared/countries.qrc
+
diff --git a/examples/corelib/bindableproperties/bindablesubscription/bindableuser.cpp b/examples/corelib/bindableproperties/bindablesubscription/bindableuser.cpp
new file mode 100644
index 0000000000..9cc3b7a4a6
--- /dev/null
+++ b/examples/corelib/bindableproperties/bindablesubscription/bindableuser.cpp
@@ -0,0 +1,18 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "bindableuser.h"
+
+//! [bindable-user-setters]
+
+void BindableUser::setCountry(Country country)
+{
+ m_country = country;
+}
+
+void BindableUser::setAge(int age)
+{
+ m_age = age;
+}
+
+//! [bindable-user-setters]
diff --git a/examples/corelib/bindableproperties/bindablesubscription/bindableuser.h b/examples/corelib/bindableproperties/bindablesubscription/bindableuser.h
new file mode 100644
index 0000000000..6bb9bcdcb5
--- /dev/null
+++ b/examples/corelib/bindableproperties/bindablesubscription/bindableuser.h
@@ -0,0 +1,37 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef BINDABLEUSER_H
+#define BINDABLEUSER_H
+
+#include <QBindable>
+#include <QLocale>
+#include <QProperty>
+
+//! [bindable-user-class]
+
+class BindableUser
+{
+public:
+ using Country = QLocale::Territory;
+
+public:
+ BindableUser() = default;
+ BindableUser(const BindableUser &) = delete;
+
+ Country country() const { return m_country; }
+ void setCountry(Country country);
+ QBindable<Country> bindableCountry() { return &m_country; }
+
+ int age() const { return m_age; }
+ void setAge(int age);
+ QBindable<int> bindableAge() { return &m_age; }
+
+private:
+ QProperty<Country> m_country { QLocale::AnyTerritory };
+ QProperty<int> m_age { 0 };
+};
+
+//! [bindable-user-class]
+
+#endif // BINDABLEUSER_H
diff --git a/examples/corelib/bindableproperties/bindablesubscription/main.cpp b/examples/corelib/bindableproperties/bindablesubscription/main.cpp
new file mode 100644
index 0000000000..466f487b8e
--- /dev/null
+++ b/examples/corelib/bindableproperties/bindablesubscription/main.cpp
@@ -0,0 +1,77 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "../shared/subscriptionwindow.h"
+#include "bindablesubscription.h"
+#include "bindableuser.h"
+
+#include <QApplication>
+#include <QBindable>
+#include <QLabel>
+#include <QLocale>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QSpinBox>
+#include <QString>
+
+using namespace Qt::StringLiterals;
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ BindableUser user;
+ BindableSubscription subscription(&user);
+
+ SubscriptionWindow w;
+ // clazy:excludeall=lambda-in-connect
+ // when subscription is out of scope so is window
+
+ // Initialize subscription data
+ QRadioButton *monthly = w.findChild<QRadioButton *>(u"btnMonthly"_s);
+ QObject::connect(monthly, &QRadioButton::clicked, monthly, [&] {
+ subscription.setDuration(BindableSubscription::Monthly);
+ });
+ QRadioButton *quarterly = w.findChild<QRadioButton *>(u"btnQuarterly"_s);
+ QObject::connect(quarterly, &QRadioButton::clicked, quarterly, [&] {
+ subscription.setDuration(BindableSubscription::Quarterly);
+ });
+ QRadioButton *yearly = w.findChild<QRadioButton *>(u"btnYearly"_s);
+ QObject::connect(yearly, &QRadioButton::clicked, yearly, [&] {
+ subscription.setDuration(BindableSubscription::Yearly);
+ });
+
+ // Initialize user data
+ QPushButton *germany = w.findChild<QPushButton *>(u"btnGermany"_s);
+ QObject::connect(germany, &QPushButton::clicked, germany, [&] {
+ user.setCountry(BindableUser::Country::Germany);
+ });
+ QPushButton *finland = w.findChild<QPushButton *>(u"btnFinland"_s);
+ QObject::connect(finland, &QPushButton::clicked, finland, [&] {
+ user.setCountry(BindableUser::Country::Finland);
+ });
+ QPushButton *norway = w.findChild<QPushButton *>(u"btnNorway"_s);
+ QObject::connect(norway, &QPushButton::clicked, norway, [&] {
+ user.setCountry(BindableUser::Country::Norway);
+ });
+
+ QSpinBox *ageSpinBox = w.findChild<QSpinBox *>(u"ageSpinBox"_s);
+ QBindable<int> ageBindable(ageSpinBox, "value");
+ user.bindableAge().setBinding([ageBindable](){ return ageBindable.value();});
+
+ QLabel *priceDisplay = w.findChild<QLabel *>(u"priceDisplay"_s);
+
+ // Track price changes
+//! [update-ui]
+ auto priceChangeHandler = subscription.bindablePrice().subscribe([&] {
+ QLocale lc{QLocale::AnyLanguage, user.country()};
+ priceDisplay->setText(lc.toCurrencyString(subscription.price() / subscription.duration()));
+ });
+
+ auto priceValidHandler = subscription.bindableIsValid().subscribe([&] {
+ priceDisplay->setEnabled(subscription.isValid());
+ });
+//! [update-ui]
+
+ w.show();
+ return a.exec();
+}
diff --git a/examples/corelib/bindableproperties/doc/images/bindable_properties_example.png b/examples/corelib/bindableproperties/doc/images/bindable_properties_example.png
new file mode 100644
index 0000000000..f38261a217
--- /dev/null
+++ b/examples/corelib/bindableproperties/doc/images/bindable_properties_example.png
Binary files differ
diff --git a/examples/corelib/bindableproperties/doc/src/bindableproperties.qdoc b/examples/corelib/bindableproperties/doc/src/bindableproperties.qdoc
new file mode 100644
index 0000000000..476522b086
--- /dev/null
+++ b/examples/corelib/bindableproperties/doc/src/bindableproperties.qdoc
@@ -0,0 +1,179 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example bindableproperties
+ \examplecategory {Data Processing & I/O}
+ \title Bindable Properties
+ \brief Demonstrates how the usage of bindable properties can simplify
+ your C++ code.
+
+ In this example we will demonstrate two approaches for expressing the
+ relationships between different objects depending on each other:
+ signal/slot connection-based and bindable property-based. For this
+ purpose we will consider a subscription service model to calculate the
+ cost of the subscription.
+
+ \image bindable_properties_example.png
+
+ \section1 Modeling Subscription System with Signal/Slot Approach
+
+ Let's first consider the usual pre-Qt 6 implementation.
+ To model the subscription service the \c Subscription class is used:
+
+ \snippet bindableproperties/subscription/subscription.h subscription-class
+
+ It stores the information about the subscription and provides corresponding
+ getters, setters, and notifier signals for informing the listeners about the
+ subscription information changes. It also keeps a pointer to an instance of
+ the \c User class.
+
+ The price of the subscription is calculated based on the duration of the
+ subscription:
+
+ \snippet bindableproperties/subscription/subscription.cpp calculate-discount
+
+ And user's location:
+
+ \snippet bindableproperties/subscription/subscription.cpp calculate-base-price
+
+ When the price changes, the \c priceChanged() signal is emitted, to notify the
+ listeners about the change:
+
+ \snippet bindableproperties/subscription/subscription.cpp calculate-price
+
+ Similarly, when the duration of the subscription changes, the \c durationChanged()
+ signal is emitted.
+
+ \snippet bindableproperties/subscription/subscription.cpp set-duration
+
+ \note Both methods need to check if the data is actually changed and
+ only then emit the signals. \c setDuration() also needs to recalculate
+ the price when the duration has changed.
+
+ The \c Subscription is not valid unless the user has a valid country and
+ age, so the validity is updated in the following way:
+
+ \snippet bindableproperties/subscription/subscription.cpp update-validity
+
+ The \c User class is simple: it stores country and age of the user and
+ provides the corresponding getters, setters, and notifier signals:
+
+ \snippet bindableproperties/subscription/user.h user-class
+
+ \snippet bindableproperties/subscription/user.cpp user-setters
+
+ In the \c main() function we initialize instances of \c User and
+ \c Subscription:
+
+ \snippet bindableproperties/subscription/main.cpp init
+
+ And do the proper signal-slot connections to update the \c user and
+ \c subscription data when UI elements change. That is straightforward,
+ so we will skip this part.
+
+ Next, we connect to \c Subscription::priceChanged() to update the price
+ in the UI when the price changes.
+
+ \snippet bindableproperties/subscription/main.cpp connect-price-changed
+
+ We also connect to \c Subscription::isValidChanged() to disable the price
+ display if the subscription isn't valid.
+
+ \snippet bindableproperties/subscription/main.cpp connect-validity-changed
+
+ Because the subscription price and validity also depend on the user's
+ country and age, we also need to connect to the \c User::countryChanged()
+ and \c User::ageChanged() signals and update \c subscription accordingly.
+
+ \snippet bindableproperties/subscription/main.cpp connect-user
+
+ This works, but there are some problems:
+
+ \list
+ \li There's a lot of boilerplate code for the signal-slot connections
+ in order to properly track changes to both \c user and \c subscription.
+ If any of the dependencies of the price changes, we need to remember to emit the
+ corresponding notifier signals, recalculate the price, and update it in
+ the UI.
+ \li If more dependencies for price calculation are added in the future, we'll
+ need to add more signal-slot connections and make sure all the dependencies
+ are properly updated whenever any of them changes. The overall complexity
+ will grow, and the code will become harder to maintain.
+ \li The \c Subscription and \c User classes depend on the metaobject system
+ to be able to use the signal/slot mechanism.
+ \endlist
+
+ Can we do better?
+
+ \section1 Modeling Subscription System with Bindbable Properties
+
+ Now let's see how the \l {Qt Bindable Properties} can help to solve the
+ same problem. First, let's have a look at the \c BindableSubscription class,
+ which is similar to the \c Subscription class, but is implemented using
+ bindable properties:
+
+ \snippet bindableproperties/bindablesubscription/bindablesubscription.h bindable-subscription-class
+
+ The first difference we can notice, is that the data fields are now wrapped
+ inside \l QProperty classes, and the notifier signals (and as a consequence the
+ dependency from the metaobject system) are gone, and new methods returning a
+ \l QBindable for each \l QProperty are added instead. The \c calculatePrice()
+ and \c updateValidty() methods are also removed. We'll see below why they aren't
+ needed anymore.
+
+ The \c BindableUser class differs from the \c User class in a similar way:
+
+ \snippet bindableproperties/bindablesubscription/bindableuser.h bindable-user-class
+
+ The second difference is in the implementation of these classes. First of
+ all, the dependencies between \c subscription and \c user are now tracked via
+ binding expressions:
+
+ \snippet bindableproperties/bindablesubscription/bindablesubscription.cpp binding-expressions
+
+ Behind the scenes the bindable properties track the dependency changes and
+ update the property's value whenever a change is detected. So if, for example,
+ user's country or age is changed, subscription's price and validity will be
+ updated automatically.
+
+ Another difference is that the setters are now trivial:
+
+ \snippet bindableproperties/bindablesubscription/bindablesubscription.cpp set-duration
+
+ \snippet bindableproperties/bindablesubscription/bindableuser.cpp bindable-user-setters
+
+ There's no need to check inside the setters if the property's value has
+ actually changed, \l QProperty already does that. The dependent properties
+ will be notified about the change only if the value has actually changed.
+
+ The code for updating the information about the price in the UI is also
+ simplified:
+
+ \snippet bindableproperties/bindablesubscription/main.cpp update-ui
+
+ We subscribe to changes via \c bindablePrice() and \c bindableIsValid()
+ and update the price display accordingly when any of these properties
+ changes the value. The subscriptions will stay alive as long as the
+ corresponding handlers are alive.
+
+ Also note that the copy constructors of both \c BindableSubscription and
+ \c BindableUser are disabled, since it's not defined what should happen
+ with their bindings when copying.
+
+ As you can see, the code became much simpler, and the problems mentioned
+ above are solved:
+
+ \list
+ \li The boilerplate code for the signal-slot connections is removed, the
+ dependencies are now tracked automatically.
+ \li The code is easier to maintain. Adding more dependencies in the future
+ will only require adding the corresponding bindable properties and setting
+ the binding expressions that reflect the relationships between each other.
+ \li The \c Subscription and \c User classes don't depend on the metaobject
+ system anymore. Of course, you can still expose them to the metaobject
+ system and add \l {Q_PROPERTY}s if you need, and have the advantages of
+ bindable properties both in \c C++ and \c QML code. You can use the
+ \l QObjectBindableProperty class for that.
+ \endlist
+*/
diff --git a/examples/corelib/bindableproperties/shared/CMakeLists.txt b/examples/corelib/bindableproperties/shared/CMakeLists.txt
new file mode 100644
index 0000000000..efc85e5d4d
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/CMakeLists.txt
@@ -0,0 +1,23 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+add_library(bindableproperties_shared STATIC
+ subscriptionwindow.cpp
+ subscriptionwindow.h
+ subscriptionwindow.ui
+)
+
+target_link_libraries(bindableproperties_shared PUBLIC
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+)
+
+qt_add_resources(bindableproperties_shared "countries"
+ PREFIX
+ "/"
+ FILES
+ "finland.png"
+ "germany.png"
+ "norway.png"
+)
diff --git a/examples/corelib/bindableproperties/shared/countries.qrc b/examples/corelib/bindableproperties/shared/countries.qrc
new file mode 100644
index 0000000000..cdf6312ebb
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/countries.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>germany.png</file>
+ <file>norway.png</file>
+ <file>finland.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/corelib/bindableproperties/shared/finland.png b/examples/corelib/bindableproperties/shared/finland.png
new file mode 100644
index 0000000000..92653289c1
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/finland.png
Binary files differ
diff --git a/examples/corelib/bindableproperties/shared/germany.png b/examples/corelib/bindableproperties/shared/germany.png
new file mode 100644
index 0000000000..efc389f52a
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/germany.png
Binary files differ
diff --git a/examples/corelib/bindableproperties/shared/norway.png b/examples/corelib/bindableproperties/shared/norway.png
new file mode 100644
index 0000000000..daee6c3c15
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/norway.png
Binary files differ
diff --git a/examples/corelib/bindableproperties/shared/subscriptionwindow.cpp b/examples/corelib/bindableproperties/shared/subscriptionwindow.cpp
new file mode 100644
index 0000000000..0e17283d40
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/subscriptionwindow.cpp
@@ -0,0 +1,16 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "subscriptionwindow.h"
+#include "ui_subscriptionwindow.h"
+
+SubscriptionWindow::SubscriptionWindow(QWidget *parent)
+ : QWidget(parent), ui(new Ui::SubscriptionWindow)
+{
+ ui->setupUi(this);
+}
+
+SubscriptionWindow::~SubscriptionWindow()
+{
+ delete ui;
+}
diff --git a/examples/corelib/bindableproperties/shared/subscriptionwindow.h b/examples/corelib/bindableproperties/shared/subscriptionwindow.h
new file mode 100644
index 0000000000..75f6a1eb83
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/subscriptionwindow.h
@@ -0,0 +1,29 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SUBSCRIPTIONWINDOW_H
+#define SUBSCRIPTIONWINDOW_H
+
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class SubscriptionWindow;
+}
+QT_END_NAMESPACE
+
+class User;
+
+class SubscriptionWindow : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit SubscriptionWindow(QWidget *parent = nullptr);
+ ~SubscriptionWindow();
+
+private:
+ Ui::SubscriptionWindow *ui;
+};
+
+#endif // SUBSCRIPTIONWINDOW_H
diff --git a/examples/corelib/bindableproperties/shared/subscriptionwindow.ui b/examples/corelib/bindableproperties/shared/subscriptionwindow.ui
new file mode 100644
index 0000000000..7bc2931373
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/subscriptionwindow.ui
@@ -0,0 +1,280 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SubscriptionWindow</class>
+ <widget class="QWidget" name="SubscriptionWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>639</width>
+ <height>269</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Subscription</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0,0,0">
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <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="btnGermany">
+ <property name="toolTip">
+ <string>Germany</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>:/germany.png</normaloff>:/germany.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnNorway">
+ <property name="toolTip">
+ <string>Norway</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>:/norway.png</normaloff>:/norway.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnFinland">
+ <property name="toolTip">
+ <string>Finland</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>:/finland.png</normaloff>:/finland.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="ageLabel">
+ <property name="font">
+ <font>
+ <pointsize>14</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Age</string>
+ </property>
+ <property name="margin">
+ <number>3</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="ageSpinBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <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>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="intervalLabel">
+ <property name="font">
+ <font>
+ <pointsize>14</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Interval</string>
+ </property>
+ <property name="margin">
+ <number>3</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="btnMonthly">
+ <property name="text">
+ <string>Monthly</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="btnQuarterly">
+ <property name="text">
+ <string>Quarterly</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="btnYearly">
+ <property name="text">
+ <string>Yearly</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="priceLabel">
+ <property name="font">
+ <font>
+ <pointsize>14</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Price/month</string>
+ </property>
+ <property name="margin">
+ <number>3</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="priceDisplay">
+ <property name="text">
+ <string>0.0</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <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>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/corelib/bindableproperties/subscription/CMakeLists.txt b/examples/corelib/bindableproperties/subscription/CMakeLists.txt
new file mode 100644
index 0000000000..91b9340fbf
--- /dev/null
+++ b/examples/corelib/bindableproperties/subscription/CMakeLists.txt
@@ -0,0 +1,12 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+qt_add_executable(subscription
+ main.cpp
+ subscription.cpp subscription.h
+ user.cpp user.h
+)
+
+target_link_libraries(subscription PRIVATE
+ bindableproperties_shared
+)
diff --git a/examples/corelib/bindableproperties/subscription/main.cpp b/examples/corelib/bindableproperties/subscription/main.cpp
new file mode 100644
index 0000000000..3f98da7467
--- /dev/null
+++ b/examples/corelib/bindableproperties/subscription/main.cpp
@@ -0,0 +1,95 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "../shared/subscriptionwindow.h"
+#include "subscription.h"
+#include "user.h"
+
+#include <QApplication>
+#include <QLabel>
+#include <QLocale>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QSpinBox>
+#include <QString>
+
+using namespace Qt::StringLiterals;
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+//! [init]
+ User user;
+ Subscription subscription(&user);
+//! [init]
+
+ SubscriptionWindow w;
+
+ // Initialize subscription data
+ QRadioButton *monthly = w.findChild<QRadioButton *>(u"btnMonthly"_s);
+ QObject::connect(monthly, &QRadioButton::clicked, &subscription, [&] {
+ subscription.setDuration(Subscription::Monthly);
+ });
+ QRadioButton *quarterly = w.findChild<QRadioButton *>(u"btnQuarterly"_s);
+ QObject::connect(quarterly, &QRadioButton::clicked, &subscription, [&] {
+ subscription.setDuration(Subscription::Quarterly);
+ });
+ QRadioButton *yearly = w.findChild<QRadioButton *>(u"btnYearly"_s);
+ QObject::connect(yearly, &QRadioButton::clicked, &subscription, [&] {
+ subscription.setDuration(Subscription::Yearly);
+ });
+
+ // Initialize user data
+ QPushButton *germany = w.findChild<QPushButton *>(u"btnGermany"_s);
+ QObject::connect(germany, &QPushButton::clicked, &user, [&] {
+ user.setCountry(User::Country::Germany);
+ });
+ QPushButton *finland = w.findChild<QPushButton *>(u"btnFinland"_s);
+ QObject::connect(finland, &QPushButton::clicked, &user, [&] {
+ user.setCountry(User::Country::Finland);
+ });
+ QPushButton *norway = w.findChild<QPushButton *>(u"btnNorway"_s);
+ QObject::connect(norway, &QPushButton::clicked, &user, [&] {
+ user.setCountry(User::Country::Norway);
+ });
+
+ QSpinBox *ageSpinBox = w.findChild<QSpinBox *>(u"ageSpinBox"_s);
+ QObject::connect(ageSpinBox, &QSpinBox::valueChanged, &user, [&](int value) {
+ user.setAge(value);
+ });
+
+ // Initialize price data
+ QLabel *priceDisplay = w.findChild<QLabel *>(u"priceDisplay"_s);
+ priceDisplay->setText(QString::number(subscription.price()));
+ priceDisplay->setEnabled(subscription.isValid());
+
+ // Track the price changes
+
+//! [connect-price-changed]
+ QObject::connect(&subscription, &Subscription::priceChanged, priceDisplay, [&] {
+ QLocale lc{QLocale::AnyLanguage, user.country()};
+ priceDisplay->setText(lc.toCurrencyString(subscription.price() / subscription.duration()));
+ });
+//! [connect-price-changed]
+
+//! [connect-validity-changed]
+ QObject::connect(&subscription, &Subscription::isValidChanged, priceDisplay, [&] {
+ priceDisplay->setEnabled(subscription.isValid());
+ });
+//! [connect-validity-changed]
+
+//! [connect-user]
+ QObject::connect(&user, &User::countryChanged, &subscription, [&] {
+ subscription.calculatePrice();
+ subscription.updateValidity();
+ });
+
+ QObject::connect(&user, &User::ageChanged, &subscription, [&] {
+ subscription.updateValidity();
+ });
+//! [connect-user]
+
+ w.show();
+ return a.exec();
+}
diff --git a/examples/corelib/bindableproperties/subscription/subscription.cpp b/examples/corelib/bindableproperties/subscription/subscription.cpp
new file mode 100644
index 0000000000..85cc5798cc
--- /dev/null
+++ b/examples/corelib/bindableproperties/subscription/subscription.cpp
@@ -0,0 +1,79 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "subscription.h"
+#include "user.h"
+
+Subscription::Subscription(User *user) : m_user(user)
+{
+ Q_ASSERT(user);
+}
+
+//! [calculate-price]
+
+void Subscription::calculatePrice()
+{
+ const auto oldPrice = m_price;
+
+ m_price = qRound(calculateDiscount() * int(m_duration) * basePrice());
+ if (m_price != oldPrice)
+ emit priceChanged();
+}
+
+//! [calculate-price]
+
+//! [set-duration]
+
+void Subscription::setDuration(Duration newDuration)
+{
+ if (newDuration != m_duration) {
+ m_duration = newDuration;
+ calculatePrice();
+ emit durationChanged();
+ }
+}
+
+//! [set-duration]
+
+//! [calculate-discount]
+
+double Subscription::calculateDiscount() const
+{
+ switch (m_duration) {
+ case Monthly:
+ return 1;
+ case Quarterly:
+ return 0.9;
+ case Yearly:
+ return 0.6;
+ }
+ Q_ASSERT(false);
+ return -1;
+}
+
+//! [calculate-discount]
+
+//! [calculate-base-price]
+
+int Subscription::basePrice() const
+{
+ if (m_user->country() == User::Country::AnyTerritory)
+ return 0;
+
+ return (m_user->country() == User::Country::Norway) ? 100 : 80;
+}
+
+//! [calculate-base-price]
+
+//! [update-validity]
+
+void Subscription::updateValidity()
+{
+ bool isValid = m_isValid;
+ m_isValid = m_user->country() != User::Country::AnyTerritory && m_user->age() > 12;
+
+ if (m_isValid != isValid)
+ emit isValidChanged();
+}
+
+//! [update-validity]
diff --git a/examples/corelib/bindableproperties/subscription/subscription.h b/examples/corelib/bindableproperties/subscription/subscription.h
new file mode 100644
index 0000000000..8f0d34e948
--- /dev/null
+++ b/examples/corelib/bindableproperties/subscription/subscription.h
@@ -0,0 +1,48 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SUBSCRIPTION_H
+#define SUBSCRIPTION_H
+
+#include <QObject>
+#include <QPointer>
+
+class User;
+
+//! [subscription-class]
+
+class Subscription : public QObject
+{
+ Q_OBJECT
+public:
+ enum Duration { Monthly = 1, Quarterly = 3, Yearly = 12 };
+
+ Subscription(User *user);
+
+ void calculatePrice();
+ int price() const { return m_price; }
+
+ Duration duration() const { return m_duration; }
+ void setDuration(Duration newDuration);
+
+ bool isValid() const { return m_isValid; }
+ void updateValidity();
+
+signals:
+ void priceChanged();
+ void durationChanged();
+ void isValidChanged();
+
+private:
+ double calculateDiscount() const;
+ int basePrice() const;
+
+ QPointer<User> m_user;
+ Duration m_duration = Monthly;
+ int m_price = 0;
+ bool m_isValid = false;
+};
+
+//! [subscription-class]
+
+#endif // SUBSCRIPTION_H
diff --git a/examples/corelib/bindableproperties/subscription/subscription.pro b/examples/corelib/bindableproperties/subscription/subscription.pro
new file mode 100644
index 0000000000..68910904bb
--- /dev/null
+++ b/examples/corelib/bindableproperties/subscription/subscription.pro
@@ -0,0 +1,22 @@
+QT += widgets
+TARGET = subscription
+
+SOURCES += main.cpp \
+ subscription.cpp \
+ user.cpp \
+ ../shared/subscriptionwindow.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/corelib/bindableproperties/subscription
+INSTALLS += target
+
+FORMS += \
+ ../shared/subscriptionwindow.ui
+
+HEADERS += \
+ subscription.h \
+ user.h \
+ ../shared/subscriptionwindow.h
+
+RESOURCES += \
+ ../shared/countries.qrc
+
diff --git a/examples/corelib/bindableproperties/subscription/user.cpp b/examples/corelib/bindableproperties/subscription/user.cpp
new file mode 100644
index 0000000000..575bcb13ee
--- /dev/null
+++ b/examples/corelib/bindableproperties/subscription/user.cpp
@@ -0,0 +1,24 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "user.h"
+
+//! [user-setters]
+
+void User::setCountry(Country country)
+{
+ if (m_country != country) {
+ m_country = country;
+ emit countryChanged();
+ }
+}
+
+void User::setAge(int age)
+{
+ if (m_age != age) {
+ m_age = age;
+ emit ageChanged();
+ }
+}
+
+//! [user-setters]
diff --git a/examples/corelib/bindableproperties/subscription/user.h b/examples/corelib/bindableproperties/subscription/user.h
new file mode 100644
index 0000000000..dd32a4fe23
--- /dev/null
+++ b/examples/corelib/bindableproperties/subscription/user.h
@@ -0,0 +1,36 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef USER_H
+#define USER_H
+
+#include <QLocale>
+#include <QObject>
+
+//! [user-class]
+
+class User : public QObject
+{
+ Q_OBJECT
+
+public:
+ using Country = QLocale::Territory;
+
+public:
+ Country country() const { return m_country; }
+ void setCountry(Country country);
+
+ int age() const { return m_age; }
+ void setAge(int age);
+
+signals:
+ void countryChanged();
+ void ageChanged();
+
+private:
+ Country m_country { QLocale::AnyTerritory };
+ int m_age { 0 };
+};
+
+//! [user-class]
+#endif // USER_H
diff --git a/examples/corelib/corelib.pro b/examples/corelib/corelib.pro
index 8caf2c16df..625957ca1a 100644
--- a/examples/corelib/corelib.pro
+++ b/examples/corelib/corelib.pro
@@ -5,6 +5,7 @@ SUBDIRS = \
ipc \
mimetypes \
serialization \
- tools
+ tools \
+ platform
qtConfig(thread): SUBDIRS += threads
diff --git a/examples/corelib/ipc/CMakeLists.txt b/examples/corelib/ipc/CMakeLists.txt
index 29a8d4f592..270f71faec 100644
--- a/examples/corelib/ipc/CMakeLists.txt
+++ b/examples/corelib/ipc/CMakeLists.txt
@@ -1,12 +1,13 @@
-# Generated from ipc.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# 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_sharedmemory)
- add_subdirectory(sharedmemory)
+if(QT_FEATURE_sharedmemory AND QT_FEATURE_systemsemaphore)
+ qt_internal_add_example(sharedmemory)
endif()
-if(QT_FEATURE_localserver AND TARGET Qt::Network)
- add_subdirectory(localfortuneserver)
- add_subdirectory(localfortuneclient)
+if(QT_FEATURE_localserver AND TARGET Qt6::Network)
+ qt_internal_add_example(localfortuneserver)
+ qt_internal_add_example(localfortuneclient)
endif()
diff --git a/examples/corelib/ipc/doc/images/localfortuneserver-example.png b/examples/corelib/ipc/doc/images/localfortuneserver-example.png
index 2f04c7528e..778c7c85b0 100644
--- a/examples/corelib/ipc/doc/images/localfortuneserver-example.png
+++ b/examples/corelib/ipc/doc/images/localfortuneserver-example.png
Binary files differ
diff --git a/examples/corelib/ipc/doc/src/localfortuneclient.qdoc b/examples/corelib/ipc/doc/src/localfortuneclient.qdoc
index 0ccc1f3a4e..a2bdb69b8b 100644
--- a/examples/corelib/ipc/doc/src/localfortuneclient.qdoc
+++ b/examples/corelib/ipc/doc/src/localfortuneclient.qdoc
@@ -1,40 +1,18 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example ipc/localfortuneclient
- \title Local Fortune Client Example
+ \examplecategory {Connectivity}
+ \title Local Fortune Client
\ingroup examples-ipc
\brief Demonstrates using QLocalSocket for a simple local service client.
The Local Fortune Client example shows how to create a client for a simple
local service using QLocalSocket. It is intended to be run alongside the
- \l{Local Fortune Server Example}.
+ \l{Local Fortune Server} example.
- \image localfortuneclient-example.png Screenshot of the Local Fortune Client example
+ \image localfortuneclient-example.png Screenshot of the Local Fortune Client
+ example
*/
diff --git a/examples/corelib/ipc/doc/src/localfortuneserver.qdoc b/examples/corelib/ipc/doc/src/localfortuneserver.qdoc
index 8d44c99617..6b359a8680 100644
--- a/examples/corelib/ipc/doc/src/localfortuneserver.qdoc
+++ b/examples/corelib/ipc/doc/src/localfortuneserver.qdoc
@@ -1,39 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example ipc/localfortuneserver
- \title Local Fortune Server Example
+ \examplecategory {Connectivity}
+ \title Local Fortune Server
\ingroup examples-ipc
\brief Demonstrates using QLocalServer and QLocalSocket for serving a simple local service.
The Local Fortune Server example shows how to create a server for a simple
local service. It is intended to be run alongside the
- \l{Local Fortune Client Example}
+ \l{Local Fortune Client} example.
\image localfortuneserver-example.png Screenshot of the Local Fortune Server example
*/
diff --git a/examples/corelib/ipc/doc/src/sharedmemory.qdoc b/examples/corelib/ipc/doc/src/sharedmemory.qdoc
index fb2ae21812..80645f3495 100644
--- a/examples/corelib/ipc/doc/src/sharedmemory.qdoc
+++ b/examples/corelib/ipc/doc/src/sharedmemory.qdoc
@@ -1,36 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example ipc/sharedmemory
- \title Shared Memory Example
+ \examplecategory {Data Processing & I/O}
+ \title IPC: Shared Memory
\ingroup examples-ipc
- \brief Demonstrates doing inter-process communication using shared memory with
- the QSharedMemory class.
+ \brief Demonstrates how to share image data between different processes
+ using the Shared Memory IPC mechanism.
The Shared Memory example shows how to use the QSharedMemory class
to implement inter-process communication using shared memory. To
diff --git a/examples/corelib/ipc/localfortuneclient/CMakeLists.txt b/examples/corelib/ipc/localfortuneclient/CMakeLists.txt
index b01023b009..f3f2b13f92 100644
--- a/examples/corelib/ipc/localfortuneclient/CMakeLists.txt
+++ b/examples/corelib/ipc/localfortuneclient/CMakeLists.txt
@@ -1,42 +1,39 @@
-# Generated from localfortuneclient.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(localfortuneclient LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/ipc/localfortuneclient")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(localfortuneclient
client.cpp client.h
main.cpp
)
+
set_target_properties(localfortuneclient PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(localfortuneclient PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(localfortuneclient PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS localfortuneclient
- 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 localfortuneclient
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/ipc/localfortuneclient/client.cpp b/examples/corelib/ipc/localfortuneclient/client.cpp
index 1ab0c34d6c..b71409560b 100644
--- a/examples/corelib/ipc/localfortuneclient/client.cpp
+++ b/examples/corelib/ipc/localfortuneclient/client.cpp
@@ -1,61 +1,19 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-#include <QtNetwork>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "client.h"
+#include <QDialogButtonBox>
+#include <QGridLayout>
+#include <QGuiApplication>
+#include <QMessageBox>
+#include <QTimer>
+
+using namespace Qt::StringLiterals;
+
Client::Client(QWidget *parent)
: QDialog(parent),
- hostLineEdit(new QLineEdit("fortune")),
+ hostLineEdit(new QLineEdit(u"fortune"_s)),
getFortuneButton(new QPushButton(tr("Get Fortune"))),
statusLabel(new QLabel(tr("This examples requires that you run the "
"Local Fortune Server example as well."))),
@@ -75,7 +33,7 @@ Client::Client(QWidget *parent)
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
in.setDevice(socket);
- in.setVersion(QDataStream::Qt_5_10);
+ in.setVersion(QDataStream::Qt_6_0);
connect(hostLineEdit, &QLineEdit::textChanged,
this, &Client::enableGetFortuneButton);
@@ -105,20 +63,14 @@ void Client::requestNewFortune()
void Client::readFortune()
{
- if (blockSize == 0) {
- // Relies on the fact that QDataStream serializes a quint32 into
- // sizeof(quint32) bytes
- if (socket->bytesAvailable() < (int)sizeof(quint32))
- return;
- in >> blockSize;
- }
-
- if (socket->bytesAvailable() < blockSize || in.atEnd())
- return;
+ in.startTransaction();
QString nextFortune;
in >> nextFortune;
+ if (!in.commitTransaction())
+ return;
+
if (nextFortune == currentFortune) {
QTimer::singleShot(0, this, &Client::requestNewFortune);
return;
diff --git a/examples/corelib/ipc/localfortuneclient/client.h b/examples/corelib/ipc/localfortuneclient/client.h
index 7248428440..b4c949a21a 100644
--- a/examples/corelib/ipc/localfortuneclient/client.h
+++ b/examples/corelib/ipc/localfortuneclient/client.h
@@ -1,65 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CLIENT_H
#define CLIENT_H
-#include <QDialog>
#include <QDataStream>
+#include <QDialog>
+#include <QLabel>
+#include <QLineEdit>
#include <QLocalSocket>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-class QLineEdit;
-class QPushButton;
-QT_END_NAMESPACE
+#include <QPushButton>
class Client : public QDialog
{
diff --git a/examples/corelib/ipc/localfortuneclient/main.cpp b/examples/corelib/ipc/localfortuneclient/main.cpp
index ed5cf4c569..f52807ec48 100644
--- a/examples/corelib/ipc/localfortuneclient/main.cpp
+++ b/examples/corelib/ipc/localfortuneclient/main.cpp
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "client.h"
+#include <QApplication>
+
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
diff --git a/examples/corelib/ipc/localfortuneserver/CMakeLists.txt b/examples/corelib/ipc/localfortuneserver/CMakeLists.txt
index 86cd90a3cf..75f037171c 100644
--- a/examples/corelib/ipc/localfortuneserver/CMakeLists.txt
+++ b/examples/corelib/ipc/localfortuneserver/CMakeLists.txt
@@ -1,42 +1,39 @@
-# Generated from localfortuneserver.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(localfortuneserver LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/ipc/localfortuneserver")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(localfortuneserver
main.cpp
server.cpp server.h
)
+
set_target_properties(localfortuneserver PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(localfortuneserver PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(localfortuneserver PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS localfortuneserver
- 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 localfortuneserver
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/ipc/localfortuneserver/main.cpp b/examples/corelib/ipc/localfortuneserver/main.cpp
index 430005a1d3..c18fa17dfb 100644
--- a/examples/corelib/ipc/localfortuneserver/main.cpp
+++ b/examples/corelib/ipc/localfortuneserver/main.cpp
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "server.h"
+#include <QApplication>
+
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
diff --git a/examples/corelib/ipc/localfortuneserver/server.cpp b/examples/corelib/ipc/localfortuneserver/server.cpp
index 9be5ed5051..a602a57f72 100644
--- a/examples/corelib/ipc/localfortuneserver/server.cpp
+++ b/examples/corelib/ipc/localfortuneserver/server.cpp
@@ -1,76 +1,35 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "server.h"
-#include <QtWidgets>
-#include <QtNetwork>
+#include <QDialogButtonBox>
+#include <QGuiApplication>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QLocalSocket>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QRandomGenerator>
+
+using namespace Qt::StringLiterals;
+
+static const QString idleStateText = QObject::tr("Press \"Listen\" to start the server");
Server::Server(QWidget *parent)
- : QDialog(parent)
+ : QDialog(parent),
+ server(new QLocalServer(this)),
+ hostLineEdit(new QLineEdit(u"fortune"_s)),
+ statusLabel(new QLabel(idleStateText)),
+ listenButton(new QPushButton(tr("Listen"))),
+ stopListeningButton(new QPushButton(tr("Stop Listening")))
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
- server = new QLocalServer(this);
- if (!server->listen("fortune")) {
- QMessageBox::critical(this, tr("Local Fortune Server"),
- tr("Unable to start the server: %1.")
- .arg(server->errorString()));
- close();
- return;
- }
-
- QLabel *statusLabel = new QLabel;
statusLabel->setWordWrap(true);
- statusLabel->setText(tr("The server is running.\n"
- "Run the Local Fortune Client example now."));
+
+ stopListeningButton->setDisabled(true);
fortunes << tr("You've been leading a dog's life. Stay off the furniture.")
<< tr("You've got to think about tomorrow.")
@@ -80,31 +39,73 @@ Server::Server(QWidget *parent)
<< tr("You cannot kill time without injuring eternity.")
<< tr("Computers are not intelligent. They only think they are.");
+ QLabel *hostLabel = new QLabel(tr("Server name:"));
+
+ connect(server, &QLocalServer::newConnection, this, &Server::sendFortune);
+ connect(hostLineEdit, &QLineEdit::textChanged, this, &Server::toggleListenButton);
+ connect(listenButton, &QPushButton::clicked, this, &Server::listenToServer);
+ connect(stopListeningButton, &QPushButton::clicked,this, &Server::stopListening);
+
QPushButton *quitButton = new QPushButton(tr("Quit"));
quitButton->setAutoDefault(false);
connect(quitButton, &QPushButton::clicked, this, &Server::close);
- connect(server, &QLocalServer::newConnection, this, &Server::sendFortune);
- QHBoxLayout *buttonLayout = new QHBoxLayout;
- buttonLayout->addStretch(1);
- buttonLayout->addWidget(quitButton);
- buttonLayout->addStretch(1);
+ QDialogButtonBox *buttonBox = new QDialogButtonBox;
+ buttonBox->addButton(listenButton, QDialogButtonBox::ActionRole);
+ buttonBox->addButton(stopListeningButton, QDialogButtonBox::ActionRole);
+ buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
- mainLayout->addWidget(statusLabel);
- mainLayout->addLayout(buttonLayout);
+ QGridLayout *mainLayout = new QGridLayout(this);
+ mainLayout->addWidget(hostLabel, 0, 0);
+ mainLayout->addWidget(hostLineEdit, 0, 1);
+ mainLayout->addWidget(statusLabel, 2, 0, 3, 2);
+ mainLayout->addWidget(buttonBox, 10, 0, 2, 2);
setWindowTitle(QGuiApplication::applicationDisplayName());
+ hostLineEdit->setFocus();
+}
+
+void Server::listenToServer()
+{
+ name = hostLineEdit->text();
+ if (!server->listen(name)) {
+ QMessageBox::critical(this, tr("Local Fortune Server"),
+ tr("Unable to start the server: %1.")
+ .arg(server->errorString()));
+ name.clear();
+ return;
+ }
+ statusLabel->setText(tr("The server is running.\n"
+ "Run the Local Fortune Client example now."));
+ toggleListenButton();
+}
+
+void Server::stopListening()
+{
+ server->close();
+ name.clear();
+ statusLabel->setText(idleStateText);
+ toggleListenButton();
+}
+
+void Server::toggleListenButton()
+{
+ if (server->isListening()) {
+ listenButton->setDisabled(true);
+ stopListeningButton->setEnabled(true);
+ } else {
+ listenButton->setEnabled(!hostLineEdit->text().isEmpty());
+ stopListeningButton->setDisabled(true);
+ }
}
void Server::sendFortune()
{
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
- out.setVersion(QDataStream::Qt_5_10);
+ out.setVersion(QDataStream::Qt_6_5);
const int fortuneIndex = QRandomGenerator::global()->bounded(0, fortunes.size());
const QString &message = fortunes.at(fortuneIndex);
- out << quint32(message.size());
out << message;
QLocalSocket *clientConnection = server->nextPendingConnection();
diff --git a/examples/corelib/ipc/localfortuneserver/server.h b/examples/corelib/ipc/localfortuneserver/server.h
index 6b90ba5932..1efba8fca9 100644
--- a/examples/corelib/ipc/localfortuneserver/server.h
+++ b/examples/corelib/ipc/localfortuneserver/server.h
@@ -1,77 +1,36 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SERVER_H
#define SERVER_H
+#include <QApplication>
#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-class QPushButton;
-class QLocalServer;
-QT_END_NAMESPACE
+#include <QLabel>
+#include <QLineEdit>
+#include <QLocalServer>
+#include <QPushButton>
class Server : public QDialog
{
- Q_OBJECT
+ Q_DECLARE_TR_FUNCTIONS(Server)
public:
explicit Server(QWidget *parent = nullptr);
-private slots:
+private:
void sendFortune();
+ void toggleListenButton();
+ void listenToServer();
+ void stopListening();
-private:
QLocalServer *server;
+ QLineEdit *hostLineEdit;
+ QLabel *statusLabel;
+ QPushButton *listenButton;
+ QPushButton *stopListeningButton;
QStringList fortunes;
+ QString name;
};
#endif
diff --git a/examples/corelib/ipc/sharedmemory/CMakeLists.txt b/examples/corelib/ipc/sharedmemory/CMakeLists.txt
index 74580e9472..db94911fc6 100644
--- a/examples/corelib/ipc/sharedmemory/CMakeLists.txt
+++ b/examples/corelib/ipc/sharedmemory/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from sharedmemory.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(sharedmemory LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/ipc/sharedmemory")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(sharedmemory
dialog.cpp dialog.h dialog.ui
main.cpp
)
+
set_target_properties(sharedmemory PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(sharedmemory PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+
+target_link_libraries(sharedmemory PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS sharedmemory
- 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 sharedmemory
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/ipc/sharedmemory/dialog.cpp b/examples/corelib/ipc/sharedmemory/dialog.cpp
index 4e999d1bcf..4e8f93a77b 100644
--- a/examples/corelib/ipc/sharedmemory/dialog.cpp
+++ b/examples/corelib/ipc/sharedmemory/dialog.cpp
@@ -1,56 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "dialog.h"
-#include <QFileDialog>
+
#include <QBuffer>
+#include <QFileDialog>
+#include <QNativeIpcKey>
+
+using namespace Qt::StringLiterals;
/*!
\class Dialog
@@ -76,8 +33,9 @@
each button.
*/
//! [0]
+
Dialog::Dialog(QWidget *parent)
- : QDialog(parent), sharedMemory("QSharedMemoryExample")
+ : QDialog(parent), sharedMemory(QNativeIpcKey(u"QSharedMemoryExample"_s))
{
ui.setupUi(this);
connect(ui.loadFromFileButton, &QPushButton::clicked,
@@ -136,8 +94,13 @@ void Dialog::loadFromFile()
int size = buffer.size();
if (!sharedMemory.create(size)) {
- ui.label->setText(tr("Unable to create shared memory segment."));
- return;
+ if (sharedMemory.error() == QSharedMemory::AlreadyExists) {
+ sharedMemory.attach();
+ } else {
+ ui.label->setText(tr("Unable to create or attach to shared memory segment: %1")
+ .arg(sharedMemory.errorString()));
+ return;
+ }
}
sharedMemory.lock();
char *to = (char*)sharedMemory.data();
diff --git a/examples/corelib/ipc/sharedmemory/dialog.h b/examples/corelib/ipc/sharedmemory/dialog.h
index 693333256c..679af423ff 100644
--- a/examples/corelib/ipc/sharedmemory/dialog.h
+++ b/examples/corelib/ipc/sharedmemory/dialog.h
@@ -1,58 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QSharedMemory>
+
#include "ui_dialog.h"
//! [0]
@@ -60,21 +14,21 @@ class Dialog : public QDialog
{
Q_OBJECT
- public:
+public:
Dialog(QWidget *parent = nullptr);
- public slots:
+public slots:
void loadFromFile();
void loadFromMemory();
- private:
+private:
void detach();
- private:
+private:
Ui::Dialog ui;
QSharedMemory sharedMemory;
};
//! [0]
-#endif
+#endif // DIALOG_H
diff --git a/examples/corelib/ipc/sharedmemory/main.cpp b/examples/corelib/ipc/sharedmemory/main.cpp
index 080f92c001..ffdd656502 100644
--- a/examples/corelib/ipc/sharedmemory/main.cpp
+++ b/examples/corelib/ipc/sharedmemory/main.cpp
@@ -1,56 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include <QApplication>
#include "dialog.h"
+#include <QApplication>
+
//! [0]
int main(int argc, char *argv[])
{
diff --git a/examples/corelib/mimetypes/CMakeLists.txt b/examples/corelib/mimetypes/CMakeLists.txt
index ac06659362..3b395090a2 100644
--- a/examples/corelib/mimetypes/CMakeLists.txt
+++ b/examples/corelib/mimetypes/CMakeLists.txt
@@ -1,5 +1,6 @@
-# Generated from mimetypes.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-if(TARGET Qt::Widgets)
- add_subdirectory(mimetypebrowser)
+if(TARGET Qt6::Widgets)
+ qt_internal_add_example(mimetypebrowser)
endif()
diff --git a/examples/corelib/mimetypes/doc/src/mimetypebrowser.qdoc b/examples/corelib/mimetypes/doc/src/mimetypebrowser.qdoc
index 7b204db51a..cc76abe2e5 100644
--- a/examples/corelib/mimetypes/doc/src/mimetypebrowser.qdoc
+++ b/examples/corelib/mimetypes/doc/src/mimetypebrowser.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example mimetypes/mimetypebrowser
+ \examplecategory {Data Processing & I/O}
\ingroup examples-mimetype
- \title MIME Type Browser Example
+ \title MIME Type Browser
\brief Shows the hierarchy of MIME types and
can be used to determine the MIME type of a file.
diff --git a/examples/corelib/mimetypes/mimetypebrowser/CMakeLists.txt b/examples/corelib/mimetypes/mimetypebrowser/CMakeLists.txt
index 977c072e00..b514965ff9 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/CMakeLists.txt
+++ b/examples/corelib/mimetypes/mimetypebrowser/CMakeLists.txt
@@ -1,41 +1,39 @@
-# Generated from mimetypebrowser.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(mimetypebrowser LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/mimetypes/mimetypebrowser")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(mimetypebrowser
main.cpp
mainwindow.cpp mainwindow.h
mimetypemodel.cpp mimetypemodel.h
)
+
set_target_properties(mimetypebrowser PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE FALSE
)
-target_link_libraries(mimetypebrowser PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+
+target_link_libraries(mimetypebrowser PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS mimetypebrowser
- 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 mimetypebrowser
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/mimetypes/mimetypebrowser/main.cpp b/examples/corelib/mimetypes/mimetypebrowser/main.cpp
index 679d97dc7b..03c905e6af 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/main.cpp
+++ b/examples/corelib/mimetypes/mimetypebrowser/main.cpp
@@ -1,60 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include <QApplication>
-#include <QScreen>
-
#include <QCommandLineParser>
-#include <QCommandLineOption>
+#include <QScreen>
int main(int argc, char *argv[])
{
diff --git a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp
index 7315523f98..0163fec574 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp
+++ b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp
@@ -1,73 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "mimetypemodel.h"
-#include <QAction>
#include <QApplication>
#include <QFileDialog>
+#include <QFileInfo>
#include <QInputDialog>
+#include <QItemSelectionModel>
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
-#include <QPlainTextEdit>
-#include <QSplitter>
-#include <QStatusBar>
-#include <QTextEdit>
-#include <QTreeView>
-
-#include <QFileInfo>
-#include <QItemSelectionModel>
#include <QMimeDatabase>
#include <QMimeType>
+#include <QSplitter>
+#include <QStatusBar>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
@@ -92,7 +40,8 @@ MainWindow::MainWindow(QWidget *parent)
findAction->setShortcuts(QKeySequence::Find);
m_findNextAction = findMenu->addAction(tr("Find &Next"), this, &MainWindow::findNext);
m_findNextAction->setShortcuts(QKeySequence::FindNext);
- m_findPreviousAction = findMenu->addAction(tr("Find &Previous"), this, &MainWindow::findPrevious);
+ m_findPreviousAction = findMenu->addAction(tr("Find &Previous"), this,
+ &MainWindow::findPrevious);
m_findPreviousAction->setShortcuts(QKeySequence::FindPrevious);
menuBar()->addMenu(tr("&About"))->addAction(tr("&About Qt"), qApp, &QApplication::aboutQt);
@@ -101,8 +50,8 @@ MainWindow::MainWindow(QWidget *parent)
setCentralWidget(centralSplitter);
m_treeView->setUniformRowHeights(true);
m_treeView->setModel(m_model);
-
- const auto items = m_model->findItems("application/octet-stream", Qt::MatchContains | Qt::MatchFixedString | Qt::MatchRecursive);
+ const auto flags = Qt::MatchContains | Qt::MatchFixedString | Qt::MatchRecursive;
+ const auto items = m_model->findItems("application/octet-stream", flags);
if (!items.isEmpty())
m_treeView->expand(m_model->indexFromItem(items.constFirst()));
@@ -140,7 +89,8 @@ void MainWindow::detectFile()
const QModelIndex index = mimeType.isValid()
? m_model->indexForMimeType(mimeType.name()) : QModelIndex();
if (index.isValid()) {
- statusBar()->showMessage(tr("\"%1\" is of type \"%2\"").arg(fi.fileName(), mimeType.name()));
+ statusBar()->showMessage(tr("\"%1\" is of type \"%2\"").arg(fi.fileName(),
+ mimeType.name()));
selectAndGoTo(index);
} else {
QMessageBox::information(this, tr("Unknown File Type"),
@@ -185,8 +135,8 @@ void MainWindow::find()
m_findMatches.clear();
m_findIndex = 0;
- const QList<QStandardItem *> items =
- m_model->findItems(value, Qt::MatchContains | Qt::MatchFixedString | Qt::MatchRecursive);
+ const auto flags = Qt::MatchContains | Qt::MatchFixedString | Qt::MatchRecursive;
+ const QList<QStandardItem *> items = m_model->findItems(value, flags);
for (const QStandardItem *item : items)
m_findMatches.append(m_model->indexFromItem(item));
statusBar()->showMessage(tr("%n mime types match \"%1\".", 0, m_findMatches.size()).arg(value));
diff --git a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.h b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.h
index 978cdec4f4..04827529fa 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.h
+++ b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.h
@@ -1,62 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
+#include <QAction>
#include <QMainWindow>
#include <QModelIndexList>
-
-QT_FORWARD_DECLARE_CLASS(QAction)
-QT_FORWARD_DECLARE_CLASS(QTextEdit)
-QT_FORWARD_DECLARE_CLASS(QTreeView)
+#include <QTextEdit>
+#include <QTreeView>
class MimetypeModel;
diff --git a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp
index 64732ba980..3598bb542e 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp
+++ b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mimetypemodel.h"
diff --git a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h
index 6c537f4001..061ede3c47 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h
+++ b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h
@@ -1,64 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MIMETYPEMODEL_H
#define MIMETYPEMODEL_H
-#include <QStandardItemModel>
+#include <QCoreApplication>
#include <QHash>
-
-QT_FORWARD_DECLARE_CLASS(QMimeType)
+#include <QMimeType>
+#include <QStandardItemModel>
class MimetypeModel : public QStandardItemModel
{
- Q_OBJECT
+ Q_DECLARE_TR_FUNCTIONS(MimetypeModel)
public:
enum Columns { NameColumn, ColumnCount };
diff --git a/examples/corelib/platform/CMakeLists.txt b/examples/corelib/platform/CMakeLists.txt
new file mode 100644
index 0000000000..b195713074
--- /dev/null
+++ b/examples/corelib/platform/CMakeLists.txt
@@ -0,0 +1,6 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+if(ANDROID)
+ qt_internal_add_example(androidnotifier)
+endif()
diff --git a/examples/corelib/platform/androidnotifier/CMakeLists.txt b/examples/corelib/platform/androidnotifier/CMakeLists.txt
new file mode 100644
index 0000000000..b356b15a43
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/CMakeLists.txt
@@ -0,0 +1,57 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(androidnotifier LANGUAGES CXX)
+
+if(NOT ANDROID)
+ message(FATAL_ERROR "Example only works on Android")
+endif()
+
+find_package(Qt6 REQUIRED COMPONENTS Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(androidnotifier
+ MANUAL_FINALIZATION
+ main.cpp
+ notificationclient.cpp
+ notificationclient.h
+ android/src/org/qtproject/example/androidnotifier/NotificationClient.java
+ android/AndroidManifest.xml
+)
+
+target_link_libraries(androidnotifier PRIVATE
+ Qt6::CorePrivate
+ Qt6::Widgets
+)
+
+set_property(TARGET androidnotifier APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
+ ${CMAKE_CURRENT_SOURCE_DIR}/android)
+
+qt_finalize_executable(androidnotifier)
+
+set(qml_resource_files
+ "images/happy.png"
+ "images/sad.png"
+)
+
+qt_add_resources(androidnotifier "main"
+ PREFIX
+ "/"
+ FILES
+ ${qml_resource_files}
+)
+
+install(TARGETS androidnotifier
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET androidnotifier
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/platform/androidnotifier/android/AndroidManifest.xml b/examples/corelib/platform/androidnotifier/android/AndroidManifest.xml
new file mode 100644
index 0000000000..778028a566
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/AndroidManifest.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.qtproject.example.androidnotifier"
+ android:installLocation="auto"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <!-- %%INSERT_PERMISSIONS -->
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
+ <!-- %%INSERT_FEATURES -->
+
+ <supports-screens
+ android:anyDensity="true"
+ android:largeScreens="true"
+ android:normalScreens="true"
+ android:smallScreens="true" />
+ <application
+ android:name="org.qtproject.qt.android.bindings.QtApplication"
+ android:extractNativeLibs="true"
+ android:hardwareAccelerated="true"
+ android:label="Qt Notifier"
+ android:requestLegacyExternalStorage="true"
+ android:icon="@drawable/icon"
+ android:allowBackup="true"
+ android:fullBackupOnly="false">
+ <activity
+ android:name="org.qtproject.qt.android.bindings.QtActivity"
+ android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
+ android:label="Qt Notifier"
+ android:launchMode="singleTop"
+ android:screenOrientation="unspecified"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+
+ <meta-data
+ android:name="android.app.lib_name"
+ android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
+
+ <meta-data
+ android:name="android.app.background_running"
+ android:value="false"/>
+ </activity>
+ </application>
+</manifest>
diff --git a/examples/corelib/platform/androidnotifier/android/res/drawable-hdpi/icon.png b/examples/corelib/platform/androidnotifier/android/res/drawable-hdpi/icon.png
new file mode 100644
index 0000000000..d3ccebe1f2
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/res/drawable-hdpi/icon.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/android/res/drawable-ldpi/icon.png b/examples/corelib/platform/androidnotifier/android/res/drawable-ldpi/icon.png
new file mode 100644
index 0000000000..2194be145e
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/res/drawable-ldpi/icon.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/android/res/drawable-mdpi/icon.png b/examples/corelib/platform/androidnotifier/android/res/drawable-mdpi/icon.png
new file mode 100644
index 0000000000..31812ccdd9
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/res/drawable-mdpi/icon.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/android/res/drawable-xhdpi/icon.png b/examples/corelib/platform/androidnotifier/android/res/drawable-xhdpi/icon.png
new file mode 100644
index 0000000000..3aeae642d9
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/res/drawable-xhdpi/icon.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/android/res/drawable-xxhdpi/icon.png b/examples/corelib/platform/androidnotifier/android/res/drawable-xxhdpi/icon.png
new file mode 100644
index 0000000000..f754fd18ae
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/res/drawable-xxhdpi/icon.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/android/res/drawable-xxxhdpi/icon.png b/examples/corelib/platform/androidnotifier/android/res/drawable-xxxhdpi/icon.png
new file mode 100644
index 0000000000..d0d043bf9c
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/res/drawable-xxxhdpi/icon.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java b/examples/corelib/platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java
new file mode 100644
index 0000000000..4cd6c959f6
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java
@@ -0,0 +1,46 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+package org.qtproject.example.androidnotifier;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.graphics.BitmapFactory;
+import android.app.NotificationChannel;
+
+public class NotificationClient
+{
+ public static void notify(Context context, String message) {
+ try {
+ NotificationManager m_notificationManager = (NotificationManager)
+ context.getSystemService(Context.NOTIFICATION_SERVICE);
+
+ Notification.Builder m_builder;
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
+ int importance = NotificationManager.IMPORTANCE_DEFAULT;
+ NotificationChannel notificationChannel;
+ notificationChannel = new NotificationChannel("Qt", "Qt Notifier", importance);
+ m_notificationManager.createNotificationChannel(notificationChannel);
+ m_builder = new Notification.Builder(context, notificationChannel.getId());
+ } else {
+ m_builder = new Notification.Builder(context);
+ }
+
+ Bitmap icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon);
+ m_builder.setSmallIcon(R.drawable.icon)
+ .setLargeIcon(icon)
+ .setContentTitle("A message from Qt!")
+ .setContentText(message)
+ .setDefaults(Notification.DEFAULT_SOUND)
+ .setColor(Color.GREEN)
+ .setAutoCancel(true);
+
+ m_notificationManager.notify(0, m_builder.build());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/examples/corelib/platform/androidnotifier/androidnotifier.pro b/examples/corelib/platform/androidnotifier/androidnotifier.pro
new file mode 100644
index 0000000000..6ac4c69eb3
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/androidnotifier.pro
@@ -0,0 +1,21 @@
+QT += core gui
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+QT += core-private # For Notification permission request
+
+SOURCES += \
+ main.cpp \
+ notificationclient.cpp
+
+HEADERS += \
+ notificationclient.h
+
+RESOURCES += \
+ main.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/corelib/platform/androidnotifier
+INSTALLS += target
+
+ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
+OTHER_FILES += \
+ android/src/org/qtproject/example/androidnotifier/NotificationClient.java \
+ android/AndroidManifest.xml
diff --git a/examples/corelib/platform/androidnotifier/doc/images/androidnotifier.png b/examples/corelib/platform/androidnotifier/doc/images/androidnotifier.png
new file mode 100644
index 0000000000..36a4a50c47
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/doc/images/androidnotifier.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/doc/src/androidnotifier-example.qdoc b/examples/corelib/platform/androidnotifier/doc/src/androidnotifier-example.qdoc
new file mode 100644
index 0000000000..1315ad7762
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/doc/src/androidnotifier-example.qdoc
@@ -0,0 +1,62 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \title Qt Android Notifier
+ \example platform/androidnotifier
+ \meta tag {widgets,android,notification}
+ \brief Demonstrates calling Java code from Qt in an Android application.
+ \ingroup androidplatform
+
+ \image androidnotifier.png
+
+ This example demonstrates how to add a custom Java class to an Android
+ application, and how to call it using the JNI convenience APIs in Qt.
+
+ Click on one of the smiley faces to send a notification in the status bar
+ of the Android screen.
+
+ \include examples-run.qdocinc
+
+ \section1 Calling Java Methods from C++ Code
+
+ We define a custom Java class called \c NotificationClient in the
+ NotificationClient.java file:
+
+ \quotefromfile platform/androidnotifier/android/src/org/qtproject/example/androidnotifier/NotificationClient.java
+ \skipto org.qtproject.example.androidnotifier
+ \printuntil /^\}/
+
+ In the NotificationClient C++ class header file, \c notificationclient.h, we
+ declare a simple C++ API to display notifications on an Android device. It
+ consists of a single string property, \c notification, and a slot,
+ \c updateAndroidNotification(), that calls the Java code:
+
+ \snippet platform/androidnotifier/notificationclient.h Qt Notification Class
+
+ We connect the \c notificationChanged() signal to the
+ \c updateAndroidNotification() slot to update the notification text when the
+ \c notification text changes:
+
+ \snippet platform/androidnotifier/notificationclient.cpp notification changed signal
+
+ The \c updateAndroidNotification() function calls the Java method responsible
+ for sending the notification from the Android platform APIs. First, we construct
+ a Java string \c jstring from the notification string, then pass the \c jstring
+ object as a parameter to the \c notify() method in Java:
+
+ \snippet platform/androidnotifier/notificationclient.cpp Send notification message to Java
+
+ The call to the Java meethod use \l QJniObject which relies on the Java Native
+ Interface (JNI) APIs to communicate with Java. Also, in the previous snippet,
+ we are passing the app's context object, which the static Java code can use
+ to tap into the app's specific properties and APIs.
+
+ To make sure our smiley buttons do what they are supposed to, we add the
+ the following code to change the notification text if either of them are
+ clicked:
+
+ \snippet platform/androidnotifier/main.cpp Connect button signals
+
+ \sa {Qt for Android}
+*/
diff --git a/examples/corelib/platform/androidnotifier/images/happy.png b/examples/corelib/platform/androidnotifier/images/happy.png
new file mode 100644
index 0000000000..af9412c2fb
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/images/happy.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/images/sad.png b/examples/corelib/platform/androidnotifier/images/sad.png
new file mode 100644
index 0000000000..928184b413
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/images/sad.png
Binary files differ
diff --git a/examples/corelib/platform/androidnotifier/main.cpp b/examples/corelib/platform/androidnotifier/main.cpp
new file mode 100644
index 0000000000..07eff5d2b0
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/main.cpp
@@ -0,0 +1,56 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "notificationclient.h"
+
+#include <QApplication>
+#include <QWidget>
+#include <QPushButton>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QFont>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ QWidget widget;
+ QPushButton happyButton;
+ happyButton.setIcon(QIcon(":/images/happy.png"));
+ happyButton.setIconSize(QSize(happyButton.width(), 120));
+
+ QPushButton sadButton;
+ sadButton.setIcon(QIcon(":/images/sad.png"));
+ sadButton.setIconSize(QSize(sadButton.width(), 120));
+
+ QVBoxLayout mainLayout;
+ QHBoxLayout labelLayout;
+ QLabel label = QLabel("Click a smiley to notify your mood");
+ QFont font = label.font();
+ font.setPointSize(20);
+ label.setFont(font);
+ labelLayout.addWidget(&label);
+ labelLayout.setAlignment(Qt::AlignHCenter);
+ mainLayout.addLayout(&labelLayout);
+
+ QHBoxLayout smileysLayout;
+ smileysLayout.addWidget(&sadButton);
+ smileysLayout.addWidget(&happyButton);
+ smileysLayout.setAlignment(Qt::AlignCenter);
+ mainLayout.addLayout(&smileysLayout);
+ widget.setLayout(&mainLayout);
+
+//! [Connect button signals]
+ QObject::connect(&happyButton, &QPushButton::clicked, &happyButton, []() {
+ NotificationClient().setNotification("The user is happy!");
+ });
+
+ QObject::connect(&sadButton, &QPushButton::clicked, &happyButton, []() {
+ NotificationClient().setNotification("The user is sad!");
+ });
+//! [Connect button signals]
+
+ widget.show();
+ return a.exec();
+}
+
diff --git a/examples/corelib/platform/androidnotifier/main.qrc b/examples/corelib/platform/androidnotifier/main.qrc
new file mode 100644
index 0000000000..e0bb052fd2
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/main.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>images/happy.png</file>
+ <file>images/sad.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/corelib/platform/androidnotifier/notificationclient.cpp b/examples/corelib/platform/androidnotifier/notificationclient.cpp
new file mode 100644
index 0000000000..aa6093c29c
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/notificationclient.cpp
@@ -0,0 +1,55 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "notificationclient.h"
+
+#include <QtCore/qjniobject.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/private/qandroidextras_p.h>
+
+using namespace Qt::StringLiterals;
+
+NotificationClient::NotificationClient(QObject *parent)
+ : QObject(parent)
+{
+ if (QNativeInterface::QAndroidApplication::sdkVersion() >= __ANDROID_API_T__) {
+ const auto notificationPermission = "android.permission.POST_NOTIFICATIONS"_L1;
+ auto requestResult = QtAndroidPrivate::requestPermission(notificationPermission);
+ if (requestResult.result() != QtAndroidPrivate::Authorized) {
+ qWarning() << "Failed to acquire permission to post notifications "
+ "(required for Android 13+)";
+ }
+ }
+
+ connect(this, &NotificationClient::notificationChanged,
+ this, &NotificationClient::updateAndroidNotification);
+}
+
+void NotificationClient::setNotification(const QString &notification)
+{
+ if (m_notification == notification)
+ return;
+
+//! [notification changed signal]
+ m_notification = notification;
+ emit notificationChanged();
+//! [notification changed signal]
+}
+
+QString NotificationClient::notification() const
+{
+ return m_notification;
+}
+
+//! [Send notification message to Java]
+void NotificationClient::updateAndroidNotification()
+{
+ QJniObject javaNotification = QJniObject::fromString(m_notification);
+ QJniObject::callStaticMethod<void>(
+ "org/qtproject/example/androidnotifier/NotificationClient",
+ "notify",
+ "(Landroid/content/Context;Ljava/lang/String;)V",
+ QNativeInterface::QAndroidApplication::context(),
+ javaNotification.object<jstring>());
+}
+//! [Send notification message to Java]
diff --git a/examples/corelib/platform/androidnotifier/notificationclient.h b/examples/corelib/platform/androidnotifier/notificationclient.h
new file mode 100644
index 0000000000..4ed7bfff50
--- /dev/null
+++ b/examples/corelib/platform/androidnotifier/notificationclient.h
@@ -0,0 +1,29 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef NOTIFICATIONCLIENT_H
+#define NOTIFICATIONCLIENT_H
+
+#include <QObject>
+
+//! [Qt Notification Class]
+class NotificationClient : public QObject
+{
+ Q_OBJECT
+public:
+ explicit NotificationClient(QObject *parent = 0);
+
+ void setNotification(const QString &notification);
+ QString notification() const;
+
+signals:
+ void notificationChanged();
+
+private slots:
+ void updateAndroidNotification();
+
+private:
+ QString m_notification;
+};
+//! [Qt Notification Class]
+#endif // NOTIFICATIONCLIENT_H
diff --git a/examples/corelib/platform/platform.pro b/examples/corelib/platform/platform.pro
new file mode 100644
index 0000000000..b9e58c7c7e
--- /dev/null
+++ b/examples/corelib/platform/platform.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+CONFIG += no_docs_target
+
+android: SUBDIRS += androidnotifier
diff --git a/examples/corelib/serialization/CMakeLists.txt b/examples/corelib/serialization/CMakeLists.txt
index a64b5130d2..e32e4df441 100644
--- a/examples/corelib/serialization/CMakeLists.txt
+++ b/examples/corelib/serialization/CMakeLists.txt
@@ -1,5 +1,11 @@
-# Generated from serialization.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(cbordump)
-add_subdirectory(convert)
-add_subdirectory(savegame)
+if(NOT ANDROID)
+ qt_internal_add_example(cbordump)
+ qt_internal_add_example(convert)
+ qt_internal_add_example(savegame)
+endif()
+if(TARGET Qt6::Widgets)
+ qt_internal_add_example(streambookmarks)
+endif()
diff --git a/examples/corelib/serialization/cbordump/CMakeLists.txt b/examples/corelib/serialization/cbordump/CMakeLists.txt
index 542c6f5ad0..b2c3a536e3 100644
--- a/examples/corelib/serialization/cbordump/CMakeLists.txt
+++ b/examples/corelib/serialization/cbordump/CMakeLists.txt
@@ -1,35 +1,34 @@
-# Generated from cbordump.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(cbordump LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+if (ANDROID)
+ message(FATAL_ERROR "This project cannot be built on Android.")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/serialization/cbordump")
+find_package(Qt6 REQUIRED COMPONENTS Core)
-find_package(Qt6 COMPONENTS Core)
+qt_standard_project_setup()
qt_add_executable(cbordump
main.cpp
)
-set_target_properties(cbordump PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(cbordump PUBLIC
- Qt::Core
+
+target_link_libraries(cbordump PRIVATE
+ Qt6::Core
)
install(TARGETS cbordump
- 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 cbordump
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/serialization/cbordump/cbortag.py b/examples/corelib/serialization/cbordump/cbortag.py
new file mode 100755
index 0000000000..26a0f969e4
--- /dev/null
+++ b/examples/corelib/serialization/cbordump/cbortag.py
@@ -0,0 +1,188 @@
+#!/bin/env python3
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+"""Digest cbor-tags.xml file into code for insertion into main.cpp
+
+See main.cpp's comment on how to regenerate its GENERATED CODE.
+See ./cbortag.py --help for further details on how to invoke.
+You can import this is a module without invoking the script.
+"""
+
+def firstChild(parent, tag):
+ """Return parent's first child element with the given tag."""
+ return next(node for node in parent.childNodes
+ if node.nodeType == parent.ELEMENT_NODE and node.nodeName == tag)
+
+def nodeAttrIs(node, attr, seek):
+ """Checks whether the node has a given value for an attribute
+
+ Takes the node to check, the name of the attribute and the value
+ to check against. Returns true if the node does have that value
+ for the named attribute."""
+ if node.nodeType != node.ELEMENT_NODE:
+ return False
+ if node.attributes is None or attr not in node.attributes:
+ return False
+ return node.attributes[attr].value == seek
+
+def getRfcValue(node):
+ """Extract RFC reference from an <xref type="rfc" ...> element
+
+ Some of these have a reference including section details as the
+ body of the element, otherwise the data attribute should identify
+ the RFC. If neither is found, an empty string is returned."""
+ if node.childNodes:
+ return node.childNodes[0].nodeValue # Maybe accumulate several children ?
+ if node.attributes is None or 'data' not in node.attributes:
+ return ''
+ return node.attributes['data'].value
+
+def readRegistry(filename):
+ """Handles the XML parsing and returns the relevant parts.
+
+ Single argument is the path to the cbor-tags.xml file; returns a
+ twople of the title element's text and an interator over the
+ record nodes. Checks some things are as expected while doing so."""
+ from xml.dom.minidom import parse
+ doc = parse(filename).documentElement
+ assert nodeAttrIs(doc, 'id', 'cbor-tags')
+ title = firstChild(doc, 'title').childNodes[0].nodeValue
+ registry = firstChild(doc, 'registry')
+ assert nodeAttrIs(registry, 'id', 'tags')
+ records = (node for node in registry.childNodes if node.nodeName == 'record')
+ return title, records
+
+def digest(record):
+ """Digest a single record from cbor-tags.xml
+
+ If the record is not of interest, returns the twople (None, None).
+ For records of interest, returns (n, t) where n is the numeric tag
+ code of the record and t is a text describing it. If the record,
+ or its semantics field, has an xref child with type="rfc", the RFC
+ mentioned there is included with the text of the semantics; such a
+ record is of interest, provided it has a semantics field and no
+ dash in its value. Records with a value field containing a dash
+ (indicating a range) are not of interest. Records with a value of
+ 256 or above are only of interest if they include an RFC."""
+ data = {}
+ for kid in record.childNodes:
+ if kid.nodeName == 'xref':
+ if not nodeAttrIs(kid, 'type', 'rfc'):
+ continue
+ rfc = getRfcValue(kid)
+ if rfc:
+ # Potentially stomping one taken from semantics
+ data['rfc'] = rfc
+ elif kid.nodeName == 'semantics':
+ text = rfc = ''
+ for part in kid.childNodes:
+ if part.nodeType == kid.TEXT_NODE:
+ text += part.nodeValue
+ elif part.nodeType == kid.ELEMENT_NODE:
+ if part.nodeName != 'xref' or not nodeAttrIs(part, 'type', 'rfc'):
+ continue # potentially append content to text
+ assert not rfc, ('Duplicate RFC ?', rfc, part)
+ rfc = getRfcValue(part)
+ if rfc:
+ if text.endswith('()'):
+ text = text[:-2].rstrip()
+ if 'rfc' not in data:
+ data['rfc'] = rfc
+ data['semantics'] = ' '.join(text.split())
+ elif kid.nodeName == 'value':
+ data['value'] = kid.childNodes[0].nodeValue
+ text = data.get('semantics')
+ if not text or 'value' not in data or '-' in data['value']:
+ return None, None
+ value = int(data['value'])
+ if 'rfc' in data:
+ rfc = data["rfc"].replace('rfc', 'RFC')
+ text = f'{text} [{rfc}]'
+ elif value >= 256:
+ return None, None
+ return value, text
+
+def entries(records):
+ """Digest each record of interest into a value and text.
+
+ The value and text form the raw material of the tagDescriptions
+ array in main.cpp; see digest for which records are retained."""
+ for record in records:
+ value, text = digest(record)
+ if value is not None:
+ yield value, text
+
+def marginBound(text, prior, left, right):
+ """Split up a string literal for tidy display.
+
+ The first parameter, text, is the content of the string literal;
+ quotes shall be added. It may be split into several fragments,
+ each quoted, so as to abide by line length constraints.
+
+ The remaining parameters are integers: prior is the text already
+ present on the line before text is to be added; left is the width
+ of the left margin for all subsequent lines; and right is the
+ right margin to stay within, where possible. The returned string
+ is either a space with the whole quoted text following, to fit on
+ the line already started to length prior, or a sequence of quoted
+ strings, each preceded by a newline and indent of width left."""
+ if prior + 3 + len(text) < right: # 1 for space, 2 for quotes
+ return f' "{text}"'
+ width = right - left - 2 # 2 for the quotes
+ words = iter(text.split(' '))
+ lines, current = [''], [next(words)]
+ for word in words:
+ if len(word) + sum(len(w) + 1 for w in current) > width:
+ line = ' '.join(current)
+ lines.append(f'"{line}"')
+ current = ['', word]
+ else:
+ current.append(word)
+ line = ' '.join(current)
+ lines.append(f'"{line}"')
+ return ('\n' + ' ' * left).join(lines)
+
+def main(argv, speak):
+ """Takes care of driving the process.
+
+ Takes the command-line argument list (whose first entry is the
+ name of this script) and standard output (or compatible stream of
+ your choosing) to which to write data. If the --out option is
+ specified in the arguments, the file it names is used in place of
+ this output stream."""
+ from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
+ parser = ArgumentParser(
+ description='Digest cbor-tags.xml into code to insert in main.cpp',
+ formatter_class=ArgumentDefaultsHelpFormatter)
+ parser.add_argument('path', help='path of the cbor-tags.xml file',
+ default='cbor-tags.xml')
+ parser.add_argument('--out', help='file to write instead of standard output')
+ args = parser.parse_args(argv[1:])
+ emit = (open(args.out) if args.out else speak).write
+
+ title, records = readRegistry(args.path)
+ emit(f"""\
+struct CborTagDescription
+{{
+ QCborTag tag;
+ const char *description; // with space and parentheses
+}};
+
+// {title}
+static const CborTagDescription tagDescriptions[] = {{
+ // from https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml
+""")
+
+ for value, text in sorted(entries(records)):
+ prior = f' {{ QCborTag({value}),'
+ body = marginBound(f' ({text})', len(prior), 6, 96)
+ emit(f"{prior}{body} }},\n")
+
+ emit("""\
+ { QCborTag(-1), nullptr }
+};
+""")
+
+if __name__ == '__main__':
+ import sys
+ sys.exit(main(sys.argv, sys.stdout))
diff --git a/examples/corelib/serialization/cbordump/doc/images/cbordump.png b/examples/corelib/serialization/cbordump/doc/images/cbordump.png
new file mode 100644
index 0000000000..d5ff1da0bf
--- /dev/null
+++ b/examples/corelib/serialization/cbordump/doc/images/cbordump.png
Binary files differ
diff --git a/examples/corelib/serialization/cbordump/doc/src/cbordump.qdoc b/examples/corelib/serialization/cbordump/doc/src/cbordump.qdoc
new file mode 100644
index 0000000000..a4dc01116f
--- /dev/null
+++ b/examples/corelib/serialization/cbordump/doc/src/cbordump.qdoc
@@ -0,0 +1,55 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example serialization/cbordump
+ \examplecategory {Data Processing & I/O}
+ \meta tag {network}
+ \title Parsing and displaying CBOR data
+
+ \brief A demonstration of how to parse files in CBOR format.
+
+ This example shows how to use the QCborStreamReader class directly to parse
+ CBOR content. The \c cbordump program reads content in CBOR format from
+ files or standard input and dumps the decoded content to stdout in a
+ human-readable format. It can output in CBOR diagnostic notation (which is
+ similar to JSON), or it can produce a verbose output where each byte input
+ is displayed with its encoding beside it.
+
+ \sa QCborStreamReader
+
+ \image cbordump.png
+
+ \section1 The CborDumper Class
+
+ The CborDumper class contains a QCborStreamReader object that is initialized
+ using the QFile object argument passed to the CborDumper constructor. Based
+ on the arguments the dump function calls either dumpOne() or
+ dumpOneDetailed() to dump the contents to standard output,
+
+ \snippet serialization/cbordump/main.cpp 0
+
+ \section2 The dumpOne() Function
+
+ Switching on QCborStreamReader::type() enables printing appropriate to the
+ type of the current value in the stream. If the type is an array or map, the
+ value's content is iterated over, and for each entry the dumpOne() function
+ is called recursively with a higher indentation argument. If the type is a
+ tag, it is printed out and dumpOne() is called once without increasing the
+ indentation argument.
+
+ \section2 The dumpOneDetailed() Function
+
+ This function dumps out both the incoming bytes and the decoded contents
+ on the same line. It uses lambda functions to print out the bytes and
+ decoded content, but otherwise has a similar structure as dumpOne().
+
+ \section1 CborTagDescription
+
+ The \c tagDescriptions table, describing the CBOR tags available, is
+ automatically generated from an XML file available from the iana.org
+ website. When \c dumpOneDetailed() reports a tag, it uses its description
+ from this table.
+
+ \sa {CBOR Support in Qt}
+*/
diff --git a/examples/corelib/serialization/cbordump/main.cpp b/examples/corelib/serialization/cbordump/main.cpp
index 928bc024c5..03c940452e 100644
--- a/examples/corelib/serialization/cbordump/main.cpp
+++ b/examples/corelib/serialization/cbordump/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QCborStreamReader>
#include <QCommandLineParser>
@@ -61,86 +14,137 @@
#include <stdarg.h>
#include <stdio.h>
+using namespace Qt::StringLiterals;
+
/*
* To regenerate:
* curl -O https://www.iana.org/assignments/cbor-tags/cbor-tags.xml
- * xsltproc tag-transform.xslt cbor-tags.xml
+ * ./cbortag.py cbor-tags.xml
+ *
+ * The XHTML URL mentioned in the comment below is a human-readable version of
+ * the same resource.
*/
// GENERATED CODE
struct CborTagDescription
{
QCborTag tag;
- const char *description; // with space and parentheses
+ const char *description; // with space and parentheses
};
-// CBOR Tags
+// Concise Binary Object Representation (CBOR) Tags
static const CborTagDescription tagDescriptions[] = {
// from https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml
- { QCborTag(0), " (Standard date/time string; see Section 2.4.1 [RFC7049])" },
- { QCborTag(1), " (Epoch-based date/time; see Section 2.4.1 [RFC7049])" },
- { QCborTag(2), " (Positive bignum; see Section 2.4.2 [RFC7049])" },
- { QCborTag(3), " (Negative bignum; see Section 2.4.2 [RFC7049])" },
- { QCborTag(4), " (Decimal fraction; see Section 2.4.3 [RFC7049])" },
- { QCborTag(5), " (Bigfloat; see Section 2.4.3 [RFC7049])" },
- { QCborTag(16), " (COSE Single Recipient Encrypted Data Object [RFC8152])" },
- { QCborTag(17), " (COSE Mac w/o Recipients Object [RFC8152])" },
- { QCborTag(18), " (COSE Single Signer Data Object [RFC8152])" },
- { QCborTag(21), " (Expected conversion to base64url encoding; see Section 2.4.4.2 [RFC7049])" },
- { QCborTag(22), " (Expected conversion to base64 encoding; see Section 2.4.4.2 [RFC7049])" },
- { QCborTag(23), " (Expected conversion to base16 encoding; see Section 2.4.4.2 [RFC7049])" },
- { QCborTag(24), " (Encoded CBOR data item; see Section 2.4.4.1 [RFC7049])" },
+ { QCborTag(0), " (Standard date/time string; see Section 3.4.1 [RFC8949])" },
+ { QCborTag(1), " (Epoch-based date/time; see Section 3.4.2 [RFC8949])" },
+ { QCborTag(2), " (Positive bignum; see Section 3.4.3 [RFC8949])" },
+ { QCborTag(3), " (Negative bignum; see Section 3.4.3 [RFC8949])" },
+ { QCborTag(4), " (Decimal fraction; see Section 3.4.4 [RFC8949])" },
+ { QCborTag(5), " (Bigfloat; see Section 3.4.4 [RFC8949])" },
+ { QCborTag(16), " (COSE Single Recipient Encrypted Data Object [RFC9052])" },
+ { QCborTag(17), " (COSE Mac w/o Recipients Object [RFC9052])" },
+ { QCborTag(18), " (COSE Single Signer Data Object [RFC9052])" },
+ { QCborTag(19), " (COSE standalone V2 countersignature [RFC9338])" },
+ { QCborTag(21),
+ " (Expected conversion to base64url encoding; see Section 3.4.5.2 [RFC8949])" },
+ { QCborTag(22), " (Expected conversion to base64 encoding; see Section 3.4.5.2 [RFC8949])" },
+ { QCborTag(23), " (Expected conversion to base16 encoding; see Section 3.4.5.2 [RFC8949])" },
+ { QCborTag(24), " (Encoded CBOR data item; see Section 3.4.5.1 [RFC8949])" },
{ QCborTag(25), " (reference the nth previously seen string)" },
{ QCborTag(26), " (Serialised Perl object with classname and constructor arguments)" },
- { QCborTag(27), " (Serialised language-independent object with type name and constructor arguments)" },
+ { QCborTag(27),
+ " (Serialised language-independent object with type name and constructor arguments)" },
{ QCborTag(28), " (mark value as (potentially) shared)" },
{ QCborTag(29), " (reference nth marked value)" },
{ QCborTag(30), " (Rational number)" },
- { QCborTag(32), " (URI; see Section 2.4.4.3 [RFC7049])" },
- { QCborTag(33), " (base64url; see Section 2.4.4.3 [RFC7049])" },
- { QCborTag(34), " (base64; see Section 2.4.4.3 [RFC7049])" },
+ { QCborTag(31), " (Absent value in a CBOR Array)" },
+ { QCborTag(32), " (URI; see Section 3.4.5.3 [RFC8949])" },
+ { QCborTag(33), " (base64url; see Section 3.4.5.3 [RFC8949])" },
+ { QCborTag(34), " (base64; see Section 3.4.5.3 [RFC8949])" },
{ QCborTag(35), " (Regular expression; see Section 2.4.4.3 [RFC7049])" },
- { QCborTag(36), " (MIME message; see Section 2.4.4.3 [RFC7049])" },
- { QCborTag(37), " (Binary UUID ( section 4.1.2))" },
- { QCborTag(38), " (Language-tagged string)" },
+ { QCborTag(36), " (MIME message; see Section 3.4.5.3 [RFC8949])" },
+ { QCborTag(37), " (Binary UUID [RFC4122, Section 4.1.2])" },
+ { QCborTag(38), " (Language-tagged string [RFC9290, Appendix A])" },
{ QCborTag(39), " (Identifier)" },
- { QCborTag(61), " (CBOR Web Token (CWT))" },
- { QCborTag(96), " (COSE Encrypted Data Object [RFC8152])" },
- { QCborTag(97), " (COSE MACed Data Object [RFC8152])" },
- { QCborTag(98), " (COSE Signed Data Object [RFC8152])" },
- { QCborTag(256), " (mark value as having string references)" },
- { QCborTag(257), " (Binary MIME message)" },
- { QCborTag(258), " (Mathematical finite set)" },
- { QCborTag(260), " (Network Address (IPv4 or IPv6 or MAC Address))" },
- { QCborTag(264), " (Decimal fraction with arbitrary exponent)" },
- { QCborTag(265), " (Bigfloat with arbitrary exponent)" },
- { QCborTag(1001), " (extended time)" },
- { QCborTag(1002), " (duration)" },
- { QCborTag(1003), " (period)" },
- { QCborTag(22098), " (hint that indicates an additional level of indirection)" },
- { QCborTag(55799), " (Self-describe CBOR; see Section 2.4.5 [RFC7049])" },
- { QCborTag(15309736), " (RAINS Message)" },
+ { QCborTag(40), " (Multi-dimensional Array, row-major order [RFC8746])" },
+ { QCborTag(41), " (Homogeneous Array [RFC8746])" },
+ { QCborTag(42), " (IPLD content identifier)" },
+ { QCborTag(43), " (YANG bits datatype; see Section 6.7. [RFC9254])" },
+ { QCborTag(44), " (YANG enumeration datatype; see Section 6.6. [RFC9254])" },
+ { QCborTag(45), " (YANG identityref datatype; see Section 6.10. [RFC9254])" },
+ { QCborTag(46), " (YANG instance-identifier datatype; see Section 6.13. [RFC9254])" },
+ { QCborTag(47), " (YANG Schema Item iDentifier (sid); see Section 3.2. [RFC9254])" },
+ { QCborTag(52), " (IPv4, [prefixlen,IPv4], [IPv4,prefixpart] [RFC9164])" },
+ { QCborTag(54), " (IPv6, [prefixlen,IPv6], [IPv6,prefixpart] [RFC9164])" },
+ { QCborTag(61), " (CBOR Web Token (CWT) [RFC8392])" },
+ { QCborTag(63), " (Encoded CBOR Sequence [RFC8742])" },
+ { QCborTag(64), " (uint8 Typed Array [RFC8746])" },
+ { QCborTag(65), " (uint16, big endian, Typed Array [RFC8746])" },
+ { QCborTag(66), " (uint32, big endian, Typed Array [RFC8746])" },
+ { QCborTag(67), " (uint64, big endian, Typed Array [RFC8746])" },
+ { QCborTag(68), " (uint8 Typed Array, clamped arithmetic [RFC8746])" },
+ { QCborTag(69), " (uint16, little endian, Typed Array [RFC8746])" },
+ { QCborTag(70), " (uint32, little endian, Typed Array [RFC8746])" },
+ { QCborTag(71), " (uint64, little endian, Typed Array [RFC8746])" },
+ { QCborTag(72), " (sint8 Typed Array [RFC8746])" },
+ { QCborTag(73), " (sint16, big endian, Typed Array [RFC8746])" },
+ { QCborTag(74), " (sint32, big endian, Typed Array [RFC8746])" },
+ { QCborTag(75), " (sint64, big endian, Typed Array [RFC8746])" },
+ { QCborTag(76), " ((reserved) [RFC8746])" },
+ { QCborTag(77), " (sint16, little endian, Typed Array [RFC8746])" },
+ { QCborTag(78), " (sint32, little endian, Typed Array [RFC8746])" },
+ { QCborTag(79), " (sint64, little endian, Typed Array [RFC8746])" },
+ { QCborTag(80), " (IEEE 754 binary16, big endian, Typed Array [RFC8746])" },
+ { QCborTag(81), " (IEEE 754 binary32, big endian, Typed Array [RFC8746])" },
+ { QCborTag(82), " (IEEE 754 binary64, big endian, Typed Array [RFC8746])" },
+ { QCborTag(83), " (IEEE 754 binary128, big endian, Typed Array [RFC8746])" },
+ { QCborTag(84), " (IEEE 754 binary16, little endian, Typed Array [RFC8746])" },
+ { QCborTag(85), " (IEEE 754 binary32, little endian, Typed Array [RFC8746])" },
+ { QCborTag(86), " (IEEE 754 binary64, little endian, Typed Array [RFC8746])" },
+ { QCborTag(87), " (IEEE 754 binary128, little endian, Typed Array [RFC8746])" },
+ { QCborTag(96), " (COSE Encrypted Data Object [RFC9052])" },
+ { QCborTag(97), " (COSE MACed Data Object [RFC9052])" },
+ { QCborTag(98), " (COSE Signed Data Object [RFC9052])" },
+ { QCborTag(100), " (Number of days since the epoch date 1970-01-01 [RFC8943])" },
+ { QCborTag(101), " (alternatives as given by the uint + 128; see Section 9.1)" },
+ { QCborTag(103), " (Geographic Coordinates)" },
+ { QCborTag(104), " (Geographic Coordinate Reference System WKT or EPSG number)" },
+ { QCborTag(110), " (relative object identifier (BER encoding); SDNV sequence [RFC9090])" },
+ { QCborTag(111), " (object identifier (BER encoding) [RFC9090])" },
+ { QCborTag(112), " (object identifier (BER encoding), relative to 1.3.6.1.4.1 [RFC9090])" },
+ { QCborTag(120), " (Internet of Things Data Point)" },
+ { QCborTag(260),
+ " (Network Address (IPv4 or IPv6 or MAC Address) (DEPRECATED in favor of 52 and 54 for IP"
+ " addresses) [RFC9164])" },
+ { QCborTag(261),
+ " (Network Address Prefix (IPv4 or IPv6 Address + Mask Length) (DEPRECATED in favor of 52"
+ " and 54 for IP addresses) [RFC9164])" },
+ { QCborTag(271),
+ " (DDoS Open Threat Signaling (DOTS) signal channel object, as defined in [RFC9132])" },
+ { QCborTag(1004), " (full-date string [RFC8943])" },
+ { QCborTag(1040), " (Multi-dimensional Array, column-major order [RFC8746])" },
+ { QCborTag(55799), " (Self-described CBOR; see Section 3.4.6 [RFC8949])" },
+ { QCborTag(55800), " (indicates that the file contains CBOR Sequences [RFC9277])" },
+ { QCborTag(55801),
+ " (indicates that the file starts with a CBOR-Labeled Non-CBOR Data label. [RFC9277])" },
{ QCborTag(-1), nullptr }
};
// END GENERATED CODE
enum {
// See RFC 7049 section 2.
- SmallValueBitLength = 5,
- SmallValueMask = (1 << SmallValueBitLength) - 1, /* 0x1f */
- Value8Bit = 24,
- Value16Bit = 25,
- Value32Bit = 26,
- Value64Bit = 27
+ SmallValueBitLength = 5,
+ SmallValueMask = (1 << SmallValueBitLength) - 1, /* 0x1f */
+ Value8Bit = 24,
+ Value16Bit = 25,
+ Value32Bit = 26,
+ Value64Bit = 27
};
+//! [0]
struct CborDumper
{
- enum DumpOption {
- ShowCompact = 0x01,
- ShowWidthIndicators = 0x02,
- ShowAnnotated = 0x04
- };
+ enum DumpOption { ShowCompact = 0x01, ShowWidthIndicators = 0x02, ShowAnnotated = 0x04 };
Q_DECLARE_FLAGS(DumpOptions, DumpOption)
CborDumper(QFile *f, DumpOptions opts_);
@@ -160,6 +164,7 @@ private:
qint64 offset = 0;
DumpOptions opts;
};
+//! [0]
Q_DECLARE_OPERATORS_FOR_FLAGS(CborDumper::DumpOptions)
static int cborNumberSize(quint64 value)
@@ -176,8 +181,7 @@ static int cborNumberSize(quint64 value)
return normalSize;
}
-CborDumper::CborDumper(QFile *f, DumpOptions opts_)
- : opts(opts_)
+CborDumper::CborDumper(QFile *f, DumpOptions opts_) : opts(opts_)
{
// try to mmap the file, this is faster
char *ptr = reinterpret_cast<char *>(f->map(0, f->size(), QFile::MapPrivateOption));
@@ -224,51 +228,54 @@ QCborError CborDumper::dump()
return err;
}
-template <typename T> static inline bool canConvertTo(double v)
+template<typename T>
+static inline bool canConvertTo(double v)
{
+ using TypeInfo = std::numeric_limits<T>;
// The [conv.fpint] (7.10 Floating-integral conversions) section of the
// standard says only exact conversions are guaranteed. Converting
// integrals to floating-point with loss of precision has implementation-
// defined behavior whether the next higher or next lower is returned;
// converting FP to integral is UB if it can't be represented.;
- static_assert(std::numeric_limits<T>::is_integer);
+ static_assert(TypeInfo::is_integer);
- double supremum = ldexp(1, std::numeric_limits<T>::digits);
+ double supremum = ldexp(1, TypeInfo::digits);
if (v >= supremum)
return false;
- if (v < std::numeric_limits<T>::min()) // either zero or a power of two, so it's exact
+ if (v < TypeInfo::min()) // either zero or a power of two, so it's exact
return false;
// we're in range
return v == floor(v);
}
-static QString fpToString(double v, const char *suffix)
+static QString fpToString(double v, QLatin1StringView suffix = ""_L1)
{
if (qIsInf(v))
- return v < 0 ? QStringLiteral("-inf") : QStringLiteral("inf");
+ return v < 0 ? "-inf"_L1 : "inf"_L1;
if (qIsNaN(v))
- return QStringLiteral("nan");
+ return "nan"_L1;
if (canConvertTo<qint64>(v))
- return QString::number(qint64(v)) + ".0" + suffix;
+ return QString::number(qint64(v)) + ".0"_L1 + suffix;
if (canConvertTo<quint64>(v))
- return QString::number(quint64(v)) + ".0" + suffix;
+ return QString::number(quint64(v)) + ".0"_L1 + suffix;
QString s = QString::number(v, 'g', QLocale::FloatingPointShortest);
- if (!s.contains('.') && !s.contains('e'))
- s += '.';
- s += suffix;
+ if (!s.contains(u'.') && !s.contains(u'e'))
+ s += u'.';
+ if (suffix.size())
+ s += suffix;
return s;
};
void CborDumper::dumpOne(int nestingLevel)
{
- QString indent(1, QLatin1Char(' '));
+ QString indent(1, u' ');
QString indented = indent;
if (!opts.testFlag(ShowCompact)) {
- indent = QLatin1Char('\n') + QString(4 * nestingLevel, QLatin1Char(' '));
- indented = QLatin1Char('\n') + QString(4 + 4 * nestingLevel, QLatin1Char(' '));
+ indent = u'\n' + QString(4 * nestingLevel, u' ');
+ indented = u'\n' + QString(4 + 4 * nestingLevel, u' ');
}
switch (reader.type()) {
@@ -308,7 +315,7 @@ void CborDumper::dumpOne(int nestingLevel)
printStringWidthIndicator(r.data.size());
r = reader.readByteArray();
- comma = QLatin1Char(',') + indented;
+ comma = u',' + indented;
}
} else {
auto r = reader.readString();
@@ -317,7 +324,7 @@ void CborDumper::dumpOne(int nestingLevel)
printStringWidthIndicator(r.data.toUtf8().size());
r = reader.readString();
- comma = QLatin1Char(',') + indented;
+ comma = u',' + indented;
}
}
@@ -373,7 +380,7 @@ void CborDumper::dumpOne(int nestingLevel)
if (reader.next()) {
printWidthIndicator(quint64(tag));
printf("(");
- dumpOne(nestingLevel); // same level!
+ dumpOne(nestingLevel); // same level!
printf(")");
}
@@ -405,15 +412,15 @@ void CborDumper::dumpOne(int nestingLevel)
break;
case QCborStreamReader::Float16:
- printf("%s", qPrintable(fpToString(reader.toFloat16(), "f16")));
+ printf("%s", qPrintable(fpToString(reader.toFloat16(), "f16"_L1)));
reader.next();
break;
case QCborStreamReader::Float:
- printf("%s", qPrintable(fpToString(reader.toFloat(), "f")));
+ printf("%s", qPrintable(fpToString(reader.toFloat(), "f"_L1)));
reader.next();
break;
case QCborStreamReader::Double:
- printf("%s", qPrintable(fpToString(reader.toDouble(), "")));
+ printf("%s", qPrintable(fpToString(reader.toDouble())));
reader.next();
break;
case QCborStreamReader::Invalid:
@@ -438,7 +445,7 @@ void CborDumper::dumpOneDetailed(int nestingLevel)
if (cborNumberSize(value) != actualSize)
printf(" (overlong)");
};
- auto print = [=](const char *descr, const char *fmt, ...) {
+ auto print = [&](const char *descr, const char *fmt, ...) {
qint64 prevOffset = offset;
offset = reader.currentOffset();
if (prevOffset == offset)
@@ -466,13 +473,14 @@ void CborDumper::dumpOneDetailed(int nestingLevel)
};
auto printFp = [=](const char *descr, double d) {
- QString s = fpToString(d, "");
+ QString s = fpToString(d);
if (s.size() <= 6)
return print(descr, "%s", qPrintable(s));
return print(descr, "%a", d);
};
- auto printString = [=](const char *descr) {
+ auto printString = [&](const char *descr) {
+ constexpr qsizetype ChunkSizeLimit = std::numeric_limits<int>::max();
QByteArray indent(nestingLevel * 2, ' ');
const char *chunkStr = (reader.isLengthKnown() ? "" : "chunk ");
int width = 48 - indent.size();
@@ -480,8 +488,8 @@ void CborDumper::dumpOneDetailed(int nestingLevel)
qsizetype size = reader.currentStringChunkSize();
if (size < 0)
- return; // error
- if (size >= std::numeric_limits<int>::max()) {
+ return; // error
+ if (size >= ChunkSizeLimit) {
fprintf(stderr, "String length too big, %lli\n", qint64(size));
exit(EXIT_FAILURE);
}
@@ -525,7 +533,7 @@ void CborDumper::dumpOneDetailed(int nestingLevel)
printf(" %s%s", indent.constData(), section.toHex(' ').constData());
// print the decode
- QByteArray spaces(width > 0 ? width - section.size() * 3 + 1: 0, ' ');
+ QByteArray spaces(width > 0 ? width - section.size() * 3 + 1 : 0, ' ');
printf("%s # \"", spaces.constData());
auto ptr = reinterpret_cast<const uchar *>(section.constData());
for (int j = 0; j < section.size(); ++j)
@@ -537,8 +545,8 @@ void CborDumper::dumpOneDetailed(int nestingLevel)
// get the next chunk
size = reader.currentStringChunkSize();
if (size < 0)
- return; // error
- if (size >= std::numeric_limits<int>::max()) {
+ return; // error
+ if (size >= ChunkSizeLimit) {
fprintf(stderr, "String length too big, %lli\n", qint64(size));
exit(EXIT_FAILURE);
}
@@ -676,7 +684,9 @@ void CborDumper::printByteArray(const QByteArray &ba)
break;
case quint8(QCborKnownTags::ExpectedBase64url):
- printf("b64'%s'", ba.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals).constData());
+ printf("b64'%s'",
+ ba.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals)
+ .constData());
break;
}
}
@@ -717,23 +727,20 @@ int main(int argc, char *argv[])
setlocale(LC_ALL, "C");
QCommandLineParser parser;
- parser.setApplicationDescription(QStringLiteral("CBOR Dumper tool"));
+ parser.setApplicationDescription("CBOR Dumper tool"_L1);
parser.addHelpOption();
- QCommandLineOption compact({QStringLiteral("c"), QStringLiteral("compact")},
- QStringLiteral("Use compact form (no line breaks)"));
+ QCommandLineOption compact({"c"_L1, "compact"_L1}, "Use compact form (no line breaks)"_L1);
parser.addOption(compact);
- QCommandLineOption showIndicators({QStringLiteral("i"), QStringLiteral("indicators")},
- QStringLiteral("Show indicators for width of lengths and integrals"));
+ QCommandLineOption showIndicators({ "i"_L1, "indicators"_L1 },
+ "Show indicators for width of lengths and integrals"_L1);
parser.addOption(showIndicators);
- QCommandLineOption verbose({QStringLiteral("a"), QStringLiteral("annotated")},
- QStringLiteral("Show bytes and annotated decoding"));
+ QCommandLineOption verbose({"a"_L1, "annotated"_L1}, "Show bytes and annotated decoding"_L1);
parser.addOption(verbose);
- parser.addPositionalArgument(QStringLiteral("[source]"),
- QStringLiteral("CBOR file to read from"));
+ parser.addPositionalArgument("[source]"_L1, "CBOR file to read from"_L1);
parser.process(app);
@@ -748,7 +755,7 @@ int main(int argc, char *argv[])
QStringList files = parser.positionalArguments();
if (files.isEmpty())
files << "-";
- for (const QString &file : qAsConst(files)) {
+ for (const QString &file : std::as_const(files)) {
QFile f(file);
if (file == "-" ? f.open(stdin, QIODevice::ReadOnly) : f.open(QIODevice::ReadOnly)) {
if (files.size() > 1)
diff --git a/examples/corelib/serialization/cbordump/tag-transform.xslt b/examples/corelib/serialization/cbordump/tag-transform.xslt
deleted file mode 100644
index 3cc1b9b293..0000000000
--- a/examples/corelib/serialization/cbordump/tag-transform.xslt
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://www.iana.org/assignments" xmlns="http://www.iana.org/assignments" xmlns:_="http://www.iana.org/assignments" xmlns:DEFAULT="http://www.iana.org/assignments" version="1.0">
-<xsl:output omit-xml-declaration="yes" indent="no" method="text"/>
-<xsl:template match="/a:registry[@id='cbor-tags']">struct CborTagDescription
-{
- QCborTag tag;
- const char *description; // with space and parentheses
-};
-
-// <xsl:value-of select="a:registry/a:title"/>
-static const CborTagDescription tagDescriptions[] = {
- // from https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml
-<xsl:for-each select="a:registry/a:record">
- <xsl:sort select="a:value" data-type="number"/>
- <xsl:if test="a:semantics != ''">
- <xsl:call-template name="row"/>
- </xsl:if>
- </xsl:for-each> { QCborTag(-1), nullptr }
-};
-</xsl:template>
-<xsl:template name="row"> { QCborTag(<xsl:value-of select="a:value"/>), " (<xsl:value-of select="a:semantics"/> <xsl:call-template name="xref"/>)" },
-</xsl:template>
-<xsl:template name="xref"><xsl:if test="a:xref/@type = 'rfc'"> [<xsl:value-of select="translate(a:xref/@data,'rfc','RFC')"/>]</xsl:if>
-</xsl:template>
-</xsl:stylesheet>
diff --git a/examples/corelib/serialization/convert/CMakeLists.txt b/examples/corelib/serialization/convert/CMakeLists.txt
index 0f2897441a..24ad5bbb6a 100644
--- a/examples/corelib/serialization/convert/CMakeLists.txt
+++ b/examples/corelib/serialization/convert/CMakeLists.txt
@@ -1,42 +1,43 @@
-# Generated from convert.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(convert LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+if (ANDROID)
+ message(FATAL_ERROR "This project cannot be built on Android.")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/serialization/convert")
+find_package(Qt6 REQUIRED COMPONENTS Core)
-find_package(Qt6 COMPONENTS Core)
+qt_standard_project_setup()
qt_add_executable(convert
cborconverter.cpp cborconverter.h
- converter.h
+ converter.cpp converter.h
datastreamconverter.cpp datastreamconverter.h
+ debugtextdumper.cpp debugtextdumper.h
jsonconverter.cpp jsonconverter.h
main.cpp
nullconverter.cpp nullconverter.h
textconverter.cpp textconverter.h
+ variantorderedmap.h
xmlconverter.cpp xmlconverter.h
)
-set_target_properties(convert PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(convert PUBLIC
- Qt::Core
+
+target_link_libraries(convert PRIVATE
+ Qt6::Core
)
install(TARGETS convert
- 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 convert
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/serialization/convert/cborconverter.cpp b/examples/corelib/serialization/convert/cborconverter.cpp
index 4fc8408983..969f2741e0 100644
--- a/examples/corelib/serialization/convert/cborconverter.cpp
+++ b/examples/corelib/serialization/convert/cborconverter.cpp
@@ -1,72 +1,29 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "cborconverter.h"
+#include "variantorderedmap.h"
+#include <QCborArray>
+#include <QCborMap>
#include <QCborStreamReader>
#include <QCborStreamWriter>
-#include <QCborMap>
-#include <QCborArray>
#include <QCborValue>
#include <QDataStream>
-#include <QFloat16>
+#include <QDebug>
#include <QFile>
+#include <QFloat16>
#include <QMetaType>
#include <QTextStream>
#include <stdio.h>
+using namespace Qt::StringLiterals;
+
static CborConverter cborConverter;
static CborDiagnosticDumper cborDiagnosticDumper;
-static const char optionHelp[] =
+static const char cborOptionHelp[] =
"convert-float-to-int=yes|no Write integers instead of floating point, if no\n"
" loss of precision occurs on conversion.\n"
"float16=yes|always|no Write using half-precision floating point.\n"
@@ -102,6 +59,7 @@ QT_END_NAMESPACE
// non-string keys in CBOR maps (QVariantMap can't handle those). Instead, we
// have our own set of converter functions so we can keep the keys properly.
+//! [0]
static QVariant convertCborValue(const QCborValue &value);
static QVariant convertCborMap(const QCborMap &map)
@@ -130,7 +88,9 @@ static QVariant convertCborValue(const QCborValue &value)
return convertCborMap(value.toMap());
return value.toVariant();
}
+//! [0]
+//! [1]
enum TrimFloatingPoint { Double, Float, Float16 };
static QCborValue convertFromVariant(const QVariant &v, TrimFloatingPoint fpTrimming)
{
@@ -161,42 +121,30 @@ static QCborValue convertFromVariant(const QVariant &v, TrimFloatingPoint fpTrim
return QCborValue::fromVariant(v);
}
+//! [1]
-QString CborDiagnosticDumper::name()
+QString CborDiagnosticDumper::name() const
{
- return QStringLiteral("cbor-dump");
+ return "cbor-dump"_L1;
}
-Converter::Direction CborDiagnosticDumper::directions()
+Converter::Directions CborDiagnosticDumper::directions() const
{
- return Out;
+ return Direction::Out;
}
-Converter::Options CborDiagnosticDumper::outputOptions()
+Converter::Options CborDiagnosticDumper::outputOptions() const
{
return SupportsArbitraryMapKeys;
}
-const char *CborDiagnosticDumper::optionsHelp()
+const char *CborDiagnosticDumper::optionsHelp() const
{
return diagnosticHelp;
}
-bool CborDiagnosticDumper::probeFile(QIODevice *f)
-{
- Q_UNUSED(f);
- return false;
-}
-
-QVariant CborDiagnosticDumper::loadFile(QIODevice *f, Converter *&outputConverter)
-{
- Q_UNREACHABLE();
- Q_UNUSED(f);
- Q_UNUSED(outputConverter);
- return QVariant();
-}
-
-void CborDiagnosticDumper::saveFile(QIODevice *f, const QVariant &contents, const QStringList &options)
+void CborDiagnosticDumper::saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const
{
QCborValue::DiagnosticNotationOptions opts = QCborValue::LineWrapped;
for (const QString &s : options) {
@@ -219,14 +167,12 @@ void CborDiagnosticDumper::saveFile(QIODevice *f, const QVariant &contents, cons
}
}
- fprintf(stderr, "Unknown CBOR diagnostic option '%s'. Available options are:\n%s",
- qPrintable(s), diagnosticHelp);
- exit(EXIT_FAILURE);
+ qFatal("Unknown CBOR diagnostic option '%s'. Available options are:\n%s",
+ qPrintable(s), diagnosticHelp);
}
QTextStream out(f);
- out << convertFromVariant(contents, Double).toDiagnosticNotation(opts)
- << Qt::endl;
+ out << convertFromVariant(contents, Double).toDiagnosticNotation(opts) << Qt::endl;
}
CborConverter::CborConverter()
@@ -234,36 +180,36 @@ CborConverter::CborConverter()
qRegisterMetaType<QCborTag>();
}
-QString CborConverter::name()
+QString CborConverter::name() const
{
return "cbor";
}
-Converter::Direction CborConverter::directions()
+Converter::Directions CborConverter::directions() const
{
- return InOut;
+ return Direction::InOut;
}
-Converter::Options CborConverter::outputOptions()
+Converter::Options CborConverter::outputOptions() const
{
return SupportsArbitraryMapKeys;
}
-const char *CborConverter::optionsHelp()
+const char *CborConverter::optionsHelp() const
{
- return optionHelp;
+ return cborOptionHelp;
}
-bool CborConverter::probeFile(QIODevice *f)
+bool CborConverter::probeFile(QIODevice *f) const
{
if (QFile *file = qobject_cast<QFile *>(f)) {
- if (file->fileName().endsWith(QLatin1String(".cbor")))
+ if (file->fileName().endsWith(".cbor"_L1))
return true;
}
return f->isReadable() && f->peek(3) == QByteArray("\xd9\xd9\xf7", 3);
}
-QVariant CborConverter::loadFile(QIODevice *f, Converter *&outputConverter)
+QVariant CborConverter::loadFile(QIODevice *f, const Converter *&outputConverter) const
{
const char *ptr = nullptr;
if (auto file = qobject_cast<QFile *>(f))
@@ -280,25 +226,24 @@ QVariant CborConverter::loadFile(QIODevice *f, Converter *&outputConverter)
QCborValue contents = QCborValue::fromCbor(reader);
qint64 offset = reader.currentOffset();
if (reader.lastError()) {
- fprintf(stderr, "Error loading CBOR contents (byte %lld): %s\n", offset,
- qPrintable(reader.lastError().toString()));
- fprintf(stderr, " bytes: %s\n",
- (ptr ? mapped.mid(offset, 9) : f->read(9)).toHex(' ').constData());
- exit(EXIT_FAILURE);
+ qFatal().nospace()
+ << "Error loading CBOR contents (byte " << offset
+ << "): " << reader.lastError().toString()
+ << "\n bytes: " << (ptr ? mapped.mid(offset, 9) : f->read(9));
} else if (offset < mapped.size() || (!ptr && f->bytesAvailable())) {
- fprintf(stderr, "Warning: bytes remaining at the end of the CBOR stream\n");
+ qWarning("Warning: bytes remaining at the end of the CBOR stream");
}
if (outputConverter == nullptr)
outputConverter = &cborDiagnosticDumper;
- else if (outputConverter == null)
+ else if (isNull(outputConverter))
return QVariant();
else if (!outputConverter->outputOptions().testFlag(SupportsArbitraryMapKeys))
return contents.toVariant();
return convertCborValue(contents);
}
-void CborConverter::saveFile(QIODevice *f, const QVariant &contents, const QStringList &options)
+void CborConverter::saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) const
{
bool useSignature = true;
bool useIntegers = true;
@@ -354,13 +299,13 @@ void CborConverter::saveFile(QIODevice *f, const QVariant &contents, const QStri
}
}
- fprintf(stderr, "Unknown CBOR format option '%s'. Valid options are:\n%s",
- qPrintable(s), optionHelp);
- exit(EXIT_FAILURE);
+ qFatal("Unknown CBOR format option '%s'. Valid options are:\n%s",
+ qPrintable(s), cborOptionHelp);
}
- QCborValue v = convertFromVariant(contents,
- useFloat16 == Always ? Float16 : useFloat == Always ? Float : Double);
+ QCborValue v =
+ convertFromVariant(contents,
+ useFloat16 == Always ? Float16 : useFloat == Always ? Float : Double);
QCborStreamWriter writer(f);
if (useSignature)
writer.append(QCborKnownTags::Signature);
@@ -374,4 +319,3 @@ void CborConverter::saveFile(QIODevice *f, const QVariant &contents, const QStri
opts |= QCborValue::UseFloat16;
v.toCbor(writer, opts);
}
-
diff --git a/examples/corelib/serialization/convert/cborconverter.h b/examples/corelib/serialization/convert/cborconverter.h
index f0a89cb141..db68f99fda 100644
--- a/examples/corelib/serialization/convert/cborconverter.h
+++ b/examples/corelib/serialization/convert/cborconverter.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CBORCONVERTER_H
#define CBORCONVERTER_H
@@ -57,13 +10,12 @@ class CborDiagnosticDumper : public Converter
{
// Converter interface
public:
- QString name() override;
- Direction directions() override;
- Options outputOptions() override;
- const char *optionsHelp() override;
- bool probeFile(QIODevice *f) override;
- QVariant loadFile(QIODevice *f, Converter *&outputConverter) override;
- void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) override;
+ QString name() const override;
+ Directions directions() const override;
+ Options outputOptions() const override;
+ const char *optionsHelp() const override;
+ void saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const override;
};
class CborConverter : public Converter
@@ -73,13 +25,14 @@ public:
// Converter interface
public:
- QString name() override;
- Direction directions() override;
- Options outputOptions() override;
- const char *optionsHelp() override;
- bool probeFile(QIODevice *f) override;
- QVariant loadFile(QIODevice *f, Converter *&outputConverter) override;
- void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) override;
+ QString name() const override;
+ Directions directions() const override;
+ Options outputOptions() const override;
+ const char *optionsHelp() const override;
+ bool probeFile(QIODevice *f) const override;
+ QVariant loadFile(QIODevice *f, const Converter *&outputConverter) const override;
+ void saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const override;
};
#endif // CBORCONVERTER_H
diff --git a/examples/corelib/serialization/convert/convert.pro b/examples/corelib/serialization/convert/convert.pro
index 4c6b0b557a..7592de7a22 100644
--- a/examples/corelib/serialization/convert/convert.pro
+++ b/examples/corelib/serialization/convert/convert.pro
@@ -11,18 +11,22 @@ target.path = $$[QT_INSTALL_EXAMPLES]/corelib/serialization/convert
INSTALLS += target
SOURCES += main.cpp \
+ converter.cpp \
cborconverter.cpp \
- jsonconverter.cpp \
datastreamconverter.cpp \
+ debugtextdumper.cpp \
+ jsonconverter.cpp \
+ nullconverter.cpp \
textconverter.cpp \
- xmlconverter.cpp \
- nullconverter.cpp
+ xmlconverter.cpp
HEADERS += \
converter.h \
cborconverter.h \
- jsonconverter.h \
datastreamconverter.h \
+ debugtextdumper.h \
+ jsonconverter.h \
+ nullconverter.h \
textconverter.h \
- xmlconverter.h \
- nullconverter.h
+ variantorderedmap.h \
+ xmlconverter.h
diff --git a/examples/corelib/serialization/convert/converter.cpp b/examples/corelib/serialization/convert/converter.cpp
new file mode 100644
index 0000000000..a57f305971
--- /dev/null
+++ b/examples/corelib/serialization/convert/converter.cpp
@@ -0,0 +1,44 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "converter.h"
+
+//! [0]
+Converter::Converter()
+{
+ converters().append(this);
+}
+
+Converter::~Converter()
+{
+ converters().removeAll(this);
+}
+
+QList<const Converter *> &Converter::converters()
+{
+ Q_CONSTINIT static QList<const Converter *> store;
+ return store;
+}
+
+const QList<const Converter *> &Converter::allConverters()
+{
+ return converters();
+}
+//! [0]
+
+// Some virtual methods that Converter classes needn't override, when not relevant:
+Converter::Options Converter::outputOptions() const { return {}; }
+const char *Converter::optionsHelp() const { return nullptr; }
+bool Converter::probeFile(QIODevice *) const { return false; }
+
+// The virtual method they should override if they claim to support In:
+QVariant Converter::loadFile(QIODevice *, const Converter *&outputConverter) const
+{
+ Q_ASSERT(!directions().testFlag(Converter::Direction::In));
+ // For those that don't, this should never be called.
+ Q_UNIMPLEMENTED();
+ // But every implementation should at least do this:
+ if (!outputConverter)
+ outputConverter = this;
+ return QVariant();
+}
diff --git a/examples/corelib/serialization/convert/converter.h b/examples/corelib/serialization/convert/converter.h
index 56b501a076..40b7575a1e 100644
--- a/examples/corelib/serialization/convert/converter.h
+++ b/examples/corelib/serialization/convert/converter.h
@@ -1,103 +1,45 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CONVERTER_H
#define CONVERTER_H
#include <QIODevice>
-#include <QPair>
-#include <QVariant>
#include <QList>
+#include <QStringList>
+#include <QVariant>
-class VariantOrderedMap : public QList<QPair<QVariant, QVariant>>
-{
-public:
- VariantOrderedMap() = default;
- VariantOrderedMap(const QVariantMap &map)
- {
- reserve(map.size());
- for (auto it = map.begin(); it != map.end(); ++it)
- append({it.key(), it.value()});
- }
-};
-using Map = VariantOrderedMap;
-Q_DECLARE_METATYPE(Map)
-
+//! [0]
class Converter
{
+ static QList<const Converter *> &converters();
protected:
Converter();
+ static bool isNull(const Converter *converter); // in nullconverter.cpp
public:
- static Converter *null;
+ static const QList<const Converter *> &allConverters();
- enum Direction {
- In = 1, Out = 2, InOut = 3
- };
+ enum class Direction { In = 1, Out = 2, InOut = In | Out };
+ Q_DECLARE_FLAGS(Directions, Direction)
- enum Option {
- SupportsArbitraryMapKeys = 0x01
- };
+ enum Option { SupportsArbitraryMapKeys = 0x01 };
Q_DECLARE_FLAGS(Options, Option)
virtual ~Converter() = 0;
- virtual QString name() = 0;
- virtual Direction directions() = 0;
- virtual Options outputOptions() = 0;
- virtual const char *optionsHelp() = 0;
- virtual bool probeFile(QIODevice *f) = 0;
- virtual QVariant loadFile(QIODevice *f, Converter *&outputConverter) = 0;
- virtual void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) = 0;
+ virtual QString name() const = 0;
+ virtual Directions directions() const = 0;
+ virtual Options outputOptions() const;
+ virtual const char *optionsHelp() const;
+ virtual bool probeFile(QIODevice *f) const;
+ virtual QVariant loadFile(QIODevice *f, const Converter *&outputConverter) const;
+ virtual void saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const = 0;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(Converter::Directions)
Q_DECLARE_OPERATORS_FOR_FLAGS(Converter::Options)
+//! [0]
#endif // CONVERTER_H
diff --git a/examples/corelib/serialization/convert/datastreamconverter.cpp b/examples/corelib/serialization/convert/datastreamconverter.cpp
index c459696b26..ce28fcb98e 100644
--- a/examples/corelib/serialization/convert/datastreamconverter.cpp
+++ b/examples/corelib/serialization/convert/datastreamconverter.cpp
@@ -1,68 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "datastreamconverter.h"
+#include "debugtextdumper.h"
+#include "variantorderedmap.h"
#include <QDataStream>
-#include <QDebug>
-#include <QTextStream>
-static const char optionHelp[] =
+using namespace Qt::StringLiterals;
+
+static const char dataStreamOptionHelp[] =
"byteorder=host|big|little Byte order to use.\n"
- "version=<n> QDataStream version (default: Qt 5.0).\n"
+ "version=<n> QDataStream version (default: Qt 6.0).\n"
;
static const char signature[] = "qds";
-static DataStreamDumper dataStreamDumper;
-static DataStreamConverter DataStreamConverter;
+static DataStreamConverter dataStreamConverter;
+static DebugTextDumper debugTextDumper;
QDataStream &operator<<(QDataStream &ds, const VariantOrderedMap &map)
{
@@ -89,126 +44,44 @@ QDataStream &operator>>(QDataStream &ds, VariantOrderedMap &map)
return ds;
}
-
-static QString dumpVariant(const QVariant &v, const QString &indent = QLatin1String("\n"))
-{
- QString result;
- QString indented = indent + QLatin1String(" ");
-
- int type = v.userType();
- if (type == qMetaTypeId<VariantOrderedMap>() || type == QMetaType::QVariantMap) {
- const auto map = (type == QMetaType::QVariantMap) ?
- VariantOrderedMap(v.toMap()) : qvariant_cast<VariantOrderedMap>(v);
-
- result = QLatin1String("Map {");
- for (const auto &pair : map) {
- result += indented + dumpVariant(pair.first, indented);
- result.chop(1); // remove comma
- result += QLatin1String(" => ") + dumpVariant(pair.second, indented);
-
- }
- result.chop(1); // remove comma
- result += indent + QLatin1String("},");
- } else if (type == QMetaType::QVariantList) {
- const QVariantList list = v.toList();
-
- result = QLatin1String("List [");
- for (const auto &item : list)
- result += indented + dumpVariant(item, indented);
- result.chop(1); // remove comma
- result += indent + QLatin1String("],");
- } else {
- QDebug debug(&result);
- debug.nospace() << v << ',';
- }
- return result;
-}
-
-QString DataStreamDumper::name()
-{
- return QStringLiteral("datastream-dump");
-}
-
-Converter::Direction DataStreamDumper::directions()
-{
- return Out;
-}
-
-Converter::Options DataStreamDumper::outputOptions()
-{
- return SupportsArbitraryMapKeys;
-}
-
-const char *DataStreamDumper::optionsHelp()
-{
- return nullptr;
-}
-
-bool DataStreamDumper::probeFile(QIODevice *f)
-{
- Q_UNUSED(f);
- return false;
-}
-
-QVariant DataStreamDumper::loadFile(QIODevice *f, Converter *&outputConverter)
-{
- Q_UNREACHABLE();
- Q_UNUSED(f);
- Q_UNUSED(outputConverter);
- return QVariant();
-}
-
-void DataStreamDumper::saveFile(QIODevice *f, const QVariant &contents, const QStringList &options)
-{
- Q_UNUSED(options);
- QString s = dumpVariant(contents);
- s[s.size() - 1] = QLatin1Char('\n'); // replace the comma with newline
-
- QTextStream out(f);
- out << s;
-}
-
DataStreamConverter::DataStreamConverter()
{
qRegisterMetaType<VariantOrderedMap>();
}
-QString DataStreamConverter::name()
+QString DataStreamConverter::name() const
{
- return QStringLiteral("datastream");
+ return "datastream"_L1;
}
-Converter::Direction DataStreamConverter::directions()
+Converter::Directions DataStreamConverter::directions() const
{
- return InOut;
+ return Direction::InOut;
}
-Converter::Options DataStreamConverter::outputOptions()
+Converter::Options DataStreamConverter::outputOptions() const
{
return SupportsArbitraryMapKeys;
}
-const char *DataStreamConverter::optionsHelp()
+const char *DataStreamConverter::optionsHelp() const
{
- return optionHelp;
+ return dataStreamOptionHelp;
}
-bool DataStreamConverter::probeFile(QIODevice *f)
+bool DataStreamConverter::probeFile(QIODevice *f) const
{
return f->isReadable() && f->peek(sizeof(signature) - 1) == signature;
}
-QVariant DataStreamConverter::loadFile(QIODevice *f, Converter *&outputConverter)
+QVariant DataStreamConverter::loadFile(QIODevice *f, const Converter *&outputConverter) const
{
if (!outputConverter)
- outputConverter = &dataStreamDumper;
+ outputConverter = &debugTextDumper;
char c;
- if (f->read(sizeof(signature) -1) != signature ||
- !f->getChar(&c) || (c != 'l' && c != 'B')) {
- fprintf(stderr, "Could not load QDataStream file: invalid signature.\n");
- exit(EXIT_FAILURE);
- }
+ if (f->read(sizeof(signature) - 1) != signature || !f->getChar(&c) || (c != 'l' && c != 'B'))
+ qFatal("Could not load QDataStream file: invalid signature.");
QDataStream ds(f);
ds.setByteOrder(c == 'l' ? QDataStream::LittleEndian : QDataStream::BigEndian);
@@ -222,9 +95,10 @@ QVariant DataStreamConverter::loadFile(QIODevice *f, Converter *&outputConverter
return result;
}
-void DataStreamConverter::saveFile(QIODevice *f, const QVariant &contents, const QStringList &options)
+void DataStreamConverter::saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const
{
- QDataStream::Version version = QDataStream::Qt_5_0;
+ QDataStream::Version version = QDataStream::Qt_6_0;
auto order = QDataStream::ByteOrder(QSysInfo::ByteOrder);
for (const QString &option : options) {
const QStringList pair = option.split('=');
@@ -249,18 +123,16 @@ void DataStreamConverter::saveFile(QIODevice *f, const QVariant &contents, const
continue;
}
- fprintf(stderr, "Invalid version number '%s': must be a number from 1 to %d.\n",
- qPrintable(pair.last()), QDataStream::Qt_DefaultCompiledVersion);
- exit(EXIT_FAILURE);
+ qFatal("Invalid version number '%s': must be a number from 1 to %d.",
+ qPrintable(pair.last()), QDataStream::Qt_DefaultCompiledVersion);
}
}
- fprintf(stderr, "Unknown QDataStream formatting option '%s'. Available options are:\n%s",
- qPrintable(option), optionHelp);
- exit(EXIT_FAILURE);
+ qFatal("Unknown QDataStream formatting option '%s'. Available options are:\n%s",
+ qPrintable(option), dataStreamOptionHelp);
}
- char c = order == QDataStream::LittleEndian ? 'l' : 'B';
+ char c = order == QDataStream::LittleEndian ? 'l' : 'B';
f->write(signature);
f->write(&c, 1);
diff --git a/examples/corelib/serialization/convert/datastreamconverter.h b/examples/corelib/serialization/convert/datastreamconverter.h
index 1b74abc54f..201f3c4754 100644
--- a/examples/corelib/serialization/convert/datastreamconverter.h
+++ b/examples/corelib/serialization/convert/datastreamconverter.h
@@ -1,71 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DATASTREAMCONVERTER_H
#define DATASTREAMCONVERTER_H
#include "converter.h"
-class DataStreamDumper : public Converter
-{
- // Converter interface
-public:
- QString name() override;
- Direction directions() override;
- Options outputOptions() override;
- const char *optionsHelp() override;
- bool probeFile(QIODevice *f) override;
- QVariant loadFile(QIODevice *f, Converter *&outputConverter) override;
- void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) override;
-};
-
class DataStreamConverter : public Converter
{
public:
@@ -73,13 +13,14 @@ public:
// Converter interface
public:
- QString name() override;
- Direction directions() override;
- Options outputOptions() override;
- const char *optionsHelp() override;
- bool probeFile(QIODevice *f) override;
- QVariant loadFile(QIODevice *f, Converter *&outputConverter) override;
- void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) override;
+ QString name() const override;
+ Directions directions() const override;
+ Options outputOptions() const override;
+ const char *optionsHelp() const override;
+ bool probeFile(QIODevice *f) const override;
+ QVariant loadFile(QIODevice *f, const Converter *&outputConverter) const override;
+ void saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const override;
};
#endif // DATASTREAMCONVERTER_H
diff --git a/examples/corelib/serialization/convert/debugtextdumper.cpp b/examples/corelib/serialization/convert/debugtextdumper.cpp
new file mode 100644
index 0000000000..f010bd8e2a
--- /dev/null
+++ b/examples/corelib/serialization/convert/debugtextdumper.cpp
@@ -0,0 +1,74 @@
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "debugtextdumper.h"
+#include "variantorderedmap.h"
+
+#include <QDebug>
+#include <QTextStream>
+
+using namespace Qt::StringLiterals;
+
+// Static instance is declared in datastreamconverter.cpp, since it uses it.
+
+static QString dumpVariant(const QVariant &v, const QString &indent = "\n"_L1)
+{
+ QString result;
+ QString indented = indent + " "_L1;
+
+ int type = v.userType();
+ if (type == qMetaTypeId<VariantOrderedMap>() || type == QMetaType::QVariantMap) {
+ const auto map = (type == QMetaType::QVariantMap) ? VariantOrderedMap(v.toMap())
+ : qvariant_cast<VariantOrderedMap>(v);
+
+ result = "Map {"_L1;
+ for (const auto &pair : map) {
+ result += indented + dumpVariant(pair.first, indented);
+ result.chop(1); // remove comma
+ result += " => "_L1 + dumpVariant(pair.second, indented);
+ }
+ result.chop(1); // remove comma
+ result += indent + "},"_L1;
+ } else if (type == QMetaType::QVariantList) {
+ const QVariantList list = v.toList();
+
+ result = "List ["_L1;
+ for (const auto &item : list)
+ result += indented + dumpVariant(item, indented);
+ result.chop(1); // remove comma
+ result += indent + "],"_L1;
+ } else {
+ QDebug debug(&result);
+ debug.nospace() << v << ',';
+ }
+ return result;
+}
+
+QString DebugTextDumper::name() const
+{
+ return "debugtext-dump"_L1;
+}
+
+Converter::Directions DebugTextDumper::directions() const
+{
+ return Direction::Out;
+}
+
+Converter::Options DebugTextDumper::outputOptions() const
+{
+ return SupportsArbitraryMapKeys;
+}
+
+void DebugTextDumper::saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const
+{
+ if (!options.isEmpty()) {
+ qFatal("Unknown option '%s' to debug text output. This format has no options.",
+ qPrintable(options.first()));
+ }
+ QString s = dumpVariant(contents);
+ s[s.size() - 1] = u'\n'; // replace the comma with newline
+
+ QTextStream out(f);
+ out << s;
+}
diff --git a/examples/corelib/serialization/convert/debugtextdumper.h b/examples/corelib/serialization/convert/debugtextdumper.h
new file mode 100644
index 0000000000..7d3d762104
--- /dev/null
+++ b/examples/corelib/serialization/convert/debugtextdumper.h
@@ -0,0 +1,20 @@
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef DEBUGTEXTDUMPER_H
+#define DEBUGTEXTDUMPER_H
+
+#include "converter.h"
+
+class DebugTextDumper : public Converter
+{
+ // Converter interface
+public:
+ QString name() const override;
+ Directions directions() const override;
+ Options outputOptions() const override;
+ void saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const override;
+};
+
+#endif // DEBUGTEXTDUMPER_H
diff --git a/examples/corelib/serialization/convert/doc/images/convert.png b/examples/corelib/serialization/convert/doc/images/convert.png
new file mode 100644
index 0000000000..53e05b4333
--- /dev/null
+++ b/examples/corelib/serialization/convert/doc/images/convert.png
Binary files differ
diff --git a/examples/corelib/serialization/convert/doc/src/convert.qdoc b/examples/corelib/serialization/convert/doc/src/convert.qdoc
new file mode 100644
index 0000000000..187e81a85e
--- /dev/null
+++ b/examples/corelib/serialization/convert/doc/src/convert.qdoc
@@ -0,0 +1,156 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example serialization/convert
+ \examplecategory {Data Processing & I/O}
+ \meta tag {network}
+ \title Serialization Converter
+
+ \brief How to convert between different serialization formats.
+
+ This example converts between JSON, CBOR, XML, QDataStream and some simple
+ text formats. It can auto-detect the format being used, or be told which
+ format to use. Not all formats support both input and output, and they have
+ different sets of which content datatypes they support. QDataStream and XML
+ are the richest, followed by CBOR, then JSON, and then the plain text
+ formats. Conversion via the less capable formats is apt to lose structure
+ from the data.
+
+ \image convert.png
+
+ \sa {Parsing and displaying CBOR data}, {Saving and Loading a Game}
+
+ \section1 The Converter Class
+
+ The Converter class is the abstract superclass for all the converters to and
+ from all the formats. They all convert from or to the QVariant class, which
+ is used to represent all the datastructures internally.
+
+ \snippet serialization/convert/converter.h 0
+
+ The Converter constructor and destructor manage a list of available
+ converters used by the main program so that it knows what converters are
+ available. Each converter type defines a static instance that ensures it is
+ constructed and thus available to the main program via this list. The \c
+ allConverters() method provides \c main()'s code with access to the list.
+
+ \snippet serialization/convert/converter.cpp 0
+
+ The name() function returns the name of the converter. The directions()
+ function is used to determine if a converter can be used for input, output,
+ or both. These enable the main program to report what converters are
+ available in its help text for the command-line options to select input and
+ output formats.
+
+ \snippet serialization/convert/main.cpp 0
+
+ The optionsHelp() function is used to report the various command-line
+ options supported by the available formats, when queried using its \c
+ {--format-options <format>} command-line option.
+
+ \snippet serialization/convert/main.cpp 1
+
+ The outputOptions() function reports the output capabilities of a converter.
+ At present the only optional feature is support for arbitrary keys in
+ mappings from keys to values. An input converter's loadFile() can use this
+ information to tailor the form in which it presents the data it has read, to
+ be as faithfully represented by the output converter as its capabilities
+ permit.
+
+ The probeFile() function is used to determine if a file matches the format
+ of the converter. The main program uses this to determine what format to use
+ when reading or writing a file, based on its name and potentially content,
+ when the user has not specified the format to use on the command-line.
+
+ The loadFile() function deserializes data. The caller tells loadFile() which
+ serializer it intends to use, so that loadFile() can query its
+ outputOptions() to determine the form in which to represent the loaded data.
+ If the caller hasn't settled on a choice of output converter, loadFile()
+ supplies it with a default output converter suitable to the data it is
+ returning.
+
+ The saveFile() function serializes data. It is passed options from the
+ command-line, as described by loadHelp(), that can tune the details of how
+ it represents the data when saving to file.
+
+ Both loadFile() and saveFile() can be used with an arbitrary \l QIODevice.
+ This means that a Converter could also be used with a network socket or
+ other source of data, to read from or write to. In the present program, the
+ main program always passes a \l QFile, accessing either a file on disk or
+ one of the standard streams of the process.
+
+ \section2 The Available Converters
+
+ Several converters are supported, illustrating how the converter program
+ could be adapted to other formats, should the need arise. See the source
+ code for each for its details. The CBOR converters serve as a relatively
+ full-featured illustration of the ways converters can work, that we'll look
+ into in more detail below. This table summarizes the available converters:
+
+ \table
+ \header \li Class \li mode \li format
+ \row \li CborConverter \li In/Out \li CBOR
+ \row \li CborDiagnosticDumper \li Out \li CBOR diagnostic
+ \row \li DataStreamConverter \li In/Out \li QDataStream
+ \row \li DebugTextDumper \li Out \li Lossless, non-standard, human-readable
+ \row \li JsonConverter \li In/Out \li JSON
+ \row \li NullConverter \li Out \li No output
+ \row \li TextConverter \li In/Out \li Structured plain text
+ \row \li XmlConverter \li In/Out \li XML
+ \endtable
+
+ Those that support input use themselves as loadFile()'s fallback converter,
+ except for the CBOR and QDataStream converters, which use their respective
+ output-only dumper companion classes. The null converter can be used as
+ output converter when running the program for the sake of any validation or
+ verification that an input converter may perform.
+
+ \section2 The CborConverter and CborDiagnosticDumper Classes
+
+ The CborConverter class supports serializing to and from the CBOR format.
+ It supports various options to configure the output of floating point values
+ and a \c{signature} option to determine whether to start its output with a
+ CBOR tag that serves as a file header, identifying the file as containing
+ CBOR data.
+
+ There is also a CborDiagnosticDumper class to output in CBOR diagnostic
+ notation. It does not support loading data. The form of its output can be
+ configured using two options. One selects whether to use the (more verbose)
+ extended CBOR diagnostic format. The other control whether each CBOR value
+ appears on a separate line.
+
+ The plain diagnostic notation is similar to JSON, but not exactly, because
+ it supports displaying the contents of a CBOR stream losslessly, while a
+ conversion to JSON can be lossy. CborConverter's loadFile() uses
+ CborDiagnosticDumper for the fallback output converter, if its caller hasn't
+ determined the output format for itself.
+
+ The convertCborValue(), convertCborMap() and convertCborArray() helper
+ functions are used to convert a QCborValue to a QVariant, for the benefit of
+ CborConverter::loadFile().
+
+ \snippet serialization/convert/cborconverter.cpp 0
+
+ The convertFromVariant() function is used to convert a QVariant to a
+ QCborValue for output by the \c saveFile() of either class.
+
+ \snippet serialization/convert/cborconverter.cpp 1
+
+ \sa {CBOR Support in Qt}
+
+ \section1 The convert program
+
+ The \c main() function sets up a \l QApplication and a \l QCommandLineParser
+ to make sense of the options the user has specified and provide help if the
+ user asks for it. It uses the values obtained for the various \l
+ QCommandLineOption instances describing the user's choices, plus the
+ positional arguments for file names, to prepare the converters it will use.
+
+ It then uses its input converter to load data (and possibly resolve its
+ choice of output converter, if it hasn't selected one yet) and its output
+ converter to serialize that data, taking account of any output options the
+ user has supplied on the command-line.
+
+ \snippet serialization/convert/main.cpp 2
+*/
diff --git a/examples/corelib/serialization/convert/jsonconverter.cpp b/examples/corelib/serialization/convert/jsonconverter.cpp
index ec24af703d..1b59ed5c1f 100644
--- a/examples/corelib/serialization/convert/jsonconverter.cpp
+++ b/examples/corelib/serialization/convert/jsonconverter.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "jsonconverter.h"
@@ -56,49 +9,39 @@
#include <QJsonObject>
#include <QJsonValue>
+using namespace Qt::StringLiterals;
+
static JsonConverter jsonConverter;
-static const char optionHelp[] =
- "compact=no|yes Use compact JSON form.\n";
+static const char jsonOptionHelp[] = "compact=no|yes Use compact JSON form.\n";
static QJsonDocument convertFromVariant(const QVariant &v)
{
QJsonDocument doc = QJsonDocument::fromVariant(v);
- if (!doc.isObject() && !doc.isArray()) {
- fprintf(stderr, "Could not convert contents to JSON.\n");
- exit(EXIT_FAILURE);
- }
+ if (!doc.isObject() && !doc.isArray())
+ qFatal("Could not convert contents to JSON.");
return doc;
}
-JsonConverter::JsonConverter()
-{
-}
-
-QString JsonConverter::name()
-{
- return "json";
-}
-
-Converter::Direction JsonConverter::directions()
+QString JsonConverter::name() const
{
- return InOut;
+ return "json"_L1;
}
-Converter::Options JsonConverter::outputOptions()
+Converter::Directions JsonConverter::directions() const
{
- return {};
+ return Direction::InOut;
}
-const char *JsonConverter::optionsHelp()
+const char *JsonConverter::optionsHelp() const
{
- return optionHelp;
+ return jsonOptionHelp;
}
-bool JsonConverter::probeFile(QIODevice *f)
+bool JsonConverter::probeFile(QIODevice *f) const
{
if (QFile *file = qobject_cast<QFile *>(f)) {
- if (file->fileName().endsWith(QLatin1String(".json")))
+ if (file->fileName().endsWith(".json"_L1))
return true;
}
@@ -109,7 +52,7 @@ bool JsonConverter::probeFile(QIODevice *f)
return false;
}
-QVariant JsonConverter::loadFile(QIODevice *f, Converter *&outputConverter)
+QVariant JsonConverter::loadFile(QIODevice *f, const Converter *&outputConverter) const
{
if (!outputConverter)
outputConverter = this;
@@ -125,26 +68,26 @@ QVariant JsonConverter::loadFile(QIODevice *f, Converter *&outputConverter)
if (doc.isNull())
doc = QJsonDocument::fromJson(f->readAll(), &error);
if (error.error) {
- fprintf(stderr, "Could not parse JSON content: offset %d: %s",
- error.offset, qPrintable(error.errorString()));
- exit(EXIT_FAILURE);
+ qFatal("Could not parse JSON content: offset %d: %s",
+ error.offset, qPrintable(error.errorString()));
}
- if (outputConverter == null)
+ if (isNull(outputConverter))
return QVariant();
return doc.toVariant();
}
-void JsonConverter::saveFile(QIODevice *f, const QVariant &contents, const QStringList &options)
+void JsonConverter::saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const
{
QJsonDocument::JsonFormat format = QJsonDocument::Indented;
for (const QString &s : options) {
- if (s == QLatin1String("compact=no")) {
+ if (s == "compact=no"_L1) {
format = QJsonDocument::Indented;
- } else if (s == QLatin1String("compact=yes")) {
+ } else if (s == "compact=yes"_L1) {
format = QJsonDocument::Compact;
} else {
- fprintf(stderr, "Unknown option '%s' to JSON output. Valid options are:\n%s", qPrintable(s), optionHelp);
- exit(EXIT_FAILURE);
+ qFatal("Unknown option '%s' to JSON output. Valid options are:\n%s",
+ qPrintable(s), jsonOptionHelp);
}
}
diff --git a/examples/corelib/serialization/convert/jsonconverter.h b/examples/corelib/serialization/convert/jsonconverter.h
index 445a0e6695..e1dd1ecdb4 100644
--- a/examples/corelib/serialization/convert/jsonconverter.h
+++ b/examples/corelib/serialization/convert/jsonconverter.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef JSONCONVERTER_H
#define JSONCONVERTER_H
@@ -55,18 +8,15 @@
class JsonConverter : public Converter
{
-public:
- JsonConverter();
-
// Converter interface
public:
- QString name() override;
- Direction directions() override;
- Options outputOptions() override;
- const char *optionsHelp() override;
- bool probeFile(QIODevice *f) override;
- QVariant loadFile(QIODevice *f, Converter *&outputConverter) override;
- void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) override;
+ QString name() const override;
+ Directions directions() const override;
+ const char *optionsHelp() const override;
+ bool probeFile(QIODevice *f) const override;
+ QVariant loadFile(QIODevice *f, const Converter *&outputConverter) const override;
+ void saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const override;
};
#endif // JSONCONVERTER_H
diff --git a/examples/corelib/serialization/convert/main.cpp b/examples/corelib/serialization/convert/main.cpp
index 161fec6bcd..d3021fadca 100644
--- a/examples/corelib/serialization/convert/main.cpp
+++ b/examples/corelib/serialization/convert/main.cpp
@@ -1,52 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "converter.h"
@@ -58,177 +12,144 @@
#include <stdio.h>
-static QList<Converter *> *availableConverters;
+using namespace Qt::StringLiterals;
-Converter::Converter()
+static const Converter *prepareConverter(QString format, Converter::Direction direction,
+ QFile *stream)
{
- if (!availableConverters)
- availableConverters = new QList<Converter *>;
- availableConverters->append(this);
-}
+ const bool out = direction == Converter::Direction::Out;
+ const QIODevice::OpenMode mode = out
+ ? QIODevice::WriteOnly | QIODevice::Truncate
+ : QIODevice::ReadOnly;
+ const char *dirn = out ? "output" : "input";
+
+ if (stream->fileName().isEmpty())
+ stream->open(out ? stdout : stdin, mode);
+ else
+ stream->open(mode);
+
+ if (!stream->isOpen()) {
+ qFatal("Could not open \"%s\" for %s: %s",
+ qPrintable(stream->fileName()), dirn, qPrintable(stream->errorString()));
+ } else if (format == "auto"_L1) {
+ for (const Converter *conv : Converter::allConverters()) {
+ if (conv->directions().testFlag(direction) && conv->probeFile(stream))
+ return conv;
+ }
+ if (out) // Failure to identify output format can be remedied by loadFile().
+ return nullptr;
-Converter::~Converter()
-{
- availableConverters->removeAll(this);
+ // Input format, however, we must know before we can call that:
+ qFatal("Could not determine input format. Specify it with the -I option.");
+ } else {
+ for (const Converter *conv : Converter::allConverters()) {
+ if (conv->name() == format) {
+ if (!conv->directions().testFlag(direction)) {
+ qWarning("File format \"%s\" cannot be used for %s",
+ qPrintable(format), dirn);
+ continue; // on the off chance there's another with the same name
+ }
+ return conv;
+ }
+ }
+ qFatal("Unknown %s file format \"%s\"", dirn, qPrintable(format));
+ }
+ Q_UNREACHABLE_RETURN(nullptr);
}
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
+//! [0]
QStringList inputFormats;
QStringList outputFormats;
- for (Converter *conv : qAsConst(*availableConverters)) {
+ for (const Converter *conv : Converter::allConverters()) {
auto direction = conv->directions();
QString name = conv->name();
- if (direction & Converter::In)
+ if (direction.testFlag(Converter::Direction::In))
inputFormats << name;
- if (direction & Converter::Out)
+ if (direction.testFlag(Converter::Direction::Out))
outputFormats << name;
}
+//! [0]
inputFormats.sort();
outputFormats.sort();
- inputFormats.prepend("auto");
- outputFormats.prepend("auto");
+ inputFormats.prepend("auto"_L1);
+ outputFormats.prepend("auto"_L1);
QCommandLineParser parser;
- parser.setApplicationDescription(QStringLiteral("Qt file format conversion tool"));
+ parser.setApplicationDescription("Qt serialization format conversion tool"_L1);
parser.addHelpOption();
- QCommandLineOption inputFormatOption(QStringList{"I", "input-format"});
- inputFormatOption.setDescription(QLatin1String("Select the input format for the input file. Available formats: ") +
- inputFormats.join(", "));
- inputFormatOption.setValueName("format");
+ QCommandLineOption inputFormatOption(QStringList{ "I"_L1, "input-format"_L1 });
+ inputFormatOption.setDescription(
+ "Select the input format for the input file. Available formats: "_L1
+ + inputFormats.join(", "_L1));
+ inputFormatOption.setValueName("format"_L1);
inputFormatOption.setDefaultValue(inputFormats.constFirst());
parser.addOption(inputFormatOption);
- QCommandLineOption outputFormatOption(QStringList{"O", "output-format"});
- outputFormatOption.setDescription(QLatin1String("Select the output format for the output file. Available formats: ") +
- outputFormats.join(", "));
- outputFormatOption.setValueName("format");
+ QCommandLineOption outputFormatOption(QStringList{ "O"_L1, "output-format"_L1 });
+ outputFormatOption.setDescription(
+ "Select the output format for the output file. Available formats: "_L1
+ + outputFormats.join(", "_L1));
+ outputFormatOption.setValueName("format"_L1);
outputFormatOption.setDefaultValue(outputFormats.constFirst());
parser.addOption(outputFormatOption);
- QCommandLineOption optionOption(QStringList{"o", "option"});
- optionOption.setDescription(QStringLiteral("Format-specific options. Use --format-options to find out what options are available."));
- optionOption.setValueName("options...");
+ QCommandLineOption optionOption(QStringList{ "o"_L1, "option"_L1 });
+ optionOption.setDescription(
+ "Format-specific options. Use --format-options to find out what options are available."_L1);
+ optionOption.setValueName("options..."_L1);
optionOption.setDefaultValues({});
parser.addOption(optionOption);
- QCommandLineOption formatOptionsOption("format-options");
- formatOptionsOption.setDescription(QStringLiteral("Prints the list of valid options for --option for the converter format <format>."));
- formatOptionsOption.setValueName("format");
+ QCommandLineOption formatOptionsOption("format-options"_L1);
+ formatOptionsOption.setDescription(
+ "Prints the list of valid options for --option for the converter format <format>."_L1);
+ formatOptionsOption.setValueName("format"_L1);
parser.addOption(formatOptionsOption);
- parser.addPositionalArgument(QStringLiteral("[source]"),
- QStringLiteral("File to read from (stdin if none)"));
- parser.addPositionalArgument(QStringLiteral("[destination]"),
- QStringLiteral("File to write to (stdout if none)"));
+ parser.addPositionalArgument("[source]"_L1, "File to read from (stdin if none)"_L1);
+ parser.addPositionalArgument("[destination]"_L1, "File to write to (stdout if none)"_L1);
parser.process(app);
if (parser.isSet(formatOptionsOption)) {
QString format = parser.value(formatOptionsOption);
- for (Converter *conv : qAsConst(*availableConverters)) {
+//! [1]
+ for (const Converter *conv : Converter::allConverters()) {
if (conv->name() == format) {
const char *help = conv->optionsHelp();
- if (help)
- printf("The following options are available for format '%s':\n\n%s", qPrintable(format), help);
- else
- printf("Format '%s' supports no options.\n", qPrintable(format));
+ if (help) {
+ qInfo("The following options are available for format '%s':\n\n%s",
+ qPrintable(format), help);
+ } else {
+ qInfo("Format '%s' supports no options.", qPrintable(format));
+ }
return EXIT_SUCCESS;
}
}
+//! [1]
- fprintf(stderr, "Unknown file format '%s'\n", qPrintable(format));
- return EXIT_FAILURE;
- }
-
- Converter *inconv = nullptr;
- QString format = parser.value(inputFormatOption);
- if (format != "auto") {
- for (Converter *conv : qAsConst(*availableConverters)) {
- if (conv->name() == format) {
- inconv = conv;
- break;
- }
- }
-
- if (!inconv) {
- fprintf(stderr, "Unknown file format \"%s\"\n", qPrintable(format));
- return EXIT_FAILURE;
- }
- }
-
- Converter *outconv = nullptr;
- format = parser.value(outputFormatOption);
- if (format != "auto") {
- for (Converter *conv : qAsConst(*availableConverters)) {
- if (conv->name() == format) {
- outconv = conv;
- break;
- }
- }
-
- if (!outconv) {
- fprintf(stderr, "Unknown file format \"%s\"\n", qPrintable(format));
- return EXIT_FAILURE;
- }
+ qFatal("Unknown file format '%s'", qPrintable(format));
}
+//! [2]
QStringList files = parser.positionalArguments();
QFile input(files.value(0));
QFile output(files.value(1));
+ const Converter *inconv = prepareConverter(parser.value(inputFormatOption),
+ Converter::Direction::In, &input);
+ const Converter *outconv = prepareConverter(parser.value(outputFormatOption),
+ Converter::Direction::Out, &output);
- if (input.fileName().isEmpty())
- input.open(stdin, QIODevice::ReadOnly);
- else
- input.open(QIODevice::ReadOnly);
- if (!input.isOpen()) {
- fprintf(stderr, "Could not open \"%s\" for reading: %s\n",
- qPrintable(input.fileName()), qPrintable(input.errorString()));
- return EXIT_FAILURE;
- }
-
- if (output.fileName().isEmpty())
- output.open(stdout, QIODevice::WriteOnly | QIODevice::Truncate);
- else
- output.open(QIODevice::WriteOnly | QIODevice::Truncate);
- if (!output.isOpen()) {
- fprintf(stderr, "Could not open \"%s\" for writing: %s\n",
- qPrintable(output.fileName()), qPrintable(output.errorString()));
- return EXIT_FAILURE;
- }
-
- if (!inconv) {
- // probe the input to find a file format
- for (Converter *conv : qAsConst(*availableConverters)) {
- if (conv->directions() & Converter::In && conv->probeFile(&input)) {
- inconv = conv;
- break;
- }
- }
-
- if (!inconv) {
- fprintf(stderr, "Could not determine input format. pass -I option.\n");
- return EXIT_FAILURE;
- }
- }
-
- if (!outconv) {
- // probe the output to find a file format
- for (Converter *conv : qAsConst(*availableConverters)) {
- if (conv->directions() & Converter::Out && conv->probeFile(&output)) {
- outconv = conv;
- break;
- }
- }
- }
-
- // now finally perform the conversion
+ // Now finally perform the conversion:
QVariant data = inconv->loadFile(&input, outconv);
- Q_ASSERT_X(outconv, "Converter Tool",
+ Q_ASSERT_X(outconv, "Serialization Converter",
"Internal error: converter format did not provide default");
outconv->saveFile(&output, data, parser.values(optionOption));
return EXIT_SUCCESS;
+//! [2]
}
diff --git a/examples/corelib/serialization/convert/nullconverter.cpp b/examples/corelib/serialization/convert/nullconverter.cpp
index 2de492e64e..fb8be5c944 100644
--- a/examples/corelib/serialization/convert/nullconverter.cpp
+++ b/examples/corelib/serialization/convert/nullconverter.cpp
@@ -1,97 +1,37 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "nullconverter.h"
-static NullConverter nullConverter;
-Converter* Converter::null = &nullConverter;
-
-QString NullConverter::name()
-{
- return QLatin1String("null");
-}
-
-Converter::Direction NullConverter::directions()
-{
- return Out;
-}
+using namespace Qt::StringLiterals;
-Converter::Options NullConverter::outputOptions()
+static NullConverter nullConverter;
+bool Converter::isNull(const Converter *converter)
{
- return SupportsArbitraryMapKeys;
+ return converter == &nullConverter;
}
-const char *NullConverter::optionsHelp()
+QString NullConverter::name() const
{
- return nullptr;
+ return "null"_L1;
}
-bool NullConverter::probeFile(QIODevice *f)
+Converter::Directions NullConverter::directions() const
{
- Q_UNUSED(f);
- return false;
+ return Direction::Out;
}
-QVariant NullConverter::loadFile(QIODevice *f, Converter *&outputConverter)
+Converter::Options NullConverter::outputOptions() const
{
- Q_UNUSED(f);
- Q_UNUSED(outputConverter);
- outputConverter = this;
- return QVariant();
+ return SupportsArbitraryMapKeys;
}
-void NullConverter::saveFile(QIODevice *f, const QVariant &contents, const QStringList &options)
+void NullConverter::saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const
{
if (!options.isEmpty()) {
- fprintf(stderr, "Unknown option '%s' to null output. This format has no options.\n", qPrintable(options.first()));
- exit(EXIT_FAILURE);
+ qFatal("Unknown option '%s' to null output. This format has no options.",
+ qPrintable(options.first()));
}
Q_UNUSED(f);
diff --git a/examples/corelib/serialization/convert/nullconverter.h b/examples/corelib/serialization/convert/nullconverter.h
index af7339f092..1bdf9f22f7 100644
--- a/examples/corelib/serialization/convert/nullconverter.h
+++ b/examples/corelib/serialization/convert/nullconverter.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef NULLCONVERTER_H
#define NULLCONVERTER_H
@@ -57,13 +10,11 @@ class NullConverter : public Converter
{
// Converter interface
public:
- QString name() override;
- Direction directions() override;
- Options outputOptions() override;
- const char *optionsHelp() override;
- bool probeFile(QIODevice *f) override;
- QVariant loadFile(QIODevice *f, Converter *&outputConverter) override;
- void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) override;
+ QString name() const override;
+ Directions directions() const override;
+ Options outputOptions() const override;
+ void saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const override;
};
#endif // NULLCONVERTER_H
diff --git a/examples/corelib/serialization/convert/textconverter.cpp b/examples/corelib/serialization/convert/textconverter.cpp
index ae03b9a334..1f8b4f9c19 100644
--- a/examples/corelib/serialization/convert/textconverter.cpp
+++ b/examples/corelib/serialization/convert/textconverter.cpp
@@ -1,58 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "textconverter.h"
#include <QFile>
#include <QTextStream>
+using namespace Qt::StringLiterals;
+
static void dumpVariant(QTextStream &out, const QVariant &v)
{
switch (v.userType()) {
@@ -89,68 +44,52 @@ static void dumpVariant(QTextStream &out, const QVariant &v)
}
}
-QString TextConverter::name()
-{
- return QStringLiteral("text");
-}
-
-Converter::Direction TextConverter::directions()
-{
- return InOut;
-}
-
-Converter::Options TextConverter::outputOptions()
+QString TextConverter::name() const
{
- return {};
+ return "text"_L1;
}
-const char *TextConverter::optionsHelp()
+Converter::Directions TextConverter::directions() const
{
- return nullptr;
+ return Direction::InOut;
}
-bool TextConverter::probeFile(QIODevice *f)
+bool TextConverter::probeFile(QIODevice *f) const
{
if (QFile *file = qobject_cast<QFile *>(f))
- return file->fileName().endsWith(QLatin1String(".txt"));
+ return file->fileName().endsWith(".txt"_L1);
return false;
}
-QVariant TextConverter::loadFile(QIODevice *f, Converter *&outputConverter)
+QVariant TextConverter::loadFile(QIODevice *f, const Converter *&outputConverter) const
{
if (!outputConverter)
outputConverter = this;
QVariantList list;
QTextStream in(f);
- QString line ;
+ QString line;
while (!in.atEnd()) {
in.readLineInto(&line);
-
bool ok;
- qint64 v = line.toLongLong(&ok);
- if (ok) {
- list.append(v);
- continue;
- }
- double d = line.toDouble(&ok);
- if (ok) {
+ if (qint64 v = line.toLongLong(&ok); ok)
+ list.append(v);
+ else if (double d = line.toDouble(&ok); ok)
list.append(d);
- continue;
- }
-
- list.append(line);
+ else
+ list.append(line);
}
return list;
}
-void TextConverter::saveFile(QIODevice *f, const QVariant &contents, const QStringList &options)
+void TextConverter::saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const
{
if (!options.isEmpty()) {
- fprintf(stderr, "Unknown option '%s' to text output. This format has no options.\n", qPrintable(options.first()));
- exit(EXIT_FAILURE);
+ qFatal("Unknown option '%s' to text output. This format has no options.",
+ qPrintable(options.first()));
}
QTextStream out(f);
diff --git a/examples/corelib/serialization/convert/textconverter.h b/examples/corelib/serialization/convert/textconverter.h
index 66f5136c02..526f295517 100644
--- a/examples/corelib/serialization/convert/textconverter.h
+++ b/examples/corelib/serialization/convert/textconverter.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TEXTCONVERTER_H
#define TEXTCONVERTER_H
@@ -55,16 +8,14 @@
class TextConverter : public Converter
{
-
// Converter interface
public:
- QString name() override;
- Direction directions() override;
- Options outputOptions() override;
- const char *optionsHelp() override;
- bool probeFile(QIODevice *f) override;
- QVariant loadFile(QIODevice *f, Converter *&outputConverter) override;
- void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) override;
+ QString name() const override;
+ Directions directions() const override;
+ bool probeFile(QIODevice *f) const override;
+ QVariant loadFile(QIODevice *f, const Converter *&outputConverter) const override;
+ void saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const override;
};
#endif // TEXTCONVERTER_H
diff --git a/examples/corelib/serialization/convert/variantorderedmap.h b/examples/corelib/serialization/convert/variantorderedmap.h
new file mode 100644
index 0000000000..c65316b182
--- /dev/null
+++ b/examples/corelib/serialization/convert/variantorderedmap.h
@@ -0,0 +1,24 @@
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef VARIANTORDEREDMAP_H
+#define VARIANTORDEREDMAP_H
+
+#include <QList>
+#include <QPair>
+#include <QVariant>
+#include <QVariantMap>
+
+class VariantOrderedMap : public QList<QPair<QVariant, QVariant>>
+{
+public:
+ VariantOrderedMap() = default;
+ VariantOrderedMap(const QVariantMap &map)
+ {
+ reserve(map.size());
+ for (auto it = map.begin(); it != map.end(); ++it)
+ append({it.key(), it.value()});
+ }
+};
+
+#endif // VARIANTORDEREDMAP_H
diff --git a/examples/corelib/serialization/convert/xmlconverter.cpp b/examples/corelib/serialization/convert/xmlconverter.cpp
index c2811c5745..ef71fecb9f 100644
--- a/examples/corelib/serialization/convert/xmlconverter.cpp
+++ b/examples/corelib/serialization/convert/xmlconverter.cpp
@@ -1,54 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "xmlconverter.h"
+#include "variantorderedmap.h"
#include <QBitArray>
#include <QtCborCommon>
@@ -60,8 +14,9 @@
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
-static const char optionHelp[] =
- "compact=no|yes Use compact XML form.\n";
+using namespace Qt::StringLiterals;
+
+static const char xmlOptionHelp[] = "compact=no|yes Use compact XML form.\n";
static XmlConverter xmlConverter;
@@ -70,7 +25,7 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
static QVariantList listFromXml(QXmlStreamReader &xml, Converter::Options options)
{
QVariantList list;
- while (!xml.atEnd() && !(xml.isEndElement() && xml.name() == QLatin1String("list"))) {
+ while (!xml.atEnd() && !(xml.isEndElement() && xml.name() == "list"_L1)) {
xml.readNext();
switch (xml.tokenType()) {
case QXmlStreamReader::StartElement:
@@ -94,20 +49,19 @@ static QVariantList listFromXml(QXmlStreamReader &xml, Converter::Options option
break;
}
- fprintf(stderr, "%lld:%lld: Invalid XML %s '%s'.\n",
- xml.lineNumber(), xml.columnNumber(),
- qPrintable(xml.tokenString()), qPrintable(xml.name().toString()));
- exit(EXIT_FAILURE);
+ qFatal("%lld:%lld: Invalid XML %s '%s'.", xml.lineNumber(), xml.columnNumber(),
+ qPrintable(xml.tokenString()), qPrintable(xml.name().toString()));
}
xml.readNext();
return list;
}
-static VariantOrderedMap::value_type mapEntryFromXml(QXmlStreamReader &xml, Converter::Options options)
+static VariantOrderedMap::value_type mapEntryFromXml(QXmlStreamReader &xml,
+ Converter::Options options)
{
QVariant key, value;
- while (!xml.atEnd() && !(xml.isEndElement() && xml.name() == QLatin1String("entry"))) {
+ while (!xml.atEnd() && !(xml.isEndElement() && xml.name() == "entry"_L1)) {
xml.readNext();
switch (xml.tokenType()) {
case QXmlStreamReader::StartElement:
@@ -136,10 +90,8 @@ static VariantOrderedMap::value_type mapEntryFromXml(QXmlStreamReader &xml, Conv
break;
}
- fprintf(stderr, "%lld:%lld: Invalid XML %s '%s'.\n",
- xml.lineNumber(), xml.columnNumber(),
- qPrintable(xml.tokenString()), qPrintable(xml.name().toString()));
- exit(EXIT_FAILURE);
+ qFatal("%lld:%lld: Invalid XML %s '%s'.", xml.lineNumber(), xml.columnNumber(),
+ qPrintable(xml.tokenString()), qPrintable(xml.name().toString()));
}
return { key, value };
@@ -150,11 +102,11 @@ static QVariant mapFromXml(QXmlStreamReader &xml, Converter::Options options)
QVariantMap map1;
VariantOrderedMap map2;
- while (!xml.atEnd() && !(xml.isEndElement() && xml.name() == QLatin1String("map"))) {
+ while (!xml.atEnd() && !(xml.isEndElement() && xml.name() == "map"_L1)) {
xml.readNext();
switch (xml.tokenType()) {
case QXmlStreamReader::StartElement:
- if (xml.name() == QLatin1String("entry")) {
+ if (xml.name() == "entry"_L1) {
auto pair = mapEntryFromXml(xml, options);
if (options & Converter::SupportsArbitraryMapKeys)
map2.append(pair);
@@ -181,10 +133,8 @@ static QVariant mapFromXml(QXmlStreamReader &xml, Converter::Options options)
break;
}
- fprintf(stderr, "%lld:%lld: Invalid XML %s '%s'.\n",
- xml.lineNumber(), xml.columnNumber(),
- qPrintable(xml.tokenString()), qPrintable(xml.name().toString()));
- exit(EXIT_FAILURE);
+ qFatal("%lld:%lld: Invalid XML %s '%s'.", xml.lineNumber(), xml.columnNumber(),
+ qPrintable(xml.tokenString()), qPrintable(xml.name().toString()));
}
xml.readNext();
@@ -196,18 +146,17 @@ static QVariant mapFromXml(QXmlStreamReader &xml, Converter::Options options)
static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options)
{
QStringView name = xml.name();
- if (name == QLatin1String("list"))
+ if (name == "list"_L1)
return listFromXml(xml, options);
- if (name == QLatin1String("map"))
+ if (name == "map"_L1)
return mapFromXml(xml, options);
- if (name != QLatin1String("value")) {
- fprintf(stderr, "%lld:%lld: Invalid XML key '%s'.\n",
- xml.lineNumber(), xml.columnNumber(), qPrintable(name.toString()));
- exit(EXIT_FAILURE);
+ if (name != "value"_L1) {
+ qFatal("%lld:%lld: Invalid XML key '%s'.",
+ xml.lineNumber(), xml.columnNumber(), qPrintable(name.toString()));
}
QXmlStreamAttributes attrs = xml.attributes();
- QStringView type = attrs.value(QLatin1String("type"));
+ QStringView type = attrs.value("type"_L1);
forever {
xml.readNext();
@@ -216,10 +165,8 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
if (xml.isCDATA() || xml.isCharacters() || xml.isEndElement())
break;
- fprintf(stderr, "%lld:%lld: Invalid XML %s '%s'.\n",
- xml.lineNumber(), xml.columnNumber(),
- qPrintable(xml.tokenString()), qPrintable(name.toString()));
- exit(EXIT_FAILURE);
+ qFatal("%lld:%lld: Invalid XML %s '%s'.", xml.lineNumber(), xml.columnNumber(),
+ qPrintable(xml.tokenString()), qPrintable(name.toString()));
}
QStringView text = xml.text();
@@ -227,45 +174,43 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
text = text.trimmed();
QVariant result;
- bool ok;
if (type.isEmpty()) {
// ok
- } else if (type == QLatin1String("number")) {
+ } else if (type == "number"_L1) {
// try integer first
+ bool ok;
qint64 v = text.toLongLong(&ok);
if (ok) {
result = v;
} else {
// let's see floating point
double d = text.toDouble(&ok);
- result = d;
if (!ok) {
- fprintf(stderr, "%lld:%lld: Invalid XML: could not interpret '%s' as a number.\n",
- xml.lineNumber(), xml.columnNumber(), qPrintable(text.toString()));
- exit(EXIT_FAILURE);
+ qFatal("%lld:%lld: Invalid XML: could not interpret '%s' as a number.",
+ xml.lineNumber(), xml.columnNumber(), qPrintable(text.toString()));
}
+ result = d;
}
- } else if (type == QLatin1String("bytes")) {
+ } else if (type == "bytes"_L1) {
QByteArray data = text.toLatin1();
QStringView encoding = attrs.value("encoding");
- if (encoding == QLatin1String("base64url")) {
+ if (encoding == "base64url"_L1) {
result = QByteArray::fromBase64(data, QByteArray::Base64UrlEncoding);
- } else if (encoding == QLatin1String("hex")) {
+ } else if (encoding == "hex"_L1) {
result = QByteArray::fromHex(data);
- } else if (encoding.isEmpty() || encoding == QLatin1String("base64")) {
+ } else if (encoding.isEmpty() || encoding == "base64"_L1) {
result = QByteArray::fromBase64(data);
} else {
- fprintf(stderr, "%lld:%lld: Invalid XML: unknown encoding '%s' for bytes.\n",
- xml.lineNumber(), xml.columnNumber(), qPrintable(encoding.toString()));
- exit(EXIT_FAILURE);
+ qFatal("%lld:%lld: Invalid XML: unknown encoding '%s' for bytes.",
+ xml.lineNumber(), xml.columnNumber(), qPrintable(encoding.toString()));
}
- } else if (type == QLatin1String("string")) {
+ } else if (type == "string"_L1) {
result = text.toString();
- } else if (type == QLatin1String("null")) {
+ } else if (type == "null"_L1) {
result = QVariant::fromValue(nullptr);
- } else if (type == QLatin1String("CBOR simple type")) {
+ } else if (type == "CBOR simple type"_L1) {
result = QVariant::fromValue(QCborSimpleType(text.toShort()));
- } else if (type == QLatin1String("bits")) {
+ } else if (type == "bits"_L1) {
QBitArray ba;
ba.resize(text.size());
qsizetype n = 0;
@@ -276,36 +221,33 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
} else if (c == '0') {
++n;
} else if (!c.isSpace()) {
- fprintf(stderr, "%lld:%lld: Invalid XML: invalid bit string '%s'.\n",
- xml.lineNumber(), xml.columnNumber(), qPrintable(text.toString()));
- exit(EXIT_FAILURE);
+ qFatal("%lld:%lld: Invalid XML: invalid bit string '%s'.",
+ xml.lineNumber(), xml.columnNumber(), qPrintable(text.toString()));
}
}
ba.resize(n);
result = ba;
} else {
int id = QMetaType::UnknownType;
- if (type == QLatin1String("datetime"))
+ if (type == "datetime"_L1)
id = QMetaType::QDateTime;
- else if (type == QLatin1String("url"))
+ else if (type == "url"_L1)
id = QMetaType::QUrl;
- else if (type == QLatin1String("uuid"))
+ else if (type == "uuid"_L1)
id = QMetaType::QUuid;
- else if (type == QLatin1String("regex"))
+ else if (type == "regex"_L1)
id = QMetaType::QRegularExpression;
else
id = QMetaType::fromName(type.toLatin1()).id();
if (id == QMetaType::UnknownType) {
- fprintf(stderr, "%lld:%lld: Invalid XML: unknown type '%s'.\n",
- xml.lineNumber(), xml.columnNumber(), qPrintable(type.toString()));
- exit(EXIT_FAILURE);
+ qFatal("%lld:%lld: Invalid XML: unknown type '%s'.",
+ xml.lineNumber(), xml.columnNumber(), qPrintable(type.toString()));
}
result = text.toString();
if (!result.convert(QMetaType(id))) {
- fprintf(stderr, "%lld:%lld: Invalid XML: could not parse content as type '%s'.\n",
- xml.lineNumber(), xml.columnNumber(), qPrintable(type.toString()));
- exit(EXIT_FAILURE);
+ qFatal("%lld:%lld: Invalid XML: could not parse content as type '%s'.",
+ xml.lineNumber(), xml.columnNumber(), qPrintable(type.toString()));
}
}
@@ -314,10 +256,8 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
} while (xml.isComment() || xml.isWhitespace());
if (!xml.isEndElement()) {
- fprintf(stderr, "%lld:%lld: Invalid XML %s '%s'.\n",
- xml.lineNumber(), xml.columnNumber(),
- qPrintable(xml.tokenString()), qPrintable(name.toString()));
- exit(EXIT_FAILURE);
+ qFatal("%lld:%lld: Invalid XML %s '%s'.", xml.lineNumber(), xml.columnNumber(),
+ qPrintable(xml.tokenString()), qPrintable(name.toString()));
}
xml.readNext();
@@ -334,9 +274,9 @@ static void variantToXml(QXmlStreamWriter &xml, const QVariant &v)
variantToXml(xml, v);
xml.writeEndElement();
} else if (type == QMetaType::QVariantMap || type == qMetaTypeId<VariantOrderedMap>()) {
- const VariantOrderedMap map = (type == QMetaType::QVariantMap) ?
- VariantOrderedMap(v.toMap()) :
- qvariant_cast<VariantOrderedMap>(v);
+ const VariantOrderedMap map = (type == QMetaType::QVariantMap)
+ ? VariantOrderedMap(v.toMap())
+ : qvariant_cast<VariantOrderedMap>(v);
xml.writeStartElement("map");
for (const auto &pair : map) {
@@ -348,7 +288,7 @@ static void variantToXml(QXmlStreamWriter &xml, const QVariant &v)
xml.writeEndElement();
} else {
xml.writeStartElement("value");
- QString typeString = QStringLiteral("type");
+ QString typeString = "type"_L1;
switch (type) {
case QMetaType::Short:
case QMetaType::UShort:
@@ -437,8 +377,7 @@ static void variantToXml(QXmlStreamWriter &xml, const QVariant &v)
xml.writeAttribute(typeString, QString::fromLatin1(typeName));
xml.writeCharacters(copy.toString());
} else {
- fprintf(stderr, "XML: don't know how to serialize type '%s'.\n", typeName);
- exit(EXIT_FAILURE);
+ qFatal("XML: don't know how to serialize type '%s'.", typeName);
}
}
}
@@ -446,37 +385,37 @@ static void variantToXml(QXmlStreamWriter &xml, const QVariant &v)
}
}
-QString XmlConverter::name()
+QString XmlConverter::name() const
{
- return QStringLiteral("xml");
+ return "xml"_L1;
}
-Converter::Direction XmlConverter::directions()
+Converter::Directions XmlConverter::directions() const
{
- return InOut;
+ return Direction::InOut;
}
-Converter::Options XmlConverter::outputOptions()
+Converter::Options XmlConverter::outputOptions() const
{
return SupportsArbitraryMapKeys;
}
-const char *XmlConverter::optionsHelp()
+const char *XmlConverter::optionsHelp() const
{
- return optionHelp;
+ return xmlOptionHelp;
}
-bool XmlConverter::probeFile(QIODevice *f)
+bool XmlConverter::probeFile(QIODevice *f) const
{
if (QFile *file = qobject_cast<QFile *>(f)) {
- if (file->fileName().endsWith(QLatin1String(".xml")))
+ if (file->fileName().endsWith(".xml"_L1))
return true;
}
return f->isReadable() && f->peek(5) == "<?xml";
}
-QVariant XmlConverter::loadFile(QIODevice *f, Converter *&outputConverter)
+QVariant XmlConverter::loadFile(QIODevice *f, const Converter *&outputConverter) const
{
if (!outputConverter)
outputConverter = this;
@@ -484,25 +423,24 @@ QVariant XmlConverter::loadFile(QIODevice *f, Converter *&outputConverter)
QXmlStreamReader xml(f);
xml.readNextStartElement();
QVariant v = variantFromXml(xml, outputConverter->outputOptions());
- if (xml.hasError()) {
- fprintf(stderr, "XML error: %s", qPrintable(xml.errorString()));
- exit(EXIT_FAILURE);
- }
+ if (xml.hasError())
+ qFatal("XML error: %s", qPrintable(xml.errorString()));
return v;
}
-void XmlConverter::saveFile(QIODevice *f, const QVariant &contents, const QStringList &options)
+void XmlConverter::saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const
{
bool compact = false;
for (const QString &s : options) {
- if (s == QLatin1String("compact=no")) {
+ if (s == "compact=no"_L1) {
compact = false;
- } else if (s == QLatin1String("compact=yes")) {
+ } else if (s == "compact=yes"_L1) {
compact = true;
} else {
- fprintf(stderr, "Unknown option '%s' to XML output. Valid options are:\n%s", qPrintable(s), optionHelp);
- exit(EXIT_FAILURE);
+ qFatal("Unknown option '%s' to XML output. Valid options are:\n%s",
+ qPrintable(s), xmlOptionHelp);
}
}
diff --git a/examples/corelib/serialization/convert/xmlconverter.h b/examples/corelib/serialization/convert/xmlconverter.h
index 8fc0fea592..4888b0616f 100644
--- a/examples/corelib/serialization/convert/xmlconverter.h
+++ b/examples/corelib/serialization/convert/xmlconverter.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef XMLCONVERTER_H
#define XMLCONVERTER_H
@@ -57,13 +10,14 @@ class XmlConverter : public Converter
{
// Converter interface
public:
- QString name() override;
- Direction directions() override;
- Options outputOptions() override;
- const char *optionsHelp() override;
- bool probeFile(QIODevice *f) override;
- QVariant loadFile(QIODevice *f, Converter *&outputConverter) override;
- void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) override;
+ QString name() const override;
+ Directions directions() const override;
+ Options outputOptions() const override;
+ const char *optionsHelp() const override;
+ bool probeFile(QIODevice *f) const override;
+ QVariant loadFile(QIODevice *f, const Converter *&outputConverter) const override;
+ void saveFile(QIODevice *f, const QVariant &contents,
+ const QStringList &options) const override;
};
#endif // XMLCONVERTER_H
diff --git a/examples/corelib/serialization/savegame/CMakeLists.txt b/examples/corelib/serialization/savegame/CMakeLists.txt
index b0b410bbc5..14621ccc23 100644
--- a/examples/corelib/serialization/savegame/CMakeLists.txt
+++ b/examples/corelib/serialization/savegame/CMakeLists.txt
@@ -1,21 +1,16 @@
-# Generated from savegame.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(savegame LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+if (ANDROID)
+ message(FATAL_ERROR "This project cannot be built on Android.")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/serialization/savegame")
+find_package(Qt6 REQUIRED COMPONENTS Core)
-find_package(Qt6 COMPONENTS Core)
+qt_standard_project_setup()
qt_add_executable(savegame
character.cpp character.h
@@ -23,16 +18,20 @@ qt_add_executable(savegame
level.cpp level.h
main.cpp
)
-set_target_properties(savegame PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(savegame PUBLIC
- Qt::Core
+
+target_link_libraries(savegame PRIVATE
+ Qt6::Core
)
install(TARGETS savegame
- 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 savegame
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/serialization/savegame/character.cpp b/examples/corelib/serialization/savegame/character.cpp
index 046cde3091..863fcb9153 100644
--- a/examples/corelib/serialization/savegame/character.cpp
+++ b/examples/corelib/serialization/savegame/character.cpp
@@ -1,69 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "character.h"
#include <QMetaEnum>
#include <QTextStream>
-Character::Character() :
- mLevel(0),
- mClassType(Warrior) {
-}
+Character::Character() = default;
-Character::Character(const QString &name,
- int level,
- Character::ClassType classType) :
- mName(name),
- mLevel(level),
- mClassType(classType)
+Character::Character(const QString &name, int level, Character::ClassType classType)
+ : mName(name), mLevel(level), mClassType(classType)
{
}
@@ -97,35 +43,41 @@ void Character::setClassType(Character::ClassType classType)
mClassType = classType;
}
-//! [0]
-void Character::read(const QJsonObject &json)
+//! [fromJson]
+Character Character::fromJson(const QJsonObject &json)
{
- if (json.contains("name") && json["name"].isString())
- mName = json["name"].toString();
+ Character result;
+
+ if (const QJsonValue v = json["name"]; v.isString())
+ result.mName = v.toString();
+
+ if (const QJsonValue v = json["level"]; v.isDouble())
+ result.mLevel = v.toInt();
- if (json.contains("level") && json["level"].isDouble())
- mLevel = json["level"].toInt();
+ if (const QJsonValue v = json["classType"]; v.isDouble())
+ result.mClassType = ClassType(v.toInt());
- if (json.contains("classType") && json["classType"].isDouble())
- mClassType = ClassType(json["classType"].toInt());
+ return result;
}
-//! [0]
+//! [fromJson]
-//! [1]
-void Character::write(QJsonObject &json) const
+//! [toJson]
+QJsonObject Character::toJson() const
{
+ QJsonObject json;
json["name"] = mName;
json["level"] = mLevel;
json["classType"] = mClassType;
+ return json;
}
-//! [1]
+//! [toJson]
-void Character::print(int indentation) const
+void Character::print(QTextStream &s, int indentation) const
{
const QString indent(indentation * 2, ' ');
- QTextStream(stdout) << indent << "Name:\t" << mName << "\n";
- QTextStream(stdout) << indent << "Level:\t" << mLevel << "\n";
+ const QString className = QMetaEnum::fromType<ClassType>().valueToKey(mClassType);
- QString className = QMetaEnum::fromType<ClassType>().valueToKey(mClassType);
- QTextStream(stdout) << indent << "Class:\t" << className << "\n";
+ s << indent << "Name:\t" << mName << "\n"
+ << indent << "Level:\t" << mLevel << "\n"
+ << indent << "Class:\t" << className << "\n";
}
diff --git a/examples/corelib/serialization/savegame/character.h b/examples/corelib/serialization/savegame/character.h
index cbf06d7fd6..0504750320 100644
--- a/examples/corelib/serialization/savegame/character.h
+++ b/examples/corelib/serialization/savegame/character.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CHARACTER_H
#define CHARACTER_H
@@ -55,15 +8,15 @@
#include <QObject>
#include <QString>
+QT_FORWARD_DECLARE_CLASS(QTextStream)
+
//! [0]
class Character
{
- Q_GADGET;
+ Q_GADGET
public:
- enum ClassType {
- Warrior, Mage, Archer
- };
+ enum ClassType { Warrior, Mage, Archer };
Q_ENUM(ClassType)
Character();
@@ -78,14 +31,15 @@ public:
ClassType classType() const;
void setClassType(ClassType classType);
- void read(const QJsonObject &json);
- void write(QJsonObject &json) const;
+ static Character fromJson(const QJsonObject &json);
+ QJsonObject toJson() const;
+
+ void print(QTextStream &s, int indentation = 0) const;
- void print(int indentation = 0) const;
private:
QString mName;
- int mLevel;
- ClassType mClassType;
+ int mLevel = 0;
+ ClassType mClassType = Warrior;
};
//! [0]
diff --git a/examples/corelib/serialization/savegame/doc/src/savegame.qdoc b/examples/corelib/serialization/savegame/doc/src/savegame.qdoc
index 84807e57dc..46fca15b62 100644
--- a/examples/corelib/serialization/savegame/doc/src/savegame.qdoc
+++ b/examples/corelib/serialization/savegame/doc/src/savegame.qdoc
@@ -1,44 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example serialization/savegame
- \title JSON Save Game Example
+ \examplecategory {Data Processing & I/O}
+ \title Saving and Loading a Game
- \brief The JSON Save Game example demonstrates how to save and load a
- small game using QJsonDocument, QJsonObject and QJsonArray.
+ \brief How to save and load a game using Qt's JSON or CBOR classes.
Many games provide save functionality, so that the player's progress through
the game can be saved and loaded at a later time. The process of saving a
- game generally involves serializing each game object's member variables
- to a file. Many formats can be used for this purpose, one of which is JSON.
- With QJsonDocument, you also have the ability to serialize a document in a
- \l {https://tools.ietf.org/html/rfc7049} {CBOR} format, which is great if you
- don't want the save file to be readable, or if you need to keep the file size down.
+ game generally involves serializing each game object's member variables to a
+ file. Many formats can be used for this purpose, one of which is JSON. With
+ QJsonDocument, you also have the ability to serialize a document in a \l
+ {RFC 7049} {CBOR} format, which is great if you don't want the save file to
+ be easy to read (but see \l {Parsing and displaying CBOR data} for how it \e
+ can be read), or if you need to keep the file size down.
In this example, we'll demonstrate how to save and load a simple game to
and from JSON and binary formats.
@@ -48,45 +25,83 @@
The Character class represents a non-player character (NPC) in our game, and
stores the player's name, level, and class type.
- It provides read() and write() functions to serialise its member variables.
+ It provides static fromJson() and non-static toJson() functions to
+ serialise itself.
+
+ \note This pattern (fromJson()/toJson()) works because QJsonObjects can be
+ constructed independent of an owning QJsonDocument, and because the data
+ types being (de)serialized here are value types, so can be copied. When
+ serializing to another format — for example XML or QDataStream, which require passing
+ a document-like object — or when the object identity is important (QObject
+ subclasses, for example), other patterns may be more suitable. See the
+ \l{dombookmarks} example for XML, and the implementation of
+ \l QListWidgetItem::read() and \l QListWidgetItem::write()
+ for idiomatic QDataStream serialization. The \c{print()} functions in this example
+ are good examples of QTextStream serialization, even though they, of course, lack
+ the deserialization side.
\snippet serialization/savegame/character.h 0
- Of particular interest to us are the read and write function
+ Of particular interest to us are the fromJson() and toJson() function
implementations:
- \snippet serialization/savegame/character.cpp 0
+ \snippet serialization/savegame/character.cpp fromJson
- In the read() function, we assign Character's members values from the
- QJsonObject argument. You can use either \l QJsonObject::operator[]() or
- QJsonObject::value() to access values within the JSON object; both are
- const functions and return QJsonValue::Undefined if the key is invalid. We
- check if the keys are valid before attempting to read them with
- QJsonObject::contains().
+ In the fromJson() function, we construct a local \c result Character object
+ and assign \c{result}'s members values from the QJsonObject argument. You
+ can use either \l QJsonObject::operator[]() or QJsonObject::value() to
+ access values within the JSON object; both are const functions and return
+ QJsonValue::Undefined if the key is invalid. In particular, the \c{is...}
+ functions (for example \l QJsonValue::isString(), \l
+ QJsonValue::isDouble()) return \c false for QJsonValue::Undefined, so we
+ can check for existence as well as the correct type in a single lookup.
- \snippet serialization/savegame/character.cpp 1
+ If a value does not exist in the JSON object, or has the wrong type, we
+ don't write to the corresponding \c result member, either, thereby
+ preserving any values the default constructor may have set. This means
+ default values are centrally defined in one location (the default
+ constructor) and need not be repeated in serialisation code
+ (\l{https://en.wikipedia.org/wiki/Don%27t_repeat_yourself}{DRY}).
- In the write() function, we do the reverse of the read() function; assign
- values from the Character object to the JSON object. As with accessing
- values, there are two ways to set values on a QJsonObject:
- \l QJsonObject::operator[]() and QJsonObject::insert(). Both will override
- any existing value at the given key.
+ Observe the use of
+ \l{https://en.cppreference.com/w/cpp/language/if#If_statements_with_initializer}
+ {C++17 if-with-initializer} to separate scoping and checking of the variable \c v.
+ This means we can keep the variable name short, because its scope is limited.
- Next up is the Level class:
+ Compare that to the naïve approach using \c QJsonObject::contains():
+
+ \badcode
+ if (json.contains("name") && json["name"].isString())
+ result.mName = json["name"].toString();
+ \endcode
+
+ which, beside being less readable, requires a total of three lookups (no,
+ the compiler will \e not optimize these into one), so is three times
+ slower and repeats \c{"name"} three times (violating the DRY principle).
+
+ \snippet serialization/savegame/character.cpp toJson
+
+ In the toJson() function, we do the reverse of the fromJson() function;
+ assign values from the Character object to a new JSON object we then
+ return. As with accessing values, there are two ways to set values on a
+ QJsonObject: \l QJsonObject::operator[]() and \l QJsonObject::insert().
+ Both will override any existing value at the given key.
+
+ \section1 The Level Class
\snippet serialization/savegame/level.h 0
- We want to have several levels in our game, each with several NPCs, so we
- keep a QList of Character objects. We also provide the familiar read() and
- write() functions.
+ We want the levels in our game to each each have several NPCs, so we keep a QList
+ of Character objects. We also provide the familiar fromJson() and toJson()
+ functions.
- \snippet serialization/savegame/level.cpp 0
+ \snippet serialization/savegame/level.cpp fromJson
- Containers can be written and read to and from JSON using QJsonArray. In our
+ Containers can be written to and read from JSON using QJsonArray. In our
case, we construct a QJsonArray from the value associated with the key
\c "npcs". Then, for each QJsonValue element in the array, we call
- toObject() to get the Character's JSON object. The Character object can then
- read their JSON and be appended to our NPC array.
+ toObject() to get the Character's JSON object. Character::fromJson() can
+ then turn that QJSonObject into a Character object to append to our NPC array.
\note \l{Container Classes}{Associate containers} can be written by storing
the key in each value object (if it's not already). With this approach, the
@@ -94,11 +109,13 @@
element is used as the key to construct the container when reading it back
in.
- \snippet serialization/savegame/level.cpp 1
+ \snippet serialization/savegame/level.cpp toJson
- Again, the write() function is similar to the read() function, except
+ Again, the toJson() function is similar to the fromJson() function, except
reversed.
+ \section1 The Game Class
+
Having established the Character and Level classes, we can move on to
the Game class:
@@ -110,26 +127,43 @@
Next, we provide accessors for the player and levels. We then expose three
functions: newGame(), saveGame() and loadGame().
- The read() and write() functions are used by saveGame() and loadGame().
+ The read() and toJson() functions are used by saveGame() and loadGame().
+
+ \div{class="admonition note"}\b{Note:}
+ Despite \c Game being a value class, we assume that the author wants a game to have
+ identity, much like your main window would have. We therefore don't use a
+ static fromJson() function, which would create a new object, but a read()
+ function we can call on existing objects. There's a 1:1 correspondence
+ between read() and fromJson(), in that one can be implemented in terms of
+ the other:
+
+ \code
+ void read(const QJsonObject &json) { *this = fromJson(json); }
+ static Game fromObject(const QJsonObject &json) { Game g; g.read(json); return g; }
+ \endcode
- \snippet serialization/savegame/game.cpp 0
+ We just use what's more convenient for callers of the functions.
+ \enddiv
+
+ \snippet serialization/savegame/game.cpp newGame
To setup a new game, we create the player and populate the levels and their
NPCs.
- \snippet serialization/savegame/game.cpp 1
+ \snippet serialization/savegame/game.cpp read
- The first thing we do in the read() function is tell the player to read
- itself. We then clear the level array so that calling loadGame() on the
- same Game object twice doesn't result in old levels hanging around.
+ The read() function starts by replacing the player with the
+ one read from JSON. We then clear() the level array so that calling
+ loadGame() on the same Game object twice doesn't result in old levels
+ hanging around.
We then populate the level array by reading each Level from a QJsonArray.
- \snippet serialization/savegame/game.cpp 2
+ \snippet serialization/savegame/game.cpp toJson
- We write the game to JSON similarly to how we write Level.
+ Writing the game to JSON is similar to writing a level.
- \snippet serialization/savegame/game.cpp 3
+ \snippet serialization/savegame/game.cpp loadGame
When loading a saved game in loadGame(), the first thing we do is open the
save file based on which format it was saved to; \c "save.json" for JSON,
@@ -143,14 +177,16 @@
After constructing the QJsonDocument, we instruct the Game object to read
itself and then return \c true to indicate success.
- \snippet serialization/savegame/game.cpp 4
+ \snippet serialization/savegame/game.cpp saveGame
Not surprisingly, saveGame() looks very much like loadGame(). We determine
the file extension based on the format, print a warning and return \c false
if the opening of the file fails. We then write the Game object to a
- QJsonDocument, and call either QJsonDocument::toJson() or to
- QJsonDocument::toBinaryData() to save the game, depending on which format
- was specified.
+ QJsonObject. To save the game in the format that was specified, we
+ convert the JSON object into either a QJsonDocument for a subsequent
+ QJsonDocument::toJson() call, or a QCborValue for QCborValue::toCbor().
+
+ \section1 Tying It All Together
We are now ready to enter main():
@@ -182,5 +218,5 @@
human-readable JSON files, but you also have the option to use a binary
format if it's required, \e without rewriting any code.
- \sa {JSON Support in Qt}, {Data Storage}
+ \sa {JSON Support in Qt}, {CBOR Support in Qt}, {Data Input Output}
*/
diff --git a/examples/corelib/serialization/savegame/game.cpp b/examples/corelib/serialization/savegame/game.cpp
index bb7c2013f2..f99ecb8b51 100644
--- a/examples/corelib/serialization/savegame/game.cpp
+++ b/examples/corelib/serialization/savegame/game.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "game.h"
@@ -58,6 +11,8 @@
#include <QRandomGenerator>
#include <QTextStream>
+using namespace Qt::StringLiterals;
+
Character Game::player() const
{
return mPlayer;
@@ -68,52 +23,45 @@ QList<Level> Game::levels() const
return mLevels;
}
-//! [0]
+//! [newGame]
void Game::newGame()
{
mPlayer = Character();
- mPlayer.setName(QStringLiteral("Hero"));
+ mPlayer.setName("Hero"_L1);
mPlayer.setClassType(Character::Archer);
mPlayer.setLevel(QRandomGenerator::global()->bounded(15, 21));
mLevels.clear();
mLevels.reserve(2);
- Level village(QStringLiteral("Village"));
+ Level village("Village"_L1);
QList<Character> villageNpcs;
villageNpcs.reserve(2);
- villageNpcs.append(Character(QStringLiteral("Barry the Blacksmith"),
- QRandomGenerator::global()->bounded(8, 11),
- Character::Warrior));
- villageNpcs.append(Character(QStringLiteral("Terry the Trader"),
- QRandomGenerator::global()->bounded(6, 8),
- Character::Warrior));
+ villageNpcs.append(Character("Barry the Blacksmith"_L1,
+ QRandomGenerator::global()->bounded(8, 11), Character::Warrior));
+ villageNpcs.append(Character("Terry the Trader"_L1,
+ QRandomGenerator::global()->bounded(6, 8), Character::Warrior));
village.setNpcs(villageNpcs);
mLevels.append(village);
- Level dungeon(QStringLiteral("Dungeon"));
+ Level dungeon("Dungeon"_L1);
QList<Character> dungeonNpcs;
dungeonNpcs.reserve(3);
- dungeonNpcs.append(Character(QStringLiteral("Eric the Evil"),
- QRandomGenerator::global()->bounded(18, 26),
- Character::Mage));
- dungeonNpcs.append(Character(QStringLiteral("Eric's Left Minion"),
- QRandomGenerator::global()->bounded(5, 7),
- Character::Warrior));
- dungeonNpcs.append(Character(QStringLiteral("Eric's Right Minion"),
- QRandomGenerator::global()->bounded(4, 9),
- Character::Warrior));
+ dungeonNpcs.append(Character("Eric the Evil"_L1,
+ QRandomGenerator::global()->bounded(18, 26), Character::Mage));
+ dungeonNpcs.append(Character("Eric's Left Minion"_L1,
+ QRandomGenerator::global()->bounded(5, 7), Character::Warrior));
+ dungeonNpcs.append(Character("Eric's Right Minion"_L1,
+ QRandomGenerator::global()->bounded(4, 9), Character::Warrior));
dungeon.setNpcs(dungeonNpcs);
mLevels.append(dungeon);
}
-//! [0]
+//! [newGame]
-//! [3]
+//! [loadGame]
bool Game::loadGame(Game::SaveFormat saveFormat)
{
- QFile loadFile(saveFormat == Json
- ? QStringLiteral("save.json")
- : QStringLiteral("save.dat"));
+ QFile loadFile(saveFormat == Json ? "save.json"_L1 : "save.dat"_L1);
if (!loadFile.open(QIODevice::ReadOnly)) {
qWarning("Couldn't open save file.");
@@ -123,85 +71,72 @@ bool Game::loadGame(Game::SaveFormat saveFormat)
QByteArray saveData = loadFile.readAll();
QJsonDocument loadDoc(saveFormat == Json
- ? QJsonDocument::fromJson(saveData)
- : QJsonDocument(QCborValue::fromCbor(saveData).toMap().toJsonObject()));
+ ? QJsonDocument::fromJson(saveData)
+ : QJsonDocument(QCborValue::fromCbor(saveData).toMap().toJsonObject()));
read(loadDoc.object());
- QTextStream(stdout) << "Loaded save for "
- << loadDoc["player"]["name"].toString()
- << " using "
- << (saveFormat != Json ? "CBOR" : "JSON") << "...\n";
+ QTextStream(stdout) << "Loaded save for " << loadDoc["player"]["name"].toString()
+ << " using " << (saveFormat != Json ? "CBOR" : "JSON") << "...\n";
return true;
}
-//! [3]
+//! [loadGame]
-//! [4]
+//! [saveGame]
bool Game::saveGame(Game::SaveFormat saveFormat) const
{
- QFile saveFile(saveFormat == Json
- ? QStringLiteral("save.json")
- : QStringLiteral("save.dat"));
+ QFile saveFile(saveFormat == Json ? "save.json"_L1 : "save.dat"_L1);
if (!saveFile.open(QIODevice::WriteOnly)) {
qWarning("Couldn't open save file.");
return false;
}
- QJsonObject gameObject;
- write(gameObject);
- saveFile.write(saveFormat == Json
- ? QJsonDocument(gameObject).toJson()
- : QCborValue::fromJsonValue(gameObject).toCbor());
+ QJsonObject gameObject = toJson();
+ saveFile.write(saveFormat == Json ? QJsonDocument(gameObject).toJson()
+ : QCborValue::fromJsonValue(gameObject).toCbor());
return true;
}
-//! [4]
+//! [saveGame]
-//! [1]
+//! [read]
void Game::read(const QJsonObject &json)
{
- if (json.contains("player") && json["player"].isObject())
- mPlayer.read(json["player"].toObject());
+ if (const QJsonValue v = json["player"]; v.isObject())
+ mPlayer = Character::fromJson(v.toObject());
- if (json.contains("levels") && json["levels"].isArray()) {
- QJsonArray levelArray = json["levels"].toArray();
+ if (const QJsonValue v = json["levels"]; v.isArray()) {
+ const QJsonArray levels = v.toArray();
mLevels.clear();
- mLevels.reserve(levelArray.size());
- for (int levelIndex = 0; levelIndex < levelArray.size(); ++levelIndex) {
- QJsonObject levelObject = levelArray[levelIndex].toObject();
- Level level;
- level.read(levelObject);
- mLevels.append(level);
- }
+ mLevels.reserve(levels.size());
+ for (const QJsonValue &level : levels)
+ mLevels.append(Level::fromJson(level.toObject()));
}
}
-//! [1]
+//! [read]
-//! [2]
-void Game::write(QJsonObject &json) const
+//! [toJson]
+QJsonObject Game::toJson() const
{
- QJsonObject playerObject;
- mPlayer.write(playerObject);
- json["player"] = playerObject;
-
- QJsonArray levelArray;
- for (const Level &level : mLevels) {
- QJsonObject levelObject;
- level.write(levelObject);
- levelArray.append(levelObject);
- }
- json["levels"] = levelArray;
+ QJsonObject json;
+ json["player"] = mPlayer.toJson();
+
+ QJsonArray levels;
+ for (const Level &level : mLevels)
+ levels.append(level.toJson());
+ json["levels"] = levels;
+ return json;
}
-//! [2]
+//! [toJson]
-void Game::print(int indentation) const
+void Game::print(QTextStream &s, int indentation) const
{
const QString indent(indentation * 2, ' ');
- QTextStream(stdout) << indent << "Player\n";
- mPlayer.print(indentation + 1);
+ s << indent << "Player\n";
+ mPlayer.print(s, indentation + 1);
- QTextStream(stdout) << indent << "Levels\n";
- for (Level level : mLevels)
- level.print(indentation + 1);
+ s << indent << "Levels\n";
+ for (const Level &level : mLevels)
+ level.print(s, indentation + 1);
}
diff --git a/examples/corelib/serialization/savegame/game.h b/examples/corelib/serialization/savegame/game.h
index dfcb27eb1c..5ba5952923 100644
--- a/examples/corelib/serialization/savegame/game.h
+++ b/examples/corelib/serialization/savegame/game.h
@@ -1,69 +1,22 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef GAME_H
#define GAME_H
+#include "character.h"
+#include "level.h"
+
#include <QJsonObject>
#include <QList>
-#include "character.h"
-#include "level.h"
+QT_FORWARD_DECLARE_CLASS(QTextStream)
//! [0]
class Game
{
public:
- enum SaveFormat {
- Json, Binary
- };
+ enum SaveFormat { Json, Binary };
Character player() const;
QList<Level> levels() const;
@@ -73,9 +26,10 @@ public:
bool saveGame(SaveFormat saveFormat) const;
void read(const QJsonObject &json);
- void write(QJsonObject &json) const;
+ QJsonObject toJson() const;
+
+ void print(QTextStream &s, int indentation = 0) const;
- void print(int indentation = 0) const;
private:
Character mPlayer;
QList<Level> mLevels;
diff --git a/examples/corelib/serialization/savegame/level.cpp b/examples/corelib/serialization/savegame/level.cpp
index ea6ef147b9..f30d35e57f 100644
--- a/examples/corelib/serialization/savegame/level.cpp
+++ b/examples/corelib/serialization/savegame/level.cpp
@@ -1,61 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "level.h"
#include <QJsonArray>
#include <QTextStream>
-Level::Level(const QString &name) : mName(name)
-{
-}
+Level::Level(const QString &name) : mName(name) { }
QString Level::name() const
{
@@ -72,46 +23,43 @@ void Level::setNpcs(const QList<Character> &npcs)
mNpcs = npcs;
}
-//! [0]
-void Level::read(const QJsonObject &json)
+//! [fromJson]
+Level Level::fromJson(const QJsonObject &json)
{
- if (json.contains("name") && json["name"].isString())
- mName = json["name"].toString();
+ Level result;
+
+ if (const QJsonValue v = json["name"]; v.isString())
+ result.mName = v.toString();
- if (json.contains("npcs") && json["npcs"].isArray()) {
- QJsonArray npcArray = json["npcs"].toArray();
- mNpcs.clear();
- mNpcs.reserve(npcArray.size());
- for (int npcIndex = 0; npcIndex < npcArray.size(); ++npcIndex) {
- QJsonObject npcObject = npcArray[npcIndex].toObject();
- Character npc;
- npc.read(npcObject);
- mNpcs.append(npc);
- }
+ if (const QJsonValue v = json["npcs"]; v.isArray()) {
+ const QJsonArray npcs = v.toArray();
+ result.mNpcs.reserve(npcs.size());
+ for (const QJsonValue &npc : npcs)
+ result.mNpcs.append(Character::fromJson(npc.toObject()));
}
+
+ return result;
}
-//! [0]
+//! [fromJson]
-//! [1]
-void Level::write(QJsonObject &json) const
+//! [toJson]
+QJsonObject Level::toJson() const
{
+ QJsonObject json;
json["name"] = mName;
QJsonArray npcArray;
- for (const Character &npc : mNpcs) {
- QJsonObject npcObject;
- npc.write(npcObject);
- npcArray.append(npcObject);
- }
+ for (const Character &npc : mNpcs)
+ npcArray.append(npc.toJson());
json["npcs"] = npcArray;
+ return json;
}
-//! [1]
+//! [toJson]
-void Level::print(int indentation) const
+void Level::print(QTextStream &s, int indentation) const
{
const QString indent(indentation * 2, ' ');
- QTextStream(stdout) << indent << "Name:\t" << mName << "\n";
- QTextStream(stdout) << indent << "NPCs:\n";
+ s << indent << "Name:\t" << mName << "\n" << indent << "NPCs:\n";
for (const Character &character : mNpcs)
- character.print(2);
+ character.print(s, indentation + 1);
}
diff --git a/examples/corelib/serialization/savegame/level.h b/examples/corelib/serialization/savegame/level.h
index ecffde8f22..e487e55ae3 100644
--- a/examples/corelib/serialization/savegame/level.h
+++ b/examples/corelib/serialization/savegame/level.h
@@ -1,77 +1,33 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef LEVEL_H
#define LEVEL_H
+#include "character.h"
+
#include <QJsonObject>
#include <QList>
-#include "character.h"
+QT_FORWARD_DECLARE_CLASS(QTextStream)
//! [0]
class Level
{
public:
Level() = default;
- Level(const QString &name);
+ explicit Level(const QString &name);
QString name() const;
QList<Character> npcs() const;
void setNpcs(const QList<Character> &npcs);
- void read(const QJsonObject &json);
- void write(QJsonObject &json) const;
+ static Level fromJson(const QJsonObject &json);
+ QJsonObject toJson() const;
+
+ void print(QTextStream &s, int indentation = 0) const;
- void print(int indentation = 0) const;
private:
QString mName;
QList<Character> mNpcs;
diff --git a/examples/corelib/serialization/savegame/main.cpp b/examples/corelib/serialization/savegame/main.cpp
index d091684211..3fc0f3af10 100644
--- a/examples/corelib/serialization/savegame/main.cpp
+++ b/examples/corelib/serialization/savegame/main.cpp
@@ -1,79 +1,37 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "game.h"
#include <QCoreApplication>
+#include <QStringList>
+#include <QString>
#include <QTextStream>
-#include "game.h"
+using namespace Qt::StringLiterals; // for _L1
+
//! [0]
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
- QStringList args = QCoreApplication::arguments();
- bool newGame = true;
- if (args.length() > 1)
- newGame = (args[1].toLower() != QStringLiteral("load"));
- bool json = true;
- if (args.length() > 2)
- json = (args[2].toLower() != QStringLiteral("binary"));
+
+ const QStringList args = QCoreApplication::arguments();
+ const bool newGame
+ = args.size() <= 1 || QString::compare(args[1], "load"_L1, Qt::CaseInsensitive) != 0;
+ const bool json
+ = args.size() <= 2 || QString::compare(args[2], "binary"_L1, Qt::CaseInsensitive) != 0;
Game game;
if (newGame)
game.newGame();
else if (!game.loadGame(json ? Game::Json : Game::Binary))
- return 1;
+ return 1;
// Game is played; changes are made...
//! [0]
//! [1]
- QTextStream(stdout) << "Game ended in the following state:\n";
- game.print();
+ QTextStream s(stdout);
+ s << "Game ended in the following state:\n";
+ game.print(s);
if (!game.saveGame(json ? Game::Json : Game::Binary))
return 1;
diff --git a/examples/corelib/serialization/serialization.pro b/examples/corelib/serialization/serialization.pro
index 7651444f19..e20fcb57fd 100644
--- a/examples/corelib/serialization/serialization.pro
+++ b/examples/corelib/serialization/serialization.pro
@@ -3,3 +3,7 @@ SUBDIRS = \
cbordump \
convert \
savegame
+
+qtHaveModule(widgets) {
+ SUBDIRS += streambookmarks
+}
diff --git a/examples/corelib/serialization/streambookmarks/CMakeLists.txt b/examples/corelib/serialization/streambookmarks/CMakeLists.txt
new file mode 100644
index 0000000000..bad55fa661
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/CMakeLists.txt
@@ -0,0 +1,40 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(streambookmarks LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(streambookmarks
+ main.cpp
+ mainwindow.cpp mainwindow.h
+ xbelreader.cpp xbelreader.h
+ xbelwriter.cpp xbelwriter.h
+)
+
+set_target_properties(streambookmarks PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(streambookmarks PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+)
+
+install(TARGETS streambookmarks
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET streambookmarks
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/serialization/streambookmarks/doc/images/filemenu.png b/examples/corelib/serialization/streambookmarks/doc/images/filemenu.png
new file mode 100644
index 0000000000..1a92895ccf
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/doc/images/filemenu.png
Binary files differ
diff --git a/examples/corelib/serialization/streambookmarks/doc/images/helpmenu.png b/examples/corelib/serialization/streambookmarks/doc/images/helpmenu.png
new file mode 100644
index 0000000000..baa98bee96
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/doc/images/helpmenu.png
Binary files differ
diff --git a/examples/corelib/serialization/streambookmarks/doc/images/screenshot.png b/examples/corelib/serialization/streambookmarks/doc/images/screenshot.png
new file mode 100644
index 0000000000..422873b6d0
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/doc/images/screenshot.png
Binary files differ
diff --git a/examples/corelib/serialization/streambookmarks/doc/src/qxmlstreambookmarks.qdoc b/examples/corelib/serialization/streambookmarks/doc/src/qxmlstreambookmarks.qdoc
new file mode 100644
index 0000000000..8e32dd8d0b
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/doc/src/qxmlstreambookmarks.qdoc
@@ -0,0 +1,223 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example serialization/streambookmarks
+ \examplecategory {Data Processing & I/O}
+ \meta tag {network}
+ \title QXmlStream Bookmarks Example
+ \brief Demonstrates how to read and write XBEL files.
+ \ingroup xml-examples
+
+ The QXmlStream Bookmarks example provides a viewer for XML Bookmark Exchange
+ Language (XBEL) files. It can read bookmarks using Qt's QXmlStreamReader and
+ write them back out again using QXmlStreamWriter. As this example aims to
+ show how to use these reader and writer types, it provides no means to open
+ a bookmark, add a new one, or merge two bookmark files, and only minimal
+ scope for editing bookmarks. None the less, it could surely be extended with
+ such features, if desired.
+
+ \image screenshot.png
+
+ \section1 XbelWriter Class Definition
+
+ The \c XbelWriter class takes a \l{QTreeWidget}{tree widget} describing a
+ hierarchy of folders containing bookmarks. Its \c writeFile() provides the
+ means to write out this hierarchy, in XBEL format, to a given output device.
+
+ Internally, it records the tree widget it was given and packages a private
+ instance of QXmlStreamWriter, which provides it with the means to stream
+ XML. It has an internal \c writeItem() to write each item in its tree.
+
+ \snippet serialization/streambookmarks/xbelwriter.h 0
+
+ \section1 XbelWriter Class Implementation
+
+ The \c XbelWriter constructor accepts the \a treeWidget it will describe. It
+ stores that and enables \l{QXmlStreamWriter}'s auto-formatting property.
+ This last splits the data into several lines, with indentation to indicate
+ the structure of the tree, which makes the XML output easier to read.
+
+ \snippet serialization/streambookmarks/xbelwriter.cpp 0
+
+ The \c writeFile() function accepts a QIODevice object and directs its
+ QXmlStreamWriter member to write to this device, using \c setDevice(). This
+ function then writes the document type definition(DTD), the start element,
+ the version, and delegates writing of each of the \c{treeWidget}'s top-level
+ items to \c writeItem(). Finally, it closes the document and returns.
+
+ \snippet serialization/streambookmarks/xbelwriter.cpp 1
+
+ The \c writeItem() function accepts a QTreeWidgetItem object and writes to
+ its XML stream a representation of the object, which depends on its \c
+ UserRole, which can be one of a \c{"folder"}, \c{"bookmark"},
+ or \c{"separator"}. Within each folder, it calls itself recursively on each
+ child item, to recursively include a representation of each child within the
+ folder's XML element.
+
+ \snippet serialization/streambookmarks/xbelwriter.cpp 2
+
+ \section1 XbelReader Class Definition
+
+ The \c XbelReader takes a \l{QTreeWidget}{tree widget} to populate with
+ items describing a bookmark hierarchy. It supports reading XBEL data from a
+ QIODevice as a source of these items. If parsing of the XBEL data fails, it
+ can report what went wrong.
+
+ Internally, it records the QTreeWidget that it will populate and packages an
+ instance of QXmlStreamReader, the companion class to QXmlStreamWriter, which
+ it will use to read XBEL data.
+
+ \snippet serialization/streambookmarks/xbelreader.h 0
+
+ \section1 XbelReader Class Implementation
+
+ Since the XBEL reader is only concerned with reading XML elements, it makes
+ extensive use of the \l{QXmlStreamReader::}{readNextStartElement()}
+ convenience function.
+
+ The \c XbelReader constructor requires a QTreeWidget that it will populate.
+ It populates the tree widget's style with suitable icons: a folder icon that
+ changes form to indicate whether each folder as open or closed; and a
+ standard file icon for the individual bookmarks within those folders.
+
+ \snippet serialization/streambookmarks/xbelreader.cpp 0
+
+ The \c read() function accepts a QIODevice. It directs its QXmlStreamReader
+ member to read content from that device. Note that the XML input must be
+ well-formed to be accepted by QXmlStreamReader. First it reads the outer
+ structure and verifies the content is an XBEL 1.0 file; if it is, \c read()
+ delegates the actual reading of content to the internal \c readXBEL().
+
+ Otherwise, the \l{QXmlStreamReader::}{raiseError()} function is used to
+ record an error message. The reader itself may also do the same if it
+ encounters errors in the input. When \c read() has finished, it returns
+ true if there were no errors.
+
+ \snippet serialization/streambookmarks/xbelreader.cpp 1
+
+ If \c read() returns false, its caller can obtain a description of the
+ error, complete with line and column number within the stream, by calling
+ the \c errorString() function.
+
+ \snippet serialization/streambookmarks/xbelreader.cpp 2
+
+ The \c readXBEL() function reads the name of a startElement and calls the
+ appropriate function to read it, depending on whether if its tag name
+ is \c{"folder"}, \c{"bookmark"} or \c{"separator"}. Any other elements
+ encountered are skipped. The function starts with a precondition, verifying
+ that the XML reader has just opened an \c{"xbel"} element.
+
+ \snippet serialization/streambookmarks/xbelreader.cpp 3
+
+ The \c readBookmark() function creates a new editable item representing a
+ single bookmark. It records the XML \c{"href"} attribute of the current
+ element as second column text of the item and provisionally sets its first
+ column text to \c{"Unknown title"} before scanning the rest of the element
+ for a title element to over-ride that, skipping any unrecognized child
+ elements.
+
+ \snippet serialization/streambookmarks/xbelreader.cpp 5
+
+ The \c readTitle() function reads a bookmark's title and records it as the
+ title (first column text) of the item for which it was called.
+
+ \snippet serialization/streambookmarks/xbelreader.cpp 6
+
+ The \c readSeparator() function creates a separator and sets its flags. The
+ separator item's text is set to 30 centered dots. The rest of the element is
+ then skipped using \l{QXmlStreamReader::}{skipCurrentElement()}.
+
+ \snippet serialization/streambookmarks/xbelreader.cpp 6
+
+ The \c readFolder() function creates an item and iterates the content of the
+ folder element, adding children to this item to represent the contents of
+ the folder element. The loop over folder content is similar in form to the
+ one in \c readXBEL(), save that it now accepts a title element to set the
+ title of the folder.
+
+ \snippet serialization/streambookmarks/xbelreader.cpp 7
+
+ The \c createChildItem() helper function creates a new tree widget item
+ that's either a child of the given item or, if no parent item is given, a
+ direct child of the tree widget. It sets the new item's \c UserRole to the
+ tag name of the current XML element, matching how XbelWriter::writeFile()
+ uses that \c UserRole.
+
+ \snippet serialization/streambookmarks/xbelreader.cpp 8
+
+ \section1 MainWindow Class Definition
+
+ The \c MainWindow class is a subclass of QMainWindow, with a \c File menu
+ and a \c Help menu.
+
+ \snippet serialization/streambookmarks/mainwindow.h 0
+
+ \section1 MainWindow Class Implementation
+
+ The \c MainWindow constructor sets up its QTreeWidget object, \c treeWidget,
+ as its own central widget, with column headings for the title and location
+ of each book-mark. It configures a custom menu that enables the user to
+ perform actions on individual bookmarks within the tree widget.
+
+ It invokes \c createMenus() to set up its own menus and their corresponding
+ actions. It sets its title, announces itself as ready and sets its size to a
+ reasonable proportion of the available screen space.
+
+ \snippet serialization/streambookmarks/mainwindow.cpp 0
+
+ A custom menu, triggered when the user right-clicks on a bookmark, provides
+ for copying the bookmark as a link or directing a desktop browser to open
+ the URL it references. This menu is implemented (when relevant features are
+ enabled) by \c onCustomContextMenuRequested().
+
+ \snippet serialization/streambookmarks/mainwindow.cpp 1
+
+ The \c createMenus() function creates the \c fileMenu and \c helpMenu and
+ adds QAction objects to them, bound variously to the \c open(), \c saveAs()
+ and \c about() functions, along with QWidget::close() and
+ QApplication::aboutQt(). The connections are as shown below:
+
+ \snippet serialization/streambookmarks/mainwindow.cpp 2
+
+ This creates the menu shown in the screenshots below:
+
+ \table
+ \row
+ \li \inlineimage filemenu.png
+ \li \inlineimage helpmenu.png
+ \endtable
+
+ The \c open() function, when triggered, offers the user a file dialog to use
+ to select a bookmarks file. If a file is selected, it is parsed using an \c
+ XBelReader to populate the \c treeWidget with bookmarks. If problems arise
+ with opening or parsing the file, a suitable warning message is displayed to
+ the user, including file name and error message. Otherwise, the bookmarks
+ read from the file are displayed and the window's status bar briefly reports
+ that the file has been loaded.
+
+ \snippet serialization/streambookmarks/mainwindow.cpp 3
+
+ The \c saveAs() function displays a QFileDialog, prompting the user for a \c
+ fileName, to which to save a copy of the bookmarks data. Similar to the \c
+ open() function, this function also displays a warning message if the file
+ cannot be written to.
+
+ \snippet serialization/streambookmarks/mainwindow.cpp 4
+
+ The \c about() function displays a QMessageBox with a brief description of
+ the example, or general information about Qt and the version of it in use.
+
+ \snippet serialization/streambookmarks/mainwindow.cpp 5
+
+ \section1 \c{main()} Function
+
+ The \c main() function instantiates \c MainWindow and invokes the \c show()
+ function to display it, then its \c open(), as this is most likely what the
+ user shall want to do first.
+
+ \snippet serialization/streambookmarks/main.cpp 0
+
+ See the \l{https://pyxml.sourceforge.net/topics/xbel/} {XML Bookmark
+ Exchange Language Resource Page} for more information about XBEL files.
+*/
diff --git a/examples/corelib/serialization/streambookmarks/jennifer.xbel b/examples/corelib/serialization/streambookmarks/jennifer.xbel
new file mode 100644
index 0000000000..d504236830
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/jennifer.xbel
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE xbel>
+<xbel version="1.0">
+ <folder folded="no">
+ <title>Qt Resources</title>
+ <bookmark href="https://www.qt.io/">
+ <title>Qt home page</title>
+ </bookmark>
+ <bookmark href="https://www.qt.io/contact-us/partners">
+ <title>Qt Partners</title>
+ </bookmark>
+ <bookmark href="https://www.qt.io/qt-professional-services">
+ <title>Professional Services</title>
+ </bookmark>
+ <bookmark href="https://doc.qt.io/">
+ <title>Qt Documentation</title>
+ </bookmark>
+ <folder folded="yes">
+ <title>Community Resources</title>
+ <bookmark href="https://contribute.qt-project.org">
+ <title>The Qt Project</title>
+ </bookmark>
+ <bookmark href="https://www.qtcentre.org/content/">
+ <title>Qt Centre</title>
+ </bookmark>
+ <bookmark href="https://forum.qt.io/">
+ <title>Forum.Qt.org</title>
+ </bookmark>
+ <bookmark href="https://digitalfanatics.org/projects/qt_tutorial/">
+ <title>The Independent Qt Tutorial</title>
+ </bookmark>
+ <bookmark href="https://www.qtforum.de/">
+ <title>German Qt Forum</title>
+ </bookmark>
+ <bookmark href="https://www.qt-dev.com/">
+ <title>Korean Qt Community Site</title>
+ </bookmark>
+ <bookmark href="http://www.prog.org.ru/">
+ <title>Russian Qt Forum</title>
+ </bookmark>
+ </folder>
+ </folder>
+ <folder folded="no">
+ <title>Online Dictionaries</title>
+ <bookmark href="https://www.dictionary.com/">
+ <title>Dictionary.com</title>
+ </bookmark>
+ <bookmark href="https://www.merriam-webster.com/">
+ <title>Merriam-Webster Online</title>
+ </bookmark>
+ <bookmark href="https://dictionary.cambridge.org/">
+ <title>Cambridge Dictionaries Online</title>
+ </bookmark>
+ <bookmark href="https://www.onelook.com/">
+ <title>OneLook Dictionary Search</title>
+ </bookmark>
+ <separator/>
+ <bookmark href="https://dict.tu-chemnitz.de/">
+ <title>BEOLINGUS, a service of TU Chemnitz</title>
+ </bookmark>
+ <separator/>
+ <bookmark href="http://atilf.atilf.fr/tlf.htm">
+ <title>Trésor de la Langue Française informatisé</title>
+ </bookmark>
+ <bookmark href="https://www.dictionnaire-academie.fr/">
+ <title>Dictionnaire de l'Académie Française</title>
+ </bookmark>
+ </folder>
+</xbel>
diff --git a/examples/corelib/serialization/streambookmarks/main.cpp b/examples/corelib/serialization/streambookmarks/main.cpp
new file mode 100644
index 0000000000..0fd317de43
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/main.cpp
@@ -0,0 +1,17 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "mainwindow.h"
+
+#include <QApplication>
+
+//! [0]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow mainWin;
+ mainWin.show();
+ mainWin.open();
+ return app.exec();
+}
+//! [0]
diff --git a/examples/corelib/serialization/streambookmarks/mainwindow.cpp b/examples/corelib/serialization/streambookmarks/mainwindow.cpp
new file mode 100644
index 0000000000..a863f77ab7
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/mainwindow.cpp
@@ -0,0 +1,151 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "mainwindow.h"
+#include "xbelreader.h"
+#include "xbelwriter.h"
+
+#include <QFileDialog>
+#include <QHeaderView>
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QStatusBar>
+#include <QTreeWidget>
+
+#include <QAction>
+#if QT_CONFIG(clipboard)
+# include <QClipboard>
+#endif
+#include <QDesktopServices>
+#include <QApplication>
+#include <QScreen>
+
+using namespace Qt::StringLiterals;
+
+//! [0]
+MainWindow::MainWindow() : treeWidget(new QTreeWidget)
+{
+ treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch);
+ treeWidget->setHeaderLabels(QStringList{tr("Title"), tr("Location")});
+#if QT_CONFIG(clipboard) && QT_CONFIG(contextmenu)
+ treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(treeWidget, &QWidget::customContextMenuRequested,
+ this, &MainWindow::onCustomContextMenuRequested);
+#endif
+ setCentralWidget(treeWidget);
+
+ createMenus();
+
+ statusBar()->showMessage(tr("Ready"));
+
+ setWindowTitle(tr("QXmlStream Bookmarks"));
+ const QSize availableSize = screen()->availableGeometry().size();
+ resize(availableSize.width() / 2, availableSize.height() / 3);
+}
+//! [0]
+
+//! [1]
+#if QT_CONFIG(clipboard) && QT_CONFIG(contextmenu)
+void MainWindow::onCustomContextMenuRequested(const QPoint &pos)
+{
+ const QTreeWidgetItem *item = treeWidget->itemAt(pos);
+ if (!item)
+ return;
+ const QString url = item->text(1);
+ QMenu contextMenu;
+ QAction *copyAction = contextMenu.addAction(tr("Copy Link to Clipboard"));
+ QAction *openAction = contextMenu.addAction(tr("Open"));
+ QAction *action = contextMenu.exec(treeWidget->viewport()->mapToGlobal(pos));
+ if (action == copyAction)
+ QGuiApplication::clipboard()->setText(url);
+ else if (action == openAction)
+ QDesktopServices::openUrl(QUrl(url));
+}
+#endif // QT_CONFIG(clipboard) && QT_CONFIG(contextmenu)
+//! [1]
+
+//! [2]
+void MainWindow::createMenus()
+{
+ QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
+ QAction *openAct = fileMenu->addAction(tr("&Open..."), this, &MainWindow::open);
+ openAct->setShortcuts(QKeySequence::Open);
+
+ QAction *saveAsAct = fileMenu->addAction(tr("&Save As..."), this, &MainWindow::saveAs);
+ saveAsAct->setShortcuts(QKeySequence::SaveAs);
+
+ QAction *exitAct = fileMenu->addAction(tr("E&xit"), this, &QWidget::close);
+ exitAct->setShortcuts(QKeySequence::Quit);
+
+ menuBar()->addSeparator();
+
+ QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
+ helpMenu->addAction(tr("&About"), this, &MainWindow::about);
+ helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
+}
+//! [2]
+
+//! [3]
+void MainWindow::open()
+{
+ QFileDialog fileDialog(this, tr("Open Bookmark File"), QDir::currentPath());
+ fileDialog.setMimeTypeFilters({"application/x-xbel"_L1});
+ if (fileDialog.exec() != QDialog::Accepted)
+ return;
+
+ treeWidget->clear();
+
+ const QString fileName = fileDialog.selectedFiles().constFirst();
+ QFile file(fileName);
+ if (!file.open(QFile::ReadOnly | QFile::Text)) {
+ QMessageBox::warning(this, tr("QXmlStream Bookmarks"),
+ tr("Cannot read file %1:\n%2.")
+ .arg(QDir::toNativeSeparators(fileName), file.errorString()));
+ return;
+ }
+
+ XbelReader reader(treeWidget);
+ if (!reader.read(&file)) {
+ QMessageBox::warning(
+ this, tr("QXmlStream Bookmarks"),
+ tr("Parse error in file %1:\n\n%2")
+ .arg(QDir::toNativeSeparators(fileName), reader.errorString()));
+ } else {
+ statusBar()->showMessage(tr("File loaded"), 2000);
+ }
+}
+//! [3]
+
+//! [4]
+void MainWindow::saveAs()
+{
+ QFileDialog fileDialog(this, tr("Save Bookmark File"), QDir::currentPath());
+ fileDialog.setAcceptMode(QFileDialog::AcceptSave);
+ fileDialog.setDefaultSuffix("xbel"_L1);
+ fileDialog.setMimeTypeFilters({"application/x-xbel"_L1});
+ if (fileDialog.exec() != QDialog::Accepted)
+ return;
+
+ const QString fileName = fileDialog.selectedFiles().constFirst();
+ QFile file(fileName);
+ if (!file.open(QFile::WriteOnly | QFile::Text)) {
+ QMessageBox::warning(this, tr("QXmlStream Bookmarks"),
+ tr("Cannot write file %1:\n%2.")
+ .arg(QDir::toNativeSeparators(fileName), file.errorString()));
+ return;
+ }
+
+ XbelWriter writer(treeWidget);
+ if (writer.writeFile(&file))
+ statusBar()->showMessage(tr("File saved"), 2000);
+}
+//! [4]
+
+//! [5]
+void MainWindow::about()
+{
+ QMessageBox::about(this, tr("About QXmlStream Bookmarks"),
+ tr("The <b>QXmlStream Bookmarks</b> example demonstrates how to use Qt's "
+ "QXmlStream classes to read and write XML documents."));
+}
+//! [5]
diff --git a/examples/corelib/serialization/streambookmarks/mainwindow.h b/examples/corelib/serialization/streambookmarks/mainwindow.h
new file mode 100644
index 0000000000..d9efe6b5a5
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/mainwindow.h
@@ -0,0 +1,35 @@
+// 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 QTreeWidget;
+QT_END_NAMESPACE
+
+//! [0]
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+
+public slots:
+ void open();
+ void saveAs();
+ void about();
+#if QT_CONFIG(clipboard) && QT_CONFIG(contextmenu)
+ void onCustomContextMenuRequested(const QPoint &pos);
+#endif
+private:
+ void createMenus();
+
+ QTreeWidget *const treeWidget;
+};
+//! [0]
+
+#endif
diff --git a/examples/corelib/serialization/streambookmarks/streambookmarks.pro b/examples/corelib/serialization/streambookmarks/streambookmarks.pro
new file mode 100644
index 0000000000..34d2caae82
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/streambookmarks.pro
@@ -0,0 +1,15 @@
+HEADERS = mainwindow.h \
+ xbelreader.h \
+ xbelwriter.h
+SOURCES = main.cpp \
+ mainwindow.cpp \
+ xbelreader.cpp \
+ xbelwriter.cpp
+QT += widgets
+requires(qtConfig(filedialog))
+
+EXAMPLE_FILES = jennifer.xbel
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/corelib/serialization/streambookmarks
+INSTALLS += target
diff --git a/examples/corelib/serialization/streambookmarks/xbelreader.cpp b/examples/corelib/serialization/streambookmarks/xbelreader.cpp
new file mode 100644
index 0000000000..c622cf6642
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/xbelreader.cpp
@@ -0,0 +1,140 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "xbelreader.h"
+
+#include <QStyle>
+#include <QTreeWidget>
+
+using namespace Qt::StringLiterals;
+
+//! [0]
+XbelReader::XbelReader(QTreeWidget *treeWidget) : treeWidget(treeWidget)
+{
+ QStyle *style = treeWidget->style();
+
+ folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon), QIcon::Normal,
+ QIcon::Off);
+ folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon), QIcon::Normal, QIcon::On);
+ bookmarkIcon.addPixmap(style->standardPixmap(QStyle::SP_FileIcon));
+}
+//! [0]
+
+//! [1]
+bool XbelReader::read(QIODevice *device)
+{
+ xml.setDevice(device);
+
+ if (xml.readNextStartElement()) {
+ if (xml.name() == "xbel"_L1 && xml.attributes().value("version"_L1) == "1.0"_L1)
+ readXBEL();
+ else
+ xml.raiseError(QObject::tr("The file is not an XBEL version 1.0 file."));
+ }
+
+ return !xml.error();
+}
+//! [1]
+
+//! [2]
+QString XbelReader::errorString() const
+{
+ return QObject::tr("%1\nLine %2, column %3")
+ .arg(xml.errorString())
+ .arg(xml.lineNumber())
+ .arg(xml.columnNumber());
+}
+//! [2]
+
+//! [3]
+void XbelReader::readXBEL()
+{
+ Q_ASSERT(xml.isStartElement() && xml.name() == "xbel"_L1);
+
+ while (xml.readNextStartElement()) {
+ if (xml.name() == "folder"_L1)
+ readFolder(nullptr);
+ else if (xml.name() == "bookmark"_L1)
+ readBookmark(nullptr);
+ else if (xml.name() == "separator"_L1)
+ readSeparator(nullptr);
+ else
+ xml.skipCurrentElement();
+ }
+}
+//! [3]
+
+//! [4]
+void XbelReader::readBookmark(QTreeWidgetItem *item)
+{
+ Q_ASSERT(xml.isStartElement() && xml.name() == "bookmark"_L1);
+
+ QTreeWidgetItem *bookmark = createChildItem(item);
+ bookmark->setFlags(bookmark->flags() | Qt::ItemIsEditable);
+ bookmark->setIcon(0, bookmarkIcon);
+ bookmark->setText(0, QObject::tr("Unknown title"));
+ bookmark->setText(1, xml.attributes().value("href"_L1).toString());
+
+ while (xml.readNextStartElement()) {
+ if (xml.name() == "title"_L1)
+ readTitle(bookmark);
+ else
+ xml.skipCurrentElement();
+ }
+}
+//! [4]
+
+//! [5]
+void XbelReader::readTitle(QTreeWidgetItem *item)
+{
+ Q_ASSERT(xml.isStartElement() && xml.name() == "title"_L1);
+ item->setText(0, xml.readElementText());
+}
+//! [5]
+
+//! [6]
+void XbelReader::readSeparator(QTreeWidgetItem *item)
+{
+ Q_ASSERT(xml.isStartElement() && xml.name() == "separator"_L1);
+ constexpr char16_t midDot = u'\xB7';
+ static const QString dots(30, midDot);
+
+ QTreeWidgetItem *separator = createChildItem(item);
+ separator->setFlags(item ? item->flags() & ~Qt::ItemIsSelectable : Qt::ItemFlags{});
+ separator->setText(0, dots);
+ xml.skipCurrentElement();
+}
+//! [6]
+
+//! [7]
+void XbelReader::readFolder(QTreeWidgetItem *item)
+{
+ Q_ASSERT(xml.isStartElement() && xml.name() == "folder"_L1);
+
+ QTreeWidgetItem *folder = createChildItem(item);
+ bool folded = xml.attributes().value("folded"_L1) != "no"_L1;
+ folder->setExpanded(!folded);
+
+ while (xml.readNextStartElement()) {
+ if (xml.name() == "title"_L1)
+ readTitle(folder);
+ else if (xml.name() == "folder"_L1)
+ readFolder(folder);
+ else if (xml.name() == "bookmark"_L1)
+ readBookmark(folder);
+ else if (xml.name() == "separator"_L1)
+ readSeparator(folder);
+ else
+ xml.skipCurrentElement();
+ }
+}
+//! [7]
+
+//! [8]
+QTreeWidgetItem *XbelReader::createChildItem(QTreeWidgetItem *item)
+{
+ QTreeWidgetItem *childItem = item ? new QTreeWidgetItem(item) : new QTreeWidgetItem(treeWidget);
+ childItem->setData(0, Qt::UserRole, xml.name().toString());
+ return childItem;
+}
+//! [8]
diff --git a/examples/corelib/serialization/streambookmarks/xbelreader.h b/examples/corelib/serialization/streambookmarks/xbelreader.h
new file mode 100644
index 0000000000..a3fa59d813
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/xbelreader.h
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef XBELREADER_H
+#define XBELREADER_H
+
+#include <QIcon>
+#include <QXmlStreamReader>
+
+QT_BEGIN_NAMESPACE
+class QTreeWidget;
+class QTreeWidgetItem;
+QT_END_NAMESPACE
+
+//! [0]
+class XbelReader
+{
+public:
+//! [1]
+ XbelReader(QTreeWidget *treeWidget);
+//! [1]
+
+ bool read(QIODevice *device);
+ QString errorString() const;
+
+private:
+//! [2]
+ void readXBEL();
+ void readTitle(QTreeWidgetItem *item);
+ void readSeparator(QTreeWidgetItem *item);
+ void readFolder(QTreeWidgetItem *item);
+ void readBookmark(QTreeWidgetItem *item);
+
+ QTreeWidgetItem *createChildItem(QTreeWidgetItem *item);
+
+ QXmlStreamReader xml;
+ QTreeWidget *treeWidget;
+//! [2]
+
+ QIcon folderIcon;
+ QIcon bookmarkIcon;
+};
+//! [0]
+
+#endif
diff --git a/examples/corelib/serialization/streambookmarks/xbelwriter.cpp b/examples/corelib/serialization/streambookmarks/xbelwriter.cpp
new file mode 100644
index 0000000000..e50f47a5a5
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/xbelwriter.cpp
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "xbelwriter.h"
+
+#include <QTreeWidget>
+
+using namespace Qt::StringLiterals;
+
+//! [0]
+XbelWriter::XbelWriter(const QTreeWidget *treeWidget) : treeWidget(treeWidget)
+{
+ xml.setAutoFormatting(true);
+}
+//! [0]
+
+//! [1]
+bool XbelWriter::writeFile(QIODevice *device)
+{
+ xml.setDevice(device);
+
+ xml.writeStartDocument();
+ xml.writeDTD("<!DOCTYPE xbel>"_L1);
+ xml.writeStartElement("xbel"_L1);
+ xml.writeAttribute("version"_L1, "1.0"_L1);
+ for (int i = 0; i < treeWidget->topLevelItemCount(); ++i)
+ writeItem(treeWidget->topLevelItem(i));
+
+ xml.writeEndDocument();
+ return true;
+}
+//! [1]
+
+//! [2]
+void XbelWriter::writeItem(const QTreeWidgetItem *item)
+{
+ QString tagName = item->data(0, Qt::UserRole).toString();
+ if (tagName == "folder"_L1) {
+ bool folded = !item->isExpanded();
+ xml.writeStartElement(tagName);
+ xml.writeAttribute("folded"_L1, folded ? "yes"_L1 : "no"_L1);
+ xml.writeTextElement("title"_L1, item->text(0));
+ for (int i = 0; i < item->childCount(); ++i)
+ writeItem(item->child(i));
+ xml.writeEndElement();
+ } else if (tagName == "bookmark"_L1) {
+ xml.writeStartElement(tagName);
+ if (!item->text(1).isEmpty())
+ xml.writeAttribute("href"_L1, item->text(1));
+ xml.writeTextElement("title"_L1, item->text(0));
+ xml.writeEndElement();
+ } else if (tagName == "separator"_L1) {
+ xml.writeEmptyElement(tagName);
+ }
+}
+//! [2]
diff --git a/examples/corelib/serialization/streambookmarks/xbelwriter.h b/examples/corelib/serialization/streambookmarks/xbelwriter.h
new file mode 100644
index 0000000000..ec95315c4b
--- /dev/null
+++ b/examples/corelib/serialization/streambookmarks/xbelwriter.h
@@ -0,0 +1,28 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef XBELWRITER_H
+#define XBELWRITER_H
+
+#include <QXmlStreamWriter>
+
+QT_BEGIN_NAMESPACE
+class QTreeWidget;
+class QTreeWidgetItem;
+QT_END_NAMESPACE
+
+//! [0]
+class XbelWriter
+{
+public:
+ explicit XbelWriter(const QTreeWidget *treeWidget);
+ bool writeFile(QIODevice *device);
+
+private:
+ void writeItem(const QTreeWidgetItem *item);
+ QXmlStreamWriter xml;
+ const QTreeWidget *treeWidget;
+};
+//! [0]
+
+#endif
diff --git a/examples/corelib/threads/CMakeLists.txt b/examples/corelib/threads/CMakeLists.txt
index f84700fdb4..670821a77d 100644
--- a/examples/corelib/threads/CMakeLists.txt
+++ b/examples/corelib/threads/CMakeLists.txt
@@ -1,8 +1,11 @@
-# Generated from threads.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(semaphores)
-add_subdirectory(waitconditions)
-if(TARGET Qt::Widgets)
- add_subdirectory(mandelbrot)
- add_subdirectory(queuedcustomtype)
+if(NOT ANDROID)
+ qt_internal_add_example(semaphores)
+ qt_internal_add_example(waitconditions)
+endif()
+if(TARGET Qt6::Widgets)
+ qt_internal_add_example(mandelbrot)
+ qt_internal_add_example(queuedcustomtype)
endif()
diff --git a/examples/corelib/threads/doc/src/mandelbrot.qdoc b/examples/corelib/threads/doc/src/mandelbrot.qdoc
index 2b12743538..6081912e69 100644
--- a/examples/corelib/threads/doc/src/mandelbrot.qdoc
+++ b/examples/corelib/threads/doc/src/mandelbrot.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example threads/mandelbrot
- \title Mandelbrot Example
+ \examplecategory {Data Processing & I/O}
+ \title Mandelbrot
\ingroup qtconcurrent-mtexamples
\brief The Mandelbrot example demonstrates multi-thread programming
@@ -37,17 +14,17 @@
\image mandelbrot-example.png Screenshot of the Mandelbrot example
- The heavy computation here is the Mandelbrot set, probably the
- world's most famous fractal. These days, while sophisticated
- programs such as \l{http://matek.hu/xaos/doku.php}{XaoS} that provide real-time zooming in the
- Mandelbrot set, the standard Mandelbrot algorithm is just slow
- enough for our purposes.
+ The heavy computation here is the Mandelbrot set, probably the world's most
+ famous fractal. These days, while sophisticated programs, such as
+ \l{https://xaos-project.github.io/}{XaoS}, provide real-time zooming in
+ the Mandelbrot set, the standard Mandelbrot algorithm is just slow enough
+ for our purposes.
In real life, the approach described here is applicable to a
large set of problems, including synchronous network I/O and
database access, where the user interface must remain responsive
while some heavy operation is taking place. The \l
- {Blocking Fortune Client Example} shows the same principle at
+ {Blocking Fortune Client} example shows the same principle at
work in a TCP client.
The Mandelbrot application supports zooming and scrolling using
@@ -170,12 +147,12 @@
rendering parameters in local variables. As usual, we protect
accesses to the member variables using the class's mutex. Storing
the member variables in local variables allows us to minimize the
- amout of code that needs to be protected by a mutex. This ensures
+ amount of code that needs to be protected by a mutex. This ensures
that the main thread will never have to block for too long when
it needs to access \c{RenderThread}'s member variables (e.g., in
\c render()).
- The \c forever keyword is, like \c foreach, a Qt pseudo-keyword.
+ The \c forever keyword is a Qt pseudo-keyword.
\snippet threads/mandelbrot/renderthread.cpp 4
\snippet threads/mandelbrot/renderthread.cpp 5
@@ -327,6 +304,11 @@
\snippet threads/mandelbrot/mandelbrotwidget.cpp 13
+ Pinch to zoom has been implemented with QGesture as outlined in
+ \l{Gestures in Widgets and Graphics View}.
+
+ \snippet threads/mandelbrot/mandelbrotwidget.cpp gesture1
+
When the user presses the left mouse button, we store the mouse
pointer position in \c lastDragPos.
diff --git a/examples/corelib/threads/doc/src/queuedcustomtype.qdoc b/examples/corelib/threads/doc/src/queuedcustomtype.qdoc
index 86d5992294..8d56695c79 100644
--- a/examples/corelib/threads/doc/src/queuedcustomtype.qdoc
+++ b/examples/corelib/threads/doc/src/queuedcustomtype.qdoc
@@ -1,34 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example threads/queuedcustomtype
- \title Queued Custom Type Example
- \brief Demonstrates multi-thread programming using Qt.
+ \examplecategory {Data Processing & I/O}
+ \title Queued Custom Type
\ingroup qtconcurrent-mtexamples
\brief The Queued Custom Type example shows how to send custom types between
@@ -42,20 +18,15 @@
\section1 Overview
- In the \l{Custom Type Example}, we showed how to integrate custom types with
- the meta-object system, enabling them to be stored in QVariant objects, written
- out in debugging information and used in signal-slot communication.
-
- In this example, we create a new value class, \c Block, and register it
- with the meta-object system to enable us to send instances of it between
- threads using queued signals and slots.
+ In this example, we create a value class, \c Block, and register it with
+ the meta-object system to enable us to send instances of it between threads
+ using queued signals and slots.
\section1 The Block Class
- The \c Block class is similar to the \c Message class described in the
- \l{Custom Type Example}. It provides the default constructor, copy
- constructor and destructor in the public section of the class that the
- meta-object system requires. It describes a colored rectangle.
+ The \c Block class provides the default constructor, copy constructor, and
+ a destructor in the public section of the class as required by the
+ meta-object system. The class describes a colored rectangle.
\snippet threads/queuedcustomtype/block.h custom type definition and meta-type declaration
@@ -151,9 +122,7 @@
This example showed how a custom type can be registered with the
meta-object system so that it can be used with signal-slot connections
- between threads. For ordinary communication involving direct signals and
- slots, it is enough to simply declare the type in the way described in the
- \l{Custom Type Example}.
+ between threads.
In practice, both the Q_DECLARE_METATYPE() macro and the qRegisterMetaType()
template function can be used to register custom types, but
diff --git a/examples/corelib/threads/doc/src/semaphores.qdoc b/examples/corelib/threads/doc/src/semaphores.qdoc
index 5293e80c0e..f5ff90b014 100644
--- a/examples/corelib/threads/doc/src/semaphores.qdoc
+++ b/examples/corelib/threads/doc/src/semaphores.qdoc
@@ -1,39 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example threads/semaphores
- \title Semaphores Example
- \brief Demonstrates multi-thread programming using Qt.
+ \examplecategory {Data Processing & I/O}
+ \title Producer and Consumer using Semaphores
\ingroup qtconcurrent-mtexamples
- \brief The Semaphores example shows how to use QSemaphore to control
- access to a circular buffer shared by a producer thread and a
- consumer thread.
+ \brief The Producer and Consumer using Semaphores example shows how
+ to use QSemaphore to control access to a circular buffer shared
+ by a producer thread and a consumer thread.
The producer writes data to the buffer until it reaches the end
of the buffer, at which point it restarts from the beginning,
@@ -54,7 +30,7 @@
An alternative to using QSemaphore to solve the producer-consumer
problem is to use QWaitCondition and QMutex. This is what the
- \l{Wait Conditions Example} does.
+ \l{Producer and Consumer using Wait Conditions} example does.
\section1 Global Variables
@@ -63,7 +39,7 @@
\snippet threads/semaphores/semaphores.cpp 0
- \c DataSize is the amout of data that the producer will generate.
+ \c DataSize is the amount of data that the producer will generate.
To keep the example as simple as possible, we make it a constant.
\c BufferSize is the size of the circular buffer. It is less than
\c DataSize, meaning that at some point the producer will reach
diff --git a/examples/corelib/threads/doc/src/waitconditions.qdoc b/examples/corelib/threads/doc/src/waitconditions.qdoc
index cfac460345..d46442d079 100644
--- a/examples/corelib/threads/doc/src/waitconditions.qdoc
+++ b/examples/corelib/threads/doc/src/waitconditions.qdoc
@@ -1,39 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example threads/waitconditions
- \title Wait Conditions Example
- \brief Demonstrates multi-thread programming using Qt.
+ \examplecategory {Data Processing & I/O}
+ \title Producer and Consumer using Wait Conditions
\ingroup qtconcurrent-mtexamples
- \brief The Wait Conditions example shows how to use QWaitCondition and
- QMutex to control access to a circular buffer shared by a
- producer thread and a consumer thread.
+ \brief The Producer and Consumer using Wait Conditions example shows
+ how to use QWaitCondition and QMutex to control access to a circular
+ buffer shared by a producer thread and a consumer thread.
The producer writes data to the buffer until it reaches the end
of the buffer, at which point it restarts from the beginning,
@@ -54,7 +30,7 @@
An alternative to using QWaitCondition and QMutex to solve the
producer-consumer problem is to use QSemaphore. This is what the
- \l{Semaphores Example} does.
+ \l{Producer and Consumer using Semaphores} example does.
\section1 Global Variables
@@ -133,7 +109,7 @@
thread is the only one that can do anything; the consumer is
blocked waiting for the \c bufferNotEmpty condition to be
signalled (\c numUsedBytes is 0). Once the producer has put one
- byte in the buffer, \c numUsedBytes is \c BufferSize - 1 and the
+ byte in the buffer, \c numUsedBytes is strictly greater than 0, and the
\c bufferNotEmpty condition is signalled. At that point, two
things can happen: Either the consumer thread takes over and
reads that byte, or the producer gets to produce a second byte.
diff --git a/examples/corelib/threads/mandelbrot/CMakeLists.txt b/examples/corelib/threads/mandelbrot/CMakeLists.txt
index 96136522f7..be296918cc 100644
--- a/examples/corelib/threads/mandelbrot/CMakeLists.txt
+++ b/examples/corelib/threads/mandelbrot/CMakeLists.txt
@@ -1,47 +1,39 @@
-# Generated from mandelbrot.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(mandelbrot LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/threads/mandelbrot")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(mandelbrot
main.cpp
mandelbrotwidget.cpp mandelbrotwidget.h
renderthread.cpp renderthread.h
)
+
set_target_properties(mandelbrot PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(mandelbrot PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-if(UNIX AND NOT APPLE AND NOT HAIKU AND NOT INTEGRITY AND NOT VXWORKS)
- target_link_libraries(mandelbrot PUBLIC
- m
- )
-endif()
+target_link_libraries(mandelbrot PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+)
install(TARGETS mandelbrot
- 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 mandelbrot
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/threads/mandelbrot/main.cpp b/examples/corelib/threads/mandelbrot/main.cpp
index 9832d55514..8aafebf7d7 100644
--- a/examples/corelib/threads/mandelbrot/main.cpp
+++ b/examples/corelib/threads/mandelbrot/main.cpp
@@ -1,62 +1,42 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mandelbrotwidget.h"
+#include "renderthread.h"
#include <QApplication>
+#include <QCommandLineParser>
+#include <QCommandLineOption>
+#include <QDebug>
+
+using namespace Qt::StringLiterals;
//! [0]
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+
+ QCommandLineParser parser;
+ parser.setApplicationDescription(u"Qt Mandelbrot Example"_s);
+ parser.addHelpOption();
+ parser.addVersionOption();
+ QCommandLineOption passesOption(u"passes"_s, u"Number of passes (1-8)"_s, u"passes"_s);
+ parser.addOption(passesOption);
+ parser.process(app);
+
+ if (parser.isSet(passesOption)) {
+ const auto passesStr = parser.value(passesOption);
+ bool ok;
+ const int passes = passesStr.toInt(&ok);
+ if (!ok || passes < 1 || passes > 8) {
+ qWarning() << "Invalid value:" << passesStr;
+ return -1;
+ }
+ RenderThread::setNumPasses(passes);
+ }
+
MandelbrotWidget widget;
+ widget.grabGesture(Qt::PinchGesture);
widget.show();
return app.exec();
}
diff --git a/examples/corelib/threads/mandelbrot/mandelbrot.pro b/examples/corelib/threads/mandelbrot/mandelbrot.pro
index 92010fdc1f..7edf01ff30 100644
--- a/examples/corelib/threads/mandelbrot/mandelbrot.pro
+++ b/examples/corelib/threads/mandelbrot/mandelbrot.pro
@@ -6,8 +6,6 @@ SOURCES = main.cpp \
mandelbrotwidget.cpp \
renderthread.cpp
-unix:!mac:!vxworks:!integrity:!haiku:LIBS += -lm
-
# install
target.path = $$[QT_INSTALL_EXAMPLES]/corelib/threads/mandelbrot
INSTALLS += target
diff --git a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
index b0c3733b22..bbe694831d 100644
--- a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
+++ b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
@@ -1,68 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mandelbrotwidget.h"
-#include <QPainter>
+#include <QGesture>
+#include <QGestureEvent>
#include <QKeyEvent>
+#include <QPainter>
#include <math.h>
//! [0]
-const double DefaultCenterX = -0.637011;
-const double DefaultCenterY = -0.0395159;
-const double DefaultScale = 0.00403897;
+constexpr double DefaultCenterX = -0.637011;
+constexpr double DefaultCenterY = -0.0395159;
+constexpr double DefaultScale = 0.00403897;
-const double ZoomInFactor = 0.8;
-const double ZoomOutFactor = 1 / ZoomInFactor;
-const int ScrollStep = 20;
+constexpr double ZoomInFactor = 0.8;
+constexpr double ZoomOutFactor = 1 / ZoomInFactor;
+constexpr int ScrollStep = 20;
//! [0]
//! [1]
@@ -73,6 +28,7 @@ MandelbrotWidget::MandelbrotWidget(QWidget *parent) :
pixmapScale(DefaultScale),
curScale(DefaultScale)
{
+ help = tr("Zoom with mouse wheel, +/- keys or pinch. Scroll with arrow keys or by dragging.");
connect(&thread, &RenderThread::renderedImage,
this, &MandelbrotWidget::updatePixmap);
@@ -80,8 +36,6 @@ MandelbrotWidget::MandelbrotWidget(QWidget *parent) :
#if QT_CONFIG(cursor)
setCursor(Qt::CrossCursor);
#endif
- resize(550, 400);
-
}
//! [1]
@@ -93,7 +47,8 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */)
if (pixmap.isNull()) {
painter.setPen(Qt::white);
- painter.drawText(rect(), Qt::AlignCenter, tr("Rendering initial image, please wait..."));
+ painter.drawText(rect(), Qt::AlignCenter|Qt::TextWordWrap,
+ tr("Rendering initial image, please wait..."));
//! [2] //! [3]
return;
//! [3] //! [4]
@@ -107,36 +62,51 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */)
//! [6] //! [7]
} else {
//! [7] //! [8]
- auto previewPixmap = qFuzzyCompare(pixmap.devicePixelRatio(), qreal(1))
+ const auto previewPixmap = qFuzzyCompare(pixmap.devicePixelRatio(), qreal(1))
? pixmap
- : pixmap.scaled(pixmap.size() / pixmap.devicePixelRatio(), Qt::KeepAspectRatio,
+ : pixmap.scaled(pixmap.deviceIndependentSize().toSize(), Qt::KeepAspectRatio,
Qt::SmoothTransformation);
- double scaleFactor = pixmapScale / curScale;
- int newWidth = int(previewPixmap.width() * scaleFactor);
- int newHeight = int(previewPixmap.height() * scaleFactor);
- int newX = pixmapOffset.x() + (previewPixmap.width() - newWidth) / 2;
- int newY = pixmapOffset.y() + (previewPixmap.height() - newHeight) / 2;
+ const double scaleFactor = pixmapScale / curScale;
+ const int newWidth = int(previewPixmap.width() * scaleFactor);
+ const int newHeight = int(previewPixmap.height() * scaleFactor);
+ const int newX = pixmapOffset.x() + (previewPixmap.width() - newWidth) / 2;
+ const int newY = pixmapOffset.y() + (previewPixmap.height() - newHeight) / 2;
painter.save();
painter.translate(newX, newY);
painter.scale(scaleFactor, scaleFactor);
- QRectF exposed = painter.transform().inverted().mapRect(rect()).adjusted(-1, -1, 1, 1);
+ const QRectF exposed = painter.transform().inverted().mapRect(rect())
+ .adjusted(-1, -1, 1, 1);
painter.drawPixmap(exposed, previewPixmap, exposed);
painter.restore();
}
//! [8] //! [9]
- QString text = tr("Use mouse wheel or the '+' and '-' keys to zoom. "
- "Press and hold left mouse button to scroll.");
- QFontMetrics metrics = painter.fontMetrics();
- int textWidth = metrics.horizontalAdvance(text);
+ const QFontMetrics metrics = painter.fontMetrics();
+ if (!info.isEmpty()){
+ const int infoWidth = metrics.horizontalAdvance(info);
+ const int infoHeight = (infoWidth/width() + 1) * (metrics.height() + 5);
+
+ painter.setPen(Qt::NoPen);
+ painter.setBrush(QColor(0, 0, 0, 127));
+ painter.drawRect((width() - infoWidth) / 2 - 5, 0, infoWidth + 10, infoHeight);
+
+ painter.setPen(Qt::white);
+ painter.drawText(rect(), Qt::AlignHCenter|Qt::AlignTop|Qt::TextWordWrap, info);
+ }
+
+ const int helpWidth = metrics.horizontalAdvance(help);
+ const int helpHeight = (helpWidth/width() + 1) * (metrics.height() + 5);
painter.setPen(Qt::NoPen);
painter.setBrush(QColor(0, 0, 0, 127));
- painter.drawRect((width() - textWidth) / 2 - 5, 0, textWidth + 10, metrics.lineSpacing() + 5);
+ painter.drawRect((width() - helpWidth) / 2 - 5, height()-helpHeight, helpWidth + 10,
+ helpHeight);
+
painter.setPen(Qt::white);
- painter.drawText((width() - textWidth) / 2, metrics.leading() + metrics.ascent(), text);
+ painter.drawText(rect(), Qt::AlignHCenter|Qt::AlignBottom|Qt::TextWordWrap, help);
+
}
//! [9]
@@ -169,6 +139,9 @@ void MandelbrotWidget::keyPressEvent(QKeyEvent *event)
case Qt::Key_Up:
scroll(0, +ScrollStep);
break;
+ case Qt::Key_Q:
+ close();
+ break;
default:
QWidget::keyPressEvent(event);
}
@@ -212,9 +185,9 @@ void MandelbrotWidget::mouseReleaseEvent(QMouseEvent *event)
pixmapOffset += event->position().toPoint() - lastDragPos;
lastDragPos = QPoint();
- const auto pixmapSize = pixmap.size() / pixmap.devicePixelRatio();
- int deltaX = (width() - pixmapSize.width()) / 2 - pixmapOffset.x();
- int deltaY = (height() - pixmapSize.height()) / 2 - pixmapOffset.y();
+ const auto pixmapSize = pixmap.deviceIndependentSize().toSize();
+ const int deltaX = (width() - pixmapSize.width()) / 2 - pixmapOffset.x();
+ const int deltaY = (height() - pixmapSize.height()) / 2 - pixmapOffset.y();
scroll(deltaX, deltaY);
}
}
@@ -226,6 +199,8 @@ void MandelbrotWidget::updatePixmap(const QImage &image, double scaleFactor)
if (!lastDragPos.isNull())
return;
+ info = image.text(RenderThread::infoKey());
+
pixmap = QPixmap::fromImage(image);
pixmapOffset = QPoint();
lastDragPos = QPoint();
@@ -252,3 +227,24 @@ void MandelbrotWidget::scroll(int deltaX, int deltaY)
thread.render(centerX, centerY, curScale, size(), devicePixelRatio());
}
//! [18]
+
+//! [gesture1]
+#ifndef QT_NO_GESTURES
+bool MandelbrotWidget::gestureEvent(QGestureEvent *event)
+{
+ if (auto *pinch = static_cast<QPinchGesture *>(event->gesture(Qt::PinchGesture))) {
+ if (pinch->changeFlags().testFlag(QPinchGesture::ScaleFactorChanged))
+ zoom(1.0 / pinch->scaleFactor());
+ return true;
+ }
+ return false;
+}
+
+bool MandelbrotWidget::event(QEvent *event)
+{
+ if (event->type() == QEvent::Gesture)
+ return gestureEvent(static_cast<QGestureEvent*>(event));
+ return QWidget::event(event);
+}
+#endif
+//! [gesture1]
diff --git a/examples/corelib/threads/mandelbrot/mandelbrotwidget.h b/examples/corelib/threads/mandelbrot/mandelbrotwidget.h
index cb40962535..0d0fce56b3 100644
--- a/examples/corelib/threads/mandelbrot/mandelbrotwidget.h
+++ b/examples/corelib/threads/mandelbrot/mandelbrotwidget.h
@@ -1,70 +1,29 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MANDELBROTWIDGET_H
#define MANDELBROTWIDGET_H
+#include "renderthread.h"
+
+#include <QCoreApplication>
#include <QPixmap>
#include <QWidget>
-#include "renderthread.h"
+QT_BEGIN_NAMESPACE
+class QGestureEvent;
+QT_END_NAMESPACE
//! [0]
class MandelbrotWidget : public QWidget
{
- Q_OBJECT
+ Q_DECLARE_TR_FUNCTIONS(MandelbrotWidget)
public:
MandelbrotWidget(QWidget *parent = nullptr);
protected:
+ QSize sizeHint() const override { return {1024, 768}; };
void paintEvent(QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
@@ -74,18 +33,24 @@ protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
+#ifndef QT_NO_GESTURES
+ bool event(QEvent *event) override;
+#endif
-private slots:
+private:
void updatePixmap(const QImage &image, double scaleFactor);
void zoom(double zoomFactor);
-
-private:
void scroll(int deltaX, int deltaY);
+#ifndef QT_NO_GESTURES
+ bool gestureEvent(QGestureEvent *event);
+#endif
RenderThread thread;
QPixmap pixmap;
QPoint pixmapOffset;
QPoint lastDragPos;
+ QString help;
+ QString info;
double centerX;
double centerY;
double pixmapScale;
diff --git a/examples/corelib/threads/mandelbrot/renderthread.cpp b/examples/corelib/threads/mandelbrot/renderthread.cpp
index 4d2009471c..77a14a6ac1 100644
--- a/examples/corelib/threads/mandelbrot/renderthread.cpp
+++ b/examples/corelib/threads/mandelbrot/renderthread.cpp
@@ -1,58 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "renderthread.h"
#include <QImage>
+#include <QElapsedTimer>
+#include <QTextStream>
+
#include <cmath>
+int RenderThread::numPasses = 8;
+
//! [0]
RenderThread::RenderThread(QObject *parent)
: QThread(parent)
@@ -98,6 +56,7 @@ void RenderThread::render(double centerX, double centerY, double scaleFactor,
//! [3]
void RenderThread::run()
{
+ QElapsedTimer timer;
forever {
mutex.lock();
const double devicePixelRatio = this->devicePixelRatio;
@@ -110,19 +69,20 @@ void RenderThread::run()
//! [3]
//! [4]
- int halfWidth = resultSize.width() / 2;
+ const int halfWidth = resultSize.width() / 2;
//! [4] //! [5]
- int halfHeight = resultSize.height() / 2;
+ const int halfHeight = resultSize.height() / 2;
QImage image(resultSize, QImage::Format_RGB32);
image.setDevicePixelRatio(devicePixelRatio);
- const int NumPasses = 8;
int pass = 0;
- while (pass < NumPasses) {
+ while (pass < numPasses) {
const int MaxIterations = (1 << (2 * pass + 6)) + 32;
- const int Limit = 4;
+ constexpr int Limit = 4;
bool allBlack = true;
+ timer.restart();
+
for (int y = -halfHeight; y < halfHeight; ++y) {
if (restart)
break;
@@ -165,8 +125,20 @@ void RenderThread::run()
if (allBlack && pass == 0) {
pass = 4;
} else {
- if (!restart)
+ if (!restart) {
+ QString message;
+ QTextStream str(&message);
+ str << " Pass " << (pass + 1) << '/' << numPasses
+ << ", max iterations: " << MaxIterations << ", time: ";
+ const auto elapsed = timer.elapsed();
+ if (elapsed > 2000)
+ str << (elapsed / 1000) << 's';
+ else
+ str << elapsed << "ms";
+ image.setText(infoKey(), message);
+
emit renderedImage(image, requestedScaleFactor);
+ }
//! [5] //! [6]
++pass;
}
diff --git a/examples/corelib/threads/mandelbrot/renderthread.h b/examples/corelib/threads/mandelbrot/renderthread.h
index 6174e0ed3d..ecd8ae084d 100644
--- a/examples/corelib/threads/mandelbrot/renderthread.h
+++ b/examples/corelib/threads/mandelbrot/renderthread.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef RENDERTHREAD_H
#define RENDERTHREAD_H
@@ -72,6 +25,10 @@ public:
void render(double centerX, double centerY, double scaleFactor, QSize resultSize,
double devicePixelRatio);
+ static void setNumPasses(int n) { numPasses = n; }
+
+ static QString infoKey() { return QStringLiteral("info"); }
+
signals:
void renderedImage(const QImage &image, double scaleFactor);
@@ -88,10 +45,11 @@ private:
double scaleFactor;
double devicePixelRatio;
QSize resultSize;
+ static int numPasses;
bool restart = false;
bool abort = false;
- enum { ColormapSize = 512 };
+ static constexpr int ColormapSize = 512;
uint colormap[ColormapSize];
};
//! [0]
diff --git a/examples/corelib/threads/queuedcustomtype/CMakeLists.txt b/examples/corelib/threads/queuedcustomtype/CMakeLists.txt
index 93c26318f6..725c268615 100644
--- a/examples/corelib/threads/queuedcustomtype/CMakeLists.txt
+++ b/examples/corelib/threads/queuedcustomtype/CMakeLists.txt
@@ -1,23 +1,12 @@
-# Generated from queuedcustomtype.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(queuedcustomtype LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/threads/queuedcustomtype")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(queuedcustomtype
block.cpp block.h
@@ -25,18 +14,27 @@ qt_add_executable(queuedcustomtype
renderthread.cpp renderthread.h
window.cpp window.h
)
+
set_target_properties(queuedcustomtype PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(queuedcustomtype PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+
+target_link_libraries(queuedcustomtype PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS queuedcustomtype
- 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 queuedcustomtype
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/threads/queuedcustomtype/block.cpp b/examples/corelib/threads/queuedcustomtype/block.cpp
index 9cfad8673c..3fcc5383b7 100644
--- a/examples/corelib/threads/queuedcustomtype/block.cpp
+++ b/examples/corelib/threads/queuedcustomtype/block.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "block.h"
diff --git a/examples/corelib/threads/queuedcustomtype/block.h b/examples/corelib/threads/queuedcustomtype/block.h
index eef48b25c2..cbebfb0e3d 100644
--- a/examples/corelib/threads/queuedcustomtype/block.h
+++ b/examples/corelib/threads/queuedcustomtype/block.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef BLOCK_H
#define BLOCK_H
diff --git a/examples/corelib/threads/queuedcustomtype/main.cpp b/examples/corelib/threads/queuedcustomtype/main.cpp
index 1f25fafa1b..0a14cb48e1 100644
--- a/examples/corelib/threads/queuedcustomtype/main.cpp
+++ b/examples/corelib/threads/queuedcustomtype/main.cpp
@@ -1,59 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include <QApplication>
-#include <QPainter>
-#include <QTime>
#include "block.h"
#include "window.h"
+#include <QApplication>
+#include <QBrush>
+#include <QImage>
+#include <QPainter>
+#include <QPen>
+#include <QPointF>
+#include <QRect>
+
QImage createImage(int width, int height)
{
QImage image(width, height, QImage::Format_RGB16);
@@ -90,8 +48,8 @@ QImage createImage(int width, int height)
int x = 0;
int y = 0;
- int starWidth = image.width()/3;
- int starHeight = image.height()/3;
+ const int starWidth = image.width()/3;
+ const int starHeight = image.height()/3;
QRect rect(x, y, starWidth, starHeight);
diff --git a/examples/corelib/threads/queuedcustomtype/renderthread.cpp b/examples/corelib/threads/queuedcustomtype/renderthread.cpp
index 67cedf1e74..34a439f3fe 100644
--- a/examples/corelib/threads/queuedcustomtype/renderthread.cpp
+++ b/examples/corelib/threads/queuedcustomtype/renderthread.cpp
@@ -1,69 +1,19 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+#include "block.h"
#include "renderthread.h"
#include <QRandomGenerator>
+#include <QRgb>
RenderThread::RenderThread(QObject *parent)
: QThread(parent)
{
- m_abort = false;
}
RenderThread::~RenderThread()
{
- mutex.lock();
- m_abort = true;
- mutex.unlock();
-
wait();
}
@@ -74,27 +24,26 @@ void RenderThread::processImage(const QImage &image)
return;
m_image = image;
- m_abort = false;
start();
}
void RenderThread::run()
{
- int size = qMax(m_image.width()/20, m_image.height()/20);
+ const int size = qMax(m_image.width()/20, m_image.height()/20);
for (int s = size; s > 0; --s) {
for (int c = 0; c < 400; ++c) {
//![processing the image (start)]
- int x1 = qMax(0, QRandomGenerator::global()->bounded(m_image.width()) - s/2);
- int x2 = qMin(x1 + s/2 + 1, m_image.width());
- int y1 = qMax(0, QRandomGenerator::global()->bounded(m_image.height()) - s/2);
- int y2 = qMin(y1 + s/2 + 1, m_image.height());
+ const int x1 = qMax(0, QRandomGenerator::global()->bounded(m_image.width()) - s/2);
+ const int x2 = qMin(x1 + s/2 + 1, m_image.width());
+ const int y1 = qMax(0, QRandomGenerator::global()->bounded(m_image.height()) - s/2);
+ const int y2 = qMin(y1 + s/2 + 1, m_image.height());
int n = 0;
int red = 0;
int green = 0;
int blue = 0;
for (int i = y1; i < y2; ++i) {
for (int j = x1; j < x2; ++j) {
- QRgb pixel = m_image.pixel(j, i);
+ const QRgb pixel = m_image.pixel(j, i);
red += qRed(pixel);
green += qGreen(pixel);
blue += qBlue(pixel);
@@ -102,20 +51,13 @@ void RenderThread::run()
}
}
//![processing the image (finish)]
- Block block(QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1),
+ const Block block(QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1),
QColor(red/n, green/n, blue/n));
emit sendBlock(block);
- if (m_abort)
+ if (isInterruptionRequested())
return;
msleep(10);
}
}
}
//![processing the image (finish)]
-
-void RenderThread::stopProcess()
-{
- mutex.lock();
- m_abort = true;
- mutex.unlock();
-}
diff --git a/examples/corelib/threads/queuedcustomtype/renderthread.h b/examples/corelib/threads/queuedcustomtype/renderthread.h
index 9375b60e74..c3152e4081 100644
--- a/examples/corelib/threads/queuedcustomtype/renderthread.h
+++ b/examples/corelib/threads/queuedcustomtype/renderthread.h
@@ -1,60 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef RENDERTHREAD_H
#define RENDERTHREAD_H
#include <QImage>
-#include <QMutex>
#include <QThread>
-#include "block.h"
+
+class Block;
//! [RenderThread class definition]
class RenderThread : public QThread
@@ -70,16 +23,11 @@ public:
signals:
void sendBlock(const Block &block);
-public slots:
- void stopProcess();
-
protected:
void run();
private:
- bool m_abort;
QImage m_image;
- QMutex mutex;
};
//! [RenderThread class definition]
diff --git a/examples/corelib/threads/queuedcustomtype/window.cpp b/examples/corelib/threads/queuedcustomtype/window.cpp
index 183d9824cb..db12133206 100644
--- a/examples/corelib/threads/queuedcustomtype/window.cpp
+++ b/examples/corelib/threads/queuedcustomtype/window.cpp
@@ -1,55 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+#include "block.h"
+#include "renderthread.h"
#include "window.h"
-#include <QtWidgets>
+
+#include <QFileDialog>
+#include <QGuiApplication>
+#include <QHBoxLayout>
+#include <QImageReader>
+#include <QPainter>
+#include <QScreen>
+#include <QVBoxLayout>
//! [Window constructor start]
Window::Window(QWidget *parent)
@@ -67,7 +29,7 @@ Window::Window(QWidget *parent)
connect(loadButton, &QPushButton::clicked,
this, QOverload<>::of(&Window::loadImage));
connect(resetButton, &QPushButton::clicked,
- thread, &RenderThread::stopProcess);
+ thread, &RenderThread::requestInterruption);
connect(thread, &RenderThread::finished,
this, &Window::resetUi);
//! [set up widgets and connections] //! [connecting signal with custom type]
@@ -98,13 +60,13 @@ void Window::loadImage()
if (format.toLower() == format)
formats.append(QLatin1String("*.") + QString::fromLatin1(format));
- QString newPath = QFileDialog::getOpenFileName(this, tr("Open Image"),
+ const QString newPath = QFileDialog::getOpenFileName(this, tr("Open Image"),
path, tr("Image files (%1)").arg(formats.join(' ')));
if (newPath.isEmpty())
return;
- QImage image(newPath);
+ const QImage image(newPath);
if (!image.isNull()) {
loadImage(image);
path = newPath;
@@ -114,7 +76,7 @@ void Window::loadImage()
void Window::loadImage(const QImage &image)
{
QImage useImage;
- QRect space = QGuiApplication::primaryScreen()->availableGeometry();
+ const QRect space = QGuiApplication::primaryScreen()->availableGeometry();
if (image.width() > 0.75*space.width() || image.height() > 0.75*space.height())
useImage = image.scaled(0.75*space.width(), 0.75*space.height(),
Qt::KeepAspectRatio, Qt::SmoothTransformation);
diff --git a/examples/corelib/threads/queuedcustomtype/window.h b/examples/corelib/threads/queuedcustomtype/window.h
index 4215dfd5a7..a4f995696e 100644
--- a/examples/corelib/threads/queuedcustomtype/window.h
+++ b/examples/corelib/threads/queuedcustomtype/window.h
@@ -1,63 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
+#include <QImage>
+#include <QLabel>
+#include <QPixmap>
+#include <QPushButton>
#include <QWidget>
-#include "renderthread.h"
-QT_BEGIN_NAMESPACE
-class QLabel;
-class QPushButton;
-QT_END_NAMESPACE
+class Block;
+class RenderThread;
//! [Window class definition]
class Window : public QWidget
diff --git a/examples/corelib/threads/semaphores/CMakeLists.txt b/examples/corelib/threads/semaphores/CMakeLists.txt
index f79e241fcc..a096616e5a 100644
--- a/examples/corelib/threads/semaphores/CMakeLists.txt
+++ b/examples/corelib/threads/semaphores/CMakeLists.txt
@@ -1,35 +1,34 @@
-# Generated from semaphores.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(semaphores LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+if (ANDROID)
+ message(FATAL_ERROR "This project cannot be built on Android.")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/threads/semaphores")
+find_package(Qt6 REQUIRED COMPONENTS Core)
-find_package(Qt6 COMPONENTS Core)
+qt_standard_project_setup()
qt_add_executable(semaphores
semaphores.cpp
)
-set_target_properties(semaphores PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(semaphores PUBLIC
- Qt::Core
+
+target_link_libraries(semaphores PRIVATE
+ Qt6::Core
)
install(TARGETS semaphores
- 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 semaphores
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/threads/semaphores/semaphores.cpp b/examples/corelib/threads/semaphores/semaphores.cpp
index a245b9906b..103f331b0c 100644
--- a/examples/corelib/threads/semaphores/semaphores.cpp
+++ b/examples/corelib/threads/semaphores/semaphores.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtCore>
@@ -54,9 +7,9 @@
#include <stdlib.h>
//! [0]
-const int DataSize = 100000;
+constexpr int DataSize = 100000;
-const int BufferSize = 8192;
+constexpr int BufferSize = 8192;
char buffer[BufferSize];
QSemaphore freeBytes(BufferSize);
@@ -83,7 +36,6 @@ public:
class Consumer : public QThread
//! [3] //! [4]
{
- Q_OBJECT
public:
void run() override
{
@@ -111,5 +63,3 @@ int main(int argc, char *argv[])
return 0;
}
//! [6]
-
-#include "semaphores.moc"
diff --git a/examples/corelib/threads/waitconditions/CMakeLists.txt b/examples/corelib/threads/waitconditions/CMakeLists.txt
index 9581dd58e9..5fc44a079b 100644
--- a/examples/corelib/threads/waitconditions/CMakeLists.txt
+++ b/examples/corelib/threads/waitconditions/CMakeLists.txt
@@ -1,35 +1,34 @@
-# Generated from waitconditions.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(waitconditions LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+if (ANDROID)
+ message(FATAL_ERROR "This project cannot be built on Android.")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/threads/waitconditions")
+find_package(Qt6 REQUIRED COMPONENTS Core)
-find_package(Qt6 COMPONENTS Core)
+qt_standard_project_setup()
qt_add_executable(waitconditions
waitconditions.cpp
)
-set_target_properties(waitconditions PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(waitconditions PUBLIC
- Qt::Core
+
+target_link_libraries(waitconditions PRIVATE
+ Qt6::Core
)
install(TARGETS waitconditions
- 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 waitconditions
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/threads/waitconditions/waitconditions.cpp b/examples/corelib/threads/waitconditions/waitconditions.cpp
index 963ee03a76..bdc24acd8c 100644
--- a/examples/corelib/threads/waitconditions/waitconditions.cpp
+++ b/examples/corelib/threads/waitconditions/waitconditions.cpp
@@ -1,68 +1,28 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore>
+// Copyright (C) 2016 The Qt Company Ltd.
+// Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QCoreApplication>
+#include <QMutex>
+#include <QMutexLocker>
+#include <QObject>
+#include <QRandomGenerator>
+#include <QThread>
+#include <QWaitCondition>
#include <stdio.h>
#include <stdlib.h>
//! [0]
-const int DataSize = 100000;
+constexpr int DataSize = 100000;
+constexpr int BufferSize = 8192;
-const int BufferSize = 8192;
+QMutex mutex; // protects the buffer and the counter
char buffer[BufferSize];
+int numUsedBytes;
QWaitCondition bufferNotEmpty;
QWaitCondition bufferNotFull;
-QMutex mutex;
-int numUsedBytes = 0;
//! [0]
//! [1]
@@ -70,24 +30,28 @@ class Producer : public QThread
//! [1] //! [2]
{
public:
- Producer(QObject *parent = NULL) : QThread(parent)
+ explicit Producer(QObject *parent = nullptr)
+ : QThread(parent)
{
}
+private:
void run() override
{
for (int i = 0; i < DataSize; ++i) {
- mutex.lock();
- if (numUsedBytes == BufferSize)
- bufferNotFull.wait(&mutex);
- mutex.unlock();
+ {
+ const QMutexLocker locker(&mutex);
+ while (numUsedBytes == BufferSize)
+ bufferNotFull.wait(&mutex);
+ }
buffer[i % BufferSize] = "ACGT"[QRandomGenerator::global()->bounded(4)];
- mutex.lock();
- ++numUsedBytes;
- bufferNotEmpty.wakeAll();
- mutex.unlock();
+ {
+ const QMutexLocker locker(&mutex);
+ ++numUsedBytes;
+ bufferNotEmpty.wakeAll();
+ }
}
}
};
@@ -97,32 +61,32 @@ public:
class Consumer : public QThread
//! [3] //! [4]
{
- Q_OBJECT
public:
- Consumer(QObject *parent = NULL) : QThread(parent)
+ explicit Consumer(QObject *parent = nullptr)
+ : QThread(parent)
{
}
+private:
void run() override
{
for (int i = 0; i < DataSize; ++i) {
- mutex.lock();
- if (numUsedBytes == 0)
- bufferNotEmpty.wait(&mutex);
- mutex.unlock();
+ {
+ const QMutexLocker locker(&mutex);
+ while (numUsedBytes == 0)
+ bufferNotEmpty.wait(&mutex);
+ }
fprintf(stderr, "%c", buffer[i % BufferSize]);
- mutex.lock();
- --numUsedBytes;
- bufferNotFull.wakeAll();
- mutex.unlock();
+ {
+ const QMutexLocker locker(&mutex);
+ --numUsedBytes;
+ bufferNotFull.wakeAll();
+ }
}
fprintf(stderr, "\n");
}
-
-signals:
- void stringConsumed(const QString &text);
};
//! [4]
@@ -142,4 +106,3 @@ int main(int argc, char *argv[])
}
//! [6]
-#include "waitconditions.moc"
diff --git a/examples/corelib/tools/CMakeLists.txt b/examples/corelib/tools/CMakeLists.txt
index a9f82dfab5..15188b0219 100644
--- a/examples/corelib/tools/CMakeLists.txt
+++ b/examples/corelib/tools/CMakeLists.txt
@@ -1,8 +1,7 @@
-# Generated from tools.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-if(NOT TARGET Qt::Widgets)
+if(NOT TARGET Qt6::Widgets)
return()
endif()
-add_subdirectory(contiguouscache)
-add_subdirectory(customtype)
-add_subdirectory(customtypesending)
+qt_internal_add_example(contiguouscache)
diff --git a/examples/corelib/tools/contiguouscache/CMakeLists.txt b/examples/corelib/tools/contiguouscache/CMakeLists.txt
index 7650bdd4ac..2fab4803c1 100644
--- a/examples/corelib/tools/contiguouscache/CMakeLists.txt
+++ b/examples/corelib/tools/contiguouscache/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from contiguouscache.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(contiguouscache LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/tools/contiguouscache")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(contiguouscache
main.cpp
randomlistmodel.cpp randomlistmodel.h
)
+
set_target_properties(contiguouscache PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(contiguouscache PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+
+target_link_libraries(contiguouscache PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS contiguouscache
- 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 contiguouscache
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/corelib/tools/contiguouscache/main.cpp b/examples/corelib/tools/contiguouscache/main.cpp
index 4f31e21147..29e77aff2c 100644
--- a/examples/corelib/tools/contiguouscache/main.cpp
+++ b/examples/corelib/tools/contiguouscache/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "randomlistmodel.h"
#include <QListView>
diff --git a/examples/corelib/tools/contiguouscache/randomlistmodel.cpp b/examples/corelib/tools/contiguouscache/randomlistmodel.cpp
index d028b896f2..4832f0ae24 100644
--- a/examples/corelib/tools/contiguouscache/randomlistmodel.cpp
+++ b/examples/corelib/tools/contiguouscache/randomlistmodel.cpp
@@ -1,65 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "randomlistmodel.h"
#include <QRandomGenerator>
-static const int bufferSize(500);
-static const int lookAhead(100);
-static const int halfLookAhead(lookAhead/2);
+static constexpr int bufferSize(500);
+static constexpr int lookAhead(100);
+static constexpr int halfLookAhead(lookAhead / 2);
RandomListModel::RandomListModel(QObject *parent)
-: QAbstractListModel(parent), m_rows(bufferSize), m_count(10000)
-{
-}
-
-RandomListModel::~RandomListModel()
+ : QAbstractListModel(parent), m_rows(bufferSize), m_count(10000)
{
}
@@ -78,14 +27,14 @@ QVariant RandomListModel::data(const QModelIndex &index, int role) const
if (row > m_rows.lastIndex()) {
if (row - m_rows.lastIndex() > lookAhead)
- cacheRows(row-halfLookAhead, qMin(m_count, row+halfLookAhead));
+ cacheRows(row - halfLookAhead, qMin(m_count, row + halfLookAhead));
else while (row > m_rows.lastIndex())
- m_rows.append(fetchRow(m_rows.lastIndex()+1));
+ m_rows.append(fetchRow(m_rows.lastIndex() + 1));
} else if (row < m_rows.firstIndex()) {
if (m_rows.firstIndex() - row > lookAhead)
- cacheRows(qMax(0, row-halfLookAhead), row+halfLookAhead);
+ cacheRows(qMax(0, row - halfLookAhead), row + halfLookAhead);
else while (row < m_rows.firstIndex())
- m_rows.prepend(fetchRow(m_rows.firstIndex()-1));
+ m_rows.prepend(fetchRow(m_rows.firstIndex() - 1));
}
return m_rows.at(row);
diff --git a/examples/corelib/tools/contiguouscache/randomlistmodel.h b/examples/corelib/tools/contiguouscache/randomlistmodel.h
index 1fabb0d9f5..b95acdf3f9 100644
--- a/examples/corelib/tools/contiguouscache/randomlistmodel.h
+++ b/examples/corelib/tools/contiguouscache/randomlistmodel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef RANDOMLISTMODEL_H
#define RANDOMLISTMODEL_H
@@ -60,7 +13,6 @@ class RandomListModel : public QAbstractListModel
Q_OBJECT
public:
RandomListModel(QObject *parent = nullptr);
- ~RandomListModel();
int rowCount(const QModelIndex & = QModelIndex()) const override;
QVariant data(const QModelIndex &, int) const override;
diff --git a/examples/corelib/tools/customtype/CMakeLists.txt b/examples/corelib/tools/customtype/CMakeLists.txt
deleted file mode 100644
index 68c1784bde..0000000000
--- a/examples/corelib/tools/customtype/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from customtype.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(customtype LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/tools/customtype")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(customtype
- main.cpp
- message.cpp message.h
-)
-set_target_properties(customtype PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(customtype PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS customtype
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/corelib/tools/customtype/customtype.pro b/examples/corelib/tools/customtype/customtype.pro
deleted file mode 100644
index 0e0fe9b1a5..0000000000
--- a/examples/corelib/tools/customtype/customtype.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-HEADERS = message.h
-SOURCES = main.cpp \
- message.cpp
-QT += widgets
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/corelib/tools/customtype
-INSTALLS += target
diff --git a/examples/corelib/tools/customtype/main.cpp b/examples/corelib/tools/customtype/main.cpp
deleted file mode 100644
index af8e233a19..0000000000
--- a/examples/corelib/tools/customtype/main.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QCoreApplication>
-#include <QDebug>
-#include <QVariant>
-#include "message.h"
-
-int main(int argc, char *argv[])
-{
- QCoreApplication app(argc, argv);
- QStringList headers;
- headers << "Subject: Hello World"
- << "From: address@example.com";
- QString body = "This is a test.\r\n";
-
-//! [printing a custom type]
- Message message(body, headers);
- qDebug() << "Original:" << message;
-//! [printing a custom type]
-
-//! [storing a custom value]
- QVariant stored;
- stored.setValue(message);
-//! [storing a custom value]
-
- qDebug() << "Stored:" << stored;
-
-//! [retrieving a custom value]
- Message retrieved = qvariant_cast<Message>(stored);
- qDebug() << "Retrieved:" << retrieved;
- retrieved = qvariant_cast<Message>(stored);
- qDebug() << "Retrieved:" << retrieved;
-//! [retrieving a custom value]
-
- return 0;
-}
diff --git a/examples/corelib/tools/customtype/message.cpp b/examples/corelib/tools/customtype/message.cpp
deleted file mode 100644
index 948e323dbf..0000000000
--- a/examples/corelib/tools/customtype/message.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "message.h"
-
-#include <QDebug>
-
-Message::Message(const QString &body, const QStringList &headers)
- : m_body(body), m_headers(headers)
-{
-}
-
-//! [custom type streaming operator]
-QDebug operator<<(QDebug dbg, const Message &message)
-{
- QList<QStringView> pieces = message.body().split(u"\r\n", Qt::SkipEmptyParts);
- if (pieces.isEmpty())
- dbg.nospace() << "Message()";
- else if (pieces.size() == 1)
- dbg.nospace() << "Message(" << pieces.first() << ")";
- else
- dbg.nospace() << "Message(" << pieces.first() << " ...)";
- return dbg.maybeSpace();
-}
-//! [custom type streaming operator]
-
-//! [getter functions]
-QStringView Message::body() const
-{
- return m_body;
-}
-
-QStringList Message::headers() const
-{
- return m_headers;
-}
-//! [getter functions]
diff --git a/examples/corelib/tools/customtype/message.h b/examples/corelib/tools/customtype/message.h
deleted file mode 100644
index acc439b0f6..0000000000
--- a/examples/corelib/tools/customtype/message.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MESSAGE_H
-#define MESSAGE_H
-
-#include <QMetaType>
-#include <QStringList>
-
-//! [custom type definition]
-class Message
-{
-public:
- Message() = default;
- ~Message() = default;
- Message(const Message &) = default;
- Message &operator=(const Message &) = default;
-
- Message(const QString &body, const QStringList &headers);
-
- QStringView body() const;
- QStringList headers() const;
-
-private:
- QString m_body;
- QStringList m_headers;
-};
-//! [custom type definition]
-
-//! [custom type meta-type declaration]
-Q_DECLARE_METATYPE(Message);
-//! [custom type meta-type declaration]
-
-//! [custom type streaming operator]
-QDebug operator<<(QDebug dbg, const Message &message);
-//! [custom type streaming operator]
-
-#endif
diff --git a/examples/corelib/tools/customtypesending/CMakeLists.txt b/examples/corelib/tools/customtypesending/CMakeLists.txt
deleted file mode 100644
index 1b67e23220..0000000000
--- a/examples/corelib/tools/customtypesending/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from customtypesending.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(customtypesending LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/corelib/tools/customtypesending")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(customtypesending
- main.cpp
- message.cpp message.h
- window.cpp window.h
-)
-set_target_properties(customtypesending PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(customtypesending PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS customtypesending
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/corelib/tools/customtypesending/customtypesending.pro b/examples/corelib/tools/customtypesending/customtypesending.pro
deleted file mode 100644
index da351ce828..0000000000
--- a/examples/corelib/tools/customtypesending/customtypesending.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-HEADERS = message.h \
- window.h
-SOURCES = main.cpp \
- message.cpp \
- window.cpp
-QT += widgets
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/corelib/tools/customtypesending
-INSTALLS += target
diff --git a/examples/corelib/tools/customtypesending/main.cpp b/examples/corelib/tools/customtypesending/main.cpp
deleted file mode 100644
index c5d643b9d1..0000000000
--- a/examples/corelib/tools/customtypesending/main.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include "message.h"
-#include "window.h"
-
-//! [main function]
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- QStringList headers;
- headers << "Subject: Hello World"
- << "From: address@example.com";
- QString body = "This is a test.\r\n";
- Message message(body, headers);
-
- Window window1;
- window1.setMessage(message);
-
- Window window2;
- QObject::connect(&window1, &Window::messageSent,
- &window2, &Window::setMessage);
- QObject::connect(&window2, &Window::messageSent,
- &window1, &Window::setMessage);
- window1.show();
- window2.show();
- return app.exec();
-}
-//! [main function]
diff --git a/examples/corelib/tools/customtypesending/message.cpp b/examples/corelib/tools/customtypesending/message.cpp
deleted file mode 100644
index 76f90e5144..0000000000
--- a/examples/corelib/tools/customtypesending/message.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "message.h"
-
-Message::Message(const QString &body, const QStringList &headers)
- : m_body(body), m_headers(headers)
-{
-}
-
-QString Message::body() const
-{
- return m_body;
-}
-
-QStringList Message::headers() const
-{
- return m_headers;
-}
diff --git a/examples/corelib/tools/customtypesending/message.h b/examples/corelib/tools/customtypesending/message.h
deleted file mode 100644
index 38b5c8205f..0000000000
--- a/examples/corelib/tools/customtypesending/message.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MESSAGE_H
-#define MESSAGE_H
-
-#include <QMetaType>
-#include <QStringList>
-
-//! [custom type definition]
-class Message
-{
-public:
- Message() = default;
- ~Message() = default;
- Message(const Message &) = default;
- Message &operator=(const Message &) = default;
-
- Message(const QString &body, const QStringList &headers);
-
- QString body() const;
- QStringList headers() const;
-
-private:
- QString m_body;
- QStringList m_headers;
-};
-//! [custom type definition]
-
-//! [custom type meta-type declaration]
-Q_DECLARE_METATYPE(Message);
-//! [custom type meta-type declaration]
-
-#endif
diff --git a/examples/corelib/tools/customtypesending/window.cpp b/examples/corelib/tools/customtypesending/window.cpp
deleted file mode 100644
index db4b52a985..0000000000
--- a/examples/corelib/tools/customtypesending/window.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-#include "window.h"
-
-//! [Window constructor]
-Window::Window(QWidget *parent)
- : QWidget(parent), editor(new QTextEdit(this))
-{
- QPushButton *sendButton = new QPushButton(tr("&Send message"));
-
- connect(sendButton, &QPushButton::clicked,
- this, &Window::sendMessage);
-
- QHBoxLayout *buttonLayout = new QHBoxLayout;
- buttonLayout->addStretch();
- buttonLayout->addWidget(sendButton);
- buttonLayout->addStretch();
-
- QVBoxLayout *layout = new QVBoxLayout(this);
- layout->addWidget(editor);
- layout->addLayout(buttonLayout);
-
- setWindowTitle(tr("Custom Type Sending"));
-}
-//! [Window constructor]
-
-//! [sending a message]
-void Window::sendMessage()
-{
- thisMessage = Message(editor->toPlainText(), thisMessage.headers());
- emit messageSent(thisMessage);
-}
-//! [sending a message]
-
-//! [receiving a message]
-void Window::setMessage(const Message &message)
-{
- thisMessage = message;
- editor->setPlainText(thisMessage.body());
-}
-//! [receiving a message]
diff --git a/examples/corelib/tools/customtypesending/window.h b/examples/corelib/tools/customtypesending/window.h
deleted file mode 100644
index 048fecef67..0000000000
--- a/examples/corelib/tools/customtypesending/window.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <QWidget>
-#include "message.h"
-
-QT_FORWARD_DECLARE_CLASS(QTextEdit)
-
-//! [Window class definition]
-class Window : public QWidget
-{
- Q_OBJECT
-
-public:
- Window(QWidget *parent = nullptr);
-
-signals:
- void messageSent(const Message &message);
-
-public slots:
- void setMessage(const Message &message);
-
-private slots:
- void sendMessage();
-
-private:
- Message thisMessage;
- QTextEdit *editor;
-};
-//! [Window class definition]
-
-#endif
diff --git a/examples/corelib/tools/doc/src/contiguouscache.qdoc b/examples/corelib/tools/doc/src/contiguouscache.qdoc
index 0d06036cd1..9fc572927b 100644
--- a/examples/corelib/tools/doc/src/contiguouscache.qdoc
+++ b/examples/corelib/tools/doc/src/contiguouscache.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example tools/contiguouscache
\title Contiguous Cache Example
+ \examplecategory {Data Processing & I/O}
\brief The Contiguous Cache example shows how to use QContiguousCache to manage memory usage for
very large models. In some environments memory is limited and, even when it
@@ -68,7 +45,7 @@
allow for gaps. If your cache needs to quickly jump back and forth between
rows with significant gaps between them consider using QCache instead.
- And thats it. A perfectly reasonable cache, using minimal memory for a very large
+ And that's it. A perfectly reasonable cache, using minimal memory for a very large
list. In this case the accessor for getting the words into the cache
generates random information rather than fixed information. This allows you
to see how the cache range is kept for a local number of rows when running the
diff --git a/examples/corelib/tools/doc/src/customtype.qdoc b/examples/corelib/tools/doc/src/customtype.qdoc
deleted file mode 100644
index fb63bc539c..0000000000
--- a/examples/corelib/tools/doc/src/customtype.qdoc
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example tools/customtype
- \title Custom Type Example
-
- \brief The Custom Type example shows how to integrate a custom type into Qt's
- meta-object system.
-
- Contents:
-
- \tableofcontents
-
- \section1 Overview
-
- Qt provides a range of standard value types that are used to provide
- rich and meaningful APIs. These types are integrated with the meta-object
- system, enabling them to be stored in QVariant objects, written out in
- debugging information and sent between components in signal-slot
- communication.
-
- Custom types can also be integrated with the meta-object system as long as
- they are written to conform to some simple guidelines. In this example, we
- introduce a simple \c Message class, we describe how we make it work with
- QVariant, and we show how it can be extended to generate a printable
- representation of itself for use in debugging output.
-
- \section1 The Message Class Definition
-
- The \c Message class is a simple value class that contains two pieces
- of information (a QString and a QStringList), each of which can be read
- using trivial getter functions:
-
- \snippet tools/customtype/message.h custom type definition
-
- The default constructor, copy constructor and destructor are
- all required, and must be public, if the type is to be integrated into the
- meta-object system. Other than this, we are free to implement whatever we
- need to make the type do what we want, so we also include a constructor
- that lets us set the type's data members.
-
- To enable the type to be used with QVariant, we declare it using the
- Q_DECLARE_METATYPE() macro:
-
- \snippet tools/customtype/message.h custom type meta-type declaration
-
- We do not need to write any additional code to accompany this macro.
-
- To allow us to see a readable description of each \c Message object when it
- is sent to the debug output stream, we define a streaming operator:
-
- \snippet tools/customtype/message.h custom type streaming operator
-
- This facility is useful if you need to insert tracing statements in your
- code for debugging purposes.
-
- \section1 The Message Class Implementation
-
- The streaming operator is implemented in the following way:
-
- \snippet tools/customtype/message.cpp custom type streaming operator
-
- Here, we want to represent each value depending on how many lines are stored
- in the message body. We stream text to the QDebug object passed to the
- operator and return the QDebug object obtained from its maybeSpace() member
- function; this is described in more detail in the
- \l{Creating Custom Qt Types#Making the Type Printable}{Creating Custom Qt Types}
- document.
-
- We include the code for the getter functions for completeness:
-
- \snippet tools/customtype/message.cpp getter functions
-
- With the type fully defined, implemented, and integrated with the
- meta-object system, we can now use it.
-
- \section1 Using the Message
-
- In the example's \c{main()} function, we show how a \c Message object can
- be printed to the console by sending it to the debug stream:
-
- \snippet tools/customtype/main.cpp printing a custom type
-
- You can use the type with QVariant in exactly the same way as you would
- use standard Qt value types. Here's how to store a value using the
- QVariant::setValue() function:
-
- \snippet tools/customtype/main.cpp storing a custom value
-
- Alternatively, the QVariant::fromValue() function can be used if
- you are using a compiler without support for member template
- functions.
-
- The value can be retrieved using the QVariant::value() member template
- function:
-
- \snippet tools/customtype/main.cpp retrieving a custom value
-
- \section1 Further Reading
-
- The custom \c Message type can also be used with direct signal-slot
- connections.
-
- To register a custom type for use with queued signals and slots, such as
- those used in cross-thread communication, see the
- \l{Queued Custom Type Example}.
-
- More information on using custom types with Qt can be found in the
- \l{Creating Custom Qt Types} document.
-*/
diff --git a/examples/corelib/tools/tools.pro b/examples/corelib/tools/tools.pro
index 6fb4a1214f..618628d274 100644
--- a/examples/corelib/tools/tools.pro
+++ b/examples/corelib/tools/tools.pro
@@ -1,6 +1,4 @@
requires(qtHaveModule(widgets))
TEMPLATE = subdirs
-SUBDIRS = contiguouscache \
- customtype \
- customtypesending
+SUBDIRS = contiguouscache
diff --git a/examples/dbus/CMakeLists.txt b/examples/dbus/CMakeLists.txt
index 065cc76022..79caaf949d 100644
--- a/examples/dbus/CMakeLists.txt
+++ b/examples/dbus/CMakeLists.txt
@@ -1,14 +1,16 @@
-# Generated from dbus.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-if(NOT TARGET Qt::DBus)
+if(NOT TARGET Qt6::DBus)
return()
endif()
-add_subdirectory(listnames)
-add_subdirectory(pingpong)
-if(QT_FEATURE_process)
- add_subdirectory(complexpingpong)
+if(NOT ANDROID)
+ qt_internal_add_example(pingpong)
+ if(QT_FEATURE_process)
+ qt_internal_add_example(complexpingpong)
+ endif()
endif()
-if(TARGET Qt::Widgets)
- add_subdirectory(chat)
- add_subdirectory(remotecontrolledcar)
+if(TARGET Qt6::Widgets)
+ qt_internal_add_example(chat)
+ qt_internal_add_example(remotecontrolledcar)
endif()
diff --git a/examples/dbus/chat/.prev_CMakeLists.txt b/examples/dbus/chat/.prev_CMakeLists.txt
deleted file mode 100644
index 9396cce3ac..0000000000
--- a/examples/dbus/chat/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-# Generated from chat.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(chat LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/chat")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS DBus)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(chat
- chat.cpp chat.h
- chatmainwindow.ui
- chatsetnickname.ui
-)
-set_target_properties(chat PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(chat PUBLIC
- Qt::Core
- Qt::DBus
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS chat
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/dbus/chat/CMakeLists.txt b/examples/dbus/chat/CMakeLists.txt
index 998ffb5f25..472d893dee 100644
--- a/examples/dbus/chat/CMakeLists.txt
+++ b/examples/dbus/chat/CMakeLists.txt
@@ -1,57 +1,55 @@
-# Generated from chat.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(chat LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
+find_package(Qt6 REQUIRED COMPONENTS Core DBus Gui Widgets)
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
+qt_standard_project_setup()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/chat")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS DBus)
-find_package(Qt6 COMPONENTS Widgets)
-
-# special case begin
set(chat_SRCS)
-qt6_add_dbus_interface(chat_SRCS
+qt_add_dbus_interface(chat_SRCS
org.example.chat.xml
chat_interface
)
-qt6_add_dbus_adaptor(chat_SRCS
+
+qt_add_dbus_adaptor(chat_SRCS
org.example.chat.xml
qobject.h
QObject
chat_adaptor
)
-# special case end
+
qt_add_executable(chat
chat.cpp chat.h
chatmainwindow.ui
- chatsetnickname.ui
- ${chat_SRCS} # special case
+ ${chat_SRCS}
)
+
set_target_properties(chat PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(chat PUBLIC
- Qt::Core
- Qt::DBus
- Qt::Gui
- Qt::Widgets
+
+target_link_libraries(chat PRIVATE
+ Qt6::Core
+ Qt6::DBus
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS chat
- 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 chat
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/dbus/chat/chat.cpp b/examples/dbus/chat/chat.cpp
index 7855457a82..cced911955 100644
--- a/examples/dbus/chat/chat.cpp
+++ b/examples/dbus/chat/chat.cpp
@@ -1,54 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
+#include <QInputDialog>
#include <QMessageBox>
#include "chat.h"
@@ -56,105 +10,69 @@
#include "chat_interface.h"
ChatMainWindow::ChatMainWindow()
- : m_nickname(QLatin1String("nickname"))
{
setupUi(this);
- sendButton->setEnabled(false);
- connect(messageLineEdit, SIGNAL(textChanged(QString)),
- this, SLOT(textChangedSlot(QString)));
- connect(sendButton, SIGNAL(clicked(bool)), this, SLOT(sendClickedSlot()));
- connect(actionChangeNickname, SIGNAL(triggered(bool)), this, SLOT(changeNickname()));
- connect(actionAboutQt, SIGNAL(triggered(bool)), this, SLOT(aboutQt()));
- connect(qApp, SIGNAL(lastWindowClosed()), this, SLOT(exiting()));
+ connect(messageLineEdit, &QLineEdit::textChanged, this,
+ [this](const QString &newText) { sendButton->setEnabled(!newText.isEmpty()); });
+ connect(sendButton, &QPushButton::clicked, this, [this]() {
+ emit message(m_nickname, messageLineEdit->text());
+ messageLineEdit->clear();
+ });
+ connect(actionChangeNickname, &QAction::triggered,
+ this, &ChatMainWindow::changeNickname);
+ connect(actionAboutQt, &QAction::triggered, this, [this]() { QMessageBox::aboutQt(this); });
+ connect(qApp, &QApplication::lastWindowClosed, this,
+ [this]() { emit action(m_nickname, tr("leaves the chat")); });
// add our D-Bus interface and connect to D-Bus
new ChatAdaptor(this);
- QDBusConnection::sessionBus().registerObject("/", this);
-
- org::example::chat *iface;
- iface = new org::example::chat(QString(), QString(), QDBusConnection::sessionBus(), this);
- //connect(iface, SIGNAL(message(QString,QString)), this, SLOT(messageSlot(QString,QString)));
- QDBusConnection::sessionBus().connect(QString(), QString(), "org.example.chat", "message", this, SLOT(messageSlot(QString,QString)));
- connect(iface, SIGNAL(action(QString,QString)), this, SLOT(actionSlot(QString,QString)));
-
- NicknameDialog dialog;
- dialog.cancelButton->setVisible(false);
- dialog.exec();
- m_nickname = dialog.nickname->text().trimmed();
- emit action(m_nickname, QLatin1String("joins the chat"));
-}
-ChatMainWindow::~ChatMainWindow()
-{
-}
+ auto connection = QDBusConnection::sessionBus();
+ connection.registerObject("/", this);
-void ChatMainWindow::rebuildHistory()
-{
- QString history = m_messages.join( QLatin1String("\n" ) );
- chatHistory->setPlainText(history);
-}
+ using org::example::chat;
-void ChatMainWindow::messageSlot(const QString &nickname, const QString &text)
-{
- QString msg( QLatin1String("<%1> %2") );
- msg = msg.arg(nickname, text);
- m_messages.append(msg);
+ auto *iface = new chat({}, {}, connection, this);
+ connect(iface, &chat::message, this, [this](const QString &nickname, const QString &text) {
+ displayMessage(tr("<%1> %2").arg(nickname, text));
+ });
+ connect(iface, &chat::action, this, [this](const QString &nickname, const QString &text) {
+ displayMessage(tr("* %1 %2").arg(nickname, text));
+ });
- if (m_messages.count() > 100)
- m_messages.removeFirst();
- rebuildHistory();
+ if (!changeNickname(true))
+ QMetaObject::invokeMethod(qApp, &QApplication::quit, Qt::QueuedConnection);
}
-void ChatMainWindow::actionSlot(const QString &nickname, const QString &text)
+void ChatMainWindow::displayMessage(const QString &message)
{
- QString msg( QLatin1String("* %1 %2") );
- msg = msg.arg(nickname, text);
- m_messages.append(msg);
+ m_messages.append(message);
if (m_messages.count() > 100)
m_messages.removeFirst();
- rebuildHistory();
-}
-
-void ChatMainWindow::textChangedSlot(const QString &newText)
-{
- sendButton->setEnabled(!newText.isEmpty());
-}
-void ChatMainWindow::sendClickedSlot()
-{
- //emit message(m_nickname, messageLineEdit->text());
- QDBusMessage msg = QDBusMessage::createSignal("/", "org.example.chat", "message");
- msg << m_nickname << messageLineEdit->text();
- QDBusConnection::sessionBus().send(msg);
- messageLineEdit->setText(QString());
+ auto history = m_messages.join(QLatin1String("\n"));
+ chatHistory->setPlainText(history);
}
-void ChatMainWindow::changeNickname()
+bool ChatMainWindow::changeNickname(bool initial)
{
- NicknameDialog dialog(this);
- if (dialog.exec() == QDialog::Accepted) {
- QString old = m_nickname;
- m_nickname = dialog.nickname->text().trimmed();
- emit action(old, QString("is now known as %1").arg(m_nickname));
+ auto newNickname = QInputDialog::getText(this, tr("Set nickname"), tr("New nickname:"));
+ newNickname = newNickname.trimmed();
+
+ if (!newNickname.isEmpty()) {
+ auto old = m_nickname;
+ m_nickname = newNickname;
+
+ if (initial)
+ emit action(m_nickname, tr("joins the chat"));
+ else
+ emit action(old, tr("is now known as %1").arg(m_nickname));
+ return true;
}
-}
-
-void ChatMainWindow::aboutQt()
-{
- QMessageBox::aboutQt(this);
-}
-
-void ChatMainWindow::exiting()
-{
- emit action(m_nickname, QLatin1String("leaves the chat"));
-}
-NicknameDialog::NicknameDialog(QWidget *parent)
- : QDialog(parent)
-{
- setupUi(this);
+ return false;
}
int main(int argc, char **argv)
diff --git a/examples/dbus/chat/chat.h b/examples/dbus/chat/chat.h
index 444d6c9d80..f7706eeeba 100644
--- a/examples/dbus/chat/chat.h
+++ b/examples/dbus/chat/chat.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CHAT_H
#define CHAT_H
@@ -54,7 +7,6 @@
#include <QStringList>
#include "ui_chatmainwindow.h"
-#include "ui_chatsetnickname.h"
class ChatMainWindow: public QMainWindow, Ui::ChatMainWindow
{
@@ -63,29 +15,16 @@ class ChatMainWindow: public QMainWindow, Ui::ChatMainWindow
QStringList m_messages;
public:
ChatMainWindow();
- ~ChatMainWindow();
- void rebuildHistory();
+private:
+ void displayMessage(const QString &message);
signals:
void message(const QString &nickname, const QString &text);
void action(const QString &nickname, const QString &text);
private slots:
- void messageSlot(const QString &nickname, const QString &text);
- void actionSlot(const QString &nickname, const QString &text);
- void textChangedSlot(const QString &newText);
- void sendClickedSlot();
- void changeNickname();
- void aboutQt();
- void exiting();
-};
-
-class NicknameDialog: public QDialog, public Ui::NicknameDialog
-{
- Q_OBJECT
-public:
- NicknameDialog(QWidget *parent = nullptr);
+ bool changeNickname(bool initial = false);
};
#endif // CHAT_H
diff --git a/examples/dbus/chat/chat.pro b/examples/dbus/chat/chat.pro
index 631a876954..2b4630d5f1 100644
--- a/examples/dbus/chat/chat.pro
+++ b/examples/dbus/chat/chat.pro
@@ -2,11 +2,13 @@ QT += dbus widgets
HEADERS += chat.h
SOURCES += chat.cpp
-FORMS += chatmainwindow.ui chatsetnickname.ui
+FORMS += chatmainwindow.ui
DBUS_ADAPTORS += org.example.chat.xml
DBUS_INTERFACES += org.example.chat.xml
+CONFIG += no_batch # work around QTBUG-96513
+
# install
target.path = $$[QT_INSTALL_EXAMPLES]/dbus/chat
INSTALLS += target
diff --git a/examples/dbus/chat/chatsetnickname.ui b/examples/dbus/chat/chatsetnickname.ui
deleted file mode 100644
index fb9894e09f..0000000000
--- a/examples/dbus/chat/chatsetnickname.ui
+++ /dev/null
@@ -1,149 +0,0 @@
-<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>NicknameDialog</class>
- <widget class="QDialog" name="NicknameDialog" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>396</width>
- <height>105</height>
- </rect>
- </property>
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>1</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="windowTitle" >
- <string>Set nickname</string>
- </property>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <widget class="QLabel" name="label" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>1</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>New nickname:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="nickname" />
- </item>
- </layout>
- </item>
- <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>131</width>
- <height>31</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="okButton" >
- <property name="text" >
- <string>OK</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="cancelButton" >
- <property name="text" >
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <pixmapfunction></pixmapfunction>
- <resources/>
- <connections>
- <connection>
- <sender>okButton</sender>
- <signal>clicked()</signal>
- <receiver>NicknameDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>278</x>
- <y>253</y>
- </hint>
- <hint type="destinationlabel" >
- <x>96</x>
- <y>254</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>cancelButton</sender>
- <signal>clicked()</signal>
- <receiver>NicknameDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>369</x>
- <y>253</y>
- </hint>
- <hint type="destinationlabel" >
- <x>179</x>
- <y>282</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/examples/dbus/complexpingpong/CMakeLists.txt b/examples/dbus/complexpingpong/CMakeLists.txt
index 5cf1c2e9e3..da4ca95288 100644
--- a/examples/dbus/complexpingpong/CMakeLists.txt
+++ b/examples/dbus/complexpingpong/CMakeLists.txt
@@ -1,71 +1,52 @@
-# Generated from complexpingpong.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
-project(complexping LANGUAGES CXX)
+cmake_minimum_required(VERSION 3.16)
+project(complexpingpong LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+if (ANDROID)
+ message(FATAL_ERROR "This project cannot be built on Android.")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/complexpingpong")
+find_package(Qt6 REQUIRED COMPONENTS Core DBus)
-find_package(Qt6 COMPONENTS DBus)
+qt_standard_project_setup()
qt_add_executable(complexping
complexping.cpp complexping.h
ping-common.h
)
-set_target_properties(complexping PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(complexping PUBLIC
- # Remove: gui
- Qt::DBus
-)
-install(TARGETS complexping
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+target_link_libraries(complexping PRIVATE
+ Qt6::Core
+ Qt6::DBus
)
-cmake_minimum_required(VERSION 3.14)
-project(complexpong LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/complexpingpong")
-
-find_package(Qt6 COMPONENTS DBus)
qt_add_executable(complexpong
complexpong.cpp complexpong.h
)
-set_target_properties(complexpong PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
+
+target_link_libraries(complexpong PRIVATE
+ Qt6::Core
+ Qt6::DBus
)
-target_link_libraries(complexpong PUBLIC
- # Remove: gui
- Qt::DBus
+
+install(TARGETS complexping complexpong
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET complexping
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
-install(TARGETS complexpong
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+qt_generate_deploy_app_script(
+ TARGET complexpong
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/dbus/complexpingpong/complexping.cpp b/examples/dbus/complexpingpong/complexping.cpp
index 8878083ee9..9651183c92 100644
--- a/examples/dbus/complexpingpong/complexping.cpp
+++ b/examples/dbus/complexpingpong/complexping.cpp
@@ -1,105 +1,62 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "ping-common.h"
#include "complexping.h"
#include <QCoreApplication>
+#include <QDBusInterface>
#include <QDBusReply>
#include <QDBusServiceWatcher>
-#include <QFile>
#include <QDebug>
#include <QProcess>
-#include <stdio.h>
+#include <iostream>
+#include <string>
void Ping::start(const QString &name)
{
if (name != SERVICE_NAME)
return;
- // open stdin for reading
- qstdin.open(stdin, QIODevice::ReadOnly);
-
+ auto connection = QDBusConnection::sessionBus();
// find our remote
- iface = new QDBusInterface(SERVICE_NAME, "/", "org.example.QtDBus.ComplexPong.Pong",
- QDBusConnection::sessionBus(), this);
+ auto iface = new QDBusInterface(SERVICE_NAME, "/", "org.example.QtDBus.ComplexPong.Pong",
+ connection, this);
if (!iface->isValid()) {
- fprintf(stderr, "%s\n",
- qPrintable(QDBusConnection::sessionBus().lastError().message()));
+ qWarning().noquote() << connection.lastError().message();
QCoreApplication::instance()->quit();
}
connect(iface, SIGNAL(aboutToQuit()), QCoreApplication::instance(), SLOT(quit()));
+ std::string s;
+
while (true) {
- printf("Ask your question: ");
+ std::cout << qPrintable(tr("Ask your question: ")) << std::flush;
+
+ std::getline(std::cin, s);
+ auto line = QString::fromStdString(s).trimmed();
- QString line = QString::fromLocal8Bit(qstdin.readLine()).trimmed();
if (line.isEmpty()) {
iface->call("quit");
return;
} else if (line == "value") {
QVariant reply = iface->property("value");
if (!reply.isNull())
- printf("value = %s\n", qPrintable(reply.toString()));
+ std::cout << "value = " << qPrintable(reply.toString()) << std::endl;
} else if (line.startsWith("value=")) {
iface->setProperty("value", line.mid(6));
} else {
QDBusReply<QDBusVariant> reply = iface->call("query", line);
- if (reply.isValid())
- printf("Reply was: %s\n", qPrintable(reply.value().variant().toString()));
+ if (reply.isValid()) {
+ std::cout << qPrintable(tr("Reply was: %1").arg(reply.value().variant().toString()))
+ << std::endl;
+ }
}
if (iface->lastError().isValid())
- fprintf(stderr, "Call failed: %s\n", qPrintable(iface->lastError().message()));
+ qWarning().noquote() << tr("Call failed: %1").arg(iface->lastError().message());
}
}
@@ -108,9 +65,11 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv);
if (!QDBusConnection::sessionBus().isConnected()) {
- fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
+ qWarning().noquote() << QCoreApplication::translate(
+ "complexping",
+ "Cannot connect to the D-Bus session bus.\n"
"To start it, run:\n"
- "\teval `dbus-launch --auto-syntax`\n");
+ "\teval `dbus-launch --auto-syntax`");
return 1;
}
diff --git a/examples/dbus/complexpingpong/complexping.h b/examples/dbus/complexpingpong/complexping.h
index 98a4332f38..fd566a9bab 100644
--- a/examples/dbus/complexpingpong/complexping.h
+++ b/examples/dbus/complexpingpong/complexping.h
@@ -1,68 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef COMPLEXPING_H
#define COMPLEXPING_H
#include <QtCore/QObject>
-#include <QtCore/QFile>
-#include <QtDBus/QDBusInterface>
-class Ping: public QObject
+class Ping : public QObject
{
Q_OBJECT
public slots:
- void start(const QString &);
-public:
- QFile qstdin;
- QDBusInterface *iface;
+ void start(const QString &name);
};
#endif
diff --git a/examples/dbus/complexpingpong/complexpong.cpp b/examples/dbus/complexpingpong/complexpong.cpp
index 6b3430bc94..088b452b30 100644
--- a/examples/dbus/complexpingpong/complexpong.cpp
+++ b/examples/dbus/complexpingpong/complexpong.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "ping-common.h"
#include "complexpong.h"
@@ -54,12 +7,8 @@
#include <QCoreApplication>
#include <QDBusConnection>
#include <QDBusError>
-#include <QTimer>
+#include <QDebug>
-#include <stdio.h>
-#include <stdlib.h>
-
-// the property
QString Pong::value() const
{
return m_value;
@@ -72,7 +21,8 @@ void Pong::setValue(const QString &newValue)
void Pong::quit()
{
- QTimer::singleShot(0, QCoreApplication::instance(), &QCoreApplication::quit);
+ QMetaObject::invokeMethod(QCoreApplication::instance(), &QCoreApplication::quit,
+ Qt::QueuedConnection);
}
QDBusVariant Pong::query(const QString &query)
@@ -101,12 +51,13 @@ int main(int argc, char **argv)
Pong *pong = new Pong(&obj);
QObject::connect(&app, &QCoreApplication::aboutToQuit, pong, &Pong::aboutToQuit);
pong->setProperty("value", "initial value");
- QDBusConnection::sessionBus().registerObject("/", &obj);
- if (!QDBusConnection::sessionBus().registerService(SERVICE_NAME)) {
- fprintf(stderr, "%s\n",
- qPrintable(QDBusConnection::sessionBus().lastError().message()));
- exit(1);
+ auto connection = QDBusConnection::sessionBus();
+ connection.registerObject("/", &obj);
+
+ if (!connection.registerService(SERVICE_NAME)) {
+ qWarning().noquote() << connection.lastError().message();
+ return 1;
}
app.exec();
diff --git a/examples/dbus/complexpingpong/complexpong.h b/examples/dbus/complexpingpong/complexpong.h
index c116d447c6..b9328c399e 100644
--- a/examples/dbus/complexpingpong/complexpong.h
+++ b/examples/dbus/complexpingpong/complexpong.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef COMPLEXPONG_H
#define COMPLEXPONG_H
@@ -55,23 +8,26 @@
#include <QtDBus/QDBusAbstractAdaptor>
#include <QtDBus/QDBusVariant>
-class Pong: public QDBusAbstractAdaptor
+class Pong : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.example.QtDBus.ComplexPong.Pong")
Q_PROPERTY(QString value READ value WRITE setValue)
public:
- QString m_value;
QString value() const;
void setValue(const QString &newValue);
- Pong(QObject *obj) : QDBusAbstractAdaptor(obj)
- { }
+ Pong(QObject *obj) : QDBusAbstractAdaptor(obj) { }
+
signals:
void aboutToQuit();
+
public slots:
QDBusVariant query(const QString &query);
Q_NOREPLY void quit();
+
+private:
+ QString m_value;
};
#endif
diff --git a/examples/dbus/complexpingpong/ping-common.h b/examples/dbus/complexpingpong/ping-common.h
index f35a33f513..0a5f586941 100644
--- a/examples/dbus/complexpingpong/ping-common.h
+++ b/examples/dbus/complexpingpong/ping-common.h
@@ -1,51 +1,4 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#define SERVICE_NAME "org.example.QtDBus.PingExample"
diff --git a/examples/dbus/dbus.pro b/examples/dbus/dbus.pro
index 1b2164c4ae..627f362b38 100644
--- a/examples/dbus/dbus.pro
+++ b/examples/dbus/dbus.pro
@@ -1,8 +1,7 @@
requires(qtHaveModule(dbus))
TEMPLATE = subdirs
-SUBDIRS = listnames \
- pingpong
+SUBDIRS = pingpong
qtConfig(process): SUBDIRS += complexpingpong
diff --git a/examples/dbus/doc/images/dbus-chat-example.png b/examples/dbus/doc/images/dbus-chat-example.png
deleted file mode 100644
index ad66d08950..0000000000
--- a/examples/dbus/doc/images/dbus-chat-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/dbus/doc/images/dbus-chat-example.webp b/examples/dbus/doc/images/dbus-chat-example.webp
new file mode 100644
index 0000000000..82f651a50c
--- /dev/null
+++ b/examples/dbus/doc/images/dbus-chat-example.webp
Binary files differ
diff --git a/examples/dbus/doc/src/chat.qdoc b/examples/dbus/doc/src/chat.qdoc
index f643af10d3..fdbc2f30ae 100644
--- a/examples/dbus/doc/src/chat.qdoc
+++ b/examples/dbus/doc/src/chat.qdoc
@@ -1,41 +1,18 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example chat
- \title D-Bus Chat Example
+ \title D-Bus Chat
+ \examplecategory {Connectivity}
\ingroup examples-dbus
\brief Demonstrates communication among instances of an application.
\e Chat is a \l{Qt D-Bus} example which demonstrates a simple chat system
- among instances of an application. Users connect and send message to
+ among instances of an application. Users connect and send messages to
each other.
- \image dbus-chat-example.png
+ \image dbus-chat-example.webp
\include examples-run.qdocinc
*/
diff --git a/examples/dbus/doc/src/complexpingpong.qdoc b/examples/dbus/doc/src/complexpingpong.qdoc
index d09708c0ff..84fccdf561 100644
--- a/examples/dbus/doc/src/complexpingpong.qdoc
+++ b/examples/dbus/doc/src/complexpingpong.qdoc
@@ -1,37 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example complexpingpong
- \title D-Bus Complex Ping Pong Example
+ \title D-Bus Complex Ping Pong
+ \examplecategory {Connectivity}
\ingroup examples-dbus
\brief Demonstrates usage of the Qt D-Bus typesystem.
- \e{Complex Ping Pong Example} demonstrates the use of \l{Qt D-Bus}
+ \e{Complex Ping Pong} example demonstrates the use of \l{Qt D-Bus}
typesystem with QDBusVariant and QDBusReply. The example consists of the
main application \c complexping which starts the other application, \c
complexpong. Entering keywords such as \c hello and \c ping is handled by
diff --git a/examples/dbus/doc/src/listnames.qdoc b/examples/dbus/doc/src/listnames.qdoc
deleted file mode 100644
index 40be61b527..0000000000
--- a/examples/dbus/doc/src/listnames.qdoc
+++ /dev/null
@@ -1,39 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example listnames
- \title D-Bus List Names Example
- \ingroup examples-dbus
- \brief Shows how to access the D-Bus bus daemon service.
-
- \e{List Names} is a command-line example which shows how to
- access the \l{Qt D-Bus} bus daemon service. The example prints various
- information about the bus daemon service.
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/dbus/doc/src/pingpong.qdoc b/examples/dbus/doc/src/pingpong.qdoc
index 28ef737d38..1ab0ec62fe 100644
--- a/examples/dbus/doc/src/pingpong.qdoc
+++ b/examples/dbus/doc/src/pingpong.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example pingpong
- \title D-Bus Ping Pong Example
+ \title D-Bus Ping Pong
+ \examplecategory {Connectivity}
\ingroup examples-dbus
\brief Demonstrates a simple message system using D-Bus.
diff --git a/examples/dbus/listnames/CMakeLists.txt b/examples/dbus/listnames/CMakeLists.txt
deleted file mode 100644
index a1907648b1..0000000000
--- a/examples/dbus/listnames/CMakeLists.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-# Generated from listnames.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(listnames LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/listnames")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS DBus)
-
-qt_add_executable(listnames
- listnames.cpp
-)
-set_target_properties(listnames PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(listnames PUBLIC
- Qt::Core
- Qt::DBus
-)
-
-if(WIN32)
- set_target_properties(listnames PROPERTIES
- WIN32_EXECUTABLE FALSE
- )
-endif()
-
-install(TARGETS listnames
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/dbus/listnames/listnames.cpp b/examples/dbus/listnames/listnames.cpp
deleted file mode 100644
index fcd0e060a4..0000000000
--- a/examples/dbus/listnames/listnames.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QCoreApplication>
-#include <QDBusConnection>
-#include <QDBusConnectionInterface>
-#include <QDBusInterface>
-#include <QDBusReply>
-#include <QDebug>
-#include <QStringList>
-
-void method1()
-{
- qDebug() << "Method 1:";
-
- QDBusReply<QStringList> reply = QDBusConnection::sessionBus().interface()->registeredServiceNames();
- if (!reply.isValid()) {
- qDebug() << "Error:" << reply.error().message();
- exit(1);
- }
- const QStringList values = reply.value();
- for (const QString &name : values)
- qDebug() << name;
-}
-
-void method2()
-{
- qDebug() << "Method 2:";
-
- QDBusConnection bus = QDBusConnection::sessionBus();
- QDBusInterface dbus_iface("org.freedesktop.DBus", "/org/freedesktop/DBus",
- "org.freedesktop.DBus", bus);
- qDebug() << dbus_iface.call("ListNames").arguments().at(0);
-}
-
-void method3()
-{
- qDebug() << "Method 3:";
- qDebug() << QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
-}
-
-int main(int argc, char **argv)
-{
- QCoreApplication app(argc, argv);
-
- if (!QDBusConnection::sessionBus().isConnected()) {
- fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
- "To start it, run:\n"
- "\teval `dbus-launch --auto-syntax`\n");
- return 1;
- }
-
- method1();
- method2();
- method3();
-
- return 0;
-}
diff --git a/examples/dbus/listnames/listnames.pro b/examples/dbus/listnames/listnames.pro
deleted file mode 100644
index ed130f7374..0000000000
--- a/examples/dbus/listnames/listnames.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-QT -= gui
-QT += dbus
-win32:CONFIG += console
-
-SOURCES += listnames.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/dbus/listnames
-INSTALLS += target
diff --git a/examples/dbus/pingpong/CMakeLists.txt b/examples/dbus/pingpong/CMakeLists.txt
index 41b8f1b058..d159ad9ba4 100644
--- a/examples/dbus/pingpong/CMakeLists.txt
+++ b/examples/dbus/pingpong/CMakeLists.txt
@@ -1,72 +1,53 @@
-# Generated from pingpong.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
-project(ping LANGUAGES CXX)
+cmake_minimum_required(VERSION 3.16)
+project(pingpong LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+if (ANDROID)
+ message(FATAL_ERROR "This project cannot be built on Android.")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/pingpong")
+find_package(Qt6 REQUIRED COMPONENTS Core DBus)
-find_package(Qt6 COMPONENTS DBus)
+qt_standard_project_setup()
qt_add_executable(ping
ping.cpp
ping-common.h
)
-set_target_properties(ping PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(ping PUBLIC
- # Remove: gui
- Qt::DBus
-)
-install(TARGETS ping
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+target_link_libraries(ping PRIVATE
+ Qt6::Core
+ Qt6::DBus
)
-cmake_minimum_required(VERSION 3.14)
-project(pong LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/pingpong")
-
-find_package(Qt6 COMPONENTS DBus)
qt_add_executable(pong
ping-common.h
- pong.cpp pong.h
+ pong.cpp
)
-set_target_properties(pong PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
+
+target_link_libraries(pong PRIVATE
+ Qt6::Core
+ Qt6::DBus
)
-target_link_libraries(pong PUBLIC
- # Remove: gui
- Qt::DBus
+
+install(TARGETS ping pong
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET ping
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
-install(TARGETS pong
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+qt_generate_deploy_app_script(
+ TARGET pong
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/dbus/pingpong/ping-common.h b/examples/dbus/pingpong/ping-common.h
index f35a33f513..0a5f586941 100644
--- a/examples/dbus/pingpong/ping-common.h
+++ b/examples/dbus/pingpong/ping-common.h
@@ -1,51 +1,4 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#define SERVICE_NAME "org.example.QtDBus.PingExample"
diff --git a/examples/dbus/pingpong/ping.cpp b/examples/dbus/pingpong/ping.cpp
index 64c1fe6bbf..a217107835 100644
--- a/examples/dbus/pingpong/ping.cpp
+++ b/examples/dbus/pingpong/ping.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "ping-common.h"
@@ -55,32 +8,33 @@
#include <QDBusInterface>
#include <QDBusReply>
-#include <stdio.h>
+#include <iostream>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
- if (!QDBusConnection::sessionBus().isConnected()) {
- fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
- "To start it, run:\n"
- "\teval `dbus-launch --auto-syntax`\n");
+ auto connection = QDBusConnection::sessionBus();
+
+ if (!connection.isConnected()) {
+ qWarning("Cannot connect to the D-Bus session bus.\n"
+ "To start it, run:\n"
+ "\teval `dbus-launch --auto-syntax`\n");
return 1;
}
- QDBusInterface iface(SERVICE_NAME, "/", "", QDBusConnection::sessionBus());
+ QDBusInterface iface(SERVICE_NAME, "/");
if (iface.isValid()) {
QDBusReply<QString> reply = iface.call("ping", argc > 1 ? argv[1] : "");
if (reply.isValid()) {
- printf("Reply was: %s\n", qPrintable(reply.value()));
+ std::cout << "Reply was: " << qPrintable(reply.value()) << std::endl;
return 0;
}
- fprintf(stderr, "Call failed: %s\n", qPrintable(reply.error().message()));
+ qWarning("Call failed: %s\n", qPrintable(reply.error().message()));
return 1;
}
- fprintf(stderr, "%s\n",
- qPrintable(QDBusConnection::sessionBus().lastError().message()));
+ qWarning("%s\n", qPrintable(connection.lastError().message()));
return 1;
}
diff --git a/examples/dbus/pingpong/pong.cpp b/examples/dbus/pingpong/pong.cpp
index 37f6261142..ed8c90195e 100644
--- a/examples/dbus/pingpong/pong.cpp
+++ b/examples/dbus/pingpong/pong.cpp
@@ -1,67 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "ping-common.h"
-#include "pong.h"
+#include <QObject>
#include <QCoreApplication>
#include <QDBusConnection>
#include <QDBusError>
-#include <QTimer>
-#include <stdio.h>
-#include <stdlib.h>
+class Pong : public QObject
+{
+ Q_OBJECT
+public slots:
+ QString ping(const QString &arg);
+};
QString Pong::ping(const QString &arg)
{
- QMetaObject::invokeMethod(QCoreApplication::instance(), "quit");
+ QMetaObject::invokeMethod(QCoreApplication::instance(), &QCoreApplication::quit);
return QString("ping(\"%1\") got called").arg(arg);
}
@@ -69,22 +25,25 @@ int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
- if (!QDBusConnection::sessionBus().isConnected()) {
- fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
- "To start it, run:\n"
- "\teval `dbus-launch --auto-syntax`\n");
+ auto connection = QDBusConnection::sessionBus();
+
+ if (!connection.isConnected()) {
+ qWarning("Cannot connect to the D-Bus session bus.\n"
+ "To start it, run:\n"
+ "\teval `dbus-launch --auto-syntax`\n");
return 1;
}
- if (!QDBusConnection::sessionBus().registerService(SERVICE_NAME)) {
- fprintf(stderr, "%s\n",
- qPrintable(QDBusConnection::sessionBus().lastError().message()));
+ if (!connection.registerService(SERVICE_NAME)) {
+ qWarning("%s\n", qPrintable(connection.lastError().message()));
exit(1);
}
Pong pong;
- QDBusConnection::sessionBus().registerObject("/", &pong, QDBusConnection::ExportAllSlots);
+ connection.registerObject("/", &pong, QDBusConnection::ExportAllSlots);
app.exec();
return 0;
}
+
+#include "pong.moc"
diff --git a/examples/dbus/pingpong/pong.h b/examples/dbus/pingpong/pong.h
deleted file mode 100644
index 0b22f37eb7..0000000000
--- a/examples/dbus/pingpong/pong.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PONG_H
-#define PONG_H
-
-#include <QtCore/QObject>
-
-class Pong: public QObject
-{
- Q_OBJECT
-public slots:
- Q_SCRIPTABLE QString ping(const QString &arg);
-};
-
-#endif
diff --git a/examples/dbus/pingpong/pong.pro b/examples/dbus/pingpong/pong.pro
index bc78730534..1307e70805 100644
--- a/examples/dbus/pingpong/pong.pro
+++ b/examples/dbus/pingpong/pong.pro
@@ -1,7 +1,7 @@
QT -= gui
QT += dbus
-HEADERS += ping-common.h pong.h
+HEADERS += ping-common.h
SOURCES += pong.cpp
target.path = $$[QT_INSTALL_EXAMPLES]/dbus/pingpong
diff --git a/examples/dbus/remotecontrolledcar/CMakeLists.txt b/examples/dbus/remotecontrolledcar/CMakeLists.txt
index 4d41919962..fdca3256ad 100644
--- a/examples/dbus/remotecontrolledcar/CMakeLists.txt
+++ b/examples/dbus/remotecontrolledcar/CMakeLists.txt
@@ -1,4 +1,12 @@
-# Generated from remotecontrolledcar.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(remotecontrolledcar LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core DBus Gui Widgets)
+
+qt_standard_project_setup()
add_subdirectory(car)
add_subdirectory(controller)
diff --git a/examples/dbus/remotecontrolledcar/car/.prev_CMakeLists.txt b/examples/dbus/remotecontrolledcar/car/.prev_CMakeLists.txt
deleted file mode 100644
index 86b3fb8e52..0000000000
--- a/examples/dbus/remotecontrolledcar/car/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-# Generated from car.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(car LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/remotecontrolledcar/car")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS DBus)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(car
- car.cpp car.h
- main.cpp
-)
-set_target_properties(car PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(car PUBLIC
- Qt::Core
- Qt::DBus
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS car
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/dbus/remotecontrolledcar/car/CMakeLists.txt b/examples/dbus/remotecontrolledcar/car/CMakeLists.txt
index e20f657a9a..24bbdb669c 100644
--- a/examples/dbus/remotecontrolledcar/car/CMakeLists.txt
+++ b/examples/dbus/remotecontrolledcar/car/CMakeLists.txt
@@ -1,52 +1,43 @@
-# Generated from car.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(car LANGUAGES CXX)
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/remotecontrolledcar/car")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS DBus)
-find_package(Qt6 COMPONENTS Widgets)
-
-# special case begin
set(car_SRCS)
-qt6_add_dbus_adaptor(car_SRCS
- car.xml
+qt_add_dbus_adaptor(car_SRCS
+ ../common/car.xml
qobject.h
"" # empty parent_class value on purpose to not pass -l flag
car_adaptor
)
-# special case end
+
qt_add_executable(car
car.cpp car.h
main.cpp
- ${car_SRCS} # special case
+ ${car_SRCS}
)
+
set_target_properties(car PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(car PUBLIC
- Qt::Core
- Qt::DBus
- Qt::Gui
- Qt::Widgets
+
+target_link_libraries(car PRIVATE
+ Qt6::Core
+ Qt6::DBus
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS car
- 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 car
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/dbus/remotecontrolledcar/car/car.cpp b/examples/dbus/remotecontrolledcar/car/car.cpp
index 2de4e6447a..0920658281 100644
--- a/examples/dbus/remotecontrolledcar/car/car.cpp
+++ b/examples/dbus/remotecontrolledcar/car/car.cpp
@@ -1,67 +1,19 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "car.h"
#include <QtWidgets/QtWidgets>
-#include <qmath.h>
+#include <cmath>
QRectF Car::boundingRect() const
{
return QRectF(-35, -81, 70, 115);
}
-Car::Car() : color(Qt::green), wheelsAngle(0), speed(0)
+Car::Car()
{
startTimer(1000 / 33);
- setFlag(QGraphicsItem::ItemIsMovable, true);
- setFlag(QGraphicsItem::ItemIsFocusable, true);
+ setFlags(ItemIsMovable | ItemIsFocusable);
}
void Car::accelerate()
@@ -134,12 +86,31 @@ void Car::timerEvent(QTimerEvent *event)
const qreal axelDistance = 54;
qreal wheelsAngleRads = qDegreesToRadians(wheelsAngle);
- qreal turnDistance = ::cos(wheelsAngleRads) * axelDistance * 2;
+ qreal turnDistance = std::cos(wheelsAngleRads) * axelDistance * 2;
qreal turnRateRads = wheelsAngleRads / turnDistance; // rough estimate
qreal turnRate = qRadiansToDegrees(turnRateRads);
qreal rotation = speed * turnRate;
setTransform(QTransform().rotate(rotation), true);
setTransform(QTransform::fromTranslate(0, -speed), true);
+
+ if (!scene()->views().isEmpty()) {
+ QRect viewRect = scene()->views().at(0)->sceneRect().toRect();
+ QTransform fx = transform();
+ qreal dx = fx.dx();
+ qreal dy = fx.dy();
+ while (dx < viewRect.left() - 10)
+ dx += viewRect.width();
+ while (dy < viewRect.top() - 10)
+ dy += viewRect.height();
+ while (dx > viewRect.right() + 10)
+ dx -= viewRect.width();
+ while (dy > viewRect.bottom() + 10)
+ dy -= viewRect.width();
+ setTransform(QTransform(fx.m11(), fx.m12(), fx.m13(),
+ fx.m21(), fx.m22(), fx.m23(),
+ dx, dy, fx.m33()));
+ }
+
update();
}
diff --git a/examples/dbus/remotecontrolledcar/car/car.h b/examples/dbus/remotecontrolledcar/car/car.h
index e843786e5b..5a1e199ae0 100644
--- a/examples/dbus/remotecontrolledcar/car/car.h
+++ b/examples/dbus/remotecontrolledcar/car/car.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CAR_H
#define CAR_H
@@ -59,25 +12,23 @@ class Car : public QGraphicsObject
Q_OBJECT
public:
Car();
- QRectF boundingRect() const;
+ QRectF boundingRect() const override;
-public Q_SLOTS:
+public slots:
void accelerate();
void decelerate();
void turnLeft();
void turnRight();
-Q_SIGNALS:
- void crashed();
-
protected:
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr);
- void timerEvent(QTimerEvent *event);
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget = nullptr) override;
+ void timerEvent(QTimerEvent *event) override;
private:
- QBrush color;
- qreal wheelsAngle; // used when applying rotation
- qreal speed; // delta movement along the body axis
+ QBrush color = Qt::green;
+ qreal wheelsAngle = 0; // used when applying rotation
+ qreal speed = 0; // delta movement along the body axis
};
#endif // CAR_H
diff --git a/examples/dbus/remotecontrolledcar/car/car.pro b/examples/dbus/remotecontrolledcar/car/car.pro
index 35a186c7fe..4c0f2a1eb9 100644
--- a/examples/dbus/remotecontrolledcar/car/car.pro
+++ b/examples/dbus/remotecontrolledcar/car/car.pro
@@ -1,9 +1,11 @@
QT += dbus widgets
-DBUS_ADAPTORS += car.xml
+DBUS_ADAPTORS += ../common/car.xml
HEADERS += car.h
SOURCES += car.cpp main.cpp
+CONFIG += no_batch # work around QTBUG-96513
+
# install
target.path = $$[QT_INSTALL_EXAMPLES]/dbus/remotecontrolledcar/car
INSTALLS += target
diff --git a/examples/dbus/remotecontrolledcar/car/car.xml b/examples/dbus/remotecontrolledcar/car/car.xml
deleted file mode 100644
index 6d8c9d19f2..0000000000
--- a/examples/dbus/remotecontrolledcar/car/car.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node name="/com/trollech/examples/car">
- <interface name="org.example.Examples.CarInterface">
- <method name="accelerate"/>
- <method name="decelerate"/>
- <method name="turnLeft"/>
- <method name="turnRight"/>
- <signal name="crashed"/>
- </interface>
-</node> \ No newline at end of file
diff --git a/examples/dbus/remotecontrolledcar/car/main.cpp b/examples/dbus/remotecontrolledcar/car/main.cpp
index 463add47cf..81b8cdfc20 100644
--- a/examples/dbus/remotecontrolledcar/car/main.cpp
+++ b/examples/dbus/remotecontrolledcar/car/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "car.h"
#include "car_adaptor.h"
@@ -63,18 +16,18 @@ int main(int argc, char *argv[])
scene.setSceneRect(-500, -500, 1000, 1000);
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
- Car *car = new Car();
+ auto car = new Car();
scene.addItem(car);
QGraphicsView view(&scene);
view.setRenderHint(QPainter::Antialiasing);
view.setBackgroundBrush(Qt::darkGray);
view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Qt DBus Controlled Car"));
- view.resize(400, 300);
+ view.resize(view.sizeHint());
view.show();
new CarInterfaceAdaptor(car);
- QDBusConnection connection = QDBusConnection::sessionBus();
+ auto connection = QDBusConnection::sessionBus();
connection.registerObject("/Car", car);
connection.registerService("org.example.CarExample");
diff --git a/examples/dbus/remotecontrolledcar/common/car.xml b/examples/dbus/remotecontrolledcar/common/car.xml
new file mode 100644
index 0000000000..ea9a000bb8
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/common/car.xml
@@ -0,0 +1,10 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node name="/com/trollech/examples/car">
+ <interface name="org.example.Examples.CarInterface">
+ <method name="accelerate"/>
+ <method name="decelerate"/>
+ <method name="turnLeft"/>
+ <method name="turnRight"/>
+ </interface>
+</node>
diff --git a/examples/dbus/remotecontrolledcar/controller/.prev_CMakeLists.txt b/examples/dbus/remotecontrolledcar/controller/.prev_CMakeLists.txt
deleted file mode 100644
index f1916c93f2..0000000000
--- a/examples/dbus/remotecontrolledcar/controller/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-# Generated from controller.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(controller LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/remotecontrolledcar/controller")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS DBus)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(controller
- controller.cpp controller.h controller.ui
- main.cpp
-)
-set_target_properties(controller PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(controller PUBLIC
- Qt::Core
- Qt::DBus
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS controller
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/dbus/remotecontrolledcar/controller/CMakeLists.txt b/examples/dbus/remotecontrolledcar/controller/CMakeLists.txt
index f2433a43a2..a0c1aea7c5 100644
--- a/examples/dbus/remotecontrolledcar/controller/CMakeLists.txt
+++ b/examples/dbus/remotecontrolledcar/controller/CMakeLists.txt
@@ -1,50 +1,53 @@
-# Generated from controller.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(controller LANGUAGES CXX)
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/remotecontrolledcar/controller")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS DBus)
-find_package(Qt6 COMPONENTS Widgets)
-
-# special case begin
set(controller_SRCS)
-qt6_add_dbus_interface(controller_SRCS
- car.xml
+qt_add_dbus_interface(controller_SRCS
+ ../common/car.xml
car_interface
)
-# special case end
+
qt_add_executable(controller
- controller.cpp controller.h controller.ui
+ controller.cpp controller.h
main.cpp
- ${controller_SRCS} # special case
+ ${controller_SRCS}
)
+
+qt_add_resources(controller
+ PREFIX
+ "/"
+ FILES
+ down.svg
+ left.svg
+ right.svg
+ up.svg
+ connected.svg
+ connecting.svg
+)
+
set_target_properties(controller PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(controller PUBLIC
- Qt::Core
- Qt::DBus
- Qt::Gui
- Qt::Widgets
+
+target_link_libraries(controller PRIVATE
+ Qt6::Core
+ Qt6::DBus
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS controller
- 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 controller
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/dbus/remotecontrolledcar/controller/car.xml b/examples/dbus/remotecontrolledcar/controller/car.xml
deleted file mode 100644
index 6d8c9d19f2..0000000000
--- a/examples/dbus/remotecontrolledcar/controller/car.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node name="/com/trollech/examples/car">
- <interface name="org.example.Examples.CarInterface">
- <method name="accelerate"/>
- <method name="decelerate"/>
- <method name="turnLeft"/>
- <method name="turnRight"/>
- <signal name="crashed"/>
- </interface>
-</node> \ No newline at end of file
diff --git a/examples/dbus/remotecontrolledcar/controller/connected.svg b/examples/dbus/remotecontrolledcar/controller/connected.svg
new file mode 100644
index 0000000000..a3616b769e
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/connected.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M19 11C19 11.5523 19.4477 12 20 12C20.5523 12 21 11.5523 21 11V10.8478C21 8.11075 19.7088 5.53404 17.5163 3.89561C17.0739 3.56501 16.4472 3.65565 16.1166 4.09805C15.786 4.54046 15.8767 5.1671 16.3191 5.4977C18.0064 6.75857 19 8.74149 19 10.8478V11ZM4 12C4.55228 12 5 11.5523 5 11V10.8478C5 8.74149 5.99363 6.75857 7.68091 5.4977C8.12331 5.1671 8.21395 4.54046 7.88335 4.09805C7.55275 3.65565 6.92611 3.56501 6.4837 3.89561C4.29117 5.53404 3 8.11075 3 10.8478V11C3 11.5523 3.44772 12 4 12ZM7.10555 19.5528C7.35253 19.0588 7.95321 18.8586 8.44719 19.1055C10.6837 20.2238 13.3162 20.2238 15.5528 19.1056C16.0467 18.8586 16.6474 19.0588 16.8944 19.5528C17.1414 20.0468 16.9412 20.6474 16.4472 20.8944C13.6476 22.2942 10.3523 22.2942 7.55276 20.8944C7.05878 20.6474 6.85856 20.0467 7.10555 19.5528Z" fill="black"/>
+<path id="Layer02" fill-rule="evenodd" clip-rule="evenodd" d="M13 5C13 5.55228 12.5523 6 12 6C11.4477 6 11 5.55228 11 5C11 4.44772 11.4477 4 12 4C12.5523 4 13 4.44772 13 5ZM15 5C15 6.65685 13.6569 8 12 8C10.3431 8 9 6.65685 9 5C9 3.34315 10.3431 2 12 2C13.6569 2 15 3.34315 15 5ZM5 17C5.55228 17 6 16.5523 6 16C6 15.4477 5.55228 15 5 15C4.44772 15 4 15.4477 4 16C4 16.5523 4.44772 17 5 17ZM5 19C6.65685 19 8 17.6569 8 16C8 14.3431 6.65685 13 5 13C3.34315 13 2 14.3431 2 16C2 17.6569 3.34315 19 5 19ZM19 17C19.5523 17 20 16.5523 20 16C20 15.4477 19.5523 15 19 15C18.4477 15 18 15.4477 18 16C18 16.5523 18.4477 17 19 17ZM19 19C20.6569 19 22 17.6569 22 16C22 14.3431 20.6569 13 19 13C17.3431 13 16 14.3431 16 16C16 17.6569 17.3431 19 19 19Z" fill="black"/>
+</svg>
diff --git a/examples/dbus/remotecontrolledcar/controller/connecting.svg b/examples/dbus/remotecontrolledcar/controller/connecting.svg
new file mode 100644
index 0000000000..4097d0b276
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/connecting.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path id="Layer01" d="M14 12C14 13.1046 13.1046 14 12 14C10.8954 14 10 13.1046 10 12C10 10.8954 10.8954 10 12 10C13.1046 10 14 10.8954 14 12Z" fill="#0D0D0D"/>
+<path id="Layer02" fill-rule="evenodd" clip-rule="evenodd" d="M3 12C3 14.2728 3.94193 16.5032 5.71196 18.2978C6.09978 18.691 6.09543 19.3241 5.70223 19.712C5.30902 20.0998 4.67587 20.0954 4.28805 19.7022C2.18112 17.5661 1 14.8427 1 12C1 9.15729 2.18112 6.43389 4.28805 4.29777C4.67587 3.90457 5.30902 3.90022 5.70223 4.28804C6.09543 4.67587 6.09978 5.30902 5.71195 5.70223C3.94193 7.49678 3 9.72715 3 12ZM8.80201 14.404C8.27734 13.6971 7.99902 12.8569 7.99902 12C7.99902 11.1431 8.27734 10.3029 8.80201 9.596C9.13117 9.15252 9.0385 8.52617 8.59502 8.19701C8.15154 7.86785 7.5252 7.96052 7.19604 8.404C6.41969 9.44998 5.99902 10.7067 5.99902 12C5.99902 13.2933 6.41969 14.55 7.19604 15.596C7.5252 16.0395 8.15154 16.1321 8.59502 15.803C9.0385 15.4738 9.13117 14.8475 8.80201 14.404ZM15.197 14.404C15.7217 13.6971 16 12.8569 16 12C16 11.1431 15.7217 10.3029 15.197 9.596C14.8679 9.15252 14.9605 8.52617 15.404 8.19701C15.8475 7.86785 16.4738 7.96052 16.803 8.404C17.5793 9.44998 18 10.7067 18 12C18 13.2933 17.5793 14.55 16.803 15.596C16.4738 16.0395 15.8475 16.1321 15.404 15.803C14.9605 15.4738 14.8679 14.8475 15.197 14.404ZM18.2871 18.2978C20.0571 16.5032 20.999 14.2728 20.999 12C20.999 9.72715 20.0571 7.49678 18.2871 5.70223C17.8992 5.30902 17.9036 4.67587 18.2968 4.28804C18.69 3.90022 19.3232 3.90457 19.711 4.29777C21.8179 6.43389 22.999 9.15729 22.999 12C22.999 14.8427 21.8179 17.5661 19.711 19.7022C19.3231 20.0954 18.69 20.0998 18.2968 19.712C17.9036 19.3241 17.8992 18.691 18.2871 18.2978Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/dbus/remotecontrolledcar/controller/controller.cpp b/examples/dbus/remotecontrolledcar/controller/controller.cpp
index cb2e7591d8..ccff2b1743 100644
--- a/examples/dbus/remotecontrolledcar/controller/controller.cpp
+++ b/examples/dbus/remotecontrolledcar/controller/controller.cpp
@@ -1,92 +1,58 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "controller.h"
-#include "car_interface.h"
+#include <QGridLayout>
+#include <QHBoxLayout>
+
+using org::example::Examples::CarInterface;
-Controller::Controller(QWidget *parent)
- : QWidget(parent)
+Controller::Controller(QWidget *parent) : QWidget(parent)
{
- ui.setupUi(this);
- car = new org::example::Examples::CarInterface("org.example.CarExample", "/Car",
- QDBusConnection::sessionBus(), this);
+ car = new CarInterface("org.example.CarExample", "/Car", QDBusConnection::sessionBus(), this);
+
+ accelerate = new QPushButton(QIcon(":up.svg"), "", this);
+ accelerate->setFixedSize(80, 64);
+ accelerate->setIconSize(QSize(44, 44));
+ decelerate = new QPushButton(QIcon(":down.svg"), "", this);
+ decelerate->setFixedSize(80, 64);
+ decelerate->setIconSize(QSize(44, 44));
+ left = new QPushButton(QIcon(":left.svg"), "", this);
+ left->setFixedSize(64, 80);
+ left->setIconSize(QSize(44, 44));
+ right = new QPushButton(QIcon(":right.svg"), "", this);
+ right->setFixedSize(64, 80);
+ right->setIconSize(QSize(44, 44));
+
+ status = new QLabel(this);
+ statusSymbol = new QLabel(this);
+ statusSymbol->setFixedHeight(24);
+
+ QGridLayout *layout = new QGridLayout(this);
+ layout->addWidget(accelerate, 1, 1);
+ layout->addWidget(left, 2, 0);
+ layout->addWidget(right, 2, 2);
+ layout->addWidget(decelerate, 3, 1);
+
+ QHBoxLayout *statusLayout = new QHBoxLayout();
+ statusLayout->addWidget(status);
+ statusLayout->addWidget(statusSymbol);
+ layout->addLayout(statusLayout, 0, 1, 1, 2, Qt::AlignTop | Qt::AlignRight);
+
+ connect(accelerate, &QPushButton::clicked, car, &CarInterface::accelerate);
+ connect(decelerate, &QPushButton::clicked, car, &CarInterface::decelerate);
+ connect(left, &QPushButton::clicked, car, &CarInterface::turnLeft);
+ connect(right, &QPushButton::clicked, car, &CarInterface::turnRight);
+
startTimer(1000);
}
void Controller::timerEvent(QTimerEvent *event)
{
Q_UNUSED(event);
- if (car->isValid())
- ui.label->setText("connected");
- else
- ui.label->setText("disconnected");
-}
-
-void Controller::on_accelerate_clicked()
-{
- car->accelerate();
-}
-void Controller::on_decelerate_clicked()
-{
- car->decelerate();
-}
-
-void Controller::on_left_clicked()
-{
- car->turnLeft();
-}
-
-void Controller::on_right_clicked()
-{
- car->turnRight();
+ static QPixmap connectedIcon = QPixmap::fromImage(QImage(":connected.svg"));
+ static QPixmap connectingIcon = QPixmap::fromImage(QImage(":connecting.svg"));
+ status->setText(car->isValid() ? tr("connected") : tr("searching..."));
+ statusSymbol->setPixmap(car->isValid() ? connectedIcon : connectingIcon);
}
diff --git a/examples/dbus/remotecontrolledcar/controller/controller.h b/examples/dbus/remotecontrolledcar/controller/controller.h
index 87359661ba..8df4ed2d1e 100644
--- a/examples/dbus/remotecontrolledcar/controller/controller.h
+++ b/examples/dbus/remotecontrolledcar/controller/controller.h
@@ -1,57 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CONTROLLER_H
#define CONTROLLER_H
-#include "ui_controller.h"
+#include <QWidget>
+#include <QPushButton>
+#include <QLabel>
+
#include "car_interface.h"
class Controller : public QWidget
@@ -59,20 +15,19 @@ class Controller : public QWidget
Q_OBJECT
public:
- Controller(QWidget *parent = nullptr);
+ explicit Controller(QWidget *parent = nullptr);
protected:
- void timerEvent(QTimerEvent *event);
-
-private slots:
- void on_accelerate_clicked();
- void on_decelerate_clicked();
- void on_left_clicked();
- void on_right_clicked();
+ void timerEvent(QTimerEvent *event) override;
private:
- Ui::Controller ui;
org::example::Examples::CarInterface *car;
+ QPushButton *accelerate;
+ QPushButton *decelerate;
+ QPushButton *left;
+ QPushButton *right;
+ QLabel *statusSymbol;
+ QLabel *status;
};
#endif
diff --git a/examples/dbus/remotecontrolledcar/controller/controller.pro b/examples/dbus/remotecontrolledcar/controller/controller.pro
index 07767141f4..ce16f21f36 100644
--- a/examples/dbus/remotecontrolledcar/controller/controller.pro
+++ b/examples/dbus/remotecontrolledcar/controller/controller.pro
@@ -1,9 +1,9 @@
QT += dbus widgets
-DBUS_INTERFACES += car.xml
-FORMS += controller.ui
+DBUS_INTERFACES += ../common/car.xml
HEADERS += controller.h
SOURCES += main.cpp controller.cpp
+RESOURCES += icons.qrc
# Work-around CI issue. Not needed in user code.
CONFIG += no_batch
diff --git a/examples/dbus/remotecontrolledcar/controller/controller.ui b/examples/dbus/remotecontrolledcar/controller/controller.ui
deleted file mode 100644
index 379015bf30..0000000000
--- a/examples/dbus/remotecontrolledcar/controller/controller.ui
+++ /dev/null
@@ -1,64 +0,0 @@
-<ui version="4.0" >
- <class>Controller</class>
- <widget class="QWidget" name="Controller" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>255</width>
- <height>111</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Controller</string>
- </property>
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="1" column="1" >
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>Controller</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="2" column="1" >
- <widget class="QPushButton" name="decelerate" >
- <property name="text" >
- <string>Decelerate</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QPushButton" name="accelerate" >
- <property name="text" >
- <string>Accelerate</string>
- </property>
- </widget>
- </item>
- <item row="1" column="2" >
- <widget class="QPushButton" name="right" >
- <property name="text" >
- <string>Right</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QPushButton" name="left" >
- <property name="text" >
- <string>Left</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/dbus/remotecontrolledcar/controller/down.svg b/examples/dbus/remotecontrolledcar/controller/down.svg
new file mode 100644
index 0000000000..f9a417b65e
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/down.svg
@@ -0,0 +1,3 @@
+<svg width="55" height="55" viewBox="0 0 55 55" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M49.7455 16.7129C48.8505 15.8179 47.3995 15.8179 46.5046 16.7129L27.5 35.7174L8.49547 16.7129C7.60052 15.8179 6.14952 15.8179 5.25456 16.7129C4.35961 17.6078 4.35961 19.0588 5.25456 19.9538L25.8796 40.5788C26.7745 41.4737 28.2255 41.4737 29.1205 40.5788L49.7455 19.9538C50.6404 19.0588 50.6404 17.6078 49.7455 16.7129Z" fill="black"/>
+</svg>
diff --git a/examples/dbus/remotecontrolledcar/controller/icons.qrc b/examples/dbus/remotecontrolledcar/controller/icons.qrc
new file mode 100644
index 0000000000..0aad87cf32
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/icons.qrc
@@ -0,0 +1,10 @@
+<RCC>
+ <qresource prefix="/">
+ <file>connected.svg</file>
+ <file>connecting.svg</file>
+ <file>down.svg</file>
+ <file>left.svg</file>
+ <file>right.svg</file>
+ <file>up.svg</file>
+ </qresource>
+</RCC>
diff --git a/examples/dbus/remotecontrolledcar/controller/left.svg b/examples/dbus/remotecontrolledcar/controller/left.svg
new file mode 100644
index 0000000000..12d6420f48
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/left.svg
@@ -0,0 +1,3 @@
+<svg width="55" height="55" viewBox="0 0 55 55" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M38.2871 5.25453C39.1821 6.14948 39.1821 7.60048 38.2871 8.49543L19.2826 27.5L38.2871 46.5045C39.1821 47.3995 39.1821 48.8505 38.2871 49.7454C37.3922 50.6404 35.9412 50.6404 35.0462 49.7454L14.4212 29.1204C13.5263 28.2255 13.5263 26.7745 14.4212 25.8795L35.0462 5.25453C35.9412 4.35958 37.3922 4.35958 38.2871 5.25453Z" fill="black"/>
+</svg>
diff --git a/examples/dbus/remotecontrolledcar/controller/main.cpp b/examples/dbus/remotecontrolledcar/controller/main.cpp
index 4aeff8635e..7d91048729 100644
--- a/examples/dbus/remotecontrolledcar/controller/main.cpp
+++ b/examples/dbus/remotecontrolledcar/controller/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
diff --git a/examples/dbus/remotecontrolledcar/controller/right.svg b/examples/dbus/remotecontrolledcar/controller/right.svg
new file mode 100644
index 0000000000..26a39a74ca
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/right.svg
@@ -0,0 +1,3 @@
+<svg width="55" height="55" viewBox="0 0 55 55" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M16.7129 5.25453C15.8179 6.14948 15.8179 7.60048 16.7129 8.49543L35.7174 27.5L16.7129 46.5045C15.8179 47.3995 15.8179 48.8505 16.7129 49.7454C17.6078 50.6404 19.0588 50.6404 19.9538 49.7454L40.5788 29.1204C41.4737 28.2255 41.4737 26.7745 40.5788 25.8795L19.9538 5.25453C19.0588 4.35958 17.6078 4.35958 16.7129 5.25453Z" fill="black"/>
+</svg>
diff --git a/examples/dbus/remotecontrolledcar/controller/up.svg b/examples/dbus/remotecontrolledcar/controller/up.svg
new file mode 100644
index 0000000000..ea5f1bfcfb
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/controller/up.svg
@@ -0,0 +1,3 @@
+<svg width="55" height="55" viewBox="0 0 55 55" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M49.7455 38.2871C48.8505 39.1821 47.3995 39.1821 46.5046 38.2871L27.5 19.2826L8.49547 38.2871C7.60052 39.1821 6.14952 39.1821 5.25456 38.2871C4.35961 37.3922 4.35961 35.9412 5.25456 35.0462L25.8796 14.4212C26.7745 13.5263 28.2255 13.5263 29.1205 14.4212L49.7455 35.0462C50.6404 35.9412 50.6404 37.3922 49.7455 38.2871Z" fill="black"/>
+</svg>
diff --git a/examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.png b/examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.png
deleted file mode 100644
index 7e08340c80..0000000000
--- a/examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.webp b/examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.webp
new file mode 100644
index 0000000000..958b466e9f
--- /dev/null
+++ b/examples/dbus/remotecontrolledcar/doc/images/remotecontrolledcar-car-example.webp
Binary files differ
diff --git a/examples/dbus/remotecontrolledcar/doc/src/dbus-remotecontrolledcar.qdoc b/examples/dbus/remotecontrolledcar/doc/src/dbus-remotecontrolledcar.qdoc
index e18f963103..94c914b642 100644
--- a/examples/dbus/remotecontrolledcar/doc/src/dbus-remotecontrolledcar.qdoc
+++ b/examples/dbus/remotecontrolledcar/doc/src/dbus-remotecontrolledcar.qdoc
@@ -1,40 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example remotecontrolledcar
- \title D-Bus Remote Controlled Car Example
+ \title D-Bus Remote Controlled Car
+ \examplecategory {Connectivity}
\ingroup examples-dbus
\brief Shows how to use Qt D-Bus to control a car from another application.
The Remote Controlled Car example shows how to use \l{Qt D-Bus} to control
one application from another.
- \image remotecontrolledcar-car-example.png
+ \image remotecontrolledcar-car-example.webp
\include examples-run.qdocinc
*/
diff --git a/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro b/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro
index 2a1fddb500..dd275b1099 100644
--- a/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro
+++ b/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
SUBDIRS = car \
- controller
+ controller
diff --git a/examples/embedded/CMakeLists.txt b/examples/embedded/CMakeLists.txt
deleted file mode 100644
index 84292edccc..0000000000
--- a/examples/embedded/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-# Generated from embedded.pro.
-
-if(NOT TARGET Qt::Gui OR (NOT embedded AND NOT x11))
- return()
-endif()
-add_subdirectory(styleexample)
-add_subdirectory(raycasting)
-add_subdirectory(flickable)
-add_subdirectory(digiflip)
-add_subdirectory(lightmaps)
-add_subdirectory(flightinfo)
diff --git a/examples/embedded/digiflip/CMakeLists.txt b/examples/embedded/digiflip/CMakeLists.txt
deleted file mode 100644
index 2f7de56f25..0000000000
--- a/examples/embedded/digiflip/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated from digiflip.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(digiflip LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/embedded/digiflip")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(digiflip
- digiflip.cpp
-)
-set_target_properties(digiflip PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(digiflip PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS digiflip
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/embedded/digiflip/digiflip.cpp b/examples/embedded/digiflip/digiflip.cpp
deleted file mode 100644
index 729337e5d1..0000000000
--- a/examples/embedded/digiflip/digiflip.cpp
+++ /dev/null
@@ -1,418 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore>
-#include <QtWidgets>
-
-class Digits: public QWidget
-{
- Q_OBJECT
-
-public:
-
- enum {
- Slide,
- Flip,
- Rotate
- };
-
- Digits(QWidget *parent)
- : QWidget(parent)
- , m_number(0)
- , m_transition(Slide)
- {
- setAttribute(Qt::WA_OpaquePaintEvent, true);
- setAttribute(Qt::WA_NoSystemBackground, true);
- connect(&m_animator, SIGNAL(frameChanged(int)), SLOT(update()));
- m_animator.setFrameRange(0, 100);
- m_animator.setDuration(600);
- m_animator.setEasingCurve(QEasingCurve::InOutSine);
- }
-
- void setTransition(int tr) {
- m_transition = tr;
- }
-
- int transition() const {
- return m_transition;
- }
-
- void setNumber(int n) {
- if (m_number != n) {
- m_number = qBound(0, n, 99);
- preparePixmap();
- update();
- }
- }
-
- void flipTo(int n) {
- if (m_number != n) {
- m_number = qBound(0, n, 99);
- m_lastPixmap = m_pixmap;
- preparePixmap();
- m_animator.stop();
- m_animator.start();
- }
- }
-
-protected:
-
- void drawFrame(QPainter *p, const QRect &rect) {
- p->setPen(Qt::NoPen);
- QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
- gradient.setColorAt(0.00, QColor(245, 245, 245));
- gradient.setColorAt(0.49, QColor(192, 192, 192));
- gradient.setColorAt(0.51, QColor(245, 245, 245));
- gradient.setColorAt(1.00, QColor(192, 192, 192));
- p->setBrush(gradient);
- QRect r = rect;
- p->drawRoundedRect(r, 15, 15, Qt::RelativeSize);
- r.adjust(1, 4, -1, -4);
- p->setPen(QColor(181, 181, 181));
- p->setBrush(Qt::NoBrush);
- p->drawRoundedRect(r, 15, 15, Qt::RelativeSize);
- p->setPen(QColor(159, 159, 159));
- int y = rect.top() + rect.height() / 2 - 1;
- p->drawLine(rect.left(), y, rect.right(), y);
- }
-
- QPixmap drawDigits(int n, const QRect &rect) {
-
- int scaleFactor = 2;
-
- QString str = QString::number(n);
- if (str.length() == 1)
- str.prepend('0');
-
- QFont font;
- font.setFamily("Helvetica");
- int fontHeight = scaleFactor * 0.55 * rect.height();
- font.setPixelSize(fontHeight);
- font.setBold(true);
-
- QPixmap pixmap(rect.size() * scaleFactor);
- pixmap.fill(Qt::transparent);
-
- QLinearGradient gradient(QPoint(0, 0), QPoint(0, pixmap.height()));
- gradient.setColorAt(0.00, QColor(128, 128, 128));
- gradient.setColorAt(0.49, QColor(64, 64, 64));
- gradient.setColorAt(0.51, QColor(128, 128, 128));
- gradient.setColorAt(1.00, QColor(16, 16, 16));
-
- QPainter p;
- p.begin(&pixmap);
- p.setFont(font);
- QPen pen;
- pen.setBrush(QBrush(gradient));
- p.setPen(pen);
- p.drawText(pixmap.rect(), Qt::AlignCenter, str);
- p.end();
-
- return pixmap.scaledToWidth(width(), Qt::SmoothTransformation);
- }
-
- void preparePixmap() {
- m_pixmap = QPixmap(size());
- m_pixmap.fill(Qt::transparent);
- QPainter p;
- p.begin(&m_pixmap);
- p.drawPixmap(0, 0, drawDigits(m_number, rect()));
- p.end();
- }
-
- void resizeEvent(QResizeEvent*) {
- preparePixmap();
- update();
- }
-
- void paintStatic() {
- QPainter p(this);
- p.fillRect(rect(), Qt::black);
-
- int pad = width() / 10;
- drawFrame(&p, rect().adjusted(pad, pad, -pad, -pad));
- p.drawPixmap(0, 0, m_pixmap);
- }
-
- void paintSlide() {
- QPainter p(this);
- p.fillRect(rect(), Qt::black);
-
- int pad = width() / 10;
- QRect fr = rect().adjusted(pad, pad, -pad, -pad);
- drawFrame(&p, fr);
- p.setClipRect(fr);
-
- int y = height() * m_animator.currentFrame() / 100;
- p.drawPixmap(0, y, m_lastPixmap);
- p.drawPixmap(0, y - height(), m_pixmap);
- }
-
- void paintFlip() {
- QPainter p(this);
- p.setRenderHint(QPainter::SmoothPixmapTransform, true);
- p.setRenderHint(QPainter::Antialiasing, true);
- p.fillRect(rect(), Qt::black);
-
- int hw = width() / 2;
- int hh = height() / 2;
-
- // behind is the new pixmap
- int pad = width() / 10;
- QRect fr = rect().adjusted(pad, pad, -pad, -pad);
- drawFrame(&p, fr);
- p.drawPixmap(0, 0, m_pixmap);
-
- int index = m_animator.currentFrame();
-
- if (index <= 50) {
-
- // the top part of the old pixmap is flipping
- int angle = -180 * index / 100;
- QTransform transform;
- transform.translate(hw, hh);
- transform.rotate(angle, Qt::XAxis);
- p.setTransform(transform);
- drawFrame(&p, fr.adjusted(-hw, -hh, -hw, -hh));
- p.drawPixmap(-hw, -hh, m_lastPixmap);
-
- // the bottom part is still the old pixmap
- p.resetTransform();
- p.setClipRect(0, hh, width(), hh);
- drawFrame(&p, fr);
- p.drawPixmap(0, 0, m_lastPixmap);
- } else {
-
- p.setClipRect(0, hh, width(), hh);
-
- // the bottom part is still the old pixmap
- drawFrame(&p, fr);
- p.drawPixmap(0, 0, m_lastPixmap);
-
- // the bottom part of the new pixmap is flipping
- int angle = 180 - 180 * m_animator.currentFrame() / 100;
- QTransform transform;
- transform.translate(hw, hh);
- transform.rotate(angle, Qt::XAxis);
- p.setTransform(transform);
- drawFrame(&p, fr.adjusted(-hw, -hh, -hw, -hh));
- p.drawPixmap(-hw, -hh, m_pixmap);
-
- }
-
- }
-
- void paintRotate() {
- QPainter p(this);
-
- int pad = width() / 10;
- QRect fr = rect().adjusted(pad, pad, -pad, -pad);
- drawFrame(&p, fr);
- p.setClipRect(fr);
-
- int angle1 = -180 * m_animator.currentFrame() / 100;
- int angle2 = 180 - 180 * m_animator.currentFrame() / 100;
- int angle = (m_animator.currentFrame() <= 50) ? angle1 : angle2;
- QPixmap pix = (m_animator.currentFrame() <= 50) ? m_lastPixmap : m_pixmap;
-
- QTransform transform;
- transform.translate(width() / 2, height() / 2);
- transform.rotate(angle, Qt::XAxis);
-
- p.setTransform(transform);
- p.setRenderHint(QPainter::SmoothPixmapTransform, true);
- p.drawPixmap(-width() / 2, -height() / 2, pix);
- }
-
- void paintEvent(QPaintEvent *event) {
- Q_UNUSED(event);
- if (m_animator.state() == QTimeLine::Running) {
- if (m_transition == Slide)
- paintSlide();
- if (m_transition == Flip)
- paintFlip();
- if (m_transition == Rotate)
- paintRotate();
- } else {
- paintStatic();
- }
- }
-
-private:
- int m_number;
- int m_transition;
- QPixmap m_pixmap;
- QPixmap m_lastPixmap;
- QTimeLine m_animator;
-};
-
-class DigiFlip : public QMainWindow
-{
- Q_OBJECT
-
-public:
- DigiFlip(QWidget *parent = nullptr)
- : QMainWindow(parent)
- {
- m_hour = new Digits(this);
- m_hour->show();
- m_minute = new Digits(this);
- m_minute->show();
-
- QPalette pal = palette();
- pal.setColor(QPalette::Window, Qt::black);
- setPalette(pal);
-
- m_ticker.start(1000, this);
- QTime t = QTime::currentTime();
- m_hour->setNumber(t.hour());
- m_minute->setNumber(t.minute());
- updateTime();
-
- QAction *slideAction = new QAction("&Slide", this);
- QAction *flipAction = new QAction("&Flip", this);
- QAction *rotateAction = new QAction("&Rotate", this);
- connect(slideAction, SIGNAL(triggered()), SLOT(chooseSlide()));
- connect(flipAction, SIGNAL(triggered()), SLOT(chooseFlip()));
- connect(rotateAction, SIGNAL(triggered()), SLOT(chooseRotate()));
- addAction(slideAction);
- addAction(flipAction);
- addAction(rotateAction);
- setContextMenuPolicy(Qt::ActionsContextMenu);
- }
-
- void updateTime() {
- QTime t = QTime::currentTime();
- m_hour->flipTo(t.hour());
- m_minute->flipTo(t.minute());
- QString str = t.toString("hh:mm:ss");
- str.prepend(": ");
- if (m_hour->transition() == Digits::Slide)
- str.prepend("Slide");
- if (m_hour->transition() == Digits::Flip)
- str.prepend("Flip");
- if (m_hour->transition() == Digits::Rotate)
- str.prepend("Rotate");
- setWindowTitle(str);
- }
-
- void switchTransition(int delta) {
- int i = (m_hour->transition() + delta + 3) % 3;
- m_hour->setTransition(i);
- m_minute->setTransition(i);
- updateTime();
- }
-
-protected:
- void resizeEvent(QResizeEvent*) {
- int digitsWidth = width() / 2;
- int digitsHeight = digitsWidth * 1.2;
-
- int y = (height() - digitsHeight) / 3;
-
- m_hour->resize(digitsWidth, digitsHeight);
- m_hour->move(0, y);
-
- m_minute->resize(digitsWidth, digitsHeight);
- m_minute->move(width() / 2, y);
- }
-
- void timerEvent(QTimerEvent*) {
- updateTime();
- }
-
- void keyPressEvent(QKeyEvent *event) {
- if (event->key() == Qt::Key_Right) {
- switchTransition(1);
- event->accept();
- }
- if (event->key() == Qt::Key_Left) {
- switchTransition(-1);
- event->accept();
- }
- }
-
-private slots:
- void chooseSlide() {
- m_hour->setTransition(0);
- m_minute->setTransition(0);
- updateTime();
- }
-
- void chooseFlip() {
- m_hour->setTransition(1);
- m_minute->setTransition(1);
- updateTime();
- }
-
- void chooseRotate() {
- m_hour->setTransition(2);
- m_minute->setTransition(2);
- updateTime();
- }
-
-private:
- QBasicTimer m_ticker;
- Digits *m_hour;
- Digits *m_minute;
-};
-
-#include "digiflip.moc"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- DigiFlip time;
- time.resize(320, 240);
- time.show();
-
- return app.exec();
-}
diff --git a/examples/embedded/digiflip/digiflip.pro b/examples/embedded/digiflip/digiflip.pro
deleted file mode 100644
index af6c2773c8..0000000000
--- a/examples/embedded/digiflip/digiflip.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-QT += widgets
-
-SOURCES = digiflip.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/embedded/digiflip
-INSTALLS += target
diff --git a/examples/embedded/embedded.pro b/examples/embedded/embedded.pro
deleted file mode 100644
index e772eb88aa..0000000000
--- a/examples/embedded/embedded.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-requires(if(embedded|x11):qtHaveModule(gui))
-
-TEMPLATE = subdirs
-SUBDIRS = styleexample raycasting flickable digiflip
-
-SUBDIRS += lightmaps
-SUBDIRS += flightinfo
diff --git a/examples/embedded/flickable/CMakeLists.txt b/examples/embedded/flickable/CMakeLists.txt
deleted file mode 100644
index 002ccf1198..0000000000
--- a/examples/embedded/flickable/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from flickable.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(flickable LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/embedded/flickable")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(flickable
- flickable.cpp flickable.h
- main.cpp
-)
-set_target_properties(flickable PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(flickable PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS flickable
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/embedded/flickable/flickable.cpp b/examples/embedded/flickable/flickable.cpp
deleted file mode 100644
index 8cf7a28cde..0000000000
--- a/examples/embedded/flickable/flickable.cpp
+++ /dev/null
@@ -1,293 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "flickable.h"
-
-#include <QtCore>
-#include <QtWidgets>
-
-class FlickableTicker: QObject
-{
-public:
- FlickableTicker(Flickable *scroller) {
- m_scroller = scroller;
- }
-
- void start(int interval) {
- if (!m_timer.isActive())
- m_timer.start(interval, this);
- }
-
- void stop() {
- m_timer.stop();
- }
-
-protected:
- void timerEvent(QTimerEvent *event) {
- Q_UNUSED(event);
- m_scroller->tick();
- }
-
-private:
- Flickable *m_scroller;
- QBasicTimer m_timer;
-};
-
-class FlickablePrivate
-{
-public:
- typedef enum {
- Steady,
- Pressed,
- ManualScroll,
- AutoScroll,
- Stop
- } State;
-
- State state;
- int threshold;
- QPoint pressPos;
- QPoint offset;
- QPoint delta;
- QPoint speed;
- FlickableTicker *ticker;
- QElapsedTimer timeStamp;
- QWidget *target;
- QList<QEvent*> ignoreList;
-};
-
-Flickable::Flickable()
-{
- d = new FlickablePrivate;
- d->state = FlickablePrivate::Steady;
- d->threshold = 10;
- d->ticker = new FlickableTicker(this);
- d->timeStamp.start();
- d->target = 0;
-}
-
-Flickable::~Flickable()
-{
- delete d;
-}
-
-void Flickable::setThreshold(int th)
-{
- if (th >= 0)
- d->threshold = th;
-}
-
-int Flickable::threshold() const
-{
- return d->threshold;
-}
-
-void Flickable::setAcceptMouseClick(QWidget *target)
-{
- d->target = target;
-}
-
-static QPoint deaccelerate(const QPoint &speed, int a = 1, int max = 64)
-{
- int x = qBound(-max, speed.x(), max);
- int y = qBound(-max, speed.y(), max);
- x = (x == 0) ? x : (x > 0) ? qMax(0, x - a) : qMin(0, x + a);
- y = (y == 0) ? y : (y > 0) ? qMax(0, y - a) : qMin(0, y + a);
- return QPoint(x, y);
-}
-
-void Flickable::handleMousePress(QMouseEvent *event)
-{
- event->ignore();
-
- if (event->button() != Qt::LeftButton)
- return;
-
- if (d->ignoreList.removeAll(event))
- return;
-
- switch (d->state) {
-
- case FlickablePrivate::Steady:
- event->accept();
- d->state = FlickablePrivate::Pressed;
- d->pressPos = event->position().toPoint();
- break;
-
- case FlickablePrivate::AutoScroll:
- event->accept();
- d->state = FlickablePrivate::Stop;
- d->speed = QPoint(0, 0);
- d->pressPos = event->position().toPoint();
- d->offset = scrollOffset();
- d->ticker->stop();
- break;
-
- default:
- break;
- }
-}
-
-void Flickable::handleMouseRelease(QMouseEvent *event)
-{
- event->ignore();
-
- if (event->button() != Qt::LeftButton)
- return;
-
- if (d->ignoreList.removeAll(event))
- return;
-
- QPoint delta;
-
- switch (d->state) {
-
- case FlickablePrivate::Pressed:
- event->accept();
- d->state = FlickablePrivate::Steady;
- if (d->target) {
- QMouseEvent *event1 = new QMouseEvent(QEvent::MouseButtonPress,
- d->pressPos, Qt::LeftButton,
- Qt::LeftButton, Qt::NoModifier);
- QMouseEvent *event2 = event->clone();
- d->ignoreList << event1;
- d->ignoreList << event2;
- QApplication::postEvent(d->target, event1);
- QApplication::postEvent(d->target, event2);
- }
- break;
-
- case FlickablePrivate::ManualScroll:
- event->accept();
- delta = event->position().toPoint() - d->pressPos;
- if (d->timeStamp.elapsed() > 100) {
- d->timeStamp.start();
- d->speed = delta - d->delta;
- d->delta = delta;
- }
- d->offset = scrollOffset();
- d->pressPos = event->position().toPoint();
- if (d->speed == QPoint(0, 0)) {
- d->state = FlickablePrivate::Steady;
- } else {
- d->speed /= 4;
- d->state = FlickablePrivate::AutoScroll;
- d->ticker->start(20);
- }
- break;
-
- case FlickablePrivate::Stop:
- event->accept();
- d->state = FlickablePrivate::Steady;
- d->offset = scrollOffset();
- break;
-
- default:
- break;
- }
-}
-
-void Flickable::handleMouseMove(QMouseEvent *event)
-{
- event->ignore();
-
- if (!(event->buttons() & Qt::LeftButton))
- return;
-
- if (d->ignoreList.removeAll(event))
- return;
-
- QPoint delta;
-
- switch (d->state) {
-
- case FlickablePrivate::Pressed:
- case FlickablePrivate::Stop:
- delta = event->position().toPoint() - d->pressPos;
- if (delta.x() > d->threshold || delta.x() < -d->threshold ||
- delta.y() > d->threshold || delta.y() < -d->threshold) {
- d->timeStamp.start();
- d->state = FlickablePrivate::ManualScroll;
- d->delta = QPoint(0, 0);
- d->pressPos = event->position().toPoint();
- event->accept();
- }
- break;
-
- case FlickablePrivate::ManualScroll:
- event->accept();
- delta = event->position().toPoint() - d->pressPos;
- setScrollOffset(d->offset - delta);
- if (d->timeStamp.elapsed() > 100) {
- d->timeStamp.start();
- d->speed = delta - d->delta;
- d->delta = delta;
- }
- break;
-
- default:
- break;
- }
-}
-
-void Flickable::tick()
-{
- if (d->state == FlickablePrivate:: AutoScroll) {
- d->speed = deaccelerate(d->speed);
- setScrollOffset(d->offset - d->speed);
- d->offset = scrollOffset();
- if (d->speed == QPoint(0, 0)) {
- d->state = FlickablePrivate::Steady;
- d->ticker->stop();
- }
- } else {
- d->ticker->stop();
- }
-}
diff --git a/examples/embedded/flickable/flickable.h b/examples/embedded/flickable/flickable.h
deleted file mode 100644
index 276510a849..0000000000
--- a/examples/embedded/flickable/flickable.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef FLICKABLE_H
-#define FLICKABLE_H
-
-#include <QWidget>
-
-class FlickableTicker;
-class FlickablePrivate;
-
-class Flickable
-{
-public:
-
- Flickable();
- virtual ~Flickable();
-
- void setThreshold(int threshold);
- int threshold() const;
-
- void setAcceptMouseClick(QWidget *target);
-
- void handleMousePress(QMouseEvent *event);
- void handleMouseMove(QMouseEvent *event);
- void handleMouseRelease(QMouseEvent *event);
-
-protected:
- virtual QPoint scrollOffset() const = 0;
- virtual void setScrollOffset(const QPoint &offset) = 0;
-
-private:
- void tick();
-
-private:
- FlickablePrivate *d;
- friend class FlickableTicker;
-};
-
-#endif // FLICKABLE_H
diff --git a/examples/embedded/flickable/flickable.pro b/examples/embedded/flickable/flickable.pro
deleted file mode 100644
index 5929207414..0000000000
--- a/examples/embedded/flickable/flickable.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-QT += widgets
-
-SOURCES = flickable.cpp main.cpp
-HEADERS = flickable.h
-
-target.path = $$[QT_INSTALL_EXAMPLES]/embedded/flickable
-INSTALLS += target
diff --git a/examples/embedded/flickable/main.cpp b/examples/embedded/flickable/main.cpp
deleted file mode 100644
index fd30d15e49..0000000000
--- a/examples/embedded/flickable/main.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore>
-#include <QtWidgets>
-
-#include "flickable.h"
-
-// Returns a list of two-word color names
-static QStringList colorPairs(int max)
-{
- // capitalize the first letter
- QStringList colors = QColor::colorNames();
- colors.removeAll("transparent");
- int num = colors.count();
- for (int c = 0; c < num; ++c)
- colors[c] = colors[c][0].toUpper() + colors[c].mid(1);
-
- // combine two colors, e.g. "lime skyblue"
- QStringList combinedColors;
- for (int i = 0; i < num; ++i)
- for (int j = 0; j < num; ++j)
- combinedColors << QString("%1 %2").arg(colors[i]).arg(colors[j]);
-
- // randomize it
- colors.clear();
- while (combinedColors.count()) {
- int i = QRandomGenerator::global()->bounded(int(combinedColors.count()));
- colors << combinedColors[i];
- combinedColors.removeAt(i);
- if (colors.count() == max)
- break;
- }
-
- return colors;
-}
-
-class ColorList : public QWidget, public Flickable
-{
- Q_OBJECT
-
-public:
- ColorList(QWidget *parent = nullptr)
- : QWidget(parent) {
- m_offset = 0;
- m_height = QFontMetrics(font()).height() + 5;
- m_highlight = -1;
- m_selected = -1;
-
- QStringList colors = colorPairs(999);
- for (int i = 0; i < colors.count(); ++i) {
- const QString c = colors[i];
- const QString str = QString::asprintf("%4d", i + 1);
- m_colorNames << (str + " " + c);
-
- QStringList duet = c.split(' ');
- m_firstColor << duet[0];
- m_secondColor << duet[1];
- }
-
- setAttribute(Qt::WA_OpaquePaintEvent, true);
- setAttribute(Qt::WA_NoSystemBackground, true);
-
- setMouseTracking(true);
- Flickable::setAcceptMouseClick(this);
- }
-
-protected:
- // reimplement from Flickable
- virtual QPoint scrollOffset() const {
- return QPoint(0, m_offset);
- }
-
- // reimplement from Flickable
- virtual void setScrollOffset(const QPoint &offset) {
- int yy = offset.y();
- if (yy != m_offset) {
- m_offset = qBound(0, yy, m_height * m_colorNames.count() - height());
- update();
- }
- }
-
-protected:
- void paintEvent(QPaintEvent *event) {
- QPainter p(this);
- p.fillRect(event->rect(), Qt::white);
- int start = m_offset / m_height;
- int y = start * m_height - m_offset;
- if (m_offset <= 0) {
- start = 0;
- y = -m_offset;
- }
- int end = start + height() / m_height + 1;
- if (end > m_colorNames.count() - 1)
- end = m_colorNames.count() - 1;
- for (int i = start; i <= end; ++i, y += m_height) {
-
- p.setBrush(Qt::NoBrush);
- p.setPen(Qt::black);
- if (i == m_highlight) {
- p.fillRect(0, y, width(), m_height, QColor(0, 64, 128));
- p.setPen(Qt::white);
- }
- if (i == m_selected) {
- p.fillRect(0, y, width(), m_height, QColor(0, 128, 240));
- p.setPen(Qt::white);
- }
-
- p.drawText(m_height + 2, y, width(), m_height, Qt::AlignVCenter, m_colorNames[i]);
-
- p.setPen(Qt::NoPen);
- p.setBrush(m_firstColor[i]);
- p.drawRect(1, y + 1, m_height - 2, m_height - 2);
- p.setBrush(m_secondColor[i]);
- p.drawRect(5, y + 5, m_height - 11, m_height - 11);
- }
- p.end();
- }
-
- void keyReleaseEvent(QKeyEvent *event) {
- if (event->key() == Qt::Key_Down) {
- m_offset += 20;
- event->accept();
- update();
- return;
- }
- if (event->key() == Qt::Key_Up) {
- m_offset -= 20;
- event->accept();
- update();
- return;
- }
- }
-
- void mousePressEvent(QMouseEvent *event) {
- Flickable::handleMousePress(event);
- if (event->isAccepted())
- return;
-
- if (event->button() == Qt::LeftButton) {
- int y = event->position().toPoint().y() + m_offset;
- int i = y / m_height;
- if (i != m_highlight) {
- m_highlight = i;
- m_selected = -1;
- update();
- }
- event->accept();
- }
- }
-
- void mouseMoveEvent(QMouseEvent *event) {
- Flickable::handleMouseMove(event);
- }
-
- void mouseReleaseEvent(QMouseEvent *event) {
- Flickable::handleMouseRelease(event);
- if (event->isAccepted())
- return;
-
- if (event->button() == Qt::LeftButton) {
- m_selected = m_highlight;
- event->accept();
- update();
- }
- }
-
-private:
- int m_offset;
- int m_height;
- int m_highlight;
- int m_selected;
- QStringList m_colorNames;
- QList<QColor> m_firstColor;
- QList<QColor> m_secondColor;
-};
-
-#include "main.moc"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- ColorList list;
- list.setWindowTitle("Kinetic Scrolling");
- list.resize(320, 320);
- list.show();
-
- return app.exec();
-}
diff --git a/examples/embedded/flightinfo/.prev_CMakeLists.txt b/examples/embedded/flightinfo/.prev_CMakeLists.txt
deleted file mode 100644
index f7898e8ed8..0000000000
--- a/examples/embedded/flightinfo/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-# Generated from flightinfo.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(flightinfo LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-set(INSTALL_EXAMPLEDIR "examples/embedded/flightinfo")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(flightinfo
- flightinfo.cpp
- form.ui
-)
-target_link_libraries(flightinfo PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
-)
-
-
-# Resources:
-set(flightinfo_resource_files
- "aircraft.png"
-)
-
-qt6_add_resources(flightinfo "flightinfo"
- PREFIX
- "/"
- FILES
- ${flightinfo_resource_files}
-)
-
-install(TARGETS flightinfo
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/embedded/flightinfo/CMakeLists.txt b/examples/embedded/flightinfo/CMakeLists.txt
deleted file mode 100644
index 2021f5099f..0000000000
--- a/examples/embedded/flightinfo/CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-# Generated from flightinfo.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(flightinfo LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/embedded/flightinfo")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(flightinfo
- flightinfo.cpp
- form.ui
-)
-set_target_properties(flightinfo PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(flightinfo PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
-)
-
-
-# Resources:
-set(flightinfo_resource_files
- "aircraft.png"
-)
-
-qt6_add_resources(flightinfo "flightinfo"
- PREFIX
- "/"
- FILES
- ${flightinfo_resource_files}
-)
-
-install(TARGETS flightinfo
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/embedded/flightinfo/aircraft.png b/examples/embedded/flightinfo/aircraft.png
deleted file mode 100644
index 2312bcc9f0..0000000000
--- a/examples/embedded/flightinfo/aircraft.png
+++ /dev/null
Binary files differ
diff --git a/examples/embedded/flightinfo/flightinfo.cpp b/examples/embedded/flightinfo/flightinfo.cpp
deleted file mode 100644
index 32f0cd4401..0000000000
--- a/examples/embedded/flightinfo/flightinfo.cpp
+++ /dev/null
@@ -1,401 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore>
-#include <QtWidgets>
-#include <QtNetwork>
-
-#include "ui_form.h"
-
-#define FLIGHTVIEW_URL "http://mobile.flightview.com/TrackByFlight.aspx"
-#define FLIGHTVIEW_RANDOM "http://mobile.flightview.com/TrackSampleFlight.aspx"
-
-// strips all invalid constructs that might trip QXmlStreamReader
-static QString sanitized(const QString &xml)
-{
- QString data = xml;
-
- // anything up to the html tag
- int i = data.indexOf("<html");
- if (i > 0)
- data.remove(0, i - 1);
-
- // everything inside the head tag
- i = data.indexOf("<head");
- if (i > 0)
- data.remove(i, data.indexOf("</head>") - i + 7);
-
- // invalid link for JavaScript code
- while (true) {
- i = data.indexOf("onclick=\"gotoUrl(");
- if (i < 0)
- break;
- data.remove(i, data.indexOf('\"', i + 9) - i + 1);
- }
-
- // all inline frames
- while (true) {
- i = data.indexOf("<iframe");
- if (i < 0)
- break;
- data.remove(i, data.indexOf("</iframe>") - i + 8);
- }
-
- // entities
- data.remove("&nbsp;");
- data.remove("&copy;");
-
- return data;
-}
-
-class FlightInfo : public QMainWindow
-{
- Q_OBJECT
-
-private:
-
- Ui_Form ui;
- QUrl m_url;
- QDate m_searchDate;
- QPixmap m_map;
- QNetworkAccessManager m_manager;
- QList<QNetworkReply *> mapReplies;
-
-public:
-
- FlightInfo(QMainWindow *parent = nullptr): QMainWindow(parent) {
-
- QWidget *w = new QWidget(this);
- ui.setupUi(w);
- setCentralWidget(w);
-
- ui.searchBar->hide();
- ui.infoBox->hide();
- connect(ui.searchButton, SIGNAL(clicked()), SLOT(startSearch()));
- connect(ui.flightEdit, SIGNAL(returnPressed()), SLOT(startSearch()));
-
- setWindowTitle("Flight Info");
-
- // Rendered from the public-domain vectorized aircraft
- // http://openclipart.org/media/people/Jarno
- m_map = QPixmap(":/aircraft.png");
-
- QAction *searchTodayAction = new QAction("Today's Flight", this);
- QAction *searchYesterdayAction = new QAction("Yesterday's Flight", this);
- QAction *randomAction = new QAction("Random Flight", this);
- connect(searchTodayAction, SIGNAL(triggered()), SLOT(today()));
- connect(searchYesterdayAction, SIGNAL(triggered()), SLOT(yesterday()));
- connect(randomAction, SIGNAL(triggered()), SLOT(randomFlight()));
- connect(&m_manager, SIGNAL(finished(QNetworkReply*)),
- this, SLOT(handleNetworkData(QNetworkReply*)));
- addAction(searchTodayAction);
- addAction(searchYesterdayAction);
- addAction(randomAction);
- setContextMenuPolicy(Qt::ActionsContextMenu);
- }
-
-private slots:
-
- void handleNetworkData(QNetworkReply *networkReply) {
- if (!networkReply->error()) {
- if (!mapReplies.contains(networkReply)) {
- // Assume UTF-8 encoded
- QByteArray data = networkReply->readAll();
- QString xml = QString::fromUtf8(data);
- digest(xml);
- } else {
- mapReplies.removeOne(networkReply);
- m_map.loadFromData(networkReply->readAll());
- update();
- }
- }
- networkReply->deleteLater();
- }
-
- void today() {
- QDateTime timestamp = QDateTime::currentDateTime();
- m_searchDate = timestamp.date();
- searchFlight();
- }
-
- void yesterday() {
- QDateTime timestamp = QDateTime::currentDateTime();
- timestamp = timestamp.addDays(-1);
- m_searchDate = timestamp.date();
- searchFlight();
- }
-
- void searchFlight() {
- ui.searchBar->show();
- ui.infoBox->hide();
- ui.flightStatus->hide();
- ui.flightName->setText("Enter flight number");
- ui.flightEdit->setFocus();
-#ifdef QT_KEYPAD_NAVIGATION
- ui.flightEdit->setEditFocus(true);
-#endif
- m_map = QPixmap();
- update();
- }
-
- void startSearch() {
- ui.searchBar->hide();
- QString flight = ui.flightEdit->text().simplified();
- if (!flight.isEmpty())
- request(flight, m_searchDate);
- }
-
- void randomFlight() {
- request(QString(), QDate::currentDate());
- }
-
-public slots:
-
- void request(const QString &flightCode, QDate date) {
-
- setWindowTitle("Loading...");
-
- QString code = flightCode.simplified();
- QString airlineCode = code.left(2).toUpper();
- QString flightNumber = code.mid(2, code.length());
-
- ui.flightName->setText("Searching for " + code);
-
- QUrlQuery query;
- query.addQueryItem("view", "detail");
- query.addQueryItem("al", airlineCode);
- query.addQueryItem("fn", flightNumber);
- query.addQueryItem("dpdat", date.toString("yyyyMMdd"));
- m_url = QUrl(FLIGHTVIEW_URL);
- m_url.setQuery(query);
-
- if (code.isEmpty()) {
- // random flight as sample
- m_url = QUrl(FLIGHTVIEW_RANDOM);
- ui.flightName->setText("Getting a random flight...");
- }
-
- m_manager.get(QNetworkRequest(m_url));
- }
-
-
-private:
-
- void digest(const QString &content) {
-
- setWindowTitle("Flight Info");
- QString data = sanitized(content);
-
- // do we only get the flight list?
- // we grab the first leg in the flight list
- // then fetch another URL for the real flight info
- int i = data.indexOf("a href=\"?view=detail");
- if (i > 0) {
- QString href = data.mid(i, data.indexOf('\"', i + 8) - i + 1);
- QRegularExpression regex("dpap=([A-Za-z0-9]+)");
- QRegularExpressionMatch match = regex.match(href);
- QString airport = match.captured(1);
- QUrlQuery query(m_url);
- query.addQueryItem("dpap", airport);
- m_url.setQuery(query);
- m_manager.get(QNetworkRequest(m_url));
- return;
- }
-
- QXmlStreamReader xml(data);
- bool inFlightName = false;
- bool inFlightStatus = false;
- bool inFlightMap = false;
- bool inFieldName = false;
- bool inFieldValue = false;
-
- QString flightName;
- QString flightStatus;
- QStringList fieldNames;
- QStringList fieldValues;
-
- while (!xml.atEnd()) {
- xml.readNext();
-
- if (xml.tokenType() == QXmlStreamReader::StartElement) {
- auto className = xml.attributes().value("class");
- inFlightName |= xml.name() == u"h1";
- inFlightStatus |= className == u"FlightDetailHeaderStatus";
- inFlightMap |= className == u"flightMap";
- if (xml.name() == u"td" && !className.isEmpty()) {
- if (className.contains(u"fieldTitle")) {
- inFieldName = true;
- fieldNames += QString();
- fieldValues += QString();
- }
- if (className.contains(u"fieldValue"))
- inFieldValue = true;
- }
- if (xml.name() == u"img" && inFlightMap) {
- const QByteArray encoded
- = ("http://mobile.flightview.com/" % xml.attributes().value("src")).toLatin1();
- QUrl url = QUrl::fromPercentEncoding(encoded);
- mapReplies.append(m_manager.get(QNetworkRequest(url)));
- }
- }
-
- if (xml.tokenType() == QXmlStreamReader::EndElement) {
- inFlightName &= xml.name() != u"h1";
- inFlightStatus &= xml.name() != u"div";
- inFlightMap &= xml.name() != u"div";
- inFieldName &= xml.name() != u"td";
- inFieldValue &= xml.name() != u"td";
- }
-
- if (xml.tokenType() == QXmlStreamReader::Characters) {
- if (inFlightName)
- flightName += xml.text();
- if (inFlightStatus)
- flightStatus += xml.text();
- if (inFieldName)
- fieldNames.last() += xml.text();
- if (inFieldValue)
- fieldValues.last() += xml.text();
- }
- }
-
- if (fieldNames.isEmpty()) {
- QString code = ui.flightEdit->text().simplified().left(10);
- QString msg = QString("Flight %1 is not found").arg(code);
- ui.flightName->setText(msg);
- return;
- }
-
- ui.flightName->setText(flightName);
- flightStatus.remove("Status: ");
- ui.flightStatus->setText(flightStatus);
- ui.flightStatus->show();
-
- QStringList whiteList;
- whiteList << "Departure";
- whiteList << "Arrival";
- whiteList << "Scheduled";
- whiteList << "Takeoff";
- whiteList << "Estimated";
- whiteList << "Term-Gate";
-
- QString text;
- text = QString("<table width=%1>").arg(width() - 25);
- for (int i = 0; i < fieldNames.count(); i++) {
- QString fn = fieldNames[i].simplified();
- if (fn.endsWith(':'))
- fn = fn.left(fn.length() - 1);
- if (!whiteList.contains(fn))
- continue;
-
- QString fv = fieldValues[i].simplified();
- bool special = false;
- special |= fn.startsWith("Departure");
- special |= fn.startsWith("Arrival");
- text += "<tr>";
- if (special) {
- text += "<td align=center colspan=2>";
- text += "<b><font size=+1>" + fv + "</font></b>";
- text += "</td>";
- } else {
- text += "<td align=right>";
- text += fn;
- text += " : ";
- text += "&nbsp;";
- text += "</td>";
- text += "<td>";
- text += fv;
- text += "</td>";
- }
- text += "</tr>";
- }
- text += "</table>";
- ui.detailedInfo->setText(text);
- ui.infoBox->show();
- }
-
- void resizeEvent(QResizeEvent *event) {
- Q_UNUSED(event);
- ui.detailedInfo->setMaximumWidth(width() - 25);
- }
-
- void paintEvent(QPaintEvent *event) {
- QMainWindow::paintEvent(event);
- QPainter p(this);
- p.fillRect(rect(), QColor(131, 171, 210));
- if (!m_map.isNull()) {
- int x = (width() - m_map.width()) / 2;
- int space = ui.infoBox->pos().y();
- if (!ui.infoBox->isVisible())
- space = height();
- int top = ui.titleBox->height();
- int y = qMax(top, (space - m_map.height()) / 2);
- p.drawPixmap(x, y, m_map);
- }
- p.end();
- }
-
-};
-
-
-#include "flightinfo.moc"
-
-int main(int argc, char **argv)
-{
- Q_INIT_RESOURCE(flightinfo);
-
- QApplication app(argc, argv);
-
- FlightInfo w;
- w.resize(360, 504);
- w.show();
-
- return app.exec();
-}
diff --git a/examples/embedded/flightinfo/flightinfo.pro b/examples/embedded/flightinfo/flightinfo.pro
deleted file mode 100644
index 4e62b24576..0000000000
--- a/examples/embedded/flightinfo/flightinfo.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-TEMPLATE = app
-TARGET = flightinfo
-SOURCES = flightinfo.cpp
-FORMS += form.ui
-RESOURCES = flightinfo.qrc
-QT += network widgets
-
-target.path = $$[QT_INSTALL_EXAMPLES]/embedded/flightinfo
-INSTALLS += target
diff --git a/examples/embedded/flightinfo/flightinfo.qrc b/examples/embedded/flightinfo/flightinfo.qrc
deleted file mode 100644
index babea7e0cb..0000000000
--- a/examples/embedded/flightinfo/flightinfo.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/" >
- <file>aircraft.png</file>
- </qresource>
-</RCC>
diff --git a/examples/embedded/flightinfo/form.ui b/examples/embedded/flightinfo/form.ui
deleted file mode 100644
index 3a24c758a6..0000000000
--- a/examples/embedded/flightinfo/form.ui
+++ /dev/null
@@ -1,226 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Form</class>
- <widget class="QWidget" name="Form">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>220</width>
- <height>171</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <property name="spacing">
- <number>0</number>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <item>
- <widget class="QFrame" name="titleBox">
- <property name="styleSheet">
- <string>QFrame {
-background-color: #45629a;
-}
-
-QLabel {
-color: white;
-}</string>
- </property>
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- <property name="lineWidth">
- <number>0</number>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <property name="spacing">
- <number>0</number>
- </property>
- <property name="margin">
- <number>4</number>
- </property>
- <item>
- <widget class="QLabel" name="flightName">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Powered by FlightView</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="flightStatus">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="font">
- <font>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
- <property name="styleSheet">
- <string>background-color: white;
-color: #45629a;</string>
- </property>
- <property name="lineWidth">
- <number>0</number>
- </property>
- <property name="text">
- <string>Ready</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- <property name="margin">
- <number>4</number>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QFrame" name="searchBar">
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <property name="margin">
- <number>5</number>
- </property>
- <item>
- <widget class="QLineEdit" name="flightEdit">
- <property name="styleSheet">
- <string>color: black;
-border: 1px solid black;
-background: white;
-selection-background-color: lightgray;</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="searchButton">
- <property name="styleSheet">
- <string>color: rgb(255, 255, 255);
-background-color: rgb(85, 85, 255);
-padding: 2px;
-border: 2px solid rgb(0, 0, 127);</string>
- </property>
- <property name="text">
- <string>Search</string>
- </property>
- <property name="toolButtonStyle">
- <enum>Qt::ToolButtonTextBesideIcon</enum>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <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>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>58</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QFrame" name="infoBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="styleSheet">
- <string>QFrame { border: 2px solid white;
-border-radius: 10px;
-margin: 5px;
-background-color: rgba(69, 98, 154, 192); }</string>
- </property>
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <property name="spacing">
- <number>0</number>
- </property>
- <property name="margin">
- <number>5</number>
- </property>
- <item>
- <widget class="QLabel" name="detailedInfo">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="styleSheet">
- <string>color: white;
-border: none;
-background-color: none;</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="textFormat">
- <enum>Qt::RichText</enum>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- <property name="textInteractionFlags">
- <set>Qt::NoTextInteraction</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/embedded/lightmaps/CMakeLists.txt b/examples/embedded/lightmaps/CMakeLists.txt
deleted file mode 100644
index a4546b8a39..0000000000
--- a/examples/embedded/lightmaps/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-# Generated from lightmaps.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(lightmaps LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/embedded/lightmaps")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(lightmaps
- lightmaps.cpp lightmaps.h
- main.cpp
- mapzoom.cpp mapzoom.h
- slippymap.cpp slippymap.h
-)
-set_target_properties(lightmaps PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(lightmaps PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
-)
-
-install(TARGETS lightmaps
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/embedded/lightmaps/lightmaps.cpp b/examples/embedded/lightmaps/lightmaps.cpp
deleted file mode 100644
index 8ad3035016..0000000000
--- a/examples/embedded/lightmaps/lightmaps.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore>
-#include <QtWidgets>
-#include <QtNetwork>
-
-#include "lightmaps.h"
-#include "slippymap.h"
-
-// how long (milliseconds) the user need to hold (after a tap on the screen)
-// before triggering the magnifying glass feature
-// 701, a prime number, is the sum of 229, 233, 239
-// (all three are also prime numbers, consecutive!)
-#define HOLD_TIME 701
-
-// maximum size of the magnifier
-// Hint: see above to find why I picked this one :)
-#define MAX_MAGNIFIER 229
-
-LightMaps::LightMaps(QWidget *parent)
- : QWidget(parent), pressed(false), snapped(false), zoomed(false),
- invert(false)
-{
- m_normalMap = new SlippyMap(this);
- m_largeMap = new SlippyMap(this);
- connect(m_normalMap, SIGNAL(updated(QRect)), SLOT(updateMap(QRect)));
- connect(m_largeMap, SIGNAL(updated(QRect)), SLOT(update()));
-}
-
-void LightMaps::setCenter(qreal lat, qreal lng)
-{
- m_normalMap->latitude = lat;
- m_normalMap->longitude = lng;
- m_normalMap->invalidate();
- m_largeMap->latitude = lat;
- m_largeMap->longitude = lng;
- m_largeMap->invalidate();
-}
-
-void LightMaps::toggleNightMode()
-{
- invert = !invert;
- update();
-}
-
-void LightMaps::updateMap(const QRect &r)
-{
- update(r);
-}
-
-void LightMaps::activateZoom()
-{
- zoomed = true;
- tapTimer.stop();
- m_largeMap->zoom = m_normalMap->zoom + 1;
- m_largeMap->width = m_normalMap->width * 2;
- m_largeMap->height = m_normalMap->height * 2;
- m_largeMap->latitude = m_normalMap->latitude;
- m_largeMap->longitude = m_normalMap->longitude;
- m_largeMap->invalidate();
- update();
-}
-
-void LightMaps::resizeEvent(QResizeEvent *)
-{
- m_normalMap->width = width();
- m_normalMap->height = height();
- m_normalMap->invalidate();
- m_largeMap->width = m_normalMap->width * 2;
- m_largeMap->height = m_normalMap->height * 2;
- m_largeMap->invalidate();
-}
-
-void LightMaps::paintEvent(QPaintEvent *event)
-{
- QPainter p;
- p.begin(this);
- m_normalMap->render(&p, event->rect());
- p.setPen(Qt::black);
- p.drawText(rect(), Qt::AlignBottom | Qt::TextWordWrap,
- "Map data CCBYSA 2009 OpenStreetMap.org contributors");
- p.end();
-
- if (zoomed) {
- int dim = qMin(width(), height());
- int magnifierSize = qMin(MAX_MAGNIFIER, dim * 2 / 3);
- int radius = magnifierSize / 2;
- int ring = radius - 15;
- QSize box = QSize(magnifierSize, magnifierSize);
-
- // reupdate our mask
- if (maskPixmap.size() != box) {
- maskPixmap = QPixmap(box);
- maskPixmap.fill(Qt::transparent);
-
- QRadialGradient g;
- g.setCenter(radius, radius);
- g.setFocalPoint(radius, radius);
- g.setRadius(radius);
- g.setColorAt(1.0, QColor(255, 255, 255, 0));
- g.setColorAt(0.5, QColor(128, 128, 128, 255));
-
- QPainter mask(&maskPixmap);
- mask.setRenderHint(QPainter::Antialiasing);
- mask.setCompositionMode(QPainter::CompositionMode_Source);
- mask.setBrush(g);
- mask.setPen(Qt::NoPen);
- mask.drawRect(maskPixmap.rect());
- mask.setBrush(QColor(Qt::transparent));
- mask.drawEllipse(g.center(), ring, ring);
- mask.end();
- }
-
- QPoint center = dragPos - QPoint(0, radius);
- center = center + QPoint(0, radius / 2);
- QPoint corner = center - QPoint(radius, radius);
-
- QPoint xy = center * 2 - QPoint(radius, radius);
-
- // only set the dimension to the magnified portion
- if (zoomPixmap.size() != box) {
- zoomPixmap = QPixmap(box);
- zoomPixmap.fill(Qt::lightGray);
- }
- if (true) {
- QPainter p(&zoomPixmap);
- p.translate(-xy);
- m_largeMap->render(&p, QRect(xy, box));
- p.end();
- }
-
- QPainterPath clipPath;
- clipPath.addEllipse(center, ring, ring);
-
- QPainter p(this);
- p.setRenderHint(QPainter::Antialiasing);
- p.setClipPath(clipPath);
- p.drawPixmap(corner, zoomPixmap);
- p.setClipping(false);
- p.drawPixmap(corner, maskPixmap);
- p.setPen(Qt::gray);
- p.drawPath(clipPath);
- }
- if (invert) {
- QPainter p(this);
- p.setCompositionMode(QPainter::CompositionMode_Difference);
- p.fillRect(event->rect(), Qt::white);
- p.end();
- }
-}
-
-void LightMaps::timerEvent(QTimerEvent *)
-{
- if (!zoomed)
- activateZoom();
- update();
-}
-
-void LightMaps::mousePressEvent(QMouseEvent *event)
-{
- if (event->buttons() != Qt::LeftButton)
- return;
- pressed = snapped = true;
- pressPos = dragPos = event->position().toPoint();
- tapTimer.stop();
- tapTimer.start(HOLD_TIME, this);
-}
-
-void LightMaps::mouseMoveEvent(QMouseEvent *event)
-{
- if (!event->buttons())
- return;
- if (!zoomed) {
- if (!pressed || !snapped) {
- QPoint delta = event->position().toPoint() - pressPos;
- pressPos = event->position().toPoint();
- m_normalMap->pan(delta);
- return;
- } else {
- const int threshold = 10;
- QPoint delta = event->position().toPoint() - pressPos;
- if (snapped) {
- snapped &= delta.x() < threshold;
- snapped &= delta.y() < threshold;
- snapped &= delta.x() > -threshold;
- snapped &= delta.y() > -threshold;
- }
- if (!snapped)
- tapTimer.stop();
- }
- } else {
- dragPos = event->position().toPoint();
- update();
- }
-}
-
-void LightMaps::mouseReleaseEvent(QMouseEvent *)
-{
- zoomed = false;
- update();
-}
-
-void LightMaps::keyPressEvent(QKeyEvent *event)
-{
- if (!zoomed) {
- if (event->key() == Qt::Key_Left)
- m_normalMap->pan(QPoint(20, 0));
- if (event->key() == Qt::Key_Right)
- m_normalMap->pan(QPoint(-20, 0));
- if (event->key() == Qt::Key_Up)
- m_normalMap->pan(QPoint(0, 20));
- if (event->key() == Qt::Key_Down)
- m_normalMap->pan(QPoint(0, -20));
- if (event->key() == Qt::Key_Z || event->key() == Qt::Key_Select) {
- dragPos = QPoint(width() / 2, height() / 2);
- activateZoom();
- }
- } else {
- if (event->key() == Qt::Key_Z || event->key() == Qt::Key_Select) {
- zoomed = false;
- update();
- }
- QPoint delta(0, 0);
- if (event->key() == Qt::Key_Left)
- delta = QPoint(-15, 0);
- if (event->key() == Qt::Key_Right)
- delta = QPoint(15, 0);
- if (event->key() == Qt::Key_Up)
- delta = QPoint(0, -15);
- if (event->key() == Qt::Key_Down)
- delta = QPoint(0, 15);
- if (delta != QPoint(0, 0)) {
- dragPos += delta;
- update();
- }
- }
-}
diff --git a/examples/embedded/lightmaps/lightmaps.h b/examples/embedded/lightmaps/lightmaps.h
deleted file mode 100644
index 25b5785edf..0000000000
--- a/examples/embedded/lightmaps/lightmaps.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef LIGHTMAPS_H
-#define LIGHTMAPS_H
-
-#include <QBasicTimer>
-#include <QWidget>
-
-class SlippyMap;
-
-class LightMaps: public QWidget
-{
- Q_OBJECT
-
-public:
- LightMaps(QWidget *parent = nullptr);
- void setCenter(qreal lat, qreal lng);
-
-public slots:
- void toggleNightMode();
-
-protected:
- void activateZoom();
- void resizeEvent(QResizeEvent *);
- void paintEvent(QPaintEvent *event);
- void timerEvent(QTimerEvent *);
- void mousePressEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *);
- void keyPressEvent(QKeyEvent *event);
-
-private slots:
- void updateMap(const QRect &r);
-
-private:
- SlippyMap *m_normalMap;
- SlippyMap *m_largeMap;
- bool pressed;
- bool snapped;
- QPoint pressPos;
- QPoint dragPos;
- QBasicTimer tapTimer;
- bool zoomed;
- QPixmap zoomPixmap;
- QPixmap maskPixmap;
- bool invert;
-};
-
-#endif
diff --git a/examples/embedded/lightmaps/lightmaps.pro b/examples/embedded/lightmaps/lightmaps.pro
deleted file mode 100644
index bb75cf0a9c..0000000000
--- a/examples/embedded/lightmaps/lightmaps.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-TEMPLATE = app
-HEADERS = lightmaps.h \
- mapzoom.h \
- slippymap.h
-SOURCES = lightmaps.cpp \
- main.cpp \
- mapzoom.cpp \
- slippymap.cpp
-QT += network widgets
-
-target.path = $$[QT_INSTALL_EXAMPLES]/embedded/lightmaps
-INSTALLS += target
diff --git a/examples/embedded/lightmaps/main.cpp b/examples/embedded/lightmaps/main.cpp
deleted file mode 100644
index 663e6a5b5d..0000000000
--- a/examples/embedded/lightmaps/main.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include "mapzoom.h"
-
-int main(int argc, char **argv)
-{
-
- QApplication app(argc, argv);
- app.setApplicationName("LightMaps");
-
- MapZoom w;
- w.resize(600, 450);
- w.show();
-
- return app.exec();
-}
diff --git a/examples/embedded/lightmaps/mapzoom.cpp b/examples/embedded/lightmaps/mapzoom.cpp
deleted file mode 100644
index 781d4f27e3..0000000000
--- a/examples/embedded/lightmaps/mapzoom.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-#include <QtNetwork>
-#include "lightmaps.h"
-#include "mapzoom.h"
-
-MapZoom::MapZoom()
- : QMainWindow(0)
-{
- map = new LightMaps(this);
- setCentralWidget(map);
- map->setFocus();
-
- QAction *osloAction = new QAction(tr("&Oslo"), this);
- QAction *berlinAction = new QAction(tr("&Berlin"), this);
- QAction *jakartaAction = new QAction(tr("&Jakarta"), this);
- QAction *nightModeAction = new QAction(tr("Night Mode"), this);
- nightModeAction->setCheckable(true);
- nightModeAction->setChecked(false);
- QAction *osmAction = new QAction(tr("About OpenStreetMap"), this);
- connect(osloAction, SIGNAL(triggered()), SLOT(chooseOslo()));
- connect(berlinAction, SIGNAL(triggered()), SLOT(chooseBerlin()));
- connect(jakartaAction, SIGNAL(triggered()), SLOT(chooseJakarta()));
- connect(nightModeAction, SIGNAL(triggered()), map, SLOT(toggleNightMode()));
- connect(osmAction, SIGNAL(triggered()), SLOT(aboutOsm()));
-
- QMenu *menu = menuBar()->addMenu(tr("&Options"));
- menu->addAction(osloAction);
- menu->addAction(berlinAction);
- menu->addAction(jakartaAction);
- menu->addSeparator();
- menu->addAction(nightModeAction);
- menu->addAction(osmAction);
-
- setWindowTitle(tr("Light Maps"));
-}
-
-void MapZoom::chooseOslo()
-{
- map->setCenter(59.9138204, 10.7387413);
-}
-
-void MapZoom::chooseBerlin()
-{
- map->setCenter(52.52958999943302, 13.383053541183472);
-}
-
-void MapZoom::chooseJakarta()
-{
- map->setCenter(-6.211544, 106.845172);
-}
-
-void MapZoom::aboutOsm()
-{
- QDesktopServices::openUrl(QUrl("http://www.openstreetmap.org"));
-}
diff --git a/examples/embedded/lightmaps/mapzoom.h b/examples/embedded/lightmaps/mapzoom.h
deleted file mode 100644
index 3844eca718..0000000000
--- a/examples/embedded/lightmaps/mapzoom.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAPZOOM_H
-#define MAPZOOM_H
-
-#include <QMainWindow>
-
-class LightMaps;
-
-class MapZoom : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MapZoom();
-
-private slots:
- void chooseOslo();
- void chooseBerlin();
- void chooseJakarta();
- void aboutOsm();
-
-private:
- LightMaps *map;
-};
-
-#endif \ No newline at end of file
diff --git a/examples/embedded/lightmaps/slippymap.cpp b/examples/embedded/lightmaps/slippymap.cpp
deleted file mode 100644
index bd97aef7ee..0000000000
--- a/examples/embedded/lightmaps/slippymap.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-#include <QtNetwork>
-#include "slippymap.h"
-#include "qmath.h"
-
-// tile size in pixels
-const int tdim = 256;
-
-QPointF tileForCoordinate(qreal lat, qreal lng, int zoom)
-{
- qreal radianLat = qDegreesToRadians(lat);
- qreal zn = static_cast<qreal>(1 << zoom);
- qreal tx = (lng + 180.0) / 360.0;
- qreal ty = 0.5 - log(tan(radianLat) + 1.0 / cos(radianLat)) / M_PI / 2.0;
- return QPointF(tx * zn, ty * zn);
-}
-
-qreal longitudeFromTile(qreal tx, int zoom)
-{
- qreal zn = static_cast<qreal>(1 << zoom);
- qreal lat = tx / zn * 360.0 - 180.0;
- return lat;
-}
-
-qreal latitudeFromTile(qreal ty, int zoom)
-{
- qreal zn = static_cast<qreal>(1 << zoom);
- qreal n = M_PI - 2 * M_PI * ty / zn;
- return qRadiansToDegrees(atan(sinh(n)));
-}
-
-
-SlippyMap::SlippyMap(QObject *parent)
- : QObject(parent), width(400), height(300), zoom(15),
- latitude(59.9138204), longitude(10.7387413)
-{
- m_emptyTile = QPixmap(tdim, tdim);
- m_emptyTile.fill(Qt::lightGray);
-
- QNetworkDiskCache *cache = new QNetworkDiskCache;
- cache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
- m_manager.setCache(cache);
- connect(&m_manager, SIGNAL(finished(QNetworkReply*)),
- this, SLOT(handleNetworkData(QNetworkReply*)));
-}
-
-void SlippyMap::invalidate()
-{
- if (width <= 0 || height <= 0)
- return;
-
- QPointF ct = tileForCoordinate(latitude, longitude, zoom);
- qreal tx = ct.x();
- qreal ty = ct.y();
-
- // top-left corner of the center tile
- int xp = width / 2 - (tx - floor(tx)) * tdim;
- int yp = height / 2 - (ty - floor(ty)) * tdim;
-
- // first tile vertical and horizontal
- int xa = (xp + tdim - 1) / tdim;
- int ya = (yp + tdim - 1) / tdim;
- int xs = static_cast<int>(tx) - xa;
- int ys = static_cast<int>(ty) - ya;
-
- // offset for top-left tile
- m_offset = QPoint(xp - xa * tdim, yp - ya * tdim);
-
- // last tile vertical and horizontal
- int xe = static_cast<int>(tx) + (width - xp - 1) / tdim;
- int ye = static_cast<int>(ty) + (height - yp - 1) / tdim;
-
- // build a rect
- m_tilesRect = QRect(xs, ys, xe - xs + 1, ye - ys + 1);
-
- if (m_url.isEmpty())
- download();
-
- emit updated(QRect(0, 0, width, height));
-}
-
-void SlippyMap::render(QPainter *p, const QRect &rect)
-{
- for (int x = 0; x <= m_tilesRect.width(); ++x)
- for (int y = 0; y <= m_tilesRect.height(); ++y) {
- QPoint tp(x + m_tilesRect.left(), y + m_tilesRect.top());
- QRect box = tileRect(tp);
- if (rect.intersects(box)) {
- if (m_tilePixmaps.contains(tp))
- p->drawPixmap(box, m_tilePixmaps.value(tp));
- else
- p->drawPixmap(box, m_emptyTile);
- }
- }
-}
-
-void SlippyMap::pan(const QPoint &delta)
-{
- QPointF dx = QPointF(delta) / qreal(tdim);
- QPointF center = tileForCoordinate(latitude, longitude, zoom) - dx;
- latitude = latitudeFromTile(center.y(), zoom);
- longitude = longitudeFromTile(center.x(), zoom);
- invalidate();
-}
-
-void SlippyMap::handleNetworkData(QNetworkReply *reply)
-{
- QImage img;
- QPoint tp = reply->request().attribute(QNetworkRequest::User).toPoint();
- if (!reply->error())
- if (!img.load(reply, 0))
- img = QImage();
- reply->deleteLater();
- m_tilePixmaps[tp] = QPixmap::fromImage(img);
- if (img.isNull())
- m_tilePixmaps[tp] = m_emptyTile;
- emit updated(tileRect(tp));
-
- // purge unused spaces
- const QRect bound = m_tilesRect.adjusted(-2, -2, 2, 2);
- for (auto it = m_tilePixmaps.keyBegin(); it != m_tilePixmaps.keyEnd(); ++it) {
- const QPoint &tp = *it;
- if (!bound.contains(tp))
- m_tilePixmaps.remove(tp);
- }
-
- download();
-}
-
-void SlippyMap::download()
-{
- QPoint grab(0, 0);
- for (int x = 0; x <= m_tilesRect.width(); ++x)
- for (int y = 0; y <= m_tilesRect.height(); ++y) {
- QPoint tp = m_tilesRect.topLeft() + QPoint(x, y);
- if (!m_tilePixmaps.contains(tp)) {
- grab = tp;
- break;
- }
- }
- if (grab == QPoint(0, 0)) {
- m_url = QUrl();
- return;
- }
-
- QString path = "http://tile.openstreetmap.org/%1/%2/%3.png";
- m_url = QUrl(path.arg(zoom).arg(grab.x()).arg(grab.y()));
- QNetworkRequest request;
- request.setUrl(m_url);
- request.setRawHeader("User-Agent", "The Qt Company (Qt) Graphics Dojo 1.0");
- request.setAttribute(QNetworkRequest::User, QVariant(grab));
- m_manager.get(request);
-}
-
-QRect SlippyMap::tileRect(const QPoint &tp)
-{
- QPoint t = tp - m_tilesRect.topLeft();
- int x = t.x() * tdim + m_offset.x();
- int y = t.y() * tdim + m_offset.y();
- return QRect(x, y, tdim, tdim);
-}
diff --git a/examples/embedded/lightmaps/slippymap.h b/examples/embedded/lightmaps/slippymap.h
deleted file mode 100644
index f20945445b..0000000000
--- a/examples/embedded/lightmaps/slippymap.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SLIPPYMAP_H
-#define SLIPPYMAP_H
-
-#include <QNetworkAccessManager>
-#include <QPixmap>
-#include <QUrl>
-
-QT_BEGIN_NAMESPACE
-class QNetworkReply;
-class QPainter;
-QT_END_NAMESPACE
-
-class SlippyMap: public QObject
-{
- Q_OBJECT
-
-public:
- SlippyMap(QObject *parent = nullptr);
- void invalidate();
- void render(QPainter *p, const QRect &rect);
- void pan(const QPoint &delta);
-
- int width;
- int height;
- int zoom;
- qreal latitude;
- qreal longitude;
-
-signals:
- void updated(const QRect &rect);
-
-private slots:
- void handleNetworkData(QNetworkReply *reply);
- void download();
-
-protected:
- QRect tileRect(const QPoint &tp);
-
-private:
- QPoint m_offset;
- QRect m_tilesRect;
- QPixmap m_emptyTile;
- QHash<QPoint, QPixmap> m_tilePixmaps;
- QNetworkAccessManager m_manager;
- QUrl m_url;
-};
-
-#endif
-
diff --git a/examples/embedded/raycasting/CMakeLists.txt b/examples/embedded/raycasting/CMakeLists.txt
deleted file mode 100644
index f39466c89c..0000000000
--- a/examples/embedded/raycasting/CMakeLists.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-# Generated from raycasting.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(raycasting LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/embedded/raycasting")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(raycasting
- raycasting.cpp
-)
-set_target_properties(raycasting PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(raycasting PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set(raycasting_resource_files
- "textures.png"
-)
-
-qt6_add_resources(raycasting "raycasting"
- PREFIX
- "/"
- FILES
- ${raycasting_resource_files}
-)
-
-install(TARGETS raycasting
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/embedded/raycasting/raycasting.cpp b/examples/embedded/raycasting/raycasting.cpp
deleted file mode 100644
index 4930dbe9f2..0000000000
--- a/examples/embedded/raycasting/raycasting.cpp
+++ /dev/null
@@ -1,383 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore>
-#include <QtWidgets>
-#include <qmath.h>
-
-#define WORLD_SIZE 8
-int world_map[WORLD_SIZE][WORLD_SIZE] = {
- { 1, 1, 1, 1, 6, 1, 1, 1 },
- { 1, 0, 0, 1, 0, 0, 0, 7 },
- { 1, 1, 0, 1, 0, 1, 1, 1 },
- { 6, 0, 0, 0, 0, 0, 0, 3 },
- { 1, 8, 8, 0, 8, 0, 8, 1 },
- { 2, 2, 0, 0, 8, 8, 7, 1 },
- { 3, 0, 0, 0, 0, 0, 0, 5 },
- { 2, 2, 2, 2, 7, 4, 4, 4 },
-};
-
-#define TEXTURE_SIZE 64
-#define TEXTURE_BLOCK (TEXTURE_SIZE * TEXTURE_SIZE)
-
-class Raycasting: public QWidget
-{
-public:
- Raycasting(QWidget *parent = nullptr)
- : QWidget(parent)
- , angle(0.5)
- , playerPos(1.5, 1.5)
- , angleDelta(0)
- , moveDelta(0)
- , touchDevice(false) {
-
- // http://www.areyep.com/RIPandMCS-TextureLibrary.html
- textureImg.load(":/textures.png");
- textureImg = textureImg.convertToFormat(QImage::Format_ARGB32);
- Q_ASSERT(textureImg.width() == TEXTURE_SIZE * 2);
- Q_ASSERT(textureImg.bytesPerLine() == 4 * TEXTURE_SIZE * 2);
- textureCount = textureImg.height() / TEXTURE_SIZE;
-
- watch.start();
- ticker.start(25, this);
- setAttribute(Qt::WA_OpaquePaintEvent, true);
- setMouseTracking(false);
- }
-
- void updatePlayer() {
- int interval = qBound(20ll, watch.elapsed(), 250ll);
- watch.start();
- angle += angleDelta * interval / 1000;
- qreal step = moveDelta * interval / 1000;
- qreal dx = cos(angle) * step;
- qreal dy = sin(angle) * step;
- QPointF pos = playerPos + 3 * QPointF(dx, dy);
- int xi = static_cast<int>(pos.x());
- int yi = static_cast<int>(pos.y());
- if (world_map[yi][xi] == 0)
- playerPos = playerPos + QPointF(dx, dy);
- }
-
- void showFps() {
- static QElapsedTimer frameTick;
- static int totalFrame = 0;
- if (!(totalFrame & 31)) {
- const qint64 elapsed = frameTick.elapsed();
- frameTick.start();
- int fps = 32 * 1000 / (1 + elapsed);
- setWindowTitle(QString("Raycasting (%1 FPS)").arg(fps));
- }
- totalFrame++;
- }
-
- void render() {
-
- // setup the screen surface
- if (buffer.size() != bufferSize)
- buffer = QImage(bufferSize, QImage::Format_ARGB32);
- int bufw = buffer.width();
- int bufh = buffer.height();
- if (bufw <= 0 || bufh <= 0)
- return;
-
- // we intentionally cheat here, to avoid detach
- const uchar *ptr = buffer.bits();
- QRgb *start = (QRgb*)(ptr);
- QRgb stride = buffer.bytesPerLine() / 4;
- QRgb *finish = start + stride * bufh;
-
- // prepare the texture pointer
- const uchar *src = textureImg.bits();
- const QRgb *texsrc = reinterpret_cast<const QRgb*>(src);
-
- // cast all rays here
- qreal sina = sin(angle);
- qreal cosa = cos(angle);
- qreal u = cosa - sina;
- qreal v = sina + cosa;
- qreal du = 2 * sina / bufw;
- qreal dv = -2 * cosa / bufw;
-
- for (int ray = 0; ray < bufw; ++ray, u += du, v += dv) {
- // every time this ray advances 'u' units in x direction,
- // it also advanced 'v' units in y direction
- qreal uu = (u < 0) ? -u : u;
- qreal vv = (v < 0) ? -v : v;
- qreal duu = 1 / uu;
- qreal dvv = 1 / vv;
- int stepx = (u < 0) ? -1 : 1;
- int stepy = (v < 0) ? -1 : 1;
-
- // the cell in the map that we need to check
- qreal px = playerPos.x();
- qreal py = playerPos.y();
- int mapx = static_cast<int>(px);
- int mapy = static_cast<int>(py);
-
- // the position and texture for the hit
- int texture = 0;
- qreal hitdist = 0.1;
- qreal texofs = 0;
- bool dark = false;
-
- // first hit at constant x and constant y lines
- qreal distx = (u > 0) ? (mapx + 1 - px) * duu : (px - mapx) * duu;
- qreal disty = (v > 0) ? (mapy + 1 - py) * dvv : (py - mapy) * dvv;
-
- // loop until we hit something
- while (texture <= 0) {
- if (distx > disty) {
- // shorter distance to a hit in constant y line
- hitdist = disty;
- disty += dvv;
- mapy += stepy;
- texture = world_map[mapy][mapx];
- if (texture > 0) {
- dark = true;
- if (stepy > 0) {
- qreal ofs = px + u * (mapy - py) / v;
- texofs = ofs - floor(ofs);
- } else {
- qreal ofs = px + u * (mapy + 1 - py) / v;
- texofs = ofs - floor(ofs);
- }
- }
- } else {
- // shorter distance to a hit in constant x line
- hitdist = distx;
- distx += duu;
- mapx += stepx;
- texture = world_map[mapy][mapx];
- if (texture > 0) {
- if (stepx > 0) {
- qreal ofs = py + v * (mapx - px) / u;
- texofs = ofs - floor(ofs);
- } else {
- qreal ofs = py + v * (mapx + 1 - px) / u;
- texofs = ceil(ofs) - ofs;
- }
- }
- }
- }
-
- // get the texture, note that the texture image
- // has two textures horizontally, "normal" vs "dark"
- int col = static_cast<int>(texofs * TEXTURE_SIZE);
- col = qBound(0, col, TEXTURE_SIZE - 1);
- texture = (texture - 1) % textureCount;
- const QRgb *tex = texsrc + TEXTURE_BLOCK * texture * 2 +
- (TEXTURE_SIZE * 2 * col);
- if (dark)
- tex += TEXTURE_SIZE;
-
- // start from the texture center (horizontally)
- int h = static_cast<int>(bufw / hitdist / 2);
- int dy = (TEXTURE_SIZE << 12) / h;
- int p1 = ((TEXTURE_SIZE / 2) << 12) - dy;
- int p2 = p1 + dy;
-
- // start from the screen center (vertically)
- // y1 will go up (decrease), y2 will go down (increase)
- int y1 = bufh / 2;
- int y2 = y1 + 1;
- QRgb *pixel1 = start + y1 * stride + ray;
- QRgb *pixel2 = pixel1 + stride;
-
- // map the texture to the sliver
- while (y1 >= 0 && y2 < bufh && p1 >= 0) {
- *pixel1 = tex[p1 >> 12];
- *pixel2 = tex[p2 >> 12];
- p1 -= dy;
- p2 += dy;
- --y1;
- ++y2;
- pixel1 -= stride;
- pixel2 += stride;
- }
-
- // ceiling and floor
- for (; pixel1 > start; pixel1 -= stride)
- *pixel1 = qRgb(0, 0, 0);
- for (; pixel2 < finish; pixel2 += stride)
- *pixel2 = qRgb(96, 96, 96);
- }
-
- update(QRect(QPoint(0, 0), bufferSize));
- }
-
-protected:
-
- void resizeEvent(QResizeEvent*) {
- touchDevice = false;
- if (touchDevice) {
- if (width() < height()) {
- trackPad = QRect(0, height() / 2, width(), height() / 2);
- centerPad = QPoint(width() / 2, height() * 3 / 4);
- bufferSize = QSize(width(), height() / 2);
- } else {
- trackPad = QRect(width() / 2, 0, width() / 2, height());
- centerPad = QPoint(width() * 3 / 4, height() / 2);
- bufferSize = QSize(width() / 2, height());
- }
- } else {
- trackPad = QRect();
- bufferSize = size();
- }
- update();
- }
-
- void timerEvent(QTimerEvent*) {
- updatePlayer();
- render();
- showFps();
- }
-
- void paintEvent(QPaintEvent *event) {
- QPainter p(this);
- p.setCompositionMode(QPainter::CompositionMode_Source);
-
- p.drawImage(event->rect(), buffer, event->rect());
-
- if (touchDevice && event->rect().intersects(trackPad)) {
- p.fillRect(trackPad, Qt::white);
- p.setPen(QPen(QColor(224, 224, 224), 6));
- int rad = qMin(trackPad.width(), trackPad.height()) * 0.3;
- p.drawEllipse(centerPad, rad, rad);
-
- p.setPen(Qt::NoPen);
- p.setBrush(Qt::gray);
-
- QPolygon poly;
- poly << QPoint(-30, 0);
- poly << QPoint(0, -40);
- poly << QPoint(30, 0);
-
- p.translate(centerPad);
- for (int i = 0; i < 4; ++i) {
- p.rotate(90);
- p.translate(0, 20 - rad);
- p.drawPolygon(poly);
- p.translate(0, rad - 20);
- }
- }
-
- p.end();
- }
-
- void keyPressEvent(QKeyEvent *event) {
- event->accept();
- if (event->key() == Qt::Key_Left)
- angleDelta = 1.3 * M_PI;
- if (event->key() == Qt::Key_Right)
- angleDelta = -1.3 * M_PI;
- if (event->key() == Qt::Key_Up)
- moveDelta = 2.5;
- if (event->key() == Qt::Key_Down)
- moveDelta = -2.5;
- }
-
- void keyReleaseEvent(QKeyEvent *event) {
- event->accept();
- if (event->key() == Qt::Key_Left)
- angleDelta = (angleDelta > 0) ? 0 : angleDelta;
- if (event->key() == Qt::Key_Right)
- angleDelta = (angleDelta < 0) ? 0 : angleDelta;
- if (event->key() == Qt::Key_Up)
- moveDelta = (moveDelta > 0) ? 0 : moveDelta;
- if (event->key() == Qt::Key_Down)
- moveDelta = (moveDelta < 0) ? 0 : moveDelta;
- }
-
- void mousePressEvent(QMouseEvent *event) {
- qreal dx = centerPad.x() - event->position().toPoint().x();
- qreal dy = centerPad.y() - event->position().toPoint().y();
- angleDelta = dx * 2 * M_PI / width();
- moveDelta = dy * 10 / height();
- }
-
- void mouseMoveEvent(QMouseEvent *event) {
- qreal dx = centerPad.x() - event->position().toPoint().x();
- qreal dy = centerPad.y() - event->position().toPoint().y();
- angleDelta = dx * 2 * M_PI / width();
- moveDelta = dy * 10 / height();
- }
-
- void mouseReleaseEvent(QMouseEvent*) {
- angleDelta = 0;
- moveDelta = 0;
- }
-
-private:
- QElapsedTimer watch;
- QBasicTimer ticker;
- QImage buffer;
- qreal angle;
- QPointF playerPos;
- qreal angleDelta;
- qreal moveDelta;
- QImage textureImg;
- int textureCount;
- bool touchDevice;
- QRect trackPad;
- QPoint centerPad;
- QSize bufferSize;
-};
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- Raycasting w;
- w.setWindowTitle("Raycasting");
- w.resize(640, 480);
- w.show();
-
- return app.exec();
-}
diff --git a/examples/embedded/raycasting/raycasting.pro b/examples/embedded/raycasting/raycasting.pro
deleted file mode 100644
index 51bf4bf4b0..0000000000
--- a/examples/embedded/raycasting/raycasting.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = app
-QT += widgets
-SOURCES = raycasting.cpp
-RESOURCES += raycasting.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/embedded/raycasting
-INSTALLS += target
diff --git a/examples/embedded/raycasting/raycasting.qrc b/examples/embedded/raycasting/raycasting.qrc
deleted file mode 100644
index 974a06093c..0000000000
--- a/examples/embedded/raycasting/raycasting.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/" >
- <file>textures.png</file>
- </qresource>
-</RCC>
diff --git a/examples/embedded/raycasting/textures.png b/examples/embedded/raycasting/textures.png
deleted file mode 100644
index 2eb1ba7ff6..0000000000
--- a/examples/embedded/raycasting/textures.png
+++ /dev/null
Binary files differ
diff --git a/examples/embedded/styleexample/.prev_CMakeLists.txt b/examples/embedded/styleexample/.prev_CMakeLists.txt
deleted file mode 100644
index ac03e58346..0000000000
--- a/examples/embedded/styleexample/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-# Generated from styleexample.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(styleexample LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-set(INSTALL_EXAMPLEDIR "examples/embedded/styleexample")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(styleexample
- main.cpp
- stylewidget.cpp stylewidget.h stylewidget.ui
-)
-target_link_libraries(styleexample PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set(styleexample_resource_files
- "files/add.png"
- "files/application.qss"
- "files/blue.qss"
- "files/khaki.qss"
- "files/nature_1.jpg"
- "files/nostyle.qss"
- "files/remove.png"
- "files/transparent.qss"
-)
-
-qt6_add_resources(styleexample "styleexample"
- PREFIX
- "/"
- FILES
- ${styleexample_resource_files}
-)
-
-install(TARGETS styleexample
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/embedded/styleexample/CMakeLists.txt b/examples/embedded/styleexample/CMakeLists.txt
deleted file mode 100644
index a224f504ca..0000000000
--- a/examples/embedded/styleexample/CMakeLists.txt
+++ /dev/null
@@ -1,60 +0,0 @@
-# Generated from styleexample.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(styleexample LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/embedded/styleexample")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(styleexample
- main.cpp
- stylewidget.cpp stylewidget.h stylewidget.ui
-)
-set_target_properties(styleexample PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(styleexample PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set(styleexample_resource_files
- "files/add.png"
- "files/application.qss"
- "files/blue.qss"
- "files/khaki.qss"
- "files/nature_1.jpg"
- "files/nostyle.qss"
- "files/remove.png"
- "files/transparent.qss"
-)
-
-qt6_add_resources(styleexample "styleexample"
- PREFIX
- "/"
- FILES
- ${styleexample_resource_files}
-)
-
-install(TARGETS styleexample
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/embedded/styleexample/files/add.png b/examples/embedded/styleexample/files/add.png
deleted file mode 100644
index fc5c16d4c8..0000000000
--- a/examples/embedded/styleexample/files/add.png
+++ /dev/null
Binary files differ
diff --git a/examples/embedded/styleexample/files/application.qss b/examples/embedded/styleexample/files/application.qss
deleted file mode 100644
index 432fe6bc76..0000000000
--- a/examples/embedded/styleexample/files/application.qss
+++ /dev/null
@@ -1,125 +0,0 @@
-QWidget#StyleWidget
-{
- background-color: none;
- background-image: url(icons:nature_1.jpg);
-}
-
-QLabel, QAbstractButton
-{
- font: bold;
- color: beige;
-}
-
-QAbstractButton
-{
- background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgba(173,216,230,60%), stop:1 rgba(0,0,139,60%) );
- border-color: black;
- border-style: solid;
- border-width: 3px;
- border-radius: 6px;
-}
-
-QAbstractButton:pressed, QAbstractButton:checked
-{
- background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0,0,139,60%), stop:1 rgba(173,216,230,60%) );
-}
-
-QSpinBox {
- padding-left: 24px;
- padding-right: 24px;
- border-color: darkkhaki;
- border-style: solid;
- border-radius: 5;
- border-width: 3;
-}
-
-QSpinBox::up-button
-{
- subcontrol-origin: padding;
- subcontrol-position: right; /* position at the top right corner */
- width: 24px;
- height: 24px;
- border-width: 3px;
-
-}
-
-QSpinBox::up-arrow
-{
- image: url(icons:add.png);
- width: 18px;
- height: 18px;
-}
-
-
-QSpinBox::down-button
-{
- subcontrol-origin: border;
- subcontrol-position: left;
- width: 24px;
- height: 24px;
- border-width: 3px;
-}
-
-QSpinBox::down-arrow
-{
- image: url(icons:remove.png);
- width: 18px;
- height: 18px;
-}
-
-
-QScrollBar:horizontal
-{
- border: 1px solid black;
- background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0,0,139,60%), stop:1 rgba(173,216,230,60%) );
- height: 15px;
- margin: 0px 20px 0 20px;
-}
-
-QScrollBar::handle:horizontal
-{
- border: 1px solid black;
- background: rgba(0,0,139,60%);
- min-width: 20px;
-}
-
-QScrollBar::add-line:horizontal
-{
- border: 1px solid black;
- background: rgba(0,0,139,60%);
- width: 20px;
- subcontrol-position: right;
- subcontrol-origin: margin;
-}
-
-QScrollBar::sub-line:horizontal
-{
- border: 1px solid black;
- background: rgba(0,0,139,60%);
- width: 20px;
- subcontrol-position: left;
- subcontrol-origin: margin;
-}
-
-QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal
-{
- border: none;
- width: 16px;
- height: 16px;
-}
-
-QScrollBar:left-arrow:horizontal
-{
- image: url(icons:add.png)
-}
-
-QScrollBar::right-arrow:horizontal
-{
- image: url(icons:remove.png)
-}
-
-QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal
-{
- background: none;
-}
-
diff --git a/examples/embedded/styleexample/files/blue.qss b/examples/embedded/styleexample/files/blue.qss
deleted file mode 100644
index ac8671b5e4..0000000000
--- a/examples/embedded/styleexample/files/blue.qss
+++ /dev/null
@@ -1,38 +0,0 @@
-*
-{
- color: beige;
-}
-
-QLabel, QAbstractButton
-{
- font: bold;
- color: yellow;
-}
-
-QFrame
-{
- background-color: rgba(96,96,255,60%);
- border-color: rgb(32,32,196);
- border-width: 3px;
- border-style: solid;
- border-radius: 5;
- padding: 3px;
-}
-
-QAbstractButton
-{
- background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
- stop:0 lightblue, stop:0.5 darkblue);
- border-width: 3px;
- border-color: darkblue;
- border-style: solid;
- border-radius: 5;
- padding: 3px;
-}
-
-QAbstractButton:pressed
-{
- background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
- stop:0.5 darkblue, stop:1 lightblue);
- border-color: beige;
-}
diff --git a/examples/embedded/styleexample/files/khaki.qss b/examples/embedded/styleexample/files/khaki.qss
deleted file mode 100644
index b0d4a0fa6f..0000000000
--- a/examples/embedded/styleexample/files/khaki.qss
+++ /dev/null
@@ -1,99 +0,0 @@
-
-QWidget#StartScreen, QWidget#MainWidget {
- border: none;
-}
-
-QWidget#StartScreen, .QFrame {
- background-color: beige;
-}
-
-QPushButton, QToolButton {
- background-color: palegoldenrod;
- border-width: 2px;
- border-color: darkkhaki;
- border-style: solid;
- border-radius: 5;
- padding: 3px;
- /* min-width: 96px; */
- /* min-height: 48px; */
-}
-
-QPushButton:hover, QToolButton:hover {
- background-color: khaki;
-}
-
-QPushButton:pressed, QToolButton:pressed {
- padding-left: 5px;
- padding-top: 5px;
- background-color: #d0d67c;
-}
-
-QLabel, QAbstractButton {
- font: italic "Times New Roman";
-}
-
-QFrame, QLabel#title {
- border-width: 2px;
- padding: 1px;
- border-style: solid;
- border-color: darkkhaki;
- border-radius: 5px;
-}
-
-QFrame:focus {
- border-width: 3px;
- padding: 0px;
-}
-
-
-QLabel {
- border: none;
- padding: 0;
- background: none;
-}
-
-QLabel#title {
- font: 32px bold;
-}
-
-QSpinBox {
- padding-left: 24px;
- padding-right: 24px;
- border-color: darkkhaki;
- border-style: solid;
- border-radius: 5;
- border-width: 3;
-}
-
-QSpinBox::up-button
-{
- subcontrol-origin: padding;
- subcontrol-position: right; /* position at the top right corner */
- width: 24px;
- height: 24px;
- border-width: 3px;
- border-image: url(:/files/spindownpng) 1;
-}
-
-QSpinBox::up-arrow {
- image: url(:/files/add.png);
- width: 12px;
- height: 12px;
- }
-
-
-QSpinBox::down-button
-{
- subcontrol-origin: border;
- subcontrol-position: left;
- width: 24px;
- height: 24px;
- border-width: 3px;
- border-image: url(:/files/spindownpng) 1;
-}
-
-QSpinBox::down-arrow {
- image: url(:/files/remove.png);
- width: 12px;
- height: 12px;
- }
diff --git a/examples/embedded/styleexample/files/nature_1.jpg b/examples/embedded/styleexample/files/nature_1.jpg
deleted file mode 100644
index 3a04edb96a..0000000000
--- a/examples/embedded/styleexample/files/nature_1.jpg
+++ /dev/null
Binary files differ
diff --git a/examples/embedded/styleexample/files/nostyle.qss b/examples/embedded/styleexample/files/nostyle.qss
deleted file mode 100644
index e69de29bb2..0000000000
--- a/examples/embedded/styleexample/files/nostyle.qss
+++ /dev/null
diff --git a/examples/embedded/styleexample/files/remove.png b/examples/embedded/styleexample/files/remove.png
deleted file mode 100644
index a0ab1fa21a..0000000000
--- a/examples/embedded/styleexample/files/remove.png
+++ /dev/null
Binary files differ
diff --git a/examples/embedded/styleexample/files/transparent.qss b/examples/embedded/styleexample/files/transparent.qss
deleted file mode 100644
index b38eb366f4..0000000000
--- a/examples/embedded/styleexample/files/transparent.qss
+++ /dev/null
@@ -1,139 +0,0 @@
-QWidget#StyleWidget
-{
- background-color: none;
- background-image: url(:/files/nature_1.jpg);
-}
-
-QLabel, QAbstractButton
-{
- color: beige;
-}
-
-QFrame, QLabel#title {
- border-width: 2px;
- padding: 1px;
- border-style: solid;
- border-color: black;
- border-radius: 5px;
-}
-
-QFrame:focus {
- border-width: 3px;
- padding: 0px;
-}
-
-
-
-QAbstractButton
-{
- background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgba(173,216,230,60%), stop:1 rgba(0,0,139,60%) );
- border-color: black;
- border-style: solid;
- border-width: 3px;
- border-radius: 6px;
-}
-
-QAbstractButton:pressed, QAbstractButton:checked
-{
- background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0,0,139,60%), stop:1 rgba(173,216,230,60%) );
-}
-
-QSpinBox {
- padding-left: 24px;
- padding-right: 24px;
- border-color: darkkhaki;
- border-style: solid;
- border-radius: 5;
- border-width: 3;
-}
-
-QSpinBox::up-button
-{
- subcontrol-origin: padding;
- subcontrol-position: right; /* position at the top right corner */
- width: 24px;
- height: 24px;
- border-width: 3px;
-
-}
-
-QSpinBox::up-arrow
-{
- image: url(:/files/add.png);
- width: 18px;
- height: 18px;
-}
-
-
-QSpinBox::down-button
-{
- subcontrol-origin: border;
- subcontrol-position: left;
- width: 24px;
- height: 24px;
- border-width: 3px;
-}
-
-QSpinBox::down-arrow
-{
- image: url(:/files/remove.png);
- width: 18px;
- height: 18px;
-}
-
-
-QScrollBar:horizontal
-{
- border: 1px solid black;
- background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0,0,139,60%), stop:1 rgba(173,216,230,60%) );
- height: 15px;
- margin: 0px 20px 0 20px;
-}
-
-QScrollBar::handle:horizontal
-{
- border: 1px solid black;
- background: rgba(0,0,139,60%);
- min-width: 20px;
-}
-
-QScrollBar::add-line:horizontal
-{
- border: 1px solid black;
- background: rgba(0,0,139,60%);
- width: 20px;
- subcontrol-position: right;
- subcontrol-origin: margin;
-}
-
-QScrollBar::sub-line:horizontal
-{
- border: 1px solid black;
- background: rgba(0,0,139,60%);
- width: 20px;
- subcontrol-position: left;
- subcontrol-origin: margin;
-}
-
-QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal
-{
- border: none;
- width: 16px;
- height: 16px;
-}
-
-QScrollBar:left-arrow:horizontal
-{
- image: url(:/files/add.png)
-}
-
-QScrollBar::right-arrow:horizontal
-{
- image: url(:/files/remove.png)
-}
-
-QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal
-{
- background: none;
-}
-
diff --git a/examples/embedded/styleexample/main.cpp b/examples/embedded/styleexample/main.cpp
deleted file mode 100644
index 58c5de4db2..0000000000
--- a/examples/embedded/styleexample/main.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QApplication>
-
-#include "stylewidget.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- Q_INIT_RESOURCE(styleexample);
-
- app.setApplicationName("style");
- app.setOrganizationName("QtProject");
- app.setOrganizationDomain("www.qt-project.org");
-
- StyleWidget widget;
- widget.showFullScreen();
-
- return app.exec();
-}
-
diff --git a/examples/embedded/styleexample/styleexample.pro b/examples/embedded/styleexample/styleexample.pro
deleted file mode 100644
index 8f29203df2..0000000000
--- a/examples/embedded/styleexample/styleexample.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QT += widgets
-
-HEADERS += stylewidget.h
-FORMS += stylewidget.ui
-SOURCES += main.cpp stylewidget.cpp
-RESOURCES += styleexample.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/embedded/styleexample
-INSTALLS += target
diff --git a/examples/embedded/styleexample/styleexample.qrc b/examples/embedded/styleexample/styleexample.qrc
deleted file mode 100644
index 96237d4203..0000000000
--- a/examples/embedded/styleexample/styleexample.qrc
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/">
- <file>files/add.png</file>
- <file>files/blue.qss</file>
- <file>files/khaki.qss</file>
- <file>files/nostyle.qss</file>
- <file>files/transparent.qss</file>
- <file>files/application.qss</file>
- <file>files/nature_1.jpg</file>
- <file>files/remove.png</file>
-</qresource>
-</RCC>
-
diff --git a/examples/embedded/styleexample/stylewidget.cpp b/examples/embedded/styleexample/stylewidget.cpp
deleted file mode 100644
index 322d0daf8c..0000000000
--- a/examples/embedded/styleexample/stylewidget.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QApplication>
-#include <QString>
-#include <QFile>
-
-#include "stylewidget.h"
-
-
-
-StyleWidget::StyleWidget(QWidget *parent)
- : QFrame(parent)
-{
- m_ui.setupUi(this);
-}
-
-
-void StyleWidget::on_close_clicked()
-{
- close();
-}
-
-void StyleWidget::on_blueStyle_clicked()
-{
- QFile styleSheet(":/files/blue.qss");
-
- if (!styleSheet.open(QIODevice::ReadOnly)) {
- qWarning("Unable to open :/files/blue.qss");
- return;
- }
-
- qApp->setStyleSheet(styleSheet.readAll());
-}
-
-void StyleWidget::on_khakiStyle_clicked()
-{
- QFile styleSheet(":/files/khaki.qss");
-
- if (!styleSheet.open(QIODevice::ReadOnly)) {
- qWarning("Unable to open :/files/khaki.qss");
- return;
- }
-
- qApp->setStyleSheet(styleSheet.readAll());
-}
-
-
-void StyleWidget::on_noStyle_clicked()
-{
- QFile styleSheet(":/files/nostyle.qss");
-
- if (!styleSheet.open(QIODevice::ReadOnly)) {
- qWarning("Unable to open :/files/nostyle.qss");
- return;
- }
-
- qApp->setStyleSheet(styleSheet.readAll());
-}
-
-
-void StyleWidget::on_transparentStyle_clicked()
-{
- QFile styleSheet(":/files/transparent.qss");
-
- if (!styleSheet.open(QIODevice::ReadOnly)) {
- qWarning("Unable to open :/files/transparent.qss");
- return;
- }
-
- qApp->setStyleSheet(styleSheet.readAll());
-}
-
-
-
diff --git a/examples/embedded/styleexample/stylewidget.h b/examples/embedded/styleexample/stylewidget.h
deleted file mode 100644
index c0ff33e297..0000000000
--- a/examples/embedded/styleexample/stylewidget.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef STYLEWIDGET_H
-#define STYLEWIDGET_H
-
-#include <QFrame>
-
-#include "ui_stylewidget.h"
-
-class StyleWidget : public QFrame
-{
- Q_OBJECT
-public:
- StyleWidget(QWidget *parent = nullptr);
-
-private:
- Ui_StyleWidget m_ui;
-
-private slots:
- void on_close_clicked();
- void on_blueStyle_clicked();
- void on_khakiStyle_clicked();
- void on_noStyle_clicked();
- void on_transparentStyle_clicked();
-};
-
-#endif
diff --git a/examples/embedded/styleexample/stylewidget.ui b/examples/embedded/styleexample/stylewidget.ui
deleted file mode 100644
index ebe2961ec6..0000000000
--- a/examples/embedded/styleexample/stylewidget.ui
+++ /dev/null
@@ -1,417 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>StyleWidget</class>
- <widget class="QWidget" name="StyleWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>184</width>
- <height>245</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" colspan="2">
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Styles</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <property name="margin">
- <number>4</number>
- </property>
- <property name="spacing">
- <number>4</number>
- </property>
- <item row="0" column="0">
- <widget class="QPushButton" name="transparentStyle">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="focusPolicy">
- <enum>Qt::StrongFocus</enum>
- </property>
- <property name="text">
- <string>Transp.</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <property name="autoExclusive">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QPushButton" name="blueStyle">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="focusPolicy">
- <enum>Qt::StrongFocus</enum>
- </property>
- <property name="text">
- <string>Blue</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <property name="autoExclusive">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QPushButton" name="khakiStyle">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="focusPolicy">
- <enum>Qt::StrongFocus</enum>
- </property>
- <property name="text">
- <string>Khaki</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <property name="autoExclusive">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QPushButton" name="noStyle">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="focusPolicy">
- <enum>Qt::StrongFocus</enum>
- </property>
- <property name="text">
- <string>None</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- <property name="autoExclusive">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0" colspan="2">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <property name="margin">
- <number>4</number>
- </property>
- <item>
- <widget class="QLabel" name="label">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Value:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSpinBox" name="spinBox">
- <property name="focusPolicy">
- <enum>Qt::WheelFocus</enum>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <property name="keyboardTracking">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="3" column="0">
- <widget class="QScrollBar" name="horizontalScrollBar">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>24</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::TabFocus</enum>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QScrollBar" name="horizontalScrollBar_2">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>24</height>
- </size>
- </property>
- <property name="focusPolicy">
- <enum>Qt::TabFocus</enum>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QPushButton" name="pushButton_2">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="focusPolicy">
- <enum>Qt::StrongFocus</enum>
- </property>
- <property name="text">
- <string>Show</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- <property name="flat">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QPushButton" name="pushButton">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="focusPolicy">
- <enum>Qt::StrongFocus</enum>
- </property>
- <property name="text">
- <string>Enable</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- <property name="flat">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="5" column="0" colspan="2">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="6" column="0">
- <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 row="6" column="1">
- <widget class="QPushButton" name="close">
- <property name="focusPolicy">
- <enum>Qt::StrongFocus</enum>
- </property>
- <property name="text">
- <string>Close</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources>
- <include location="styleexample.qrc"/>
- </resources>
- <connections>
- <connection>
- <sender>horizontalScrollBar</sender>
- <signal>valueChanged(int)</signal>
- <receiver>horizontalScrollBar_2</receiver>
- <slot>setValue(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>84</x>
- <y>147</y>
- </hint>
- <hint type="destinationlabel">
- <x>166</x>
- <y>147</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>horizontalScrollBar_2</sender>
- <signal>valueChanged(int)</signal>
- <receiver>horizontalScrollBar</receiver>
- <slot>setValue(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>166</x>
- <y>147</y>
- </hint>
- <hint type="destinationlabel">
- <x>84</x>
- <y>147</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>pushButton</sender>
- <signal>clicked(bool)</signal>
- <receiver>horizontalScrollBar_2</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>166</x>
- <y>175</y>
- </hint>
- <hint type="destinationlabel">
- <x>166</x>
- <y>147</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>pushButton_2</sender>
- <signal>clicked(bool)</signal>
- <receiver>horizontalScrollBar</receiver>
- <slot>setVisible(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>84</x>
- <y>175</y>
- </hint>
- <hint type="destinationlabel">
- <x>84</x>
- <y>147</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>spinBox</sender>
- <signal>valueChanged(int)</signal>
- <receiver>horizontalScrollBar_2</receiver>
- <slot>setValue(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>166</x>
- <y>115</y>
- </hint>
- <hint type="destinationlabel">
- <x>166</x>
- <y>147</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>horizontalScrollBar_2</sender>
- <signal>valueChanged(int)</signal>
- <receiver>spinBox</receiver>
- <slot>setValue(int)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>132</x>
- <y>132</y>
- </hint>
- <hint type="destinationlabel">
- <x>135</x>
- <y>110</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/examples/examples.pro b/examples/examples.pro
index 077e5828a9..87f00ca060 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -2,11 +2,11 @@ TEMPLATE = subdirs
CONFIG += no_docs_target
SUBDIRS = \
- corelib \
- embedded \
- qpa
+ corelib
-qtHaveModule(dbus): SUBDIRS += dbus
+!contains(TEMPLATE, "vc.*") { # QTBUG-91033
+ qtHaveModule(dbus): SUBDIRS += dbus
+}
qtHaveModule(network): SUBDIRS += network
qtHaveModule(testlib): SUBDIRS += qtestlib
qtHaveModule(concurrent): SUBDIRS += qtconcurrent
diff --git a/examples/gui/CMakeLists.txt b/examples/gui/CMakeLists.txt
index 7631777ef4..afc52ac3fa 100644
--- a/examples/gui/CMakeLists.txt
+++ b/examples/gui/CMakeLists.txt
@@ -1,7 +1,8 @@
-# Generated from gui.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-if(NOT TARGET Qt::Gui)
+if(NOT TARGET Qt6::Gui)
return()
endif()
-add_subdirectory(analogclock)
-add_subdirectory(rasterwindow)
+qt_internal_add_example(rasterwindow)
+qt_internal_add_example(rhiwindow)
diff --git a/examples/gui/analogclock/.prev_CMakeLists.txt b/examples/gui/analogclock/.prev_CMakeLists.txt
deleted file mode 100644
index 90c6091d68..0000000000
--- a/examples/gui/analogclock/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-# Generated from analogclock.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(analogclock LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/gui/analogclock")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-
-qt_add_executable(analogclock
- ../rasterwindow/rasterwindow.cpp ../rasterwindow/rasterwindow.h
- main.cpp
-)
-set_target_properties(analogclock PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_include_directories(analogclock PUBLIC
- ../rasterwindow
-)
-
-target_link_libraries(analogclock PUBLIC
- Qt::Core
- Qt::Gui
-)
-
-install(TARGETS analogclock
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/gui/analogclock/CMakeLists.txt b/examples/gui/analogclock/CMakeLists.txt
deleted file mode 100644
index 21a5fc239e..0000000000
--- a/examples/gui/analogclock/CMakeLists.txt
+++ /dev/null
@@ -1,49 +0,0 @@
-# Generated from analogclock.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(analogclock LANGUAGES CXX)
-
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/gui/gui_analogclock") # special case
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets) # special case: add
-
-qt_add_executable(gui_analogclock # special case: renamed target
- ../rasterwindow/rasterwindow.cpp ../rasterwindow/rasterwindow.h
- main.cpp
-)
-set_target_properties(gui_analogclock PROPERTIES # special case
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_include_directories(gui_analogclock PUBLIC # special case
- ../rasterwindow
-)
-# special case begin
-target_link_libraries(gui_analogclock PUBLIC # special case
- Qt::Gui
-)
-# special case end
-
-target_link_libraries(gui_analogclock PUBLIC # special case
- Qt::Core
- Qt::Gui
-)
-
-install(TARGETS gui_analogclock # special case
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/gui/analogclock/analogclock.pro b/examples/gui/analogclock/analogclock.pro
deleted file mode 100644
index eef17274f5..0000000000
--- a/examples/gui/analogclock/analogclock.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-include(../rasterwindow/rasterwindow.pri)
-
-# work-around for QTBUG-13496
-CONFIG += no_batch
-
-SOURCES += \
- main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/gui/analogclock
-INSTALLS += target
diff --git a/examples/gui/analogclock/main.cpp b/examples/gui/analogclock/main.cpp
deleted file mode 100644
index 053ccb54b5..0000000000
--- a/examples/gui/analogclock/main.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui>
-
-#include "rasterwindow.h"
-
-//! [5]
-class AnalogClockWindow : public RasterWindow
-{
-public:
- AnalogClockWindow();
-
-protected:
- void timerEvent(QTimerEvent *) override;
- void render(QPainter *p) override;
-
-private:
- int m_timerId;
-};
-//! [5]
-
-
-//! [6]
-AnalogClockWindow::AnalogClockWindow()
-{
- setTitle("Analog Clock");
- resize(200, 200);
-
- m_timerId = startTimer(1000);
-}
-//! [6]
-
-//! [7]
-void AnalogClockWindow::timerEvent(QTimerEvent *event)
-{
- if (event->timerId() == m_timerId)
- renderLater();
-}
-//! [7]
-
-//! [1] //! [14]
-void AnalogClockWindow::render(QPainter *p)
-{
-//! [14]
-//! [8]
- static const QPoint hourHand[3] = {
- QPoint(7, 8),
- QPoint(-7, 8),
- QPoint(0, -40)
- };
- static const QPoint minuteHand[3] = {
- QPoint(7, 8),
- QPoint(-7, 8),
- QPoint(0, -70)
- };
-
- QColor hourColor(127, 0, 127);
- QColor minuteColor(0, 127, 127, 191);
-//! [8]
-
-//! [9]
- p->setRenderHint(QPainter::Antialiasing);
-//! [9] //! [10]
- p->translate(width() / 2, height() / 2);
-
- int side = qMin(width(), height());
- p->scale(side / 200.0, side / 200.0);
-//! [1] //! [10]
-
-//! [11]
- p->setPen(Qt::NoPen);
- p->setBrush(hourColor);
-//! [11]
-
-//! [2]
- QTime time = QTime::currentTime();
-
- p->save();
- p->rotate(30.0 * ((time.hour() + time.minute() / 60.0)));
- p->drawConvexPolygon(hourHand, 3);
- p->restore();
-//! [2]
-
-//! [12]
- p->setPen(hourColor);
-
- for (int i = 0; i < 12; ++i) {
- p->drawLine(88, 0, 96, 0);
- p->rotate(30.0);
- }
-//! [12] //! [13]
- p->setPen(Qt::NoPen);
- p->setBrush(minuteColor);
-//! [13]
-
-//! [3]
- p->save();
- p->rotate(6.0 * (time.minute() + time.second() / 60.0));
- p->drawConvexPolygon(minuteHand, 3);
- p->restore();
-//! [3]
-
-//! [4]
- p->setPen(minuteColor);
-
- for (int j = 0; j < 60; ++j) {
- if ((j % 5) != 0)
- p->drawLine(92, 0, 96, 0);
- p->rotate(6.0);
- }
-//! [4]
-}
-
-int main(int argc, char **argv)
-{
- QGuiApplication app(argc, argv);
-
- AnalogClockWindow clock;
- clock.show();
-
- return app.exec();
-}
diff --git a/examples/gui/doc/images/analogclock-window-example.png b/examples/gui/doc/images/analogclock-window-example.png
deleted file mode 100644
index f5e92e400a..0000000000
--- a/examples/gui/doc/images/analogclock-window-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/gui/doc/images/analogclockwindow-viewport.png b/examples/gui/doc/images/analogclockwindow-viewport.png
deleted file mode 100644
index 31ce0c3c6e..0000000000
--- a/examples/gui/doc/images/analogclockwindow-viewport.png
+++ /dev/null
Binary files differ
diff --git a/examples/gui/doc/images/rhiwindow_example.jpg b/examples/gui/doc/images/rhiwindow_example.jpg
new file mode 100644
index 0000000000..ca1e44bada
--- /dev/null
+++ b/examples/gui/doc/images/rhiwindow_example.jpg
Binary files differ
diff --git a/examples/gui/doc/src/analogclockwindow.qdoc b/examples/gui/doc/src/analogclockwindow.qdoc
deleted file mode 100644
index f13f7261aa..0000000000
--- a/examples/gui/doc/src/analogclockwindow.qdoc
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example analogclock
- \title Analog Clock Window Example
-
- \brief The Analog Clock Window example shows how to draw the contents of
- a custom window.
-
- \image analogclock-window-example.png Screenshot of the Analog
- Clock Window example
-
- This example demonstrates how the transformation and scaling
- features of QPainter can be used to make drawing easier.
-
- \section1 AnalogClockWindow Class Definition
-
- The \c AnalogClockWindow class provides a clock with hour and
- minute hands that is automatically updated every few seconds. We
- make use of the RasterWindow from the \l {Raster Window Example}
- and reimplement the \c render function to draw the clock face:
-
- \snippet analogclock/main.cpp 5
-
- \section1 AnalogClock Class Implementation
-
- \snippet analogclock/main.cpp 6
-
- We set a title on the window and resize to a reasonable size. Then
- we start a timer which we will use to redraw the clock every
- second.
-
- \snippet analogclock/main.cpp 7
-
- The timerEvent function is called every second as a result of
- our startTimer call. Making use of the convenience in the base
- class, we schedule the window to be repainted.
-
- Checking the timer's id is not strictly needed as we only have
- one active timer in this instance, but it is good practice to do
- so.
-
- \snippet analogclock/main.cpp 14
- \snippet analogclock/main.cpp 8
-
- 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.
-
- \snippet analogclock/main.cpp 9
-
- We call QPainter::setRenderHint() with QPainter::Antialiasing to
- turn on antialiasing. This makes drawing of diagonal lines much
- smoother.
-
- \snippet analogclock/main.cpp 10
-
- The translation moves the origin to the center of the window, and
- the scale operation ensures that the following drawing operations
- are scaled to fit within the window. We use a scale factor that
- let's us use x and y coordinates between -100 and 100, and that
- ensures that these lie within the length of the window's shortest
- side.
-
- 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 window.
-
- We also determine the length of the window's shortest side so that we
- can fit the clock face inside the window.
-
- The painter takes care of all the transformations made during the
- rendering, and ensures that everything is drawn correctly. Letting
- the painter handle transformations is often easier than performing
- manual calculations.
-
- \image analogclockwindow-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 analogclock/main.cpp 11
-
- 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 analogclock/main.cpp 2
-
- 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 analogclock/main.cpp 12
-
- 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.
-
- \snippet analogclock/main.cpp 13
- \snippet analogclock/main.cpp 3
-
- The minute hand is rotated in a similar way to the hour hand.
-
- \snippet analogclock/main.cpp 4
-
- 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/gui/doc/src/rasterwindow.qdoc b/examples/gui/doc/src/rasterwindow.qdoc
index 0c52a62b8e..d30b4d7643 100644
--- a/examples/gui/doc/src/rasterwindow.qdoc
+++ b/examples/gui/doc/src/rasterwindow.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example rasterwindow
\title Raster Window Example
+ \examplecategory {Graphics}
\brief This example shows how to create a minimal QWindow based
application using QPainter for rendering.
diff --git a/examples/gui/doc/src/rhiwindow.qdoc b/examples/gui/doc/src/rhiwindow.qdoc
new file mode 100644
index 0000000000..3ee33c8002
--- /dev/null
+++ b/examples/gui/doc/src/rhiwindow.qdoc
@@ -0,0 +1,445 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example rhiwindow
+ \title RHI Window Example
+ \examplecategory {Graphics}
+
+ \brief This example shows how to create a minimal QWindow-based
+ application using QRhi.
+
+ \image rhiwindow_example.jpg
+
+ Qt 6.6 starts offering its accelerated 3D API and shader abstraction layer
+ for application use as well. Applications can now use the same 3D graphics
+ classes Qt itself uses to implement the Qt Quick scenegraph or the Qt Quick
+ 3D engine. In earlier Qt versions QRhi and the related classes were all
+ private APIs. From 6.6 on these classes are in a similar category as QPA
+ family of classes: neither fully public nor private, but something
+ in-between, with a more limited compatibility promise compared to public
+ APIs. On the other hand, QRhi and the related classes now come with full
+ documentation similarly to public APIs.
+
+ There are multiple ways to use QRhi, the example here shows the most
+ low-level approach: targeting a QWindow, while not using Qt Quick, Qt Quick
+ 3D, or Widgets in any form, and setting up all the rendering and windowing
+ infrastructure in the application.
+
+ In contrast, when writing a QML application with Qt Quick or Qt Quick 3D,
+ and wanting to add QRhi-based rendering to it, such an application is going
+ to rely on the window and rendering infrastructure Qt Quick has already
+ initialized, and it is likely going to query an existing QRhi instance from
+ the QQuickWindow. There dealing with QRhi::create(), platform/API specifics
+ such as \l{QVulkanInstance}{Vulkan instances}, or correctly handling
+ \l{QExposeEvent}{expose} and resize events for the window are all managed
+ by Qt Quick. Whereas in this example, all that is managed and taken care
+ of by the application itself.
+
+ \note For QWidget-based applications in particular, it should be noted that
+ QWidget::createWindowContainer() allows embedding a QWindow (backed by a
+ native window) into the widget-based user interface. Therefore, the \c
+ HelloWindow class from this example is reusable in QWidget-based
+ applications, assuming the necessary initialization from \c main() is in
+ place as well.
+
+ \section1 3D API Support
+
+ The application supports all the current \l{QRhi::Implementation}{QRhi
+ backends}. When no command-line arguments are specified, platform-specific
+ defaults are used: Direct 3D 11 on Windows, OpenGL on Linux, Metal on
+ macOS/iOS.
+
+ Running with \c{--help} shows the available command-line options:
+
+ \list
+ \li -d or --d3d11 for Direct 3D 11
+ \li -D or --d3d12 for Direct 3D 12
+ \li -m or --metal for Metal
+ \li -v or --vulkan for Vulkan
+ \li -g or --opengl for OpenGL or OpenGL ES
+ \li -n or --null for the \l{QRhi::Null}{Null backend}
+ \endlist
+
+ \section1 Build System Notes
+
+ This application relies solely on the Qt GUI module. It does not use Qt
+ Widgets or Qt Quick.
+
+ In order to access the RHI APIs, which are available to all Qt applications
+ but come with a limited compatibility promise, the \c target_link_libraries
+ CMake command lists \c{Qt6::GuiPrivate}. This is what enables the
+ \c{#include <rhi/qrhi.h>} include statement to compile successfully.
+
+ \section1 Features
+
+ The application features:
+
+ \list
+
+ \li A resizable QWindow,
+
+ \li a swapchain and depth-stencil buffer that properly follows the size of
+ the window,
+
+ \li logic to initialize, render, and tear down at the appropriate time
+ based on events such as \l QExposeEvent and \l QPlatformSurfaceEvent,
+
+ \li rendering a fullscreen textured quad, using a texture the contents of
+ which is generated in a QImage via QPainter (using the raster paint engine,
+ i.e. the generating of the image's pixel data is all CPU-based, that data
+ is then uploaded into a GPU texture),
+
+ \li rendering a triangle with blending and depth testing enabled, using a
+ perspective projection, while applying a model transform that changes on
+ every frame,
+
+ \li an efficient, cross-platform render loop using
+ \l{QWindow::requestUpdate()}{requestUpdate()}.
+
+ \endlist
+
+ \section1 Shaders
+
+ The application uses two sets of vertex and fragment shader pairs:
+
+ \list
+
+ \li one for the fullscreen quad, which uses no vertex inputs and the
+ fragment shader samples a texture (\c quad.vert, \c quad.frag),
+
+ \li and another pair for the triangle, where vertex positions and colors
+ are provided in a vertex buffer and a modelview-projection matrix is
+ provided in a uniform buffer (\c color.vert, \c color.frag).
+
+ \endlist
+
+ The shaders are written as Vulkan-compatible GLSL source code.
+
+ Due to being a Qt GUI module example, this example cannot have a dependency
+ on the \l{Qt Shader Tools} module. This means that CMake helper functions
+ such as \c{qt_add_shaders} are not available for use. Therefore, the
+ example has the pre-processed \c{.qsb} files included in the
+ \c{shaders/prebuilt} folder, and they are simply included within the
+ executable via \c{qt_add_resources}. This approach is not generally
+ recommended for applications, consider rather using \l{Qt Shader Tools
+ Build System Integration}{qt_add_shaders}, which avoids the need to
+ manually generate and manage the \c{.qsb} files.
+
+ To generate the \c{.qsb} files for this example, the command \c{qsb --qt6
+ color.vert -o prebuilt/color.vert.qsb} etc. was used. This leads to
+ compiling to \l{https://www.khronos.org/spir/}{SPIR-V} and than transpiling
+ into GLSL (\c{100 es} and \c 120), HLSL (5.0), and MSL (1.2). All the
+ shader versions are then packed together into a QShader and serialized to
+ disk.
+
+ \section1 API-specific Initialization
+
+ For some of the 3D APIs the main() function has to perform the appropriate
+ API-specific initialiation, e.g. to create a QVulkanInstance when using
+ Vulkan. For OpenGL we have to ensure a depth buffer is available, this is
+ done via QSurfaceFormat. These steps are not in the scope of QRhi since
+ QRhi backends for OpenGL or Vulkan build on the existing Qt facilities such
+ as QOpenGLContext or QVulkanInstance.
+
+ \snippet rhiwindow/main.cpp api-setup
+
+ \note For Vulkan, note how
+ QRhiVulkanInitParams::preferredInstanceExtensions() is taken into account
+ to ensure the appropriate extensions are enabled.
+
+ \c HelloWindow is a subclass of \c RhiWindow, which in turn is a QWindow.
+ \c RhiWindow contains everything needed to manage a resizable window with
+ a\ swapchain (and depth-stencil buffer), and is potentially reusable in
+ other applications as well. \c HelloWindow contains the rendering logic
+ specific to this particular example application.
+
+ In the QWindow subclass constructor the surface type is set based on the
+ selected 3D API.
+
+ \snippet rhiwindow/rhiwindow.cpp rhiwindow-ctor
+
+ Creating and initializing a QRhi object is implemented in
+ RhiWindow::init(). Note that this is invoked only when the window is
+ \c renderable, which is indicated by an \l{QExposeEvent}{expose event}.
+
+ Depending on which 3D API we use, the appropriate InitParams struct needs
+ to be passed to QRhi::create(). With OpenGL for example, a
+ QOffscreenSurface (or some other QSurface) must be created by the
+ application and provided for use to the QRhi. With Vulkan, a successfully
+ initialized QVulkanInstance is required. Others, such as Direct 3D or Metal
+ need no additional information to be able to initialize.
+
+ \snippet rhiwindow/rhiwindow.cpp rhi-init
+
+ Apart from this, everything else, all the rendering code, is fully
+ cross-platform and has no branching or conditions specific to any of the 3D
+ API.
+
+ \section1 Expose Events
+
+ What \c renderable exactly means is platform-specific. For example, on
+ macOS a window that is fully obscured (fully behind some other window) is
+ not renderable, whereas on Windows obscuring has no significance.
+ Fortunately, the application needs no special knowledge about this: Qt's
+ platform plugins abstract the differences behind the expose event. However,
+ the \l{QWindow::exposeEvent()}{exposeEvent()} reimplementation also needs
+ to be aware that an empty output size (e.g. width and height of 0) is also
+ something that should be treated as a non-renderable situation. On Windows
+ for example, this is what is going to happen when minimizing the window.
+ Hence the check based on QRhiSwapChain::surfacePixelSize().
+
+ This implementation of expose event handling attempts to be robust, safe,
+ and portable. Qt Quick itself also implements a very similar logic in its
+ render loops.
+
+ \snippet rhiwindow/rhiwindow.cpp expose
+
+ In RhiWindow::render(), which is invoked in response to the
+ \l{QEvent::UpdateRequest}{UpdateRequest} event generated by
+ \l{QWindow::requestUpdate()}{requestUpdate()}, the following check is in
+ place, to prevent attempting to render when the swapchain initialization
+ failed, or when the window became non-renderable.
+
+ \snippet rhiwindow/rhiwindow.cpp render-precheck
+
+ \section1 Swapchain, Depth-Stencil buffer, and Resizing
+
+ To render to the QWindow, a QRhiSwapChain is needed. In addition, a
+ QRhiRenderBuffer acting as the depth-stencil buffer is created as well
+ since the application demonstrates how depth testing can be enabled in a
+ graphics pipeline. With some legacy 3D APIs managing the depth/stencil
+ buffer for a window is part of the corresponding windowing system interface
+ API (EGL, WGL, GLX, etc., meaning the depth/stencil buffer is implicitly
+ managed together with the \c{window surface}), whereas with modern APIs
+ managing the depth-stencil buffer for a window-based render target is no
+ different from offscreen render targets. QRhi abstracts this, but for best
+ performance it still needs to be indicated that the QRhiRenderBuffer is
+ \l{QRhiRenderBuffer::UsedWithSwapChainOnly}{used with together with a
+ QRhiSwapChain}.
+
+ The QRhiSwapChain is associated with the QWindow and the depth/stencil
+ buffer.
+
+ \snippet rhiwindow/rhiwindow.h swapchain-data
+ \codeline
+ \snippet rhiwindow/rhiwindow.cpp swapchain-init
+
+ When the window size changes, the swapchain needs to be resized as well.
+ This is implemented in resizeSwapChain().
+
+ \snippet rhiwindow/rhiwindow.cpp swapchain-resize
+
+ Unlike other QRhiResource subclasses, QRhiSwapChain features slightly
+ different semantics when it comes to its create-function. As the name,
+ \l{QRhiSwapChain::createOrResize()}{createOrResize()}, suggests, this needs
+ to be called whenever it is known that the output window size may be out of
+ sync with what the swapchain was last initialized. The associated
+ QRhiRenderBuffer for depth-stencil gets its
+ \l{QRhiRenderBuffer::pixelSize()}{size} set automatically, and
+ \l{QRhiRenderBuffer::create()}{create()} is called on it implicitly from the
+ swapchain's createOrResize().
+
+ This is also a convenient place to (re)calculate the projection and view
+ matrices since the perspective projection we set up depends on the output
+ aspect ratio.
+
+ \note To eliminate coordinate system differences, the
+ \l{QRhi::clipSpaceCorrMatrix()}{a backend/API-specific "correction" matrix}
+ is queried from QRhi and baked in to the projection matrix. This is what
+ allows the application to work with OpenGL-style vertex data, assuming a
+ coordinate system with the origin at the bottom-left.
+
+ The resizeSwapChain() function is called from RhiWindow::render() when it
+ is discovered that the currently reported size is not the same anymore as
+ what the swapchain was last initialized with.
+
+ See QRhiSwapChain::currentPixelSize() and QRhiSwapChain::surfacePixelSize()
+ for further details.
+
+ High DPI support is built-in: the sizes, as the naming indicates, are
+ always in pixels, taking the window-specific
+ \l{QWindow::devicePixelRatio()}{scale factor} into account. On the QRhi
+ (and 3D API) level there is no concept of high DPI scaling, everything is
+ always in pixels. This means that a QWindow with a size() of 1280x720 and
+ a devicePixelRatio() of 2 is a render target (swapchain) with a (pixel) size
+ of 2560x1440.
+
+ \snippet rhiwindow/rhiwindow.cpp render-resize
+
+ \section1 Render Loop
+
+ The application renders continuously, throttled by the presentation rate
+ (vsync). This is ensured by calling
+ \l{QWindow::requestUpdate()}{requestUpdate()} from RhiWindow::render() when
+ the currently recorded frame has been submitted.
+
+ \snippet rhiwindow/rhiwindow.cpp request-update
+
+ This eventually leads to getting a \l{QEvent::UpdateRequest}{UpdateRequest}
+ event. This is handled in the reimplementation of event().
+
+ \snippet rhiwindow/rhiwindow.cpp event
+
+ \section1 Resource and Pipeline Setup
+
+ The application records a single render pass that issues two draw calls,
+ with two different graphics pipelines. One is the "background", with the
+ texture containing the QPainter-generated image, then a single triangle is
+ rendered on top with blending enabled.
+
+ The vertex and uniform buffer used with the triangle is created like this.
+ The size of the uniform buffer is 68 bytes since the shader specific a \c
+ mat4 and a \c float member in the uniform block. Watch out for the
+ \l{https://registry.khronos.org/OpenGL/specs/gl/glspec45.core.pdf#page=159}{std140
+ layout rules}. This presents no surprises in this example since the \c
+ float member that follows the \c mat4 has the correct alignment without any
+ additional padding, but it may become relevant in other applications,
+ especially when working with types such as \c vec2 or \c vec3. When in
+ doubt, consider checking the QShaderDescription for the
+ \l{QShader::description()}{QShader}, or, what is often more convenient, run
+ the \c qsb tool on the \c{.qsb} file with the \c{-d} argument to inspect
+ the metadata in human-readable form. The printed information includes,
+ among other things, the uniform block member offsets, sizes, and the total
+ size in bytes of each uniform block.
+
+ \snippet rhiwindow/rhiwindow.cpp render-init-1
+
+ The vertex and fragment shaders both need a uniform buffer at binding point
+ 0. This is ensured by the QRhiShaderResourceBindings object. The graphics
+ pipeline is then setup with the shaders and a number of additional
+ information. The example also relies on a number of convenient defaults,
+ e.g. the primitive topology is
+ \l{QRhiGraphicsPipeline::Triangles}{Triangles}, but that is the default,
+ and therefore it is not explicitly set. See QRhiGraphicsPipeline for
+ further details.
+
+ In addition to specifying the topology and various state, the pipeline must
+ also be associated with:
+
+ \list
+
+ \li The vertex input layout in form of a QRhiVertexInputLayout. This
+ specifies the type and component count for each vertex input location, the
+ total stride in bytes per vertex, and other related data.
+ QRhiVertexInputLayout only holds data, not actual native resources, and is
+ copiable.
+
+ \li A valid and successfully initialized QRhiShaderResourceBindings object.
+ This describes the layout of the resource bindings (uniform buffers,
+ textures, samplers) the shaders expect. This must either by the
+ QRhiShaderResourceBindings used when recording the draw calls, or another
+ that is
+ \l{QRhiShaderResourceBindings::isLayoutCompatible()}{layout-compatible with it}.
+ This simple application takes the former approach.
+
+ \li A valid QRhiRenderPassDescriptor object. This must be retrieved from,
+ or \l{QRhiRenderPassDescriptor::isCompatible()}{be compatible with} the
+ render target. The example uses the former, by creating a
+ QRhiRenderPassDescriptor object via
+ QRhiSwapChain::newCompatibleRenderPassDescriptor().
+
+ \endlist
+
+ \snippet rhiwindow/rhiwindow.cpp render-init-2
+
+ getShader() is a helper function that loads a \c{.qsb} file and
+ deserializes a QShader from it.
+
+ \snippet rhiwindow/rhiwindow.cpp getshader
+
+ The \c{color.vert} shader specifies the following as the vertex inputs:
+
+ \badcode
+ layout(location = 0) in vec4 position;
+ layout(location = 1) in vec3 color;
+ \endcode
+
+ The C++ code however provides vertex data as 2 floats for position, with 3
+ floats for the color interleaved. (\c x, \c y, \c r, \c g, \c b for each
+ vertex) This is why the stride is \c{5 * sizeof(float)} and the inputs for
+ locations 0 and 1 are specified as \c Float2 and \c Float3, respectively.
+ This is valid, and the \c z and \c w of the \c vec4 position will get set
+ automatically.
+
+ \section1 Rendering
+
+ Recording a frame is started by calling \l{QRhi::beginFrame()} and finished
+ by calling \l{QRhi::endFrame()}.
+
+ \snippet rhiwindow/rhiwindow.cpp beginframe
+
+ Some of the resources (buffers, textures) have static data in the
+ application, meaning the content never changes. The vertex buffer's content
+ is provided in the initialization step for example, and is not changed
+ afterwards. These data update operations are recorded in \c
+ m_initialUpdates. When not yet done, the commands on this resource update
+ batch are merged into the per-frame batch.
+
+ \snippet rhiwindow/rhiwindow.cpp render-1
+
+ Having a per-frame resource update batch is necessary since the uniform
+ buffer contents with the modelview-projection matrix and the opacity
+ changes on every frame.
+
+ \snippet rhiwindow/rhiwindow.cpp render-rotation
+
+ \snippet rhiwindow/rhiwindow.cpp render-opacity
+
+ To begin recording the render pass, a QRhiCommandBuffer is queried, and the
+ output size is determined, which will be useful for setting up the viewport
+ and resizing our fullscreen texture, if needed.
+
+ \snippet rhiwindow/rhiwindow.cpp render-cb
+
+ Starting a render pass implies clearing the render target's color and
+ depth-stencil buffers (unless the render target flags indicate otherwise,
+ but that is only an option for texture-based render targets). Here we
+ specify black for color, 1.0f for depth, and 0 for stencil (unused). The
+ last argument, \c resourceUpdates, is what ensures that the data update
+ commands recorded on the batch get committed. Alternatively, we could have
+ used QRhiCommandBuffer::resourceUpdate() instead. The render pass targets a
+ swapchain, hence calling
+ \l{QRhiSwapChain::currentFrameRenderTarget()}{currentFrameRenderTarget()}
+ to get a valid QRhiRenderTarget.
+
+ \snippet rhiwindow/rhiwindow.cpp render-pass
+
+ Recording the draw call for the triangle is straightforward: set the
+ pipeline, set the shader resources, set the vertex/index buffer(s), and
+ record the draw call. Here we use a non-indexed draw with just 3 vertices.
+
+ \snippet rhiwindow/rhiwindow.cpp render-pass-record
+
+ The \l{QRhiCommandBuffer::setShaderResources()}{setShaderResources()} call
+ has no arguments given, which implies using \c m_colorTriSrb since that was
+ associated with the active QRhiGraphicsPipeline (\c m_colorPipeline).
+
+ We will not dive into the details of the rendering of the fullscreen
+ background image. See the example source code for that. It is however worth
+ noting a common pattern for "resizing" a texture or buffer resource. There
+ is no such thing as changing the size of an existing native resource, so
+ changing a texture or buffer size must be followed by a call to create(),
+ to release and recreate the underlying native resources. To ensure that the
+ QRhiTexture always has the required size, the application implements the
+ following logic. Note that \c m_texture stays valid for the entire lifetime
+ of the window, which means object references to it, e.g. in a
+ QRhiShaderResourceBindings, continue to be valid all the time. It is only
+ the underlying native resources that come and go over time.
+
+ Note also that we set a device pixel ratio on the image that matches
+ the window that we're drawing into. This ensures that the drawing code
+ can be DPR-agnostic, producing the same layout regardless of the DPR,
+ while also taking advantage of the additional pixels for improved fidelity.
+
+ \snippet rhiwindow/rhiwindow.cpp ensure-texture
+
+ Once a QImage is generated and the QPainter-based drawing into it has
+ finished, we use
+ \l{QRhiResourceUpdateBatch::uploadTexture()}{uploadTexture()} to record a
+ texture upload on the resource update batch:
+
+ \snippet rhiwindow/rhiwindow.cpp ensure-texture-2
+
+ \sa QRhi, QRhiSwapChain, QWindow, QRhiCommandBuffer, QRhiResourceUpdateBatch, QRhiBuffer, QRhiTexture
+ */
diff --git a/examples/gui/gui.pro b/examples/gui/gui.pro
index 275adc804d..0696458db1 100644
--- a/examples/gui/gui.pro
+++ b/examples/gui/gui.pro
@@ -4,5 +4,5 @@ TEMPLATE = subdirs
QT_FOR_CONFIG += gui
CONFIG += no_docs_target
-SUBDIRS += analogclock
-SUBDIRS += rasterwindow
+SUBDIRS += rasterwindow \
+ rhiwindow
diff --git a/examples/gui/rasterwindow/.prev_CMakeLists.txt b/examples/gui/rasterwindow/.prev_CMakeLists.txt
deleted file mode 100644
index dddb5586db..0000000000
--- a/examples/gui/rasterwindow/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-# Generated from rasterwindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(rasterwindow LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/gui/rasterwindow")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-
-qt_add_executable(rasterwindow
- main.cpp
- rasterwindow.cpp rasterwindow.h
-)
-set_target_properties(rasterwindow PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_include_directories(rasterwindow PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}
-)
-
-target_link_libraries(rasterwindow PUBLIC
- Qt::Core
- Qt::Gui
-)
-
-install(TARGETS rasterwindow
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/gui/rasterwindow/CMakeLists.txt b/examples/gui/rasterwindow/CMakeLists.txt
index 845b52fc3e..7fb00895c9 100644
--- a/examples/gui/rasterwindow/CMakeLists.txt
+++ b/examples/gui/rasterwindow/CMakeLists.txt
@@ -1,43 +1,37 @@
-# Generated from rasterwindow.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(rasterwindow LANGUAGES CXX)
-find_package(Qt6 COMPONENTS Widgets) # special case: add
+find_package(Qt6 REQUIRED COMPONENTS Core Gui)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/gui/rasterwindow")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
+qt_standard_project_setup()
qt_add_executable(rasterwindow
main.cpp
rasterwindow.cpp rasterwindow.h
)
+
set_target_properties(rasterwindow PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_include_directories(rasterwindow PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}
-)
-target_link_libraries(rasterwindow PUBLIC
- Qt::Core
- Qt::Gui
+
+target_link_libraries(rasterwindow PRIVATE
+ Qt6::Core
+ Qt6::Gui
)
install(TARGETS rasterwindow
- 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 rasterwindow
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/gui/rasterwindow/main.cpp b/examples/gui/rasterwindow/main.cpp
index bd5c0df1fc..e70e98dcd5 100644
--- a/examples/gui/rasterwindow/main.cpp
+++ b/examples/gui/rasterwindow/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "rasterwindow.h"
diff --git a/examples/gui/rasterwindow/rasterwindow.cpp b/examples/gui/rasterwindow/rasterwindow.cpp
index 4dd2ac25ca..185ea76734 100644
--- a/examples/gui/rasterwindow/rasterwindow.cpp
+++ b/examples/gui/rasterwindow/rasterwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "rasterwindow.h"
diff --git a/examples/gui/rasterwindow/rasterwindow.h b/examples/gui/rasterwindow/rasterwindow.h
index 58c3ab89b2..504737dacf 100644
--- a/examples/gui/rasterwindow/rasterwindow.h
+++ b/examples/gui/rasterwindow/rasterwindow.h
@@ -1,58 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef RASTERWINDOW_H
#define RASTERWINDOW_H
//! [1]
#include <QtGui>
+#include <QScopedPointer>
class RasterWindow : public QWindow
{
@@ -73,7 +27,7 @@ protected:
void exposeEvent(QExposeEvent *event) override;
private:
- QBackingStore *m_backingStore;
+ QScopedPointer<QBackingStore> m_backingStore;
};
//! [1]
#endif // RASTERWINDOW_H
diff --git a/examples/gui/rhiwindow/CMakeLists.txt b/examples/gui/rhiwindow/CMakeLists.txt
new file mode 100644
index 0000000000..49b36286ee
--- /dev/null
+++ b/examples/gui/rhiwindow/CMakeLists.txt
@@ -0,0 +1,60 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(rhiwindow LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui)
+
+qt_standard_project_setup()
+
+qt_add_executable(rhiwindow
+ main.cpp
+ rhiwindow.cpp rhiwindow.h
+)
+
+set_target_properties(rhiwindow PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(rhiwindow PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::GuiPrivate
+)
+
+set_source_files_properties("shaders/prebuilt/color.vert.qsb"
+ PROPERTIES QT_RESOURCE_ALIAS "color.vert.qsb"
+)
+set_source_files_properties("shaders/prebuilt/color.frag.qsb"
+ PROPERTIES QT_RESOURCE_ALIAS "color.frag.qsb"
+)
+set_source_files_properties("shaders/prebuilt/quad.vert.qsb"
+ PROPERTIES QT_RESOURCE_ALIAS "quad.vert.qsb"
+)
+set_source_files_properties("shaders/prebuilt/quad.frag.qsb"
+ PROPERTIES QT_RESOURCE_ALIAS "quad.frag.qsb"
+)
+qt_add_resources(rhiwindow "rhiwindow"
+ PREFIX
+ "/"
+ FILES
+ "shaders/prebuilt/color.vert.qsb"
+ "shaders/prebuilt/color.frag.qsb"
+ "shaders/prebuilt/quad.vert.qsb"
+ "shaders/prebuilt/quad.frag.qsb"
+)
+
+install(TARGETS rhiwindow
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET rhiwindow
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/gui/rhiwindow/main.cpp b/examples/gui/rhiwindow/main.cpp
new file mode 100644
index 0000000000..37977e3a34
--- /dev/null
+++ b/examples/gui/rhiwindow/main.cpp
@@ -0,0 +1,110 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QGuiApplication>
+#include <QCommandLineParser>
+#include "rhiwindow.h"
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+
+ QRhi::Implementation graphicsApi;
+
+ // Use platform-specific defaults when no command-line arguments given.
+#if defined(Q_OS_WIN)
+ graphicsApi = QRhi::D3D11;
+#elif QT_CONFIG(metal)
+ graphicsApi = QRhi::Metal;
+#elif QT_CONFIG(vulkan)
+ graphicsApi = QRhi::Vulkan;
+#else
+ graphicsApi = QRhi::OpenGLES2;
+#endif
+
+ QCommandLineParser cmdLineParser;
+ cmdLineParser.addHelpOption();
+ QCommandLineOption nullOption({ "n", "null" }, QLatin1String("Null"));
+ cmdLineParser.addOption(nullOption);
+ QCommandLineOption glOption({ "g", "opengl" }, QLatin1String("OpenGL"));
+ cmdLineParser.addOption(glOption);
+ QCommandLineOption vkOption({ "v", "vulkan" }, QLatin1String("Vulkan"));
+ cmdLineParser.addOption(vkOption);
+ QCommandLineOption d3d11Option({ "d", "d3d11" }, QLatin1String("Direct3D 11"));
+ cmdLineParser.addOption(d3d11Option);
+ QCommandLineOption d3d12Option({ "D", "d3d12" }, QLatin1String("Direct3D 12"));
+ cmdLineParser.addOption(d3d12Option);
+ QCommandLineOption mtlOption({ "m", "metal" }, QLatin1String("Metal"));
+ cmdLineParser.addOption(mtlOption);
+
+ cmdLineParser.process(app);
+ if (cmdLineParser.isSet(nullOption))
+ graphicsApi = QRhi::Null;
+ if (cmdLineParser.isSet(glOption))
+ graphicsApi = QRhi::OpenGLES2;
+ if (cmdLineParser.isSet(vkOption))
+ graphicsApi = QRhi::Vulkan;
+ if (cmdLineParser.isSet(d3d11Option))
+ graphicsApi = QRhi::D3D11;
+ if (cmdLineParser.isSet(d3d12Option))
+ graphicsApi = QRhi::D3D12;
+ if (cmdLineParser.isSet(mtlOption))
+ graphicsApi = QRhi::Metal;
+
+ //! [api-setup]
+ // For OpenGL, to ensure there is a depth/stencil buffer for the window.
+ // With other APIs this is under the application's control (QRhiRenderBuffer etc.)
+ // and so no special setup is needed for those.
+ QSurfaceFormat fmt;
+ fmt.setDepthBufferSize(24);
+ fmt.setStencilBufferSize(8);
+ // Special case macOS to allow using OpenGL there.
+ // (the default Metal is the recommended approach, though)
+ // gl_VertexID is a GLSL 130 feature, and so the default OpenGL 2.1 context
+ // we get on macOS is not sufficient.
+#ifdef Q_OS_MACOS
+ fmt.setVersion(4, 1);
+ fmt.setProfile(QSurfaceFormat::CoreProfile);
+#endif
+ QSurfaceFormat::setDefaultFormat(fmt);
+
+ // For Vulkan.
+#if QT_CONFIG(vulkan)
+ QVulkanInstance inst;
+ if (graphicsApi == QRhi::Vulkan) {
+ // Request validation, if available. This is completely optional
+ // and has a performance impact, and should be avoided in production use.
+ inst.setLayers({ "VK_LAYER_KHRONOS_validation" });
+ // Play nice with QRhi.
+ inst.setExtensions(QRhiVulkanInitParams::preferredInstanceExtensions());
+ if (!inst.create()) {
+ qWarning("Failed to create Vulkan instance, switching to OpenGL");
+ graphicsApi = QRhi::OpenGLES2;
+ }
+ }
+#endif
+//! [api-setup]
+
+ HelloWindow window(graphicsApi);
+
+#if QT_CONFIG(vulkan)
+ if (graphicsApi == QRhi::Vulkan)
+ window.setVulkanInstance(&inst);
+#endif
+ window.resize(1280, 720);
+ window.setTitle(QCoreApplication::applicationName() + QLatin1String(" - ") + window.graphicsApiName());
+ window.show();
+
+ int ret = app.exec();
+
+ // RhiWindow::event() will not get invoked when the
+ // PlatformSurfaceAboutToBeDestroyed event is sent during the QWindow
+ // destruction. That happens only when exiting via app::quit() instead of
+ // the more common QWindow::close(). Take care of it: if the QPlatformWindow
+ // is still around (there was no close() yet), get rid of the swapchain
+ // while it's not too late.
+ if (window.handle())
+ window.releaseSwapChain();
+
+ return ret;
+}
diff --git a/examples/gui/rhiwindow/rhiwindow.cpp b/examples/gui/rhiwindow/rhiwindow.cpp
new file mode 100644
index 0000000000..3ae6faa802
--- /dev/null
+++ b/examples/gui/rhiwindow/rhiwindow.cpp
@@ -0,0 +1,436 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "rhiwindow.h"
+#include <QPlatformSurfaceEvent>
+#include <QPainter>
+#include <QFile>
+#include <rhi/qshader.h>
+
+//! [rhiwindow-ctor]
+RhiWindow::RhiWindow(QRhi::Implementation graphicsApi)
+ : m_graphicsApi(graphicsApi)
+{
+ switch (graphicsApi) {
+ case QRhi::OpenGLES2:
+ setSurfaceType(OpenGLSurface);
+ break;
+ case QRhi::Vulkan:
+ setSurfaceType(VulkanSurface);
+ break;
+ case QRhi::D3D11:
+ case QRhi::D3D12:
+ setSurfaceType(Direct3DSurface);
+ break;
+ case QRhi::Metal:
+ setSurfaceType(MetalSurface);
+ break;
+ case QRhi::Null:
+ break; // RasterSurface
+ }
+}
+//! [rhiwindow-ctor]
+
+QString RhiWindow::graphicsApiName() const
+{
+ switch (m_graphicsApi) {
+ case QRhi::Null:
+ return QLatin1String("Null (no output)");
+ case QRhi::OpenGLES2:
+ return QLatin1String("OpenGL");
+ case QRhi::Vulkan:
+ return QLatin1String("Vulkan");
+ case QRhi::D3D11:
+ return QLatin1String("Direct3D 11");
+ case QRhi::D3D12:
+ return QLatin1String("Direct3D 12");
+ case QRhi::Metal:
+ return QLatin1String("Metal");
+ }
+ return QString();
+}
+
+//! [expose]
+void RhiWindow::exposeEvent(QExposeEvent *)
+{
+ // initialize and start rendering when the window becomes usable for graphics purposes
+ if (isExposed() && !m_initialized) {
+ init();
+ resizeSwapChain();
+ m_initialized = true;
+ }
+
+ const QSize surfaceSize = m_hasSwapChain ? m_sc->surfacePixelSize() : QSize();
+
+ // stop pushing frames when not exposed (or size is 0)
+ if ((!isExposed() || (m_hasSwapChain && surfaceSize.isEmpty())) && m_initialized && !m_notExposed)
+ m_notExposed = true;
+
+ // Continue when exposed again and the surface has a valid size. Note that
+ // surfaceSize can be (0, 0) even though size() reports a valid one, hence
+ // trusting surfacePixelSize() and not QWindow.
+ if (isExposed() && m_initialized && m_notExposed && !surfaceSize.isEmpty()) {
+ m_notExposed = false;
+ m_newlyExposed = true;
+ }
+
+ // always render a frame on exposeEvent() (when exposed) in order to update
+ // immediately on window resize.
+ if (isExposed() && !surfaceSize.isEmpty())
+ render();
+}
+//! [expose]
+
+//! [event]
+bool RhiWindow::event(QEvent *e)
+{
+ switch (e->type()) {
+ case QEvent::UpdateRequest:
+ render();
+ break;
+
+ case QEvent::PlatformSurface:
+ // this is the proper time to tear down the swapchain (while the native window and surface are still around)
+ if (static_cast<QPlatformSurfaceEvent *>(e)->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed)
+ releaseSwapChain();
+ break;
+
+ default:
+ break;
+ }
+
+ return QWindow::event(e);
+}
+//! [event]
+
+//! [rhi-init]
+void RhiWindow::init()
+{
+ if (m_graphicsApi == QRhi::Null) {
+ QRhiNullInitParams params;
+ m_rhi.reset(QRhi::create(QRhi::Null, &params));
+ }
+
+#if QT_CONFIG(opengl)
+ if (m_graphicsApi == QRhi::OpenGLES2) {
+ m_fallbackSurface.reset(QRhiGles2InitParams::newFallbackSurface());
+ QRhiGles2InitParams params;
+ params.fallbackSurface = m_fallbackSurface.get();
+ params.window = this;
+ m_rhi.reset(QRhi::create(QRhi::OpenGLES2, &params));
+ }
+#endif
+
+#if QT_CONFIG(vulkan)
+ if (m_graphicsApi == QRhi::Vulkan) {
+ QRhiVulkanInitParams params;
+ params.inst = vulkanInstance();
+ params.window = this;
+ m_rhi.reset(QRhi::create(QRhi::Vulkan, &params));
+ }
+#endif
+
+#ifdef Q_OS_WIN
+ if (m_graphicsApi == QRhi::D3D11) {
+ QRhiD3D11InitParams params;
+ // Enable the debug layer, if available. This is optional
+ // and should be avoided in production builds.
+ params.enableDebugLayer = true;
+ m_rhi.reset(QRhi::create(QRhi::D3D11, &params));
+ } else if (m_graphicsApi == QRhi::D3D12) {
+ QRhiD3D12InitParams params;
+ // Enable the debug layer, if available. This is optional
+ // and should be avoided in production builds.
+ params.enableDebugLayer = true;
+ m_rhi.reset(QRhi::create(QRhi::D3D12, &params));
+ }
+#endif
+
+#if QT_CONFIG(metal)
+ if (m_graphicsApi == QRhi::Metal) {
+ QRhiMetalInitParams params;
+ m_rhi.reset(QRhi::create(QRhi::Metal, &params));
+ }
+#endif
+
+ if (!m_rhi)
+ qFatal("Failed to create RHI backend");
+//! [rhi-init]
+
+//! [swapchain-init]
+ m_sc.reset(m_rhi->newSwapChain());
+ m_ds.reset(m_rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil,
+ QSize(), // no need to set the size here, due to UsedWithSwapChainOnly
+ 1,
+ QRhiRenderBuffer::UsedWithSwapChainOnly));
+ m_sc->setWindow(this);
+ m_sc->setDepthStencil(m_ds.get());
+ m_rp.reset(m_sc->newCompatibleRenderPassDescriptor());
+ m_sc->setRenderPassDescriptor(m_rp.get());
+//! [swapchain-init]
+
+ customInit();
+}
+
+//! [swapchain-resize]
+void RhiWindow::resizeSwapChain()
+{
+ m_hasSwapChain = m_sc->createOrResize(); // also handles m_ds
+
+ const QSize outputSize = m_sc->currentPixelSize();
+ 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);
+}
+//! [swapchain-resize]
+
+void RhiWindow::releaseSwapChain()
+{
+ if (m_hasSwapChain) {
+ m_hasSwapChain = false;
+ m_sc->destroy();
+ }
+}
+
+//! [render-precheck]
+void RhiWindow::render()
+{
+ if (!m_hasSwapChain || m_notExposed)
+ return;
+//! [render-precheck]
+
+//! [render-resize]
+ // If the window got resized or newly exposed, resize the swapchain. (the
+ // newly-exposed case is not actually required by some platforms, but is
+ // here for robustness and portability)
+ //
+ // This (exposeEvent + the logic here) is the only safe way to perform
+ // resize handling. Note the usage of the RHI's surfacePixelSize(), and
+ // never QWindow::size(). (the two may or may not be the same under the hood,
+ // depending on the backend and platform)
+ //
+ if (m_sc->currentPixelSize() != m_sc->surfacePixelSize() || m_newlyExposed) {
+ resizeSwapChain();
+ if (!m_hasSwapChain)
+ return;
+ m_newlyExposed = false;
+ }
+//! [render-resize]
+
+//! [beginframe]
+ QRhi::FrameOpResult result = m_rhi->beginFrame(m_sc.get());
+ if (result == QRhi::FrameOpSwapChainOutOfDate) {
+ resizeSwapChain();
+ if (!m_hasSwapChain)
+ return;
+ result = m_rhi->beginFrame(m_sc.get());
+ }
+ if (result != QRhi::FrameOpSuccess) {
+ qWarning("beginFrame failed with %d, will retry", result);
+ requestUpdate();
+ return;
+ }
+
+ customRender();
+//! [beginframe]
+
+//! [request-update]
+ m_rhi->endFrame(m_sc.get());
+
+ // Always request the next frame via requestUpdate(). On some platforms this is backed
+ // by a platform-specific solution, e.g. CVDisplayLink on macOS, which is potentially
+ // more efficient than a timer, queued metacalls, etc.
+ requestUpdate();
+}
+//! [request-update]
+
+static float vertexData[] = {
+ // Y up (note clipSpaceCorrMatrix in m_viewProjection), CCW
+ 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,
+};
+
+//! [getshader]
+static QShader getShader(const QString &name)
+{
+ QFile f(name);
+ if (f.open(QIODevice::ReadOnly))
+ return QShader::fromSerialized(f.readAll());
+
+ return QShader();
+}
+//! [getshader]
+
+HelloWindow::HelloWindow(QRhi::Implementation graphicsApi)
+ : RhiWindow(graphicsApi)
+{
+}
+
+//! [ensure-texture]
+void HelloWindow::ensureFullscreenTexture(const QSize &pixelSize, QRhiResourceUpdateBatch *u)
+{
+ if (m_texture && m_texture->pixelSize() == pixelSize)
+ return;
+
+ if (!m_texture)
+ m_texture.reset(m_rhi->newTexture(QRhiTexture::RGBA8, pixelSize));
+ else
+ m_texture->setPixelSize(pixelSize);
+
+ m_texture->create();
+
+ QImage image(pixelSize, QImage::Format_RGBA8888_Premultiplied);
+ image.setDevicePixelRatio(devicePixelRatio());
+//! [ensure-texture]
+ QPainter painter(&image);
+ painter.fillRect(QRectF(QPointF(0, 0), size()), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f));
+ painter.setPen(Qt::transparent);
+ painter.setBrush({ QGradient(QGradient::DeepBlue) });
+ painter.drawRoundedRect(QRectF(QPointF(20, 20), size() - QSize(40, 40)), 16, 16);
+ painter.setPen(Qt::black);
+ QFont font;
+ font.setPixelSize(0.05 * qMin(width(), height()));
+ painter.setFont(font);
+ painter.drawText(QRectF(QPointF(60, 60), size() - QSize(120, 120)), 0,
+ QLatin1String("Rendering with QRhi to a resizable QWindow.\nThe 3D API is %1.\nUse the command-line options to choose a different API.")
+ .arg(graphicsApiName()));
+ painter.end();
+
+ if (m_rhi->isYUpInNDC())
+ image = image.mirrored();
+
+//! [ensure-texture-2]
+ u->uploadTexture(m_texture.get(), image);
+//! [ensure-texture-2]
+}
+
+//! [render-init-1]
+void HelloWindow::customInit()
+{
+ m_initialUpdates = m_rhi->nextResourceUpdateBatch();
+
+ m_vbuf.reset(m_rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(vertexData)));
+ m_vbuf->create();
+ m_initialUpdates->uploadStaticBuffer(m_vbuf.get(), vertexData);
+
+ static const quint32 UBUF_SIZE = 68;
+ m_ubuf.reset(m_rhi->newBuffer(QRhiBuffer::Dynamic, QRhiBuffer::UniformBuffer, UBUF_SIZE));
+ m_ubuf->create();
+//! [render-init-1]
+
+ ensureFullscreenTexture(m_sc->surfacePixelSize(), m_initialUpdates);
+
+ m_sampler.reset(m_rhi->newSampler(QRhiSampler::Linear, QRhiSampler::Linear, QRhiSampler::None,
+ QRhiSampler::ClampToEdge, QRhiSampler::ClampToEdge));
+ m_sampler->create();
+
+ //! [render-init-2]
+ m_colorTriSrb.reset(m_rhi->newShaderResourceBindings());
+ static const QRhiShaderResourceBinding::StageFlags visibility =
+ QRhiShaderResourceBinding::VertexStage | QRhiShaderResourceBinding::FragmentStage;
+ m_colorTriSrb->setBindings({
+ QRhiShaderResourceBinding::uniformBuffer(0, visibility, m_ubuf.get())
+ });
+ m_colorTriSrb->create();
+
+ m_colorPipeline.reset(m_rhi->newGraphicsPipeline());
+ // Enable depth testing; not quite needed for a simple triangle, but we
+ // have a depth-stencil buffer so why not.
+ m_colorPipeline->setDepthTest(true);
+ m_colorPipeline->setDepthWrite(true);
+ // Blend factors default to One, OneOneMinusSrcAlpha, which is convenient.
+ QRhiGraphicsPipeline::TargetBlend premulAlphaBlend;
+ premulAlphaBlend.enable = true;
+ m_colorPipeline->setTargetBlends({ premulAlphaBlend });
+ m_colorPipeline->setShaderStages({
+ { QRhiShaderStage::Vertex, getShader(QLatin1String(":/color.vert.qsb")) },
+ { QRhiShaderStage::Fragment, getShader(QLatin1String(":/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_colorPipeline->setVertexInputLayout(inputLayout);
+ m_colorPipeline->setShaderResourceBindings(m_colorTriSrb.get());
+ m_colorPipeline->setRenderPassDescriptor(m_rp.get());
+ m_colorPipeline->create();
+//! [render-init-2]
+
+ m_fullscreenQuadSrb.reset(m_rhi->newShaderResourceBindings());
+ m_fullscreenQuadSrb->setBindings({
+ QRhiShaderResourceBinding::sampledTexture(0, QRhiShaderResourceBinding::FragmentStage,
+ m_texture.get(), m_sampler.get())
+ });
+ m_fullscreenQuadSrb->create();
+
+ m_fullscreenQuadPipeline.reset(m_rhi->newGraphicsPipeline());
+ m_fullscreenQuadPipeline->setShaderStages({
+ { QRhiShaderStage::Vertex, getShader(QLatin1String(":/quad.vert.qsb")) },
+ { QRhiShaderStage::Fragment, getShader(QLatin1String(":/quad.frag.qsb")) }
+ });
+ m_fullscreenQuadPipeline->setVertexInputLayout({});
+ m_fullscreenQuadPipeline->setShaderResourceBindings(m_fullscreenQuadSrb.get());
+ m_fullscreenQuadPipeline->setRenderPassDescriptor(m_rp.get());
+ m_fullscreenQuadPipeline->create();
+}
+
+//! [render-1]
+void HelloWindow::customRender()
+{
+ QRhiResourceUpdateBatch *resourceUpdates = m_rhi->nextResourceUpdateBatch();
+
+ if (m_initialUpdates) {
+ resourceUpdates->merge(m_initialUpdates);
+ m_initialUpdates->release();
+ m_initialUpdates = nullptr;
+ }
+//! [render-1]
+
+//! [render-rotation]
+ 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-rotation]
+
+//! [render-opacity]
+ m_opacity += m_opacityDir * 0.005f;
+ if (m_opacity < 0.0f || m_opacity > 1.0f) {
+ m_opacityDir *= -1;
+ m_opacity = qBound(0.0f, m_opacity, 1.0f);
+ }
+ resourceUpdates->updateDynamicBuffer(m_ubuf.get(), 64, 4, &m_opacity);
+//! [render-opacity]
+
+//! [render-cb]
+ QRhiCommandBuffer *cb = m_sc->currentFrameCommandBuffer();
+ const QSize outputSizeInPixels = m_sc->currentPixelSize();
+//! [render-cb]
+
+ // (re)create the texture with a size matching the output surface size, when necessary.
+ ensureFullscreenTexture(outputSizeInPixels, resourceUpdates);
+
+//! [render-pass]
+ cb->beginPass(m_sc->currentFrameRenderTarget(), Qt::black, { 1.0f, 0 }, resourceUpdates);
+//! [render-pass]
+
+ cb->setGraphicsPipeline(m_fullscreenQuadPipeline.get());
+ cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) });
+ cb->setShaderResources();
+ cb->draw(3);
+
+//! [render-pass-record]
+ cb->setGraphicsPipeline(m_colorPipeline.get());
+ cb->setShaderResources();
+ const QRhiCommandBuffer::VertexInput vbufBinding(m_vbuf.get(), 0);
+ cb->setVertexInput(0, 1, &vbufBinding);
+ cb->draw(3);
+
+ cb->endPass();
+//! [render-pass-record]
+}
diff --git a/examples/gui/rhiwindow/rhiwindow.h b/examples/gui/rhiwindow/rhiwindow.h
new file mode 100644
index 0000000000..520c3e8c0a
--- /dev/null
+++ b/examples/gui/rhiwindow/rhiwindow.h
@@ -0,0 +1,78 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef WINDOW_H
+#define WINDOW_H
+
+#include <QWindow>
+#include <QOffscreenSurface>
+#include <rhi/qrhi.h>
+
+class RhiWindow : public QWindow
+{
+public:
+ RhiWindow(QRhi::Implementation graphicsApi);
+ QString graphicsApiName() const;
+ void releaseSwapChain();
+
+protected:
+ virtual void customInit() = 0;
+ virtual void customRender() = 0;
+
+ // destruction order matters to a certain degree: the fallbackSurface must
+ // outlive the rhi, the rhi must outlive all other resources. The resources
+ // need no special order when destroying.
+#if QT_CONFIG(opengl)
+ std::unique_ptr<QOffscreenSurface> m_fallbackSurface;
+#endif
+ std::unique_ptr<QRhi> m_rhi;
+//! [swapchain-data]
+ std::unique_ptr<QRhiSwapChain> m_sc;
+ std::unique_ptr<QRhiRenderBuffer> m_ds;
+ std::unique_ptr<QRhiRenderPassDescriptor> m_rp;
+//! [swapchain-data]
+ bool m_hasSwapChain = false;
+ QMatrix4x4 m_viewProjection;
+
+private:
+ void init();
+ void resizeSwapChain();
+ void render();
+
+ void exposeEvent(QExposeEvent *) override;
+ bool event(QEvent *) override;
+
+ QRhi::Implementation m_graphicsApi;
+ bool m_initialized = false;
+ bool m_notExposed = false;
+ bool m_newlyExposed = false;
+};
+
+class HelloWindow : public RhiWindow
+{
+public:
+ HelloWindow(QRhi::Implementation graphicsApi);
+
+ void customInit() override;
+ void customRender() override;
+
+private:
+ void ensureFullscreenTexture(const QSize &pixelSize, QRhiResourceUpdateBatch *u);
+
+ std::unique_ptr<QRhiBuffer> m_vbuf;
+ std::unique_ptr<QRhiBuffer> m_ubuf;
+ std::unique_ptr<QRhiTexture> m_texture;
+ std::unique_ptr<QRhiSampler> m_sampler;
+ std::unique_ptr<QRhiShaderResourceBindings> m_colorTriSrb;
+ std::unique_ptr<QRhiGraphicsPipeline> m_colorPipeline;
+ std::unique_ptr<QRhiShaderResourceBindings> m_fullscreenQuadSrb;
+ std::unique_ptr<QRhiGraphicsPipeline> m_fullscreenQuadPipeline;
+
+ QRhiResourceUpdateBatch *m_initialUpdates = nullptr;
+
+ float m_rotation = 0;
+ float m_opacity = 1;
+ int m_opacityDir = -1;
+};
+
+#endif
diff --git a/examples/gui/rhiwindow/rhiwindow.pri b/examples/gui/rhiwindow/rhiwindow.pri
new file mode 100644
index 0000000000..d0ef7a2699
--- /dev/null
+++ b/examples/gui/rhiwindow/rhiwindow.pri
@@ -0,0 +1,4 @@
+INCLUDEPATH += $$PWD
+SOURCES += $$PWD/rhiwindow.cpp
+HEADERS += $$PWD/rhiwindow.h
+RESOURCES += $$PWD/rhiwindow.qrc
diff --git a/examples/gui/rhiwindow/rhiwindow.pro b/examples/gui/rhiwindow/rhiwindow.pro
new file mode 100644
index 0000000000..18f259aaf6
--- /dev/null
+++ b/examples/gui/rhiwindow/rhiwindow.pro
@@ -0,0 +1,9 @@
+include(rhiwindow.pri)
+
+QT += gui-private
+
+SOURCES += \
+ main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/gui/rhiwindow
+INSTALLS += target
diff --git a/examples/gui/rhiwindow/rhiwindow.qrc b/examples/gui/rhiwindow/rhiwindow.qrc
new file mode 100644
index 0000000000..1009ec5dda
--- /dev/null
+++ b/examples/gui/rhiwindow/rhiwindow.qrc
@@ -0,0 +1,8 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file alias="color.vert.qsb">shaders/prebuilt/color.vert.qsb</file>
+ <file alias="color.frag.qsb">shaders/prebuilt/color.frag.qsb</file>
+ <file alias="quad.vert.qsb">shaders/prebuilt/quad.vert.qsb</file>
+ <file alias="quad.frag.qsb">shaders/prebuilt/quad.frag.qsb</file>
+</qresource>
+</RCC>
diff --git a/examples/gui/rhiwindow/shaders/color.frag b/examples/gui/rhiwindow/shaders/color.frag
new file mode 100644
index 0000000000..6e0a3bc91f
--- /dev/null
+++ b/examples/gui/rhiwindow/shaders/color.frag
@@ -0,0 +1,15 @@
+#version 440
+
+layout(location = 0) in vec3 v_color;
+
+layout(location = 0) out vec4 fragColor;
+
+layout(std140, binding = 0) uniform buf {
+ mat4 mvp;
+ float opacity;
+};
+
+void main()
+{
+ fragColor = vec4(v_color * opacity, opacity);
+}
diff --git a/examples/gui/rhiwindow/shaders/color.vert b/examples/gui/rhiwindow/shaders/color.vert
new file mode 100644
index 0000000000..70852ab86c
--- /dev/null
+++ b/examples/gui/rhiwindow/shaders/color.vert
@@ -0,0 +1,17 @@
+#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;
+ float opacity;
+};
+
+void main()
+{
+ v_color = color;
+ gl_Position = mvp * position;
+}
diff --git a/examples/gui/rhiwindow/shaders/prebuilt/color.frag.qsb b/examples/gui/rhiwindow/shaders/prebuilt/color.frag.qsb
new file mode 100644
index 0000000000..b4db470e5b
--- /dev/null
+++ b/examples/gui/rhiwindow/shaders/prebuilt/color.frag.qsb
Binary files differ
diff --git a/examples/gui/rhiwindow/shaders/prebuilt/color.vert.qsb b/examples/gui/rhiwindow/shaders/prebuilt/color.vert.qsb
new file mode 100644
index 0000000000..ab046b77f8
--- /dev/null
+++ b/examples/gui/rhiwindow/shaders/prebuilt/color.vert.qsb
Binary files differ
diff --git a/examples/gui/rhiwindow/shaders/prebuilt/quad.frag.qsb b/examples/gui/rhiwindow/shaders/prebuilt/quad.frag.qsb
new file mode 100644
index 0000000000..c2ea3cf251
--- /dev/null
+++ b/examples/gui/rhiwindow/shaders/prebuilt/quad.frag.qsb
Binary files differ
diff --git a/examples/gui/rhiwindow/shaders/prebuilt/quad.vert.qsb b/examples/gui/rhiwindow/shaders/prebuilt/quad.vert.qsb
new file mode 100644
index 0000000000..f0b64f7500
--- /dev/null
+++ b/examples/gui/rhiwindow/shaders/prebuilt/quad.vert.qsb
Binary files differ
diff --git a/examples/gui/rhiwindow/shaders/quad.frag b/examples/gui/rhiwindow/shaders/quad.frag
new file mode 100644
index 0000000000..65882a4292
--- /dev/null
+++ b/examples/gui/rhiwindow/shaders/quad.frag
@@ -0,0 +1,11 @@
+#version 440
+
+layout(location = 0) in vec2 v_uv;
+layout(location = 0) out vec4 fragColor;
+layout(binding = 0) uniform sampler2D tex;
+
+void main()
+{
+ vec4 c = texture(tex, v_uv);
+ fragColor = vec4(c.rgb * c.a, c.a);
+}
diff --git a/examples/gui/rhiwindow/shaders/quad.vert b/examples/gui/rhiwindow/shaders/quad.vert
new file mode 100644
index 0000000000..359896d080
--- /dev/null
+++ b/examples/gui/rhiwindow/shaders/quad.vert
@@ -0,0 +1,10 @@
+#version 440
+
+layout (location = 0) out vec2 v_uv;
+
+void main()
+{
+ // https://www.saschawillems.de/blog/2016/08/13/vulkan-tutorial-on-rendering-a-fullscreen-quad-without-buffers/
+ v_uv = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
+ gl_Position = vec4(v_uv * 2.0 - 1.0, 0.0, 1.0);
+}
diff --git a/examples/network/.prev_CMakeLists.txt b/examples/network/.prev_CMakeLists.txt
deleted file mode 100644
index c28c951b69..0000000000
--- a/examples/network/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Generated from network.pro.
-
-if(NOT TARGET Qt::Network)
- return()
-endif()
-add_subdirectory(download)
-add_subdirectory(downloadmanager)
-if(NOT INTEGRITY)
- add_subdirectory(dnslookup)
-endif()
-if(TARGET Qt::Widgets)
- add_subdirectory(blockingfortuneclient)
- add_subdirectory(broadcastreceiver)
- add_subdirectory(broadcastsender)
- add_subdirectory(http)
- add_subdirectory(loopback)
- add_subdirectory(threadedfortuneserver)
- add_subdirectory(googlesuggest)
- add_subdirectory(torrent)
- add_subdirectory(multicastreceiver)
- add_subdirectory(multicastsender)
- add_subdirectory(fortuneclient)
- add_subdirectory(fortuneserver)
-endif()
-if(QT_FEATURE_processenvironment AND TARGET Qt::Widgets)
- add_subdirectory(network-chat)
-endif()
-if(QT_FEATURE_ssl AND TARGET Qt::Widgets)
- add_subdirectory(securesocketclient)
-endif()
-if(QT_FEATURE_dtls AND TARGET Qt::Widgets)
- add_subdirectory(secureudpserver)
- add_subdirectory(secureudpclient)
-endif()
-if(QT_FEATURE_sctp AND TARGET Qt::Widgets)
- add_subdirectory(multistreamserver)
- add_subdirectory(multistreamclient)
-endif()
diff --git a/examples/network/CMakeLists.txt b/examples/network/CMakeLists.txt
index b6ae618d1d..6222bb7c8b 100644
--- a/examples/network/CMakeLists.txt
+++ b/examples/network/CMakeLists.txt
@@ -1,38 +1,36 @@
-# Generated from network.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-if(NOT TARGET Qt::Network)
+if(NOT TARGET Qt6::Network)
return()
endif()
-add_subdirectory(download)
-add_subdirectory(downloadmanager)
-if(NOT INTEGRITY)
- add_subdirectory(dnslookup)
+if(NOT INTEGRITY AND NOT ANDROID)
+ qt_internal_add_example(dnslookup)
endif()
-if(TARGET Qt::Widgets)
- add_subdirectory(blockingfortuneclient)
- add_subdirectory(broadcastreceiver)
- add_subdirectory(broadcastsender)
- add_subdirectory(http)
- add_subdirectory(loopback)
- add_subdirectory(threadedfortuneserver)
- add_subdirectory(googlesuggest)
- # add_subdirectory(torrent) FIXME: This does not find its ui file:-/ # special case
- add_subdirectory(multicastreceiver)
- add_subdirectory(multicastsender)
- add_subdirectory(fortuneclient)
- add_subdirectory(fortuneserver)
+if(TARGET Qt6::Widgets)
+ qt_internal_add_example(blockingfortuneclient)
+ qt_internal_add_example(broadcastreceiver)
+ qt_internal_add_example(broadcastsender)
+ qt_internal_add_example(http)
+ qt_internal_add_example(threadedfortuneserver)
+ qt_internal_add_example(torrent)
+ qt_internal_add_example(multicastreceiver)
+ qt_internal_add_example(multicastsender)
+ qt_internal_add_example(fortuneclient)
+ qt_internal_add_example(fortuneserver)
+ qt_internal_add_example(rsslisting)
endif()
-if(QT_FEATURE_processenvironment AND TARGET Qt::Widgets)
- add_subdirectory(network-chat)
+if(QT_FEATURE_processenvironment AND TARGET Qt6::Widgets)
+ qt_internal_add_example(network-chat)
endif()
-if(QT_FEATURE_ssl AND TARGET Qt::Widgets)
- add_subdirectory(securesocketclient)
+if(QT_FEATURE_ssl AND TARGET Qt6::Widgets)
+ qt_internal_add_example(securesocketclient)
endif()
-if(QT_FEATURE_dtls AND TARGET Qt::Widgets)
- add_subdirectory(secureudpserver)
- add_subdirectory(secureudpclient)
+if(QT_FEATURE_dtls AND TARGET Qt6::Widgets)
+ qt_internal_add_example(secureudpserver)
+ qt_internal_add_example(secureudpclient)
endif()
-if(QT_FEATURE_sctp AND TARGET Qt::Widgets)
- add_subdirectory(multistreamserver)
- add_subdirectory(multistreamclient)
+if(QT_FEATURE_sctp AND TARGET Qt6::Widgets)
+ qt_internal_add_example(multistreamserver)
+ qt_internal_add_example(multistreamclient)
endif()
diff --git a/examples/network/blockingfortuneclient/CMakeLists.txt b/examples/network/blockingfortuneclient/CMakeLists.txt
index 44a4a68e39..de010f3805 100644
--- a/examples/network/blockingfortuneclient/CMakeLists.txt
+++ b/examples/network/blockingfortuneclient/CMakeLists.txt
@@ -1,43 +1,40 @@
-# Generated from blockingfortuneclient.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(blockingfortuneclient LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/blockingfortuneclient")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(blockingfortuneclient
blockingclient.cpp blockingclient.h
fortunethread.cpp fortunethread.h
main.cpp
)
+
set_target_properties(blockingfortuneclient PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(blockingfortuneclient PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(blockingfortuneclient PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS blockingfortuneclient
- 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 blockingfortuneclient
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/blockingfortuneclient/blockingclient.cpp b/examples/network/blockingfortuneclient/blockingclient.cpp
index 5a1500d084..b530e052f6 100644
--- a/examples/network/blockingfortuneclient/blockingclient.cpp
+++ b/examples/network/blockingfortuneclient/blockingclient.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include <QtNetwork>
@@ -61,12 +14,11 @@ BlockingClient::BlockingClient(QWidget *parent)
// find out which IP to connect to
QString ipAddress;
- QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
+ const QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
// use the first non-localhost IPv4 address
- for (int i = 0; i < ipAddressesList.size(); ++i) {
- if (ipAddressesList.at(i) != QHostAddress::LocalHost &&
- ipAddressesList.at(i).toIPv4Address()) {
- ipAddress = ipAddressesList.at(i).toString();
+ for (const QHostAddress &entry : ipAddressesList) {
+ if (entry != QHostAddress::LocalHost && entry.toIPv4Address()) {
+ ipAddress = entry.toString();
break;
}
}
diff --git a/examples/network/blockingfortuneclient/blockingclient.h b/examples/network/blockingfortuneclient/blockingclient.h
index b8a7163160..bb00007f80 100644
--- a/examples/network/blockingfortuneclient/blockingclient.h
+++ b/examples/network/blockingfortuneclient/blockingclient.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef BLOCKINGCLIENT_H
#define BLOCKINGCLIENT_H
diff --git a/examples/network/blockingfortuneclient/fortunethread.cpp b/examples/network/blockingfortuneclient/fortunethread.cpp
index 67ac7ebfa5..464482e17b 100644
--- a/examples/network/blockingfortuneclient/fortunethread.cpp
+++ b/examples/network/blockingfortuneclient/fortunethread.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtNetwork>
@@ -109,7 +62,7 @@ void FortuneThread::run()
//! [8] //! [11]
QDataStream in(&socket);
- in.setVersion(QDataStream::Qt_4_0);
+ in.setVersion(QDataStream::Qt_6_5);
QString fortune;
//! [11] //! [12]
diff --git a/examples/network/blockingfortuneclient/fortunethread.h b/examples/network/blockingfortuneclient/fortunethread.h
index b6b63d9319..e01194f03b 100644
--- a/examples/network/blockingfortuneclient/fortunethread.h
+++ b/examples/network/blockingfortuneclient/fortunethread.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FORTUNETHREAD_H
#define FORTUNETHREAD_H
diff --git a/examples/network/blockingfortuneclient/main.cpp b/examples/network/blockingfortuneclient/main.cpp
index 128760c3b2..66870fcd87 100644
--- a/examples/network/blockingfortuneclient/main.cpp
+++ b/examples/network/blockingfortuneclient/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/network/broadcastreceiver/CMakeLists.txt b/examples/network/broadcastreceiver/CMakeLists.txt
index ecc322d86a..fca4b8d48e 100644
--- a/examples/network/broadcastreceiver/CMakeLists.txt
+++ b/examples/network/broadcastreceiver/CMakeLists.txt
@@ -1,42 +1,39 @@
-# Generated from broadcastreceiver.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(broadcastreceiver LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/broadcastreceiver")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(broadcastreceiver
main.cpp
receiver.cpp receiver.h
)
+
set_target_properties(broadcastreceiver PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(broadcastreceiver PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(broadcastreceiver PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS broadcastreceiver
- 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 broadcastreceiver
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/broadcastreceiver/main.cpp b/examples/network/broadcastreceiver/main.cpp
index ba1beeee12..53905c806d 100644
--- a/examples/network/broadcastreceiver/main.cpp
+++ b/examples/network/broadcastreceiver/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/network/broadcastreceiver/receiver.cpp b/examples/network/broadcastreceiver/receiver.cpp
index 5b932a27b9..ffade9992c 100644
--- a/examples/network/broadcastreceiver/receiver.cpp
+++ b/examples/network/broadcastreceiver/receiver.cpp
@@ -1,57 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QLabel>
#include <QPushButton>
#include <QUdpSocket>
#include <QVBoxLayout>
+#include <QCoreApplication>
#include "receiver.h"
@@ -73,7 +27,7 @@ Receiver::Receiver(QWidget *parent)
this, &Receiver::processPendingDatagrams);
//! [1]
connect(quitButton, &QPushButton::clicked,
- this, &Receiver::close);
+ qApp, &QCoreApplication::quit);
auto buttonLayout = new QHBoxLayout;
buttonLayout->addStretch(1);
diff --git a/examples/network/broadcastreceiver/receiver.h b/examples/network/broadcastreceiver/receiver.h
index e6f8d97c23..e1eb6c8588 100644
--- a/examples/network/broadcastreceiver/receiver.h
+++ b/examples/network/broadcastreceiver/receiver.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef RECEIVER_H
#define RECEIVER_H
diff --git a/examples/network/broadcastsender/CMakeLists.txt b/examples/network/broadcastsender/CMakeLists.txt
index 4c371d6494..447fcd5425 100644
--- a/examples/network/broadcastsender/CMakeLists.txt
+++ b/examples/network/broadcastsender/CMakeLists.txt
@@ -1,42 +1,39 @@
-# Generated from broadcastsender.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(broadcastsender LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/broadcastsender")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(broadcastsender
main.cpp
sender.cpp sender.h
)
+
set_target_properties(broadcastsender PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(broadcastsender PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(broadcastsender PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS broadcastsender
- 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 broadcastsender
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/broadcastsender/main.cpp b/examples/network/broadcastsender/main.cpp
index b1ccc78cea..4135aa9373 100644
--- a/examples/network/broadcastsender/main.cpp
+++ b/examples/network/broadcastsender/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/network/broadcastsender/sender.cpp b/examples/network/broadcastsender/sender.cpp
index ee4896e9dd..622d3f9616 100644
--- a/examples/network/broadcastsender/sender.cpp
+++ b/examples/network/broadcastsender/sender.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include <QtNetwork>
@@ -72,7 +25,7 @@ Sender::Sender(QWidget *parent)
//! [0]
connect(startButton, &QPushButton::clicked, this, &Sender::startBroadcasting);
- connect(quitButton, &QPushButton::clicked, this, &Sender::close);
+ connect(quitButton, &QPushButton::clicked, qApp, &QCoreApplication::quit);
connect(&timer, &QTimer::timeout, this, &Sender::broadcastDatagram);
auto mainLayout = new QVBoxLayout;
diff --git a/examples/network/broadcastsender/sender.h b/examples/network/broadcastsender/sender.h
index f91c7769ec..656b9bcd2e 100644
--- a/examples/network/broadcastsender/sender.h
+++ b/examples/network/broadcastsender/sender.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SENDER_H
#define SENDER_H
diff --git a/examples/network/dnslookup/CMakeLists.txt b/examples/network/dnslookup/CMakeLists.txt
index 5e68adb224..b1baef23d9 100644
--- a/examples/network/dnslookup/CMakeLists.txt
+++ b/examples/network/dnslookup/CMakeLists.txt
@@ -1,37 +1,35 @@
-# Generated from dnslookup.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(dnslookup LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+if (ANDROID)
+ message(FATAL_ERROR "This project cannot be built on Android.")
endif()
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/dnslookup")
+find_package(Qt6 REQUIRED COMPONENTS Core Network)
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Network)
+qt_standard_project_setup()
qt_add_executable(dnslookup
dnslookup.cpp dnslookup.h
)
-set_target_properties(dnslookup PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(dnslookup PUBLIC
- Qt::Core
- Qt::Network
+
+target_link_libraries(dnslookup PRIVATE
+ Qt6::Core
+ Qt6::Network
)
install(TARGETS dnslookup
- 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 dnslookup
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/dnslookup/dnslookup.cpp b/examples/network/dnslookup/dnslookup.cpp
index 61f8d35a3d..9e74ddcf42 100644
--- a/examples/network/dnslookup/dnslookup.cpp
+++ b/examples/network/dnslookup/dnslookup.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Jeremy Lainé <jeremy.laine@m4x.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Jeremy Lainé <jeremy.laine@m4x.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "dnslookup.h"
@@ -58,43 +11,51 @@
#include <QCommandLineParser>
#include <QCommandLineOption>
-#include <stdio.h>
+#include <cstdio>
-static int typeFromParameter(const QString &type)
+using namespace Qt::StringLiterals;
+
+static std::optional<QDnsLookup::Type> typeFromParameter(QStringView type)
{
- if (type == "a")
+ if (type.compare(u"a", Qt::CaseInsensitive) == 0)
return QDnsLookup::A;
- if (type == "aaaa")
+ if (type.compare(u"aaaa", Qt::CaseInsensitive) == 0)
return QDnsLookup::AAAA;
- if (type == "any")
+ if (type.compare(u"any", Qt::CaseInsensitive) == 0)
return QDnsLookup::ANY;
- if (type == "cname")
+ if (type.compare(u"cname", Qt::CaseInsensitive) == 0)
return QDnsLookup::CNAME;
- if (type == "mx")
+ if (type.compare(u"mx", Qt::CaseInsensitive) == 0)
return QDnsLookup::MX;
- if (type == "ns")
+ if (type.compare(u"ns", Qt::CaseInsensitive) == 0)
return QDnsLookup::NS;
- if (type == "ptr")
+ if (type.compare(u"ptr", Qt::CaseInsensitive) == 0)
return QDnsLookup::PTR;
- if (type == "srv")
+ if (type.compare(u"srv", Qt::CaseInsensitive) == 0)
return QDnsLookup::SRV;
- if (type == "txt")
+ if (type.compare(u"txt", Qt::CaseInsensitive) == 0)
return QDnsLookup::TXT;
- return -1;
+ return std::nullopt;
}
//! [0]
-enum CommandLineParseResult
+struct CommandLineParseResult
{
- CommandLineOk,
- CommandLineError,
- CommandLineVersionRequested,
- CommandLineHelpRequested
+ enum class Status {
+ Ok,
+ Error,
+ VersionRequested,
+ HelpRequested
+ };
+ Status statusCode = Status::Ok;
+ std::optional<QString> errorString = std::nullopt;
};
-CommandLineParseResult parseCommandLine(QCommandLineParser &parser, DnsQuery *query, QString *errorMessage)
+CommandLineParseResult parseCommandLine(QCommandLineParser &parser, DnsQuery *query)
{
+ using Status = CommandLineParseResult::Status;
+
parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
const QCommandLineOption nameServerOption("n", "The name server to use.", "nameserver");
parser.addOption(nameServerOption);
@@ -104,48 +65,41 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, DnsQuery *qu
const QCommandLineOption helpOption = parser.addHelpOption();
const QCommandLineOption versionOption = parser.addVersionOption();
- if (!parser.parse(QCoreApplication::arguments())) {
- *errorMessage = parser.errorText();
- return CommandLineError;
- }
+ if (!parser.parse(QCoreApplication::arguments()))
+ return { Status::Error, parser.errorText() };
if (parser.isSet(versionOption))
- return CommandLineVersionRequested;
+ return { Status::VersionRequested };
if (parser.isSet(helpOption))
- return CommandLineHelpRequested;
+ return { Status::HelpRequested };
if (parser.isSet(nameServerOption)) {
const QString nameserver = parser.value(nameServerOption);
query->nameServer = QHostAddress(nameserver);
- if (query->nameServer.isNull() || query->nameServer.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) {
- *errorMessage = "Bad nameserver address: " + nameserver;
- return CommandLineError;
+ if (query->nameServer.isNull()
+ || query->nameServer.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) {
+ return { Status::Error,
+ u"Bad nameserver address: %1"_s.arg(nameserver) };
}
}
if (parser.isSet(typeOption)) {
const QString typeParameter = parser.value(typeOption);
- const int type = typeFromParameter(typeParameter.toLower());
- if (type < 0) {
- *errorMessage = "Bad record type: " + typeParameter;
- return CommandLineError;
- }
- query->type = static_cast<QDnsLookup::Type>(type);
+ if (std::optional<QDnsLookup::Type> type = typeFromParameter(typeParameter))
+ query->type = *type;
+ else
+ return { Status::Error, u"Bad record type: %1"_s.arg(typeParameter) };
}
const QStringList positionalArguments = parser.positionalArguments();
- if (positionalArguments.isEmpty()) {
- *errorMessage = "Argument 'name' missing.";
- return CommandLineError;
- }
- if (positionalArguments.size() > 1) {
- *errorMessage = "Several 'name' arguments specified.";
- return CommandLineError;
- }
+ if (positionalArguments.isEmpty())
+ return { Status::Error, u"Argument 'name' missing."_s };
+ if (positionalArguments.size() > 1)
+ return { Status::Error, u"Several 'name' arguments specified."_s };
query->name = positionalArguments.first();
- return CommandLineOk;
+ return { Status::Ok };
}
//! [0]
@@ -169,39 +123,52 @@ void DnsManager::execute()
void DnsManager::showResults()
{
if (dns->error() != QDnsLookup::NoError)
- printf("Error: %i (%s)\n", dns->error(), qPrintable(dns->errorString()));
+ std::printf("Error: %i (%s)\n", dns->error(), qPrintable(dns->errorString()));
// CNAME records
const QList<QDnsDomainNameRecord> cnameRecords = dns->canonicalNameRecords();
- for (const QDnsDomainNameRecord &record : cnameRecords)
- printf("%s\t%i\tIN\tCNAME\t%s\n", qPrintable(record.name()), record.timeToLive(), qPrintable(record.value()));
+ for (const QDnsDomainNameRecord &record : cnameRecords) {
+ std::printf("%s\t%i\tIN\tCNAME\t%s\n", qPrintable(record.name()), record.timeToLive(),
+ qPrintable(record.value()));
+ }
// A and AAAA records
const QList<QDnsHostAddressRecord> aRecords = dns->hostAddressRecords();
for (const QDnsHostAddressRecord &record : aRecords) {
- const char *type = (record.value().protocol() == QAbstractSocket::IPv6Protocol) ? "AAAA" : "A";
- printf("%s\t%i\tIN\t%s\t%s\n", qPrintable(record.name()), record.timeToLive(), type, qPrintable(record.value().toString()));
+ const char *type =
+ (record.value().protocol() == QAbstractSocket::IPv6Protocol) ? "AAAA" : "A";
+ std::printf("%s\t%i\tIN\t%s\t%s\n", qPrintable(record.name()), record.timeToLive(), type,
+ qPrintable(record.value().toString()));
}
// MX records
const QList<QDnsMailExchangeRecord> mxRecords = dns->mailExchangeRecords();
- for (const QDnsMailExchangeRecord &record : mxRecords)
- printf("%s\t%i\tIN\tMX\t%u %s\n", qPrintable(record.name()), record.timeToLive(), record.preference(), qPrintable(record.exchange()));
+ for (const QDnsMailExchangeRecord &record : mxRecords) {
+ std::printf("%s\t%i\tIN\tMX\t%u %s\n", qPrintable(record.name()), record.timeToLive(),
+ record.preference(), qPrintable(record.exchange()));
+ }
// NS records
const QList<QDnsDomainNameRecord> nsRecords = dns->nameServerRecords();
- for (const QDnsDomainNameRecord &record : nsRecords)
- printf("%s\t%i\tIN\tNS\t%s\n", qPrintable(record.name()), record.timeToLive(), qPrintable(record.value()));
+ for (const QDnsDomainNameRecord &record : nsRecords) {
+ std::printf("%s\t%i\tIN\tNS\t%s\n", qPrintable(record.name()), record.timeToLive(),
+ qPrintable(record.value()));
+ }
// PTR records
const QList<QDnsDomainNameRecord> ptrRecords = dns->pointerRecords();
- for (const QDnsDomainNameRecord &record : ptrRecords)
- printf("%s\t%i\tIN\tPTR\t%s\n", qPrintable(record.name()), record.timeToLive(), qPrintable(record.value()));
+ for (const QDnsDomainNameRecord &record : ptrRecords) {
+ std::printf("%s\t%i\tIN\tPTR\t%s\n", qPrintable(record.name()), record.timeToLive(),
+ qPrintable(record.value()));
+ }
// SRV records
const QList<QDnsServiceRecord> srvRecords = dns->serviceRecords();
- for (const QDnsServiceRecord &record : srvRecords)
- printf("%s\t%i\tIN\tSRV\t%u %u %u %s\n", qPrintable(record.name()), record.timeToLive(), record.priority(), record.weight(), record.port(), qPrintable(record.target()));
+ for (const QDnsServiceRecord &record : srvRecords) {
+ std::printf("%s\t%i\tIN\tSRV\t%u %u %u %s\n", qPrintable(record.name()),
+ record.timeToLive(), record.priority(), record.weight(), record.port(),
+ qPrintable(record.target()));
+ }
// TXT records
const QList<QDnsTextRecord> txtRecords = dns->textRecords();
@@ -210,7 +177,8 @@ void DnsManager::showResults()
const QList<QByteArray> dnsRecords = record.values();
for (const QByteArray &ba : dnsRecords)
values << "\"" + QString::fromLatin1(ba) + "\"";
- printf("%s\t%i\tIN\tTXT\t%s\n", qPrintable(record.name()), record.timeToLive(), qPrintable(values.join(' ')));
+ std::printf("%s\t%i\tIN\tTXT\t%s\n", qPrintable(record.name()), record.timeToLive(),
+ qPrintable(values.join(' ')));
}
QCoreApplication::instance()->quit();
@@ -222,32 +190,36 @@ int main(int argc, char *argv[])
//! [1]
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCoreApplication::setApplicationName(QCoreApplication::translate("QDnsLookupExample", "DNS Lookup Example"));
+ QCoreApplication::setApplicationName(QCoreApplication::translate("QDnsLookupExample",
+ "DNS Lookup Example"));
QCommandLineParser parser;
- parser.setApplicationDescription(QCoreApplication::translate("QDnsLookupExample", "An example demonstrating the class QDnsLookup."));
+ parser.setApplicationDescription(QCoreApplication::translate("QDnsLookupExample",
+ "An example demonstrating the "
+ "class QDnsLookup."));
DnsQuery query;
- QString errorMessage;
- switch (parseCommandLine(parser, &query, &errorMessage)) {
- case CommandLineOk:
+ using Status = CommandLineParseResult::Status;
+ CommandLineParseResult parseResult = parseCommandLine(parser, &query);
+ switch (parseResult.statusCode) {
+ case Status::Ok:
break;
- case CommandLineError:
- fputs(qPrintable(errorMessage), stderr);
- fputs("\n\n", stderr);
- fputs(qPrintable(parser.helpText()), stderr);
+ case Status::Error:
+ std::fputs(qPrintable(parseResult.errorString.value_or(u"Unknown error occurred"_s)),
+ stderr);
+ std::fputs("\n\n", stderr);
+ std::fputs(qPrintable(parser.helpText()), stderr);
return 1;
- case CommandLineVersionRequested:
- printf("%s %s\n", qPrintable(QCoreApplication::applicationName()),
- qPrintable(QCoreApplication::applicationVersion()));
- return 0;
- case CommandLineHelpRequested:
+ case Status::VersionRequested:
+ parser.showVersion();
+ Q_UNREACHABLE_RETURN(0);
+ case Status::HelpRequested:
parser.showHelp();
- Q_UNREACHABLE();
+ Q_UNREACHABLE_RETURN(0);
}
//! [1]
DnsManager manager;
manager.setQuery(query);
- QTimer::singleShot(0, &manager, SLOT(execute()));
+ QTimer::singleShot(0, &manager, &DnsManager::execute);
return app.exec();
}
diff --git a/examples/network/dnslookup/dnslookup.h b/examples/network/dnslookup/dnslookup.h
index 6e521a3528..6f692537f9 100644
--- a/examples/network/dnslookup/dnslookup.h
+++ b/examples/network/dnslookup/dnslookup.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Jeremy Lainé <jeremy.laine@m4x.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Jeremy Lainé <jeremy.laine@m4x.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QDnsLookup>
#include <QHostAddress>
diff --git a/examples/network/doc/images/blockingfortuneclient-example.png b/examples/network/doc/images/blockingfortuneclient-example.png
index cdb7cac0d3..ab918e791d 100644
--- a/examples/network/doc/images/blockingfortuneclient-example.png
+++ b/examples/network/doc/images/blockingfortuneclient-example.png
Binary files differ
diff --git a/examples/network/doc/images/dnslookup-example.webp b/examples/network/doc/images/dnslookup-example.webp
new file mode 100644
index 0000000000..c835cf1af3
--- /dev/null
+++ b/examples/network/doc/images/dnslookup-example.webp
Binary files differ
diff --git a/examples/network/doc/images/fortuneclient-example.png b/examples/network/doc/images/fortuneclient-example.png
index b34a98736d..cae0b066dc 100644
--- a/examples/network/doc/images/fortuneclient-example.png
+++ b/examples/network/doc/images/fortuneclient-example.png
Binary files differ
diff --git a/examples/network/doc/images/fortuneserver-example.png b/examples/network/doc/images/fortuneserver-example.png
index 73f27d5653..55ea8b1c29 100644
--- a/examples/network/doc/images/fortuneserver-example.png
+++ b/examples/network/doc/images/fortuneserver-example.png
Binary files differ
diff --git a/examples/network/doc/images/googlesuggest-example.png b/examples/network/doc/images/googlesuggest-example.png
deleted file mode 100644
index c704f5b2b4..0000000000
--- a/examples/network/doc/images/googlesuggest-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/doc/images/http-example.png b/examples/network/doc/images/http-example.png
deleted file mode 100644
index c5f3ef1649..0000000000
--- a/examples/network/doc/images/http-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/doc/images/http-example.webp b/examples/network/doc/images/http-example.webp
new file mode 100644
index 0000000000..4f6269ec8b
--- /dev/null
+++ b/examples/network/doc/images/http-example.webp
Binary files differ
diff --git a/examples/network/doc/images/loopback-example.png b/examples/network/doc/images/loopback-example.png
deleted file mode 100644
index 2b1bd4a0f2..0000000000
--- a/examples/network/doc/images/loopback-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/doc/images/multi-stream-client-example.webp b/examples/network/doc/images/multi-stream-client-example.webp
new file mode 100644
index 0000000000..6ec651ae9e
--- /dev/null
+++ b/examples/network/doc/images/multi-stream-client-example.webp
Binary files differ
diff --git a/examples/network/doc/images/multi-stream-server-example.webp b/examples/network/doc/images/multi-stream-server-example.webp
new file mode 100644
index 0000000000..95610e7267
--- /dev/null
+++ b/examples/network/doc/images/multi-stream-server-example.webp
Binary files differ
diff --git a/examples/network/doc/images/multicastreceiver-example.png b/examples/network/doc/images/multicastreceiver-example.png
deleted file mode 100644
index 8de11cda63..0000000000
--- a/examples/network/doc/images/multicastreceiver-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/doc/images/multicastreceiver-example.webp b/examples/network/doc/images/multicastreceiver-example.webp
new file mode 100644
index 0000000000..2dd0c28036
--- /dev/null
+++ b/examples/network/doc/images/multicastreceiver-example.webp
Binary files differ
diff --git a/examples/network/doc/images/multicastsender-example.png b/examples/network/doc/images/multicastsender-example.png
deleted file mode 100644
index a619b047e3..0000000000
--- a/examples/network/doc/images/multicastsender-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/doc/images/multicastsender-example.webp b/examples/network/doc/images/multicastsender-example.webp
new file mode 100644
index 0000000000..b06da08351
--- /dev/null
+++ b/examples/network/doc/images/multicastsender-example.webp
Binary files differ
diff --git a/examples/network/doc/images/network-chat-example.png b/examples/network/doc/images/network-chat-example.png
deleted file mode 100644
index 949bb07d87..0000000000
--- a/examples/network/doc/images/network-chat-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/doc/images/network-chat-example.webp b/examples/network/doc/images/network-chat-example.webp
new file mode 100644
index 0000000000..9b8cc1fd8a
--- /dev/null
+++ b/examples/network/doc/images/network-chat-example.webp
Binary files differ
diff --git a/examples/network/doc/images/rsslisting.png b/examples/network/doc/images/rsslisting.png
new file mode 100644
index 0000000000..0b05375f93
--- /dev/null
+++ b/examples/network/doc/images/rsslisting.png
Binary files differ
diff --git a/examples/network/doc/images/securesocketclient-example.webp b/examples/network/doc/images/securesocketclient-example.webp
new file mode 100644
index 0000000000..658f93d053
--- /dev/null
+++ b/examples/network/doc/images/securesocketclient-example.webp
Binary files differ
diff --git a/examples/network/doc/images/securesocketclient.png b/examples/network/doc/images/securesocketclient.png
deleted file mode 100644
index 8736cbc264..0000000000
--- a/examples/network/doc/images/securesocketclient.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/doc/images/securesocketclient2.png b/examples/network/doc/images/securesocketclient2.png
deleted file mode 100644
index 23db851e61..0000000000
--- a/examples/network/doc/images/securesocketclient2.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/doc/images/threadedfortuneserver-example.png b/examples/network/doc/images/threadedfortuneserver-example.png
index 701a0ca035..72315e0b79 100644
--- a/examples/network/doc/images/threadedfortuneserver-example.png
+++ b/examples/network/doc/images/threadedfortuneserver-example.png
Binary files differ
diff --git a/examples/network/doc/images/torrent-example.png b/examples/network/doc/images/torrent-example.png
index 1032716e04..485bc7f719 100644
--- a/examples/network/doc/images/torrent-example.png
+++ b/examples/network/doc/images/torrent-example.png
Binary files differ
diff --git a/examples/network/doc/src/blockingfortuneclient.qdoc b/examples/network/doc/src/blockingfortuneclient.qdoc
index d1c0aa79bf..ec99447b4b 100644
--- a/examples/network/doc/src/blockingfortuneclient.qdoc
+++ b/examples/network/doc/src/blockingfortuneclient.qdoc
@@ -1,33 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example blockingfortuneclient
- \title Blocking Fortune Client Example
+ \title Blocking Fortune Client
+ \examplecategory {Networking}
+ \meta tags {tcp,network,threading,synchronous-io}
\ingroup examples-network
\brief Demonstrates how to create a client for a network service.
@@ -131,7 +109,7 @@
Now we can create a QDataStream object, passing the socket to
QDataStream's constructor, and as in the other client examples we set
- the stream protocol version to QDataStream::Qt_4_0.
+ the stream protocol version to QDataStream::Qt_6_5.
\snippet blockingfortuneclient/fortunethread.cpp 12
@@ -147,7 +125,7 @@
The final part of our loop is that we acquire the mutex so that we can
safely read from our member data. We then let the thread go to sleep by
calling QWaitCondition::wait(). At this point, we can go back to
- requestNewFortune() and look closed at the call to wakeOne():
+ requestNewFortune() and look closely at the call to wakeOne():
\snippet blockingfortuneclient/fortunethread.cpp 1
\dots
@@ -184,7 +162,7 @@
\snippet blockingfortuneclient/blockingclient.cpp 1
The requestNewFortune() slot calls FortuneThread::requestNewFortune(),
- which \e shedules the request. When the thread has received a new fortune
+ which \e schedules the request. When the thread has received a new fortune
and emits newFortune(), our showFortune() slot is called:
\snippet blockingfortuneclient/blockingclient.cpp 2
@@ -193,5 +171,5 @@
Here, we simply display the fortune we received as the argument.
- \sa {Fortune Client Example}, {Fortune Server Example}
+ \sa {Fortune Client}, {Fortune Server}
*/
diff --git a/examples/network/doc/src/broadcastreceiver.qdoc b/examples/network/doc/src/broadcastreceiver.qdoc
index f53358e936..cb134c699d 100644
--- a/examples/network/doc/src/broadcastreceiver.qdoc
+++ b/examples/network/doc/src/broadcastreceiver.qdoc
@@ -1,33 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example broadcastreceiver
- \title Broadcast Receiver Example
+ \title Broadcast Receiver
+ \examplecategory {Networking}
+ \meta tags {network,broadcast,udp}
\ingroup examples-network
\brief Demonstrates how to receive information broadcasted over a local network.
diff --git a/examples/network/doc/src/broadcastsender.qdoc b/examples/network/doc/src/broadcastsender.qdoc
index fece94e2cb..d02b179b77 100644
--- a/examples/network/doc/src/broadcastsender.qdoc
+++ b/examples/network/doc/src/broadcastsender.qdoc
@@ -1,33 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example broadcastsender
- \title Broadcast Sender Example
+ \title Broadcast Sender
+ \examplecategory {Networking}
+ \meta tags {network,broadcast,udp}
\ingroup examples-network
\brief Demonstrates how to broadcast information to multiple clients on a local network.
diff --git a/examples/network/doc/src/dnslookup.qdoc b/examples/network/doc/src/dnslookup.qdoc
new file mode 100644
index 0000000000..0a5a69f70a
--- /dev/null
+++ b/examples/network/doc/src/dnslookup.qdoc
@@ -0,0 +1,17 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example dnslookup
+ \title DNS lookup
+ \examplecategory {Networking}
+ \meta tags {network,dns,command line parser,command line,console}
+ \ingroup examples-network
+ \brief Demonstrates how to lookup a host name using QDnsLookup.
+
+ This example uses QDnsLookup to demonstrate how to look up a host
+ name and print the results on the command line. As well as how you can
+ use QCommandLineParser to parse command line arguments.
+
+ \image dnslookup-example.webp
+*/
diff --git a/examples/network/doc/src/fortuneclient.qdoc b/examples/network/doc/src/fortuneclient.qdoc
index 4cb7544fc0..054937e893 100644
--- a/examples/network/doc/src/fortuneclient.qdoc
+++ b/examples/network/doc/src/fortuneclient.qdoc
@@ -1,33 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example fortuneclient
- \title Fortune Client Example
+ \title Fortune Client
+ \examplecategory {Networking}
+ \meta tags {tcp,network}
\ingroup examples-network
\brief Demonstrates how to create a client for a network service.
@@ -62,7 +40,7 @@
\endlist
In this example, we will demonstrate the asynchronous approach. The
- \l{blockingfortuneclient}{Blocking Fortune Client Example}
+ \l{blockingfortuneclient}{Blocking Fortune Client} example
illustrates the synchronous approach.
Our class contains some data and a few private slots:
@@ -83,7 +61,7 @@
The protocol is based on QDataStream, so we set the stream device to the
newly created socket. We then explicitly set the protocol version of the
- stream to QDataStream::Qt_4_0 to ensure that we're using the same version
+ stream to QDataStream::Qt_6_5 to ensure that we're using the same version
as the fortune server, no matter which version of Qt the client and
server use.
@@ -156,5 +134,5 @@
After a successful read transaction, we call QLabel::setText() to display
the fortune.
- \sa {Fortune Server Example}, {Blocking Fortune Client Example}
+ \sa {Fortune Server}, {Blocking Fortune Client}
*/
diff --git a/examples/network/doc/src/fortuneserver.qdoc b/examples/network/doc/src/fortuneserver.qdoc
index acd05da696..1973f372ce 100644
--- a/examples/network/doc/src/fortuneserver.qdoc
+++ b/examples/network/doc/src/fortuneserver.qdoc
@@ -1,39 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example fortuneserver
- \title Fortune Server Example
+ \title Fortune Server
+ \examplecategory {Networking}
+ \meta tags {tcp,network,server}
\ingroup examples-network
\brief Demonstrates how to create a server for a network service.
This example is intended to be run alongside the
\l{fortuneclient}{Fortune Client} example or the
- \l{blockingfortuneclient}{Blocking Fortune Client Example}.
+ \l{blockingfortuneclient}{Blocking Fortune Client} example.
\image fortuneserver-example.png Screenshot of the Fortune Server example
@@ -72,7 +50,7 @@
to the connecting socket. This is a common way to transfer binary data
using QTcpSocket. First we create a QByteArray and a QDataStream object,
passing the bytearray to QDataStream's constructor. We then explicitly set
- the protocol version of QDataStream to QDataStream::Qt_4_0 to ensure that
+ the protocol version of QDataStream to QDataStream::Qt_5_10 to ensure that
we can communicate with clients from future versions of Qt (see
QDataStream::setVersion()). We continue by streaming in a random fortune.
@@ -93,5 +71,5 @@
will then close, which in turn will cause QObject::deleteLater() to delete
it.
- \sa {Fortune Client Example}, {Threaded Fortune Server Example}
+ \sa {Fortune Client}, {Threaded Fortune Server}
*/
diff --git a/examples/network/doc/src/googlesuggest.qdoc b/examples/network/doc/src/googlesuggest.qdoc
deleted file mode 100644
index adb87f4b66..0000000000
--- a/examples/network/doc/src/googlesuggest.qdoc
+++ /dev/null
@@ -1,177 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example googlesuggest
- \title Google Suggest Example
- \ingroup examples-network
- \brief Obtains the list of search recommendations by the Google search engine.
-
- The example uses the QNetworkAccessManager to obtain the list of search
- recommendations by Google as the user types into a QLineEdit.
-
- \image googlesuggest-example.png
-
- The application makes use of the \c get function in
- QNetworkAccessManager to post a request and obtain the result of the search
- query sent to the Google search engine. The results returned are listed as
- clickable links appearing below the search box as a drop-down menu.
-
- The widget is built up by a QLineEdit as the search box, and a QTreeView
- used as a popup menu below the search box.
-
- \section1 GSuggestCompletion Class Declaration
-
- This class implements an event filter and a number of functions to display
- the search results and to determent when and how to perform the search.
-
- \snippet googlesuggest/googlesuggest.h 1
-
- The class connects to a QLineEdit and uses a QTreeWidget to display the
- results. A QTimer controls the start of the network requests that are
- executed using a QNetworkAccessManager.
-
- \section1 GSuggestCompletion Class Implementation
-
- We start by defining a constant containing the URL to be used in the Google
- queries. This is the basis for the query. The letters typed into the search
- box will be added to the query to perform the search itself.
-
- \snippet googlesuggest/googlesuggest.cpp 1
-
- In the constructor, we set the parent of this GSuggestCompletion instance
- to be the QLineEdit passed in. For simplicity, the QLineEdit is also stored
- in the explicit \c editor member variable.
-
- We then create a QTreeWidget as a toplevel widget and configure the various
- properties to give it the look of a popup widget. The widget is populated
- with the results by Google Suggest API request.
-
- Furthermore, we install the GSuggestCompletion instance as an event filter
- on the QTreeWidget, and connect the \c itemClicked() signal with the \c
- doneCompletion() slot.
-
- A single-shot QTimer is used to start the request when the user has stopped
- typing for 500 ms.
-
- Finally, we connect the networkManagers \c finished() signal with the \c
- handleNetworkData() slot to handle the incoming data.
-
- \snippet googlesuggest/googlesuggest.cpp 2
-
- Since the QTreeWidget popup has been instantiated as a toplevel widget, the
- destructor has to delete it explicitly from memory to avoid a memory leak.
-
- \snippet googlesuggest/googlesuggest.cpp 3
-
- The event filter handles mouse press and key press events that are
- delivered to the popup. For mouse press events we just hide the popup and
- return focus to the editor widget, and then return true to prevent further
- event processing.
-
- Key event handling is implemented so that Enter and Return execute the
- selected link, while the Escape key hides the popup. Since we want to be
- able to navigate the list of suggestions using the different navigation
- keys on the keyboard we let Qt continue regular event processing for those
- by returning false from the eventFilter reimplementation.
-
- For all other keys, the event will be passed on to the editor widget and the
- popup is hidden. This way the user's typing will not be interrupted by the
- popping up of the completion list.
-
- \snippet googlesuggest/googlesuggest.cpp 4
-
- The \c showCompletion() function populates the QTreeWidget with the results
- returned from the query. It takes a QStringList of the suggested search
- terms.
-
- \snippet googlesuggest/googlesuggest.cpp 5
-
- A QTreeWidgetItem is created for each index in the list and inserted into
- the QTreeWidget. Finally, we adjust position and size of the popup to make
- sure that it pops up in the correct position below the editor, and show it.
-
- The \c doneCompletion() function, which is called by the event filter when
- either Enter or Return keys are pressed, stops the timer to prevent further
- requests and passes the text of the selected item to the editor. We then
- make the \c editor QLineEdit emit the returnPressed() signal, to which the
- application can connect to open the respective web page.
-
- \snippet googlesuggest/googlesuggest.cpp 6
-
- The \c autoSuggest() slot is called when the timer times out, and uses the
- text in the editor to build the complete search query. The query is then
- passed to the QNetworkAccessManager's \c get() function to start the
- request.
-
- \snippet googlesuggest/googlesuggest.cpp 7
-
- The function \c preventSuggest() stops the timer to prevent further
- requests from being started.
-
- \snippet googlesuggest/googlesuggest.cpp 8
-
- When the network request is finished, the QNetworkAccessManager delivers the
- data received from the server through the networkReply object.
-
- \snippet googlesuggest/googlesuggest.cpp 9
-
- To extract the data from the reply we use the \c readAll() function, which
- is inherited from QIODevice and returns a QByteArray. Since this data is
- encoded in XML we can use a QXmlStreamReader to traverse the data and
- extract the search result as QStrings, which we can stream into two
- QStringLists used to populate the popup.
-
- Finally, we schedule the QNetworkReply object for deletion using the \c
- deleteLater function.
-
- \section1 SearchBox Class Declaration
-
- The SearchBox class inherits QLineEdit and adds the protected slot \c
- doSearch().
-
- A \c GSuggestCompletion member provides the SearchBox with the request
- functionality and the suggestions returned from the Google search engine.
-
- \snippet googlesuggest/searchbox.h 1
-
- \section1 SearchBox Class Implementation
-
- The search box constructor instantiates the GSuggestCompletion object and
- connects the returnPressed() signal to the doSearch() slot.
-
- \snippet googlesuggest/searchbox.cpp 1
-
- The function \c doSearch() stops the completer from sending any further
- queries to the search engine.
-
- Further, the function extracts the selected search phrase and opens it
- in the default web browser using QDesktopServices.
-
- \snippet googlesuggest/searchbox.cpp 2
-
-*/
diff --git a/examples/network/doc/src/http.qdoc b/examples/network/doc/src/http.qdoc
index 815775c51d..c155997394 100644
--- a/examples/network/doc/src/http.qdoc
+++ b/examples/network/doc/src/http.qdoc
@@ -1,40 +1,19 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example http
- \title HTTP Example
+ \examplecategory {Networking}
+ \examplecategory {Web Technologies}
+ \meta tags {http,network,https,proxy}
+ \title HTTP Client
\ingroup examples-network
\brief Demonstrates a simple HTTP client.
This example demonstrates how a simple HTTP client can fetch files
from remote hosts.
- \image http-example.png
+ \image http-example.webp
The main work of this example is done in the HttpWindow class.
Thus we will focus on that.
diff --git a/examples/network/doc/src/loopback.qdoc b/examples/network/doc/src/loopback.qdoc
deleted file mode 100644
index f97c9f9c71..0000000000
--- a/examples/network/doc/src/loopback.qdoc
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example loopback
- \title Loopback Example
- \ingroup examples-network
- \brief Demonstrates the client-server communication on a local host.
-
- The example demonstrates how the clients and servers on a local host
- communicate with each other.
-
- \image loopback-example.png
-*/
diff --git a/examples/network/doc/src/multicastreceiver.qdoc b/examples/network/doc/src/multicastreceiver.qdoc
index 3709750436..16c7235c17 100644
--- a/examples/network/doc/src/multicastreceiver.qdoc
+++ b/examples/network/doc/src/multicastreceiver.qdoc
@@ -1,36 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example multicastreceiver
- \title Multicast Receiver Example
+ \title Multicast Receiver
+ \examplecategory {Networking}
+ \meta tags {network,multicast,ipv6,ipv4,udp}
\ingroup examples-network
\brief Demonstrates how to receive information sent to a multicast group.
- This example demonstrates how to receive messages sent to a multicast group
- \image multicastreceiver-example.png
+ This example demonstrates how to receive messages sent to a multicast group.
+ \image multicastreceiver-example.webp
*/
diff --git a/examples/network/doc/src/multicastsender.qdoc b/examples/network/doc/src/multicastsender.qdoc
index 72558eb062..26e0d951fe 100644
--- a/examples/network/doc/src/multicastsender.qdoc
+++ b/examples/network/doc/src/multicastsender.qdoc
@@ -1,38 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example multicastsender
- \title Multicast Sender Example
+ \title Multicast Sender
+ \examplecategory {Networking}
+ \meta tags {network,multicast,ipv6,ipv4,udp}
\ingroup examples-network
\brief Demonstrates how to send messages to a multicast group.
This example demonstrates how to send messages to the clients of a
multicast group.
- \image multicastsender-example.png
+ \image multicastsender-example.webp
*/
diff --git a/examples/network/doc/src/multistreamclient.qdoc b/examples/network/doc/src/multistreamclient.qdoc
new file mode 100644
index 0000000000..bb70eac741
--- /dev/null
+++ b/examples/network/doc/src/multistreamclient.qdoc
@@ -0,0 +1,15 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example multistreamclient
+ \title Multi-stream Client
+ \examplecategory {Networking}
+ \meta tags {network,sctp}
+ \ingroup examples-network
+ \brief Demonstrates how to use SCTP on the client side.
+
+ This example demonstrates how to use SCTP, with multiple channels,
+ to interact with other clients through a server.
+ \image multi-stream-client-example.webp
+*/
diff --git a/examples/network/doc/src/multistreamserver.qdoc b/examples/network/doc/src/multistreamserver.qdoc
new file mode 100644
index 0000000000..9e498be3c9
--- /dev/null
+++ b/examples/network/doc/src/multistreamserver.qdoc
@@ -0,0 +1,16 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example multistreamserver
+ \title Multi-stream Server
+ \examplecategory {Networking}
+ \meta tags {network,sctp}
+ \ingroup examples-network
+ \brief Demonstrates how to use SCTP on the server side.
+
+ This example demonstrates how to use SCTP, with multiple channels,
+ on the server side, receiving multiple connections and sending
+ messages to connected clients.
+ \image multi-stream-server-example.webp
+*/
diff --git a/examples/network/doc/src/network-chat.qdoc b/examples/network/doc/src/network-chat.qdoc
index 85edf611b6..6a8f0024e3 100644
--- a/examples/network/doc/src/network-chat.qdoc
+++ b/examples/network/doc/src/network-chat.qdoc
@@ -1,38 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example network-chat
- \title Network Chat Example
+ \title Network Chat
\ingroup examples-network
+ \examplecategory {Networking}
+ \meta tag {network,serialization}
\brief Demonstrates a stateful peer-to-peer Chat client.
This example uses broadcasting with QUdpSocket and QNetworkInterface to
discover its peers.
- \image network-chat-example.png
+ \image network-chat-example.webp
*/
diff --git a/examples/network/doc/src/network-download.qdoc b/examples/network/doc/src/network-download.qdoc
deleted file mode 100644
index 9d171e4142..0000000000
--- a/examples/network/doc/src/network-download.qdoc
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example download
- \title Network Download Example
- \brief Demonstrates how to use networking APIs for multiple downloads.
- \ingroup examples-network
-
- The Network Download example shows how to perform multiple downloads in
- parallel using the QNetworkAccessManager class.
-
- This example is designed to be run from the command-line.
-
- The \l{Network Download Manager Example} implements a more complex system
- that places files in a queue for sequential downloading.
-*/
diff --git a/examples/network/doc/src/network-downloadmanager.qdoc b/examples/network/doc/src/network-downloadmanager.qdoc
deleted file mode 100644
index f89ed66616..0000000000
--- a/examples/network/doc/src/network-downloadmanager.qdoc
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example downloadmanager
- \title Network Download Manager Example
- \brief Demonstrates how to use the networking APIs for multiple downloads.
- \ingroup examples-network
-
- The Network Download example shows how to implement a queue for multiple
- downloads using the QNetworkAccessManager class.
-
- This example is designed to be run from the command-line.
-
- See the \l{Network Download Example} for a simpler version of this example
- that obtains multiple files in parallel.
-*/
diff --git a/examples/network/doc/src/rsslisting.qdoc b/examples/network/doc/src/rsslisting.qdoc
new file mode 100644
index 0000000000..a1e91932f6
--- /dev/null
+++ b/examples/network/doc/src/rsslisting.qdoc
@@ -0,0 +1,129 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example rsslisting
+ \examplecategory {Networking}
+ \meta tag {serialization}
+ \title A minimal RSS listing application
+
+ \brief A demonstration of how to fetch and display a network resource.
+
+ This example shows how to fetch a resource the user has requested and
+ display data contained in the response, illustrated by an RSS listing
+ application. (RDF Site Summary, or Really Simple Syndication, is a standard
+ format for communicating updates to web sites. See
+ https://www.rssboard.org/rss-specification for details.) The user inferface
+ in the illustration is simple, as the focus of this example is on how to use
+ networking, but naturally a more sophisticated interface would be wanted for
+ a serious RSS reader.
+
+ The example also illustrates how to do asynchronous parsing of data as it is
+ received, preserving state in member variables so that an incremental parser
+ can consume chunks of data as they arrive over the network. Constituents of
+ the parsed content may start in one chunk of data but not be completed until
+ a later chunk, requiring the parser to retain state between calls.
+
+ \image rsslisting.png
+
+ The main program is fairly minimal. It simply instantiates a \l QApplication
+ and the \c RSSListing widget, shows the latter and hands over control to the
+ former. For the sake of illustration, it gives the widget the Qt blog's URL
+ as default value for the resource to check.
+
+ \snippet rsslisting/main.cpp 0
+
+ \section1 The RSSListing class
+
+ \snippet rsslisting/rsslisting.h 0
+
+ The widget itself provides a simple user interface for specifying the URL to
+ fetch and, once available updates are displayed, controlling the downloading
+ of updated items. A \l QLineEdit provides for input of the URL, and a
+ \l QTreeWidget for display of the results once fetched.
+
+ The widget downloads and parses the RSS (a form of XML) asynchronously,
+ feeding the data to an XML reader as it arrives. This supports reading of
+ very large data sources. Because the data is streamed from the network
+ through the XML reader, there is no need to retain the full text of the XML
+ in memory. In other context, a similar approach can allow the user to
+ interrupt such incremental loading.
+
+ \section2 Construction
+
+ \snippet rsslisting/rsslisting.cpp setup
+
+ The constructor sets up the assorted components of the widget and connects
+ their various signals to the slots it shall use to handle them.
+
+ The user interface consists of a line edit, a push button, and a list view
+ widget. The line edit is used for entering the URL to fetch; the push button
+ starts the process of fetching updates. The line edit is empty by default,
+ but the constructor's caller can override that, as our \c main() has done.
+ In any case, the user can replace the default with the URL of another RSS
+ feed.
+
+ The list view shows the updated items reported in the RSS feed.
+ Double-clicking on one of these sends its URL to the user's browser or other
+ user agent using \l QDesktopServices::openUrl().
+
+ \section2 The slots
+
+ \snippet rsslisting/rsslisting.cpp slots
+
+ All slots are kept simple by delegating any hard work to private methods.
+
+ When the user completes input of a URL, either by clicking the "Fetch"
+ button or by pressing the return key in the line edit, the \c fetch() slot
+ disables the "Fetch" button and disables further editing of the line edit.
+ It clears the display of available updates and delegates to \c get() the
+ initiating of an HTTP GET request.
+
+ When data is received, the network reply triggers its \l {QNetworkReply::}
+ {readyRead()} signal, which \c get() connects to the \c consumeData()
+ slot. This checks the response got a successful status code and, if it did,
+ calls \c parseXml() to consume the data.
+
+ If the network reply gets an error, this is delivered to the \c error()
+ slot, which reports the error, clears the XML stream reader then disconnects
+ from the reply and deletes it.
+
+ On completion (whether successful or otherwise) of a network reply, the \c
+ finished() slot restores the UI to be ready to accept a new URL to fetch by
+ re-enabling the line edit and "Fetch" button.
+
+ \section2 The get() method
+
+ \snippet rsslisting/rsslisting.cpp get
+
+ The private \c get() method is used by the \c fetch() slot to initiate an
+ HTTP GET request. It first clears the XML stream reader and, if a reply is
+ currently active, disconnects and deletes it. If the URL it has been passed
+ is valid, it asks the network access manager to GET it. It connects its
+ relevant slots to signals of the resulting reply (if any) and sets up its
+ XML stream reader to read data from the reply - a network reply object is
+ also a \c QIODevice, from which data can be read.
+
+ \section2 The parseXml() method
+
+ \snippet rsslisting/rsslisting.cpp parse
+
+ When data is received, and thus made available to the XML stream reader, \c
+ parseXml() reads from the XML stream, checking for \c item elements and,
+ within them, \c title and \c link elements. It will use the \c{rss:about}
+ attribute of an \c item as URL in the Link column of the tree-view, failing
+ that the content of its \c link element; and it uses the content of the \c
+ title element in the Title column of the tree-view. As each \c item element
+ closes, its details are turned into a new row in the tree widget, with the
+ extracted title and URL in the Title and Link columns.
+
+ The variables that keep track of the parsing state - \c linkString, \c
+ titleString and \c currentTag - are member variables of the \c RSSListing
+ class, even though they are only accessed from this method, because this
+ method may be called repeatedly, as new data arrives, and one chunk of
+ received data may start an element that isn't completed until a later chunk
+ arrives. This enables the parser to operate asynchronously as the data
+ arrives, instead of having to wait until all the data has arrived.
+
+ \sa QNetworkReply, QXmlStreamReader
+*/
diff --git a/examples/network/doc/src/securesocketclient.qdoc b/examples/network/doc/src/securesocketclient.qdoc
index 78cfab7af4..7ff3ae6da5 100644
--- a/examples/network/doc/src/securesocketclient.qdoc
+++ b/examples/network/doc/src/securesocketclient.qdoc
@@ -1,33 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example securesocketclient
- \title Secure Socket Client Example
+ \title Secure Socket Client
+ \examplecategory {Networking}
+ \meta tags {tcp,network,tls,ssl}
\ingroup examples-network
\brief Demonstrates how to communicate over an encrypted (SSL) connection.
@@ -35,6 +13,5 @@
encrypted connection, deal with authenticity problems, and display security
and certificate information.
- \image securesocketclient.png
- \image securesocketclient2.png
+ \image securesocketclient-example.webp
*/
diff --git a/examples/network/doc/src/secureudpclient.qdoc b/examples/network/doc/src/secureudpclient.qdoc
index dc8538cf85..b7a51c0814 100644
--- a/examples/network/doc/src/secureudpclient.qdoc
+++ b/examples/network/doc/src/secureudpclient.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example secureudpclient
\title DTLS client
+ \examplecategory {Networking}
\ingroup examples-network
\brief This example demonstrates how to implement client-side DTLS connections.
diff --git a/examples/network/doc/src/secureudpserver.qdoc b/examples/network/doc/src/secureudpserver.qdoc
index 0857f7065f..3d224d91bc 100644
--- a/examples/network/doc/src/secureudpserver.qdoc
+++ b/examples/network/doc/src/secureudpserver.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example secureudpserver
\title DTLS server
+ \examplecategory {Networking}
\ingroup examples-network
\brief This examples demonstrates how to implement a simple DTLS server.
diff --git a/examples/network/doc/src/threadedfortuneserver.qdoc b/examples/network/doc/src/threadedfortuneserver.qdoc
index 9ba76c8a0b..51198061e6 100644
--- a/examples/network/doc/src/threadedfortuneserver.qdoc
+++ b/examples/network/doc/src/threadedfortuneserver.qdoc
@@ -1,33 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example threadedfortuneserver
- \title Threaded Fortune Server Example
+ \title Threaded Fortune Server
+ \examplecategory {Networking}
+ \meta tags {tcp,network,threading,server,synchronous-io}
\ingroup examples-network
\brief The Threaded Fortune Server example shows how to create a server for a
@@ -103,6 +81,5 @@
the socket has disconnected. Because we are running in a separate thread,
the GUI will remain responsive.
- \sa {Fortune Server Example}, {Fortune Client Example}, {Blocking Fortune
- Client Example}
+ \sa {Fortune Server}, {Fortune Client}, {Blocking Fortune Client}
*/
diff --git a/examples/network/doc/src/torrent.qdoc b/examples/network/doc/src/torrent.qdoc
index 8d69bee6d1..124a697293 100644
--- a/examples/network/doc/src/torrent.qdoc
+++ b/examples/network/doc/src/torrent.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example torrent
\title Torrent Example
+ \examplecategory {Networking}
\ingroup examples-network
\brief Demonstrates complex TCP/IP operations.
diff --git a/examples/network/download/CMakeLists.txt b/examples/network/download/CMakeLists.txt
deleted file mode 100644
index 36bdfdc5fd..0000000000
--- a/examples/network/download/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Generated from download.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(download LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/download")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Network)
-
-qt_add_executable(download
- main.cpp
-)
-set_target_properties(download PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(download PUBLIC
- Qt::Core
- Qt::Network
-)
-
-install(TARGETS download
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/network/download/download.pro b/examples/network/download/download.pro
deleted file mode 100644
index 63d80a0e7c..0000000000
--- a/examples/network/download/download.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-QT = core network
-CONFIG += cmdline
-
-SOURCES += main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/network/download
-INSTALLS += target
diff --git a/examples/network/download/main.cpp b/examples/network/download/main.cpp
deleted file mode 100644
index 74a1ad0161..0000000000
--- a/examples/network/download/main.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore>
-#include <QtNetwork>
-
-#include <cstdio>
-
-QT_BEGIN_NAMESPACE
-class QSslError;
-QT_END_NAMESPACE
-
-using namespace std;
-
-class DownloadManager: public QObject
-{
- Q_OBJECT
- QNetworkAccessManager manager;
- QList<QNetworkReply *> currentDownloads;
-
-public:
- DownloadManager();
- void doDownload(const QUrl &url);
- static QString saveFileName(const QUrl &url);
- bool saveToDisk(const QString &filename, QIODevice *data);
- static bool isHttpRedirect(QNetworkReply *reply);
-
-public slots:
- void execute();
- void downloadFinished(QNetworkReply *reply);
- void sslErrors(const QList<QSslError> &errors);
-};
-
-DownloadManager::DownloadManager()
-{
- connect(&manager, &QNetworkAccessManager::finished,
- this, &DownloadManager::downloadFinished);
-}
-
-void DownloadManager::doDownload(const QUrl &url)
-{
- QNetworkRequest request(url);
- QNetworkReply *reply = manager.get(request);
-
-#if QT_CONFIG(ssl)
- connect(reply, &QNetworkReply::sslErrors,
- this, &DownloadManager::sslErrors);
-#endif
-
- currentDownloads.append(reply);
-}
-
-QString DownloadManager::saveFileName(const QUrl &url)
-{
- QString path = url.path();
- QString basename = QFileInfo(path).fileName();
-
- if (basename.isEmpty())
- basename = "download";
-
- if (QFile::exists(basename)) {
- // already exists, don't overwrite
- int i = 0;
- basename += '.';
- while (QFile::exists(basename + QString::number(i)))
- ++i;
-
- basename += QString::number(i);
- }
-
- return basename;
-}
-
-bool DownloadManager::saveToDisk(const QString &filename, QIODevice *data)
-{
- QFile file(filename);
- if (!file.open(QIODevice::WriteOnly)) {
- fprintf(stderr, "Could not open %s for writing: %s\n",
- qPrintable(filename),
- qPrintable(file.errorString()));
- return false;
- }
-
- file.write(data->readAll());
- file.close();
-
- return true;
-}
-
-bool DownloadManager::isHttpRedirect(QNetworkReply *reply)
-{
- int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
- return statusCode == 301 || statusCode == 302 || statusCode == 303
- || statusCode == 305 || statusCode == 307 || statusCode == 308;
-}
-
-void DownloadManager::execute()
-{
- QStringList args = QCoreApplication::instance()->arguments();
- args.takeFirst(); // skip the first argument, which is the program's name
- if (args.isEmpty()) {
- printf("Qt Download example - downloads all URLs in parallel\n"
- "Usage: download url1 [url2... urlN]\n"
- "\n"
- "Downloads the URLs passed in the command-line to the local directory\n"
- "If the target file already exists, a .0, .1, .2, etc. is appended to\n"
- "differentiate.\n");
- QCoreApplication::instance()->quit();
- return;
- }
-
- for (const QString &arg : qAsConst(args)) {
- QUrl url = QUrl::fromEncoded(arg.toLocal8Bit());
- doDownload(url);
- }
-}
-
-void DownloadManager::sslErrors(const QList<QSslError> &sslErrors)
-{
-#if QT_CONFIG(ssl)
- for (const QSslError &error : sslErrors)
- fprintf(stderr, "SSL error: %s\n", qPrintable(error.errorString()));
-#else
- Q_UNUSED(sslErrors);
-#endif
-}
-
-void DownloadManager::downloadFinished(QNetworkReply *reply)
-{
- QUrl url = reply->url();
- if (reply->error()) {
- fprintf(stderr, "Download of %s failed: %s\n",
- url.toEncoded().constData(),
- qPrintable(reply->errorString()));
- } else {
- if (isHttpRedirect(reply)) {
- fputs("Request was redirected.\n", stderr);
- } else {
- QString filename = saveFileName(url);
- if (saveToDisk(filename, reply)) {
- printf("Download of %s succeeded (saved to %s)\n",
- url.toEncoded().constData(), qPrintable(filename));
- }
- }
- }
-
- currentDownloads.removeAll(reply);
- reply->deleteLater();
-
- if (currentDownloads.isEmpty()) {
- // all downloads finished
- QCoreApplication::instance()->quit();
- }
-}
-
-int main(int argc, char **argv)
-{
- QCoreApplication app(argc, argv);
-
- DownloadManager manager;
- QTimer::singleShot(0, &manager, SLOT(execute()));
-
- app.exec();
-}
-
-#include "main.moc"
diff --git a/examples/network/downloadmanager/CMakeLists.txt b/examples/network/downloadmanager/CMakeLists.txt
deleted file mode 100644
index a3698a016f..0000000000
--- a/examples/network/downloadmanager/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated from downloadmanager.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(downloadmanager LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/downloadmanager")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Network)
-
-qt_add_executable(downloadmanager
- downloadmanager.cpp downloadmanager.h
- main.cpp
- textprogressbar.cpp textprogressbar.h
-)
-set_target_properties(downloadmanager PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(downloadmanager PUBLIC
- Qt::Core
- Qt::Network
-)
-
-install(TARGETS downloadmanager
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/network/downloadmanager/downloadmanager.cpp b/examples/network/downloadmanager/downloadmanager.cpp
deleted file mode 100644
index cbad29541a..0000000000
--- a/examples/network/downloadmanager/downloadmanager.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "downloadmanager.h"
-
-#include <QTextStream>
-
-#include <cstdio>
-
-using namespace std;
-
-DownloadManager::DownloadManager(QObject *parent)
- : QObject(parent)
-{
-}
-
-void DownloadManager::append(const QStringList &urls)
-{
- for (const QString &urlAsString : urls)
- append(QUrl::fromEncoded(urlAsString.toLocal8Bit()));
-
- if (downloadQueue.isEmpty())
- QTimer::singleShot(0, this, &DownloadManager::finished);
-}
-
-void DownloadManager::append(const QUrl &url)
-{
- if (downloadQueue.isEmpty())
- QTimer::singleShot(0, this, &DownloadManager::startNextDownload);
-
- downloadQueue.enqueue(url);
- ++totalCount;
-}
-
-QString DownloadManager::saveFileName(const QUrl &url)
-{
- QString path = url.path();
- QString basename = QFileInfo(path).fileName();
-
- if (basename.isEmpty())
- basename = "download";
-
- if (QFile::exists(basename)) {
- // already exists, don't overwrite
- int i = 0;
- basename += '.';
- while (QFile::exists(basename + QString::number(i)))
- ++i;
-
- basename += QString::number(i);
- }
-
- return basename;
-}
-
-void DownloadManager::startNextDownload()
-{
- if (downloadQueue.isEmpty()) {
- printf("%d/%d files downloaded successfully\n", downloadedCount, totalCount);
- emit finished();
- return;
- }
-
- QUrl url = downloadQueue.dequeue();
-
- QString filename = saveFileName(url);
- output.setFileName(filename);
- if (!output.open(QIODevice::WriteOnly)) {
- fprintf(stderr, "Problem opening save file '%s' for download '%s': %s\n",
- qPrintable(filename), url.toEncoded().constData(),
- qPrintable(output.errorString()));
-
- startNextDownload();
- return; // skip this download
- }
-
- QNetworkRequest request(url);
- currentDownload = manager.get(request);
- connect(currentDownload, &QNetworkReply::downloadProgress,
- this, &DownloadManager::downloadProgress);
- connect(currentDownload, &QNetworkReply::finished,
- this, &DownloadManager::downloadFinished);
- connect(currentDownload, &QNetworkReply::readyRead,
- this, &DownloadManager::downloadReadyRead);
-
- // prepare the output
- printf("Downloading %s...\n", url.toEncoded().constData());
- downloadTimer.start();
-}
-
-void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
-{
- progressBar.setStatus(bytesReceived, bytesTotal);
-
- // calculate the download speed
- double speed = bytesReceived * 1000.0 / downloadTimer.elapsed();
- QString unit;
- if (speed < 1024) {
- unit = "bytes/sec";
- } else if (speed < 1024*1024) {
- speed /= 1024;
- unit = "kB/s";
- } else {
- speed /= 1024*1024;
- unit = "MB/s";
- }
-
- progressBar.setMessage(QString::fromLatin1("%1 %2")
- .arg(speed, 3, 'f', 1).arg(unit));
- progressBar.update();
-}
-
-void DownloadManager::downloadFinished()
-{
- progressBar.clear();
- output.close();
-
- if (currentDownload->error()) {
- // download failed
- fprintf(stderr, "Failed: %s\n", qPrintable(currentDownload->errorString()));
- output.remove();
- } else {
- // let's check if it was actually a redirect
- if (isHttpRedirect()) {
- reportRedirect();
- output.remove();
- } else {
- printf("Succeeded.\n");
- ++downloadedCount;
- }
- }
-
- currentDownload->deleteLater();
- startNextDownload();
-}
-
-void DownloadManager::downloadReadyRead()
-{
- output.write(currentDownload->readAll());
-}
-
-bool DownloadManager::isHttpRedirect() const
-{
- int statusCode = currentDownload->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
- return statusCode == 301 || statusCode == 302 || statusCode == 303
- || statusCode == 305 || statusCode == 307 || statusCode == 308;
-}
-
-void DownloadManager::reportRedirect()
-{
- int statusCode = currentDownload->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
- QUrl requestUrl = currentDownload->request().url();
- QTextStream(stderr) << "Request: " << requestUrl.toDisplayString()
- << " was redirected with code: " << statusCode
- << '\n';
-
- QVariant target = currentDownload->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (!target.isValid())
- return;
- QUrl redirectUrl = target.toUrl();
- if (redirectUrl.isRelative())
- redirectUrl = requestUrl.resolved(redirectUrl);
- QTextStream(stderr) << "Redirected to: " << redirectUrl.toDisplayString()
- << '\n';
-}
diff --git a/examples/network/downloadmanager/downloadmanager.h b/examples/network/downloadmanager/downloadmanager.h
deleted file mode 100644
index 818a774f1f..0000000000
--- a/examples/network/downloadmanager/downloadmanager.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DOWNLOADMANAGER_H
-#define DOWNLOADMANAGER_H
-
-#include <QtNetwork>
-#include <QtCore>
-
-#include "textprogressbar.h"
-
-class DownloadManager: public QObject
-{
- Q_OBJECT
-public:
- explicit DownloadManager(QObject *parent = nullptr);
-
- void append(const QUrl &url);
- void append(const QStringList &urls);
- static QString saveFileName(const QUrl &url);
-
-signals:
- void finished();
-
-private slots:
- void startNextDownload();
- void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
- void downloadFinished();
- void downloadReadyRead();
-
-private:
- bool isHttpRedirect() const;
- void reportRedirect();
-
- QNetworkAccessManager manager;
- QQueue<QUrl> downloadQueue;
- QNetworkReply *currentDownload = nullptr;
- QFile output;
- QElapsedTimer downloadTimer;
- TextProgressBar progressBar;
-
- int downloadedCount = 0;
- int totalCount = 0;
-};
-
-#endif
diff --git a/examples/network/downloadmanager/downloadmanager.pro b/examples/network/downloadmanager/downloadmanager.pro
deleted file mode 100644
index cd1a977e5d..0000000000
--- a/examples/network/downloadmanager/downloadmanager.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-QT = core network
-CONFIG += cmdline
-
-HEADERS += downloadmanager.h textprogressbar.h
-SOURCES += downloadmanager.cpp main.cpp textprogressbar.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/network/downloadmanager
-INSTALLS += target
-
-OTHER_FILES += \
- debian/changelog \
- debian/compat \
- debian/control \
- debian/copyright \
- debian/README \
- debian/rules
diff --git a/examples/network/downloadmanager/main.cpp b/examples/network/downloadmanager/main.cpp
deleted file mode 100644
index eb1bd1ce9a..0000000000
--- a/examples/network/downloadmanager/main.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QCoreApplication>
-#include <QStringList>
-
-#include "downloadmanager.h"
-
-#include <cstdio>
-
-int main(int argc, char **argv)
-{
- using namespace std;
-
- QCoreApplication app(argc, argv);
- QStringList arguments = app.arguments();
- arguments.takeFirst(); // remove the first argument, which is the program's name
-
- if (arguments.isEmpty()) {
- printf("Qt Download example\n"
- "Usage: downloadmanager url1 [url2... urlN]\n"
- "\n"
- "Downloads the URLs passed in the command-line to the local directory\n"
- "If the target file already exists, a .0, .1, .2, etc. is appended to\n"
- "differentiate.\n");
- return 0;
- }
-
- DownloadManager manager;
- manager.append(arguments);
-
- QObject::connect(&manager, &DownloadManager::finished,
- &app, &QCoreApplication::quit);
- app.exec();
-}
diff --git a/examples/network/downloadmanager/textprogressbar.cpp b/examples/network/downloadmanager/textprogressbar.cpp
deleted file mode 100644
index 3449e6bad5..0000000000
--- a/examples/network/downloadmanager/textprogressbar.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "textprogressbar.h"
-
-#include <QByteArray>
-
-#include <cstdio>
-
-using namespace std;
-
-void TextProgressBar::clear()
-{
- printf("\n");
- fflush(stdout);
-
- value = 0;
- maximum = -1;
- iteration = 0;
-}
-
-void TextProgressBar::update()
-{
- ++iteration;
-
- if (maximum > 0) {
- // we know the maximum
- // draw a progress bar
- int percent = value * 100 / maximum;
- int hashes = percent / 2;
-
- QByteArray progressbar(hashes, '#');
- if (percent % 2)
- progressbar += '>';
-
- printf("\r[%-50s] %3d%% %s ",
- progressbar.constData(),
- percent,
- qPrintable(message));
- } else {
- // we don't know the maximum, so we can't draw a progress bar
- int center = (iteration % 48) + 1; // 50 spaces, minus 2
- QByteArray before(qMax(center - 2, 0), ' ');
- QByteArray after(qMin(center + 2, 50), ' ');
-
- printf("\r[%s###%s] %s ",
- before.constData(), after.constData(), qPrintable(message));
- }
-}
-
-void TextProgressBar::setMessage(const QString &m)
-{
- message = m;
-}
-
-void TextProgressBar::setStatus(qint64 val, qint64 max)
-{
- value = val;
- maximum = max;
-}
diff --git a/examples/network/downloadmanager/textprogressbar.h b/examples/network/downloadmanager/textprogressbar.h
deleted file mode 100644
index 30affeb55c..0000000000
--- a/examples/network/downloadmanager/textprogressbar.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef TEXTPROGRESSBAR_H
-#define TEXTPROGRESSBAR_H
-
-#include <QString>
-
-class TextProgressBar
-{
-public:
- void clear();
- void update();
- void setMessage(const QString &message);
- void setStatus(qint64 value, qint64 maximum);
-
-private:
- QString message;
- qint64 value = 0;
- qint64 maximum = -1;
- int iteration = 0;
-};
-
-#endif
diff --git a/examples/network/fortuneclient/CMakeLists.txt b/examples/network/fortuneclient/CMakeLists.txt
index 4c80076d0d..ba55939b37 100644
--- a/examples/network/fortuneclient/CMakeLists.txt
+++ b/examples/network/fortuneclient/CMakeLists.txt
@@ -1,42 +1,39 @@
-# Generated from fortuneclient.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(fortuneclient LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/fortuneclient")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(fortuneclient
client.cpp client.h
main.cpp
)
+
set_target_properties(fortuneclient PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(fortuneclient PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(fortuneclient PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS fortuneclient
- 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 fortuneclient
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp
index 2daac33c2b..af7efbd9ed 100644
--- a/examples/network/fortuneclient/client.cpp
+++ b/examples/network/fortuneclient/client.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include <QtNetwork>
@@ -61,7 +14,6 @@ Client::Client(QWidget *parent)
, getFortuneButton(new QPushButton(tr("Get Fortune")))
, tcpSocket(new QTcpSocket(this))
{
- setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
//! [0]
hostCombo->setEditable(true);
// find out name of this machine
@@ -75,16 +27,16 @@ Client::Client(QWidget *parent)
if (name != QLatin1String("localhost"))
hostCombo->addItem(QString("localhost"));
// find out IP addresses of this machine
- QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
+ const QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
// add non-localhost addresses
- for (int i = 0; i < ipAddressesList.size(); ++i) {
- if (!ipAddressesList.at(i).isLoopback())
- hostCombo->addItem(ipAddressesList.at(i).toString());
+ for (const QHostAddress &entry : ipAddressesList) {
+ if (!entry.isLoopback())
+ hostCombo->addItem(entry.toString());
}
// add localhost addresses
- for (int i = 0; i < ipAddressesList.size(); ++i) {
- if (ipAddressesList.at(i).isLoopback())
- hostCombo->addItem(ipAddressesList.at(i).toString());
+ for (const QHostAddress &entry : ipAddressesList) {
+ if (entry.isLoopback())
+ hostCombo->addItem(entry.toString());
}
portLineEdit->setValidator(new QIntValidator(1, 65535, this));
@@ -108,7 +60,7 @@ Client::Client(QWidget *parent)
//! [1]
in.setDevice(tcpSocket);
- in.setVersion(QDataStream::Qt_4_0);
+ in.setVersion(QDataStream::Qt_6_5);
//! [1]
connect(hostCombo, &QComboBox::editTextChanged,
diff --git a/examples/network/fortuneclient/client.h b/examples/network/fortuneclient/client.h
index 80177bacbf..a4f3915de7 100644
--- a/examples/network/fortuneclient/client.h
+++ b/examples/network/fortuneclient/client.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CLIENT_H
#define CLIENT_H
diff --git a/examples/network/fortuneclient/main.cpp b/examples/network/fortuneclient/main.cpp
index 6b02708ce1..044755ea21 100644
--- a/examples/network/fortuneclient/main.cpp
+++ b/examples/network/fortuneclient/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include "client.h"
diff --git a/examples/network/fortuneserver/CMakeLists.txt b/examples/network/fortuneserver/CMakeLists.txt
index f1a668cf88..af51db6a5e 100644
--- a/examples/network/fortuneserver/CMakeLists.txt
+++ b/examples/network/fortuneserver/CMakeLists.txt
@@ -1,42 +1,39 @@
-# Generated from fortuneserver.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(fortuneserver LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/fortuneserver")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(fortuneserver
main.cpp
server.cpp server.h
)
+
set_target_properties(fortuneserver PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(fortuneserver PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(fortuneserver PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS fortuneserver
- 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 fortuneserver
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/fortuneserver/main.cpp b/examples/network/fortuneserver/main.cpp
index a64fcb26dc..7f5326598b 100644
--- a/examples/network/fortuneserver/main.cpp
+++ b/examples/network/fortuneserver/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp
index 95aadb60c9..67d6117566 100644
--- a/examples/network/fortuneserver/server.cpp
+++ b/examples/network/fortuneserver/server.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include <QtNetwork>
@@ -58,7 +11,6 @@ Server::Server(QWidget *parent)
: QDialog(parent)
, statusLabel(new QLabel)
{
- setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
statusLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
initServer();
@@ -119,12 +71,11 @@ void Server::initServer()
}
//! [0]
QString ipAddress;
- QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
+ const QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
// use the first non-localhost IPv4 address
- for (int i = 0; i < ipAddressesList.size(); ++i) {
- if (ipAddressesList.at(i) != QHostAddress::LocalHost &&
- ipAddressesList.at(i).toIPv4Address()) {
- ipAddress = ipAddressesList.at(i).toString();
+ for (const QHostAddress &entry : ipAddressesList) {
+ if (entry != QHostAddress::LocalHost && entry.toIPv4Address()) {
+ ipAddress = entry.toString();
break;
}
}
@@ -143,9 +94,9 @@ void Server::sendFortune()
//! [5]
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
- out.setVersion(QDataStream::Qt_5_10);
+ out.setVersion(QDataStream::Qt_6_5);
- out << fortunes[QRandomGenerator::global()->bounded(int(fortunes.size()))];
+ out << fortunes[QRandomGenerator::global()->bounded(fortunes.size())];
//! [4] //! [7]
QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
diff --git a/examples/network/fortuneserver/server.h b/examples/network/fortuneserver/server.h
index bf0bcbc9b5..f72fd76b39 100644
--- a/examples/network/fortuneserver/server.h
+++ b/examples/network/fortuneserver/server.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SERVER_H
#define SERVER_H
diff --git a/examples/network/googlesuggest/CMakeLists.txt b/examples/network/googlesuggest/CMakeLists.txt
deleted file mode 100644
index ade5b85f2d..0000000000
--- a/examples/network/googlesuggest/CMakeLists.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-# Generated from googlesuggest.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(googlesuggest LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/googlesuggest")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(googlesuggest
- googlesuggest.cpp googlesuggest.h
- main.cpp
- searchbox.cpp searchbox.h
-)
-set_target_properties(googlesuggest PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(googlesuggest PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
-)
-
-install(TARGETS googlesuggest
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/network/googlesuggest/googlesuggest.cpp b/examples/network/googlesuggest/googlesuggest.cpp
deleted file mode 100644
index b7b6d3ab62..0000000000
--- a/examples/network/googlesuggest/googlesuggest.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "googlesuggest.h"
-
-//! [1]
-const QString gsuggestUrl(QStringLiteral("http://google.com/complete/search?output=toolbar&q=%1"));
-//! [1]
-
-//! [2]
-GSuggestCompletion::GSuggestCompletion(QLineEdit *parent): QObject(parent), editor(parent)
-{
- popup = new QTreeWidget;
- popup->setWindowFlags(Qt::Popup);
- popup->setFocusPolicy(Qt::NoFocus);
- popup->setFocusProxy(parent);
- popup->setMouseTracking(true);
-
- popup->setColumnCount(1);
- popup->setUniformRowHeights(true);
- popup->setRootIsDecorated(false);
- popup->setEditTriggers(QTreeWidget::NoEditTriggers);
- popup->setSelectionBehavior(QTreeWidget::SelectRows);
- popup->setFrameStyle(QFrame::Box | QFrame::Plain);
- popup->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- popup->header()->hide();
-
- popup->installEventFilter(this);
-
- connect(popup, &QTreeWidget::itemClicked,
- this, &GSuggestCompletion::doneCompletion);
-
- timer.setSingleShot(true);
- timer.setInterval(500);
- connect(&timer, &QTimer::timeout,
- this, &GSuggestCompletion::autoSuggest);
- connect(editor, &QLineEdit::textEdited,
- &timer, QOverload<>::of(&QTimer::start));
-
- connect(&networkManager, &QNetworkAccessManager::finished,
- this, &GSuggestCompletion::handleNetworkData);
-
-}
-//! [2]
-
-//! [3]
-GSuggestCompletion::~GSuggestCompletion()
-{
- delete popup;
-}
-//! [3]
-
-//! [4]
-bool GSuggestCompletion::eventFilter(QObject *obj, QEvent *ev)
-{
- if (obj != popup)
- return false;
-
- if (ev->type() == QEvent::MouseButtonPress) {
- popup->hide();
- editor->setFocus();
- return true;
- }
-
- if (ev->type() == QEvent::KeyPress) {
- bool consumed = false;
- int key = static_cast<QKeyEvent*>(ev)->key();
- switch (key) {
- case Qt::Key_Enter:
- case Qt::Key_Return:
- doneCompletion();
- consumed = true;
- break;
-
- case Qt::Key_Escape:
- editor->setFocus();
- popup->hide();
- consumed = true;
- break;
-
- case Qt::Key_Up:
- case Qt::Key_Down:
- case Qt::Key_Home:
- case Qt::Key_End:
- case Qt::Key_PageUp:
- case Qt::Key_PageDown:
- break;
-
- default:
- editor->setFocus();
- editor->event(ev);
- popup->hide();
- break;
- }
-
- return consumed;
- }
-
- return false;
-}
-//! [4]
-
-//! [5]
-void GSuggestCompletion::showCompletion(const QList<QString> &choices)
-{
- if (choices.isEmpty())
- return;
-
- const QPalette &pal = editor->palette();
- QColor color = pal.color(QPalette::Disabled, QPalette::WindowText);
-
- popup->setUpdatesEnabled(false);
- popup->clear();
-
- for (const auto &choice : choices) {
- auto item = new QTreeWidgetItem(popup);
- item->setText(0, choice);
- item->setForeground(0, color);
- }
-
- popup->setCurrentItem(popup->topLevelItem(0));
- popup->resizeColumnToContents(0);
- popup->setUpdatesEnabled(true);
-
- popup->move(editor->mapToGlobal(QPoint(0, editor->height())));
- popup->setFocus();
- popup->show();
-}
-//! [5]
-
-//! [6]
-void GSuggestCompletion::doneCompletion()
-{
- timer.stop();
- popup->hide();
- editor->setFocus();
- QTreeWidgetItem *item = popup->currentItem();
- if (item) {
- editor->setText(item->text(0));
- QMetaObject::invokeMethod(editor, "returnPressed");
- }
-}
-//! [6]
-
-//! [7]
-void GSuggestCompletion::autoSuggest()
-{
- QString str = editor->text();
- QString url = gsuggestUrl.arg(str);
- networkManager.get(QNetworkRequest(url));
-}
-//! [7]
-
-//! [8]
-void GSuggestCompletion::preventSuggest()
-{
- timer.stop();
-}
-//! [8]
-
-//! [9]
-void GSuggestCompletion::handleNetworkData(QNetworkReply *networkReply)
-{
- QUrl url = networkReply->url();
- if (networkReply->error() == QNetworkReply::NoError) {
- QList<QString> choices;
-
- QByteArray response(networkReply->readAll());
- QXmlStreamReader xml(response);
- while (!xml.atEnd()) {
- xml.readNext();
- if (xml.tokenType() == QXmlStreamReader::StartElement)
- if (xml.name() == u"suggestion") {
- auto str = xml.attributes().value("data");
- choices << str.toString();
- }
- }
-
- showCompletion(choices);
- }
-
- networkReply->deleteLater();
-}
-//! [9]
diff --git a/examples/network/googlesuggest/googlesuggest.h b/examples/network/googlesuggest/googlesuggest.h
deleted file mode 100644
index 909386569b..0000000000
--- a/examples/network/googlesuggest/googlesuggest.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef GOOGLESUGGEST_H
-#define GOOGLESUGGEST_H
-
-#include <QtWidgets>
-#include <QtNetwork>
-#include <QtCore>
-
-//! [1]
-class GSuggestCompletion : public QObject
-{
- Q_OBJECT
-
-public:
- explicit GSuggestCompletion(QLineEdit *parent = nullptr);
- ~GSuggestCompletion();
- bool eventFilter(QObject *obj, QEvent *ev) override;
- void showCompletion(const QList<QString> &choices);
-
-public slots:
-
- void doneCompletion();
- void preventSuggest();
- void autoSuggest();
- void handleNetworkData(QNetworkReply *networkReply);
-
-private:
- QLineEdit *editor = nullptr;
- QTreeWidget *popup = nullptr;
- QTimer timer;
- QNetworkAccessManager networkManager;
-};
-//! [1]
-#endif // GOOGLESUGGEST_H
-
diff --git a/examples/network/googlesuggest/googlesuggest.pro b/examples/network/googlesuggest/googlesuggest.pro
deleted file mode 100644
index 6e73906303..0000000000
--- a/examples/network/googlesuggest/googlesuggest.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-QT += network widgets
-requires(qtConfig(itemviews))
-SOURCES = main.cpp searchbox.cpp googlesuggest.cpp
-HEADERS = searchbox.h googlesuggest.h
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/network/googlesuggest
-INSTALLS += target
diff --git a/examples/network/googlesuggest/main.cpp b/examples/network/googlesuggest/main.cpp
deleted file mode 100644
index ab819c5502..0000000000
--- a/examples/network/googlesuggest/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "searchbox.h"
-
-int main(int argc, char * argv[])
-{
- QApplication app(argc, argv);
- SearchBox searchEdit;
- searchEdit.show();
- return app.exec();
-}
diff --git a/examples/network/googlesuggest/searchbox.cpp b/examples/network/googlesuggest/searchbox.cpp
deleted file mode 100644
index 9057c1ccdf..0000000000
--- a/examples/network/googlesuggest/searchbox.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDesktopServices>
-#include <QUrl>
-
-#include "searchbox.h"
-#include "googlesuggest.h"
-
-const QString gsearchUrl = QStringLiteral("http://www.google.com/search?q=%1");
-
-//! [1]
-SearchBox::SearchBox(QWidget *parent)
- : QLineEdit(parent)
- , completer(new GSuggestCompletion(this))
-{
- connect(this, &SearchBox::returnPressed, this, &SearchBox::doSearch);
-
- setWindowTitle("Search with Google");
-
- adjustSize();
- resize(400, height());
- setFocus();
-}
-//! [1]
-
-//! [2]
-void SearchBox::doSearch()
-{
- completer->preventSuggest();
- QString url = gsearchUrl.arg(text());
- QDesktopServices::openUrl(url);
-}
-//! [2]
-
diff --git a/examples/network/googlesuggest/searchbox.h b/examples/network/googlesuggest/searchbox.h
deleted file mode 100644
index fbd33011b7..0000000000
--- a/examples/network/googlesuggest/searchbox.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SEARCHBOX_H
-#define SEARCHBOX_H
-
-//! [1]
-#include <QLineEdit>
-
-class GSuggestCompletion;
-
-class SearchBox: public QLineEdit
-{
- Q_OBJECT
-
-public:
- explicit SearchBox(QWidget *parent = nullptr);
-
-protected slots:
- void doSearch();
-
-private:
- GSuggestCompletion *completer = nullptr;
-//! [1]
-};
-
-
-#endif // SEARCHBOX_H
diff --git a/examples/network/http/CMakeLists.txt b/examples/network/http/CMakeLists.txt
index b967881c6a..705c3a0beb 100644
--- a/examples/network/http/CMakeLists.txt
+++ b/examples/network/http/CMakeLists.txt
@@ -1,53 +1,40 @@
-# Generated from http.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(http LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/http")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(http
authenticationdialog.ui
httpwindow.cpp httpwindow.h
main.cpp
)
+
set_target_properties(http PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(http PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
-)
-if(ANDROID AND TARGET Qt::AndroidExtras)
- target_compile_definitions(http PUBLIC
- REQUEST_PERMISSIONS_ON_ANDROID
- )
-
- target_link_libraries(http PUBLIC
- Qt::AndroidExtras
- )
-endif()
+target_link_libraries(http PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
+)
install(TARGETS http
- 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 http
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/http/http.pro b/examples/network/http/http.pro
index f67cd01495..2f2d3b00ae 100644
--- a/examples/network/http/http.pro
+++ b/examples/network/http/http.pro
@@ -1,8 +1,4 @@
QT += network widgets
-android: qtHaveModule(androidextras) {
- QT += androidextras
- DEFINES += REQUEST_PERMISSIONS_ON_ANDROID
-}
HEADERS += httpwindow.h
SOURCES += httpwindow.cpp \
diff --git a/examples/network/http/httpwindow.cpp b/examples/network/http/httpwindow.cpp
index 2790b8503e..72f130734b 100644
--- a/examples/network/http/httpwindow.cpp
+++ b/examples/network/http/httpwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "httpwindow.h"
@@ -70,7 +23,6 @@ ProgressDialog::ProgressDialog(const QUrl &url, QWidget *parent)
: QProgressDialog(parent)
{
setWindowTitle(tr("Download Progress"));
- setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setLabelText(tr("Downloading %1.").arg(url.toDisplayString()));
setMinimum(0);
setValue(0);
@@ -89,17 +41,20 @@ HttpWindow::HttpWindow(QWidget *parent)
, statusLabel(new QLabel(tr("Please enter the URL of a file you want to download.\n\n"), this))
, urlLineEdit(new QLineEdit(defaultUrl))
, downloadButton(new QPushButton(tr("Download")))
- , launchCheckBox(new QCheckBox("Launch file"))
+ , launchCheckBox(new QCheckBox(tr("Launch file")))
, defaultFileLineEdit(new QLineEdit(defaultFileName))
, downloadDirectoryLineEdit(new QLineEdit)
{
- setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
- setWindowTitle(tr("HTTP"));
+ setWindowTitle(tr("HTTP Client"));
//! [qnam-auth-required-1]
connect(&qnam, &QNetworkAccessManager::authenticationRequired,
this, &HttpWindow::slotAuthenticationRequired);
//! [qnam-auth-required-1]
+#if QT_CONFIG(networkproxy)
+ connect(&qnam, &QNetworkAccessManager::proxyAuthenticationRequired,
+ this, &HttpWindow::slotProxyAuthenticationRequired);
+#endif
QFormLayout *formLayout = new QFormLayout;
urlLineEdit->setClearButtonEnabled(true);
@@ -189,19 +144,18 @@ void HttpWindow::downloadFile()
bool useDirectory = !downloadDirectory.isEmpty() && QFileInfo(downloadDirectory).isDir();
if (useDirectory)
fileName.prepend(downloadDirectory + '/');
+
if (QFile::exists(fileName)) {
- if (QMessageBox::question(this, tr("Overwrite Existing File"),
- tr("There already exists a file called %1%2."
- " Overwrite?")
- .arg(fileName,
- useDirectory
- ? QString()
- : QStringLiteral(" in the current directory")),
- QMessageBox::Yes | QMessageBox::No,
- QMessageBox::No)
- == QMessageBox::No) {
+ QString alreadyExists = useDirectory
+ ? tr("There already exists a file called %1. Overwrite?")
+ : tr("There already exists a file called %1 in the current directory. "
+ "Overwrite?");
+ QMessageBox::StandardButton response = QMessageBox::question(this,
+ tr("Overwrite Existing File"),
+ alreadyExists.arg(QDir::toNativeSeparators(fileName)),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+ if (response == QMessageBox::No)
return;
- }
QFile::remove(fileName);
}
@@ -319,11 +273,34 @@ void HttpWindow::sslErrors(const QList<QSslError> &errors)
errorString += error.errorString();
}
- if (QMessageBox::warning(this, tr("SSL Errors"),
- tr("One or more SSL errors has occurred:\n%1").arg(errorString),
- QMessageBox::Ignore | QMessageBox::Abort) == QMessageBox::Ignore) {
+ if (QMessageBox::warning(this, tr("TLS Errors"),
+ tr("One or more TLS errors has occurred:\n%1").arg(errorString),
+ QMessageBox::Ignore | QMessageBox::Abort)
+ == QMessageBox::Ignore) {
reply->ignoreSslErrors();
}
}
//! [sslerrors-2]
#endif
+
+#if QT_CONFIG(networkproxy)
+void HttpWindow::slotProxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)
+{
+ QDialog authenticationDialog;
+ Ui::Dialog ui;
+ ui.setupUi(&authenticationDialog);
+ authenticationDialog.adjustSize();
+ ui.siteDescription->setText(tr("A network proxy at %1 is requesting credentials for realm: %2")
+ .arg(proxy.hostName(), authenticator->realm()));
+
+ // If the user passed credentials in the URL to http_proxy or similar they may be available to
+ // us. Otherwise this will just leave the fields empty
+ ui.userEdit->setText(proxy.user());
+ ui.passwordEdit->setText(proxy.password());
+
+ if (authenticationDialog.exec() == QDialog::Accepted) {
+ authenticator->setUser(ui.userEdit->text());
+ authenticator->setPassword(ui.passwordEdit->text());
+ }
+}
+#endif
diff --git a/examples/network/http/httpwindow.h b/examples/network/http/httpwindow.h
index 4bb99611bb..ade0635e48 100644
--- a/examples/network/http/httpwindow.h
+++ b/examples/network/http/httpwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef HTTPWINDOW_H
#define HTTPWINDOW_H
@@ -66,6 +19,9 @@ class QSslError;
class QAuthenticator;
class QNetworkReply;
class QCheckBox;
+#if QT_CONFIG(networkproxy)
+class QNetworkProxy;
+#endif
QT_END_NAMESPACE
@@ -99,6 +55,9 @@ private slots:
#if QT_CONFIG(ssl)
void sslErrors(const QList<QSslError> &errors);
#endif
+#if QT_CONFIG(networkproxy)
+ void slotProxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
+#endif
private:
std::unique_ptr<QFile> openFileForWrite(const QString &fileName);
diff --git a/examples/network/http/main.cpp b/examples/network/http/main.cpp
index 6c86933fd6..4b0bd9e76a 100644
--- a/examples/network/http/main.cpp
+++ b/examples/network/http/main.cpp
@@ -1,91 +1,20 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QDir>
#include <QScreen>
#include "httpwindow.h"
-#ifdef REQUEST_PERMISSIONS_ON_ANDROID
-#include <QtAndroid>
-
-bool requestStoragePermission() {
- using namespace QtAndroid;
-
- QString permission = QStringLiteral("android.permission.WRITE_EXTERNAL_STORAGE");
- const QHash<QString, PermissionResult> results = requestPermissionsSync(QStringList({permission}));
- if (!results.contains(permission) || results[permission] == PermissionResult::Denied) {
- qWarning() << "Couldn't get permission: " << permission;
- return false;
- }
-
- return true;
-}
-#endif
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
-#ifdef REQUEST_PERMISSIONS_ON_ANDROID
- if (!requestStoragePermission())
- return -1;
-#endif
HttpWindow httpWin;
const QRect availableSize = httpWin.screen()->availableGeometry();
httpWin.resize(availableSize.width() / 5, availableSize.height() / 5);
httpWin.move((availableSize.width() - httpWin.width()) / 2, (availableSize.height() - httpWin.height()) / 2);
-#ifdef Q_OS_ANDROID
- httpWin.showMaximized();
-#else
httpWin.show();
-#endif
return app.exec();
}
diff --git a/examples/network/loopback/CMakeLists.txt b/examples/network/loopback/CMakeLists.txt
deleted file mode 100644
index eb0c13e230..0000000000
--- a/examples/network/loopback/CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-# Generated from loopback.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(loopback LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/loopback")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(loopback
- dialog.cpp dialog.h
- main.cpp
-)
-set_target_properties(loopback PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(loopback PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
-)
-
-install(TARGETS loopback
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/network/loopback/dialog.cpp b/examples/network/loopback/dialog.cpp
deleted file mode 100644
index 4037f4c085..0000000000
--- a/examples/network/loopback/dialog.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "dialog.h"
-
-#include <QtNetwork>
-#include <QtWidgets>
-
-static const int TotalBytes = 50 * 1024 * 1024;
-static const int PayloadSize = 64 * 1024; // 64 KB
-
-Dialog::Dialog(QWidget *parent)
- : QDialog(parent)
-{
- clientProgressBar = new QProgressBar;
- clientStatusLabel = new QLabel(tr("Client ready"));
- serverProgressBar = new QProgressBar;
- serverStatusLabel = new QLabel(tr("Server ready"));
-
- startButton = new QPushButton(tr("&Start"));
- quitButton = new QPushButton(tr("&Quit"));
-
- buttonBox = new QDialogButtonBox;
- buttonBox->addButton(startButton, QDialogButtonBox::ActionRole);
- buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
-
- connect(startButton, &QAbstractButton::clicked, this, &Dialog::start);
- connect(quitButton, &QAbstractButton::clicked, this, &QWidget::close);
- connect(&tcpServer, &QTcpServer::newConnection,
- this, &Dialog::acceptConnection);
- connect(&tcpClient, &QAbstractSocket::connected, this, &Dialog::startTransfer);
- connect(&tcpClient, &QIODevice::bytesWritten,
- this, &Dialog::updateClientProgress);
- connect(&tcpClient, &QAbstractSocket::errorOccurred,
- this, &Dialog::displayError);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(clientProgressBar);
- mainLayout->addWidget(clientStatusLabel);
- mainLayout->addWidget(serverProgressBar);
- mainLayout->addWidget(serverStatusLabel);
- mainLayout->addStretch(1);
- mainLayout->addSpacing(10);
- mainLayout->addWidget(buttonBox);
- setLayout(mainLayout);
-
- setWindowTitle(tr("Loopback"));
-}
-
-void Dialog::start()
-{
- startButton->setEnabled(false);
-
-#ifndef QT_NO_CURSOR
- QGuiApplication::setOverrideCursor(Qt::WaitCursor);
-#endif
-
- bytesWritten = 0;
- bytesReceived = 0;
-
- while (!tcpServer.isListening() && !tcpServer.listen()) {
- QMessageBox::StandardButton ret = QMessageBox::critical(this,
- tr("Loopback"),
- tr("Unable to start the test: %1.")
- .arg(tcpServer.errorString()),
- QMessageBox::Retry
- | QMessageBox::Cancel);
- if (ret == QMessageBox::Cancel)
- return;
- }
-
- serverStatusLabel->setText(tr("Listening"));
- clientStatusLabel->setText(tr("Connecting"));
- tcpClient.connectToHost(QHostAddress::LocalHost, tcpServer.serverPort());
-}
-
-void Dialog::acceptConnection()
-{
- tcpServerConnection = tcpServer.nextPendingConnection();
- if (!tcpServerConnection) {
- serverStatusLabel->setText(tr("Error: got invalid pending connection!"));
- return;
- }
-
- connect(tcpServerConnection, &QIODevice::readyRead,
- this, &Dialog::updateServerProgress);
- connect(tcpServerConnection, &QAbstractSocket::errorOccurred,
- this, &Dialog::displayError);
- connect(tcpServerConnection, &QTcpSocket::disconnected,
- tcpServerConnection, &QTcpSocket::deleteLater);
-
- serverStatusLabel->setText(tr("Accepted connection"));
- tcpServer.close();
-}
-
-void Dialog::startTransfer()
-{
- // called when the TCP client connected to the loopback server
- bytesToWrite = TotalBytes - int(tcpClient.write(QByteArray(PayloadSize, '@')));
- clientStatusLabel->setText(tr("Connected"));
-}
-
-void Dialog::updateServerProgress()
-{
- bytesReceived += int(tcpServerConnection->bytesAvailable());
- tcpServerConnection->readAll();
-
- serverProgressBar->setMaximum(TotalBytes);
- serverProgressBar->setValue(bytesReceived);
- serverStatusLabel->setText(tr("Received %1MB")
- .arg(bytesReceived / (1024 * 1024)));
-
- if (bytesReceived == TotalBytes) {
- tcpServerConnection->close();
- startButton->setEnabled(true);
-#ifndef QT_NO_CURSOR
- QGuiApplication::restoreOverrideCursor();
-#endif
- }
-}
-
-void Dialog::updateClientProgress(qint64 numBytes)
-{
- // called when the TCP client has written some bytes
- bytesWritten += int(numBytes);
-
- // only write more if not finished and when the Qt write buffer is below a certain size.
- if (bytesToWrite > 0 && tcpClient.bytesToWrite() <= 4 * PayloadSize)
- bytesToWrite -= tcpClient.write(QByteArray(qMin(bytesToWrite, PayloadSize), '@'));
-
- clientProgressBar->setMaximum(TotalBytes);
- clientProgressBar->setValue(bytesWritten);
- clientStatusLabel->setText(tr("Sent %1MB").arg(bytesWritten / (1024 * 1024)));
-}
-
-void Dialog::displayError(QAbstractSocket::SocketError socketError)
-{
- if (socketError == QTcpSocket::RemoteHostClosedError)
- return;
-
- QMessageBox::information(this, tr("Network error"),
- tr("The following error occurred: %1.")
- .arg(tcpClient.errorString()));
-
- tcpClient.close();
- tcpServer.close();
- clientProgressBar->reset();
- serverProgressBar->reset();
- clientStatusLabel->setText(tr("Client ready"));
- serverStatusLabel->setText(tr("Server ready"));
- startButton->setEnabled(true);
-#ifndef QT_NO_CURSOR
- QGuiApplication::restoreOverrideCursor();
-#endif
-}
diff --git a/examples/network/loopback/dialog.h b/examples/network/loopback/dialog.h
deleted file mode 100644
index a70c20550a..0000000000
--- a/examples/network/loopback/dialog.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DIALOG_H
-#define DIALOG_H
-
-#include <QDialog>
-#include <QTcpServer>
-#include <QTcpSocket>
-
-QT_BEGIN_NAMESPACE
-class QDialogButtonBox;
-class QLabel;
-class QProgressBar;
-class QPushButton;
-QT_END_NAMESPACE
-
-class Dialog : public QDialog
-{
- Q_OBJECT
-
-public:
- Dialog(QWidget *parent = nullptr);
-
-public slots:
- void start();
- void acceptConnection();
- void startTransfer();
- void updateServerProgress();
- void updateClientProgress(qint64 numBytes);
- void displayError(QAbstractSocket::SocketError socketError);
-
-private:
- QProgressBar *clientProgressBar = nullptr;
- QProgressBar *serverProgressBar = nullptr;
- QLabel *clientStatusLabel = nullptr;
- QLabel *serverStatusLabel = nullptr;
-
- QPushButton *startButton = nullptr;
- QPushButton *quitButton = nullptr;
- QDialogButtonBox *buttonBox = nullptr;
-
- QTcpServer tcpServer;
- QTcpSocket tcpClient;
- QTcpSocket *tcpServerConnection = nullptr;
- int bytesToWrite = 0;
- int bytesWritten = 0;
- int bytesReceived = 0;
-};
-
-#endif
diff --git a/examples/network/loopback/loopback.pro b/examples/network/loopback/loopback.pro
deleted file mode 100644
index 14b22daa57..0000000000
--- a/examples/network/loopback/loopback.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QT += network widgets
-
-HEADERS = dialog.h
-SOURCES = dialog.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/network/loopback
-INSTALLS += target
diff --git a/examples/network/loopback/main.cpp b/examples/network/loopback/main.cpp
deleted file mode 100644
index 094a11d4fc..0000000000
--- a/examples/network/loopback/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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/network/multicastreceiver/CMakeLists.txt b/examples/network/multicastreceiver/CMakeLists.txt
index c3f7837f94..cb1139e69a 100644
--- a/examples/network/multicastreceiver/CMakeLists.txt
+++ b/examples/network/multicastreceiver/CMakeLists.txt
@@ -1,42 +1,39 @@
-# Generated from multicastreceiver.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(multicastreceiver LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/multicastreceiver")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(multicastreceiver
main.cpp
receiver.cpp receiver.h
)
+
set_target_properties(multicastreceiver PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(multicastreceiver PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(multicastreceiver PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS multicastreceiver
- 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 multicastreceiver
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/multicastreceiver/main.cpp b/examples/network/multicastreceiver/main.cpp
index ba1beeee12..53905c806d 100644
--- a/examples/network/multicastreceiver/main.cpp
+++ b/examples/network/multicastreceiver/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/network/multicastreceiver/receiver.cpp b/examples/network/multicastreceiver/receiver.cpp
index 3737d64f96..23e204ca25 100644
--- a/examples/network/multicastreceiver/receiver.cpp
+++ b/examples/network/multicastreceiver/receiver.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include <QtNetwork>
@@ -85,7 +38,7 @@ Receiver::Receiver(QWidget *parent)
connect(&udpSocket6, &QUdpSocket::readyRead,
this, &Receiver::processPendingDatagrams);
connect(quitButton, &QPushButton::clicked,
- this, &Receiver::close);
+ qApp, &QCoreApplication::quit);
}
void Receiver::processPendingDatagrams()
@@ -94,7 +47,7 @@ void Receiver::processPendingDatagrams()
// using QUdpSocket::readDatagram (API since Qt 4)
while (udpSocket4.hasPendingDatagrams()) {
- datagram.resize(int(udpSocket4.pendingDatagramSize()));
+ datagram.resize(qsizetype(udpSocket4.pendingDatagramSize()));
udpSocket4.readDatagram(datagram.data(), datagram.size());
statusLabel->setText(tr("Received IPv4 datagram: \"%1\"")
.arg(datagram.constData()));
diff --git a/examples/network/multicastreceiver/receiver.h b/examples/network/multicastreceiver/receiver.h
index 0325d861df..4aca8092f5 100644
--- a/examples/network/multicastreceiver/receiver.h
+++ b/examples/network/multicastreceiver/receiver.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef RECEIVER_H
#define RECEIVER_H
diff --git a/examples/network/multicastsender/CMakeLists.txt b/examples/network/multicastsender/CMakeLists.txt
index 2ff038e269..eb45b9f2fa 100644
--- a/examples/network/multicastsender/CMakeLists.txt
+++ b/examples/network/multicastsender/CMakeLists.txt
@@ -1,42 +1,39 @@
-# Generated from multicastsender.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(multicastsender LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/multicastsender")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(multicastsender
main.cpp
sender.cpp sender.h
)
+
set_target_properties(multicastsender PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(multicastsender PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(multicastsender PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS multicastsender
- 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 multicastsender
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/multicastsender/main.cpp b/examples/network/multicastsender/main.cpp
index b1ccc78cea..4135aa9373 100644
--- a/examples/network/multicastsender/main.cpp
+++ b/examples/network/multicastsender/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/network/multicastsender/sender.cpp b/examples/network/multicastsender/sender.cpp
index a995bd7331..a56c1f28e1 100644
--- a/examples/network/multicastsender/sender.cpp
+++ b/examples/network/multicastsender/sender.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "sender.h"
diff --git a/examples/network/multicastsender/sender.h b/examples/network/multicastsender/sender.h
index 0af6f9aaec..5dba4c5e51 100644
--- a/examples/network/multicastsender/sender.h
+++ b/examples/network/multicastsender/sender.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SENDER_H
#define SENDER_H
diff --git a/examples/network/multistreamclient/CMakeLists.txt b/examples/network/multistreamclient/CMakeLists.txt
index f060c06b39..1226a4b3c7 100644
--- a/examples/network/multistreamclient/CMakeLists.txt
+++ b/examples/network/multistreamclient/CMakeLists.txt
@@ -1,24 +1,12 @@
-# Generated from multistreamclient.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(multistreamclient LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/multistreamclient")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(multistreamclient
chatconsumer.cpp chatconsumer.h
@@ -28,19 +16,28 @@ qt_add_executable(multistreamclient
movieconsumer.cpp movieconsumer.h
timeconsumer.cpp timeconsumer.h
)
+
set_target_properties(multistreamclient PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(multistreamclient PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(multistreamclient PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS multistreamclient
- 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 multistreamclient
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/multistreamclient/chatconsumer.cpp b/examples/network/multistreamclient/chatconsumer.cpp
index 723ecfaa23..d71fb107d8 100644
--- a/examples/network/multistreamclient/chatconsumer.cpp
+++ b/examples/network/multistreamclient/chatconsumer.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "chatconsumer.h"
#include <QWidget>
diff --git a/examples/network/multistreamclient/chatconsumer.h b/examples/network/multistreamclient/chatconsumer.h
index e10c0d7850..88d54a2fbc 100644
--- a/examples/network/multistreamclient/chatconsumer.h
+++ b/examples/network/multistreamclient/chatconsumer.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CHATCONSUMER_H
#define CHATCONSUMER_H
diff --git a/examples/network/multistreamclient/client.cpp b/examples/network/multistreamclient/client.cpp
index ce84f3df9a..84474658ae 100644
--- a/examples/network/multistreamclient/client.cpp
+++ b/examples/network/multistreamclient/client.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include <QtNetwork>
diff --git a/examples/network/multistreamclient/client.h b/examples/network/multistreamclient/client.h
index 220be08776..fcd03b1323 100644
--- a/examples/network/multistreamclient/client.h
+++ b/examples/network/multistreamclient/client.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CLIENT_H
#define CLIENT_H
diff --git a/examples/network/multistreamclient/consumer.h b/examples/network/multistreamclient/consumer.h
index d70f8d67bf..ea146520c8 100644
--- a/examples/network/multistreamclient/consumer.h
+++ b/examples/network/multistreamclient/consumer.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CONSUMER_H
#define CONSUMER_H
diff --git a/examples/network/multistreamclient/main.cpp b/examples/network/multistreamclient/main.cpp
index b903214710..5c6ea1b441 100644
--- a/examples/network/multistreamclient/main.cpp
+++ b/examples/network/multistreamclient/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include "client.h"
diff --git a/examples/network/multistreamclient/movieconsumer.cpp b/examples/network/multistreamclient/movieconsumer.cpp
index ff5610a0b9..7a8c6780da 100644
--- a/examples/network/multistreamclient/movieconsumer.cpp
+++ b/examples/network/multistreamclient/movieconsumer.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "movieconsumer.h"
#include <QLabel>
diff --git a/examples/network/multistreamclient/movieconsumer.h b/examples/network/multistreamclient/movieconsumer.h
index 3f78bf2060..d9928ecae4 100644
--- a/examples/network/multistreamclient/movieconsumer.h
+++ b/examples/network/multistreamclient/movieconsumer.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MOVIECONSUMER_H
#define MOVIECONSUMER_H
diff --git a/examples/network/multistreamclient/timeconsumer.cpp b/examples/network/multistreamclient/timeconsumer.cpp
index 6543e53cfc..6445e719c5 100644
--- a/examples/network/multistreamclient/timeconsumer.cpp
+++ b/examples/network/multistreamclient/timeconsumer.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "timeconsumer.h"
#include <QLCDNumber>
@@ -82,7 +35,7 @@ void TimeConsumer::readDatagram(const QByteArray &ba)
void TimeConsumer::timerTick()
{
QByteArray buf;
- QDataStream ds(&buf, QIODevice::WriteOnly);
+ QDataStream ds(&buf, QIODeviceBase::WriteOnly);
ds << lastTime;
emit writeDatagram(buf);
diff --git a/examples/network/multistreamclient/timeconsumer.h b/examples/network/multistreamclient/timeconsumer.h
index 84a7796699..9036b6279a 100644
--- a/examples/network/multistreamclient/timeconsumer.h
+++ b/examples/network/multistreamclient/timeconsumer.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TIMECONSUMER_H
#define TIMECONSUMER_H
diff --git a/examples/network/multistreamserver/CMakeLists.txt b/examples/network/multistreamserver/CMakeLists.txt
index 8273e2b029..3f77506f70 100644
--- a/examples/network/multistreamserver/CMakeLists.txt
+++ b/examples/network/multistreamserver/CMakeLists.txt
@@ -1,24 +1,12 @@
-# Generated from multistreamserver.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(multistreamserver LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/multistreamserver")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(multistreamserver
chatprovider.cpp chatprovider.h
@@ -28,19 +16,28 @@ qt_add_executable(multistreamserver
server.cpp server.h
timeprovider.cpp timeprovider.h
)
+
set_target_properties(multistreamserver PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(multistreamserver PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(multistreamserver PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS multistreamserver
- 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 multistreamserver
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/multistreamserver/chatprovider.cpp b/examples/network/multistreamserver/chatprovider.cpp
index a6ba9c6a27..6b8b555e0d 100644
--- a/examples/network/multistreamserver/chatprovider.cpp
+++ b/examples/network/multistreamserver/chatprovider.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "chatprovider.h"
#include <QString>
diff --git a/examples/network/multistreamserver/chatprovider.h b/examples/network/multistreamserver/chatprovider.h
index c52fa89240..88ebab8db7 100644
--- a/examples/network/multistreamserver/chatprovider.h
+++ b/examples/network/multistreamserver/chatprovider.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CHATPROVIDER_H
#define CHATPROVIDER_H
diff --git a/examples/network/multistreamserver/main.cpp b/examples/network/multistreamserver/main.cpp
index ae201f6b82..06c71a9692 100644
--- a/examples/network/multistreamserver/main.cpp
+++ b/examples/network/multistreamserver/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/network/multistreamserver/movieprovider.cpp b/examples/network/multistreamserver/movieprovider.cpp
index 335038a515..84bea3cc1b 100644
--- a/examples/network/multistreamserver/movieprovider.cpp
+++ b/examples/network/multistreamserver/movieprovider.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "movieprovider.h"
#include <QMovie>
diff --git a/examples/network/multistreamserver/movieprovider.h b/examples/network/multistreamserver/movieprovider.h
index 46de20a648..3eb7142d15 100644
--- a/examples/network/multistreamserver/movieprovider.h
+++ b/examples/network/multistreamserver/movieprovider.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MOVIEPROVIDER_H
#define MOVIEPROVIDER_H
diff --git a/examples/network/multistreamserver/provider.h b/examples/network/multistreamserver/provider.h
index 5be14d5ed8..d1c3960cfa 100644
--- a/examples/network/multistreamserver/provider.h
+++ b/examples/network/multistreamserver/provider.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef PROVIDER_H
#define PROVIDER_H
diff --git a/examples/network/multistreamserver/server.cpp b/examples/network/multistreamserver/server.cpp
index 1d18514c0e..81d24fb6fb 100644
--- a/examples/network/multistreamserver/server.cpp
+++ b/examples/network/multistreamserver/server.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include <QtNetwork>
diff --git a/examples/network/multistreamserver/server.h b/examples/network/multistreamserver/server.h
index bbfc653ee1..e6934cbfaf 100644
--- a/examples/network/multistreamserver/server.h
+++ b/examples/network/multistreamserver/server.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SERVER_H
#define SERVER_H
diff --git a/examples/network/multistreamserver/timeprovider.cpp b/examples/network/multistreamserver/timeprovider.cpp
index fb50baac26..dab1addbc1 100644
--- a/examples/network/multistreamserver/timeprovider.cpp
+++ b/examples/network/multistreamserver/timeprovider.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "timeprovider.h"
#include <QDataStream>
@@ -71,7 +24,7 @@ void TimeProvider::readDatagram(QSctpSocket &from, const QByteArray &ba)
|| curTime.minute() != clientTime.minute()
|| curTime.hour() != clientTime.hour()) {
QByteArray buf;
- QDataStream out_ds(&buf, QIODevice::WriteOnly);
+ QDataStream out_ds(&buf, QIODeviceBase::WriteOnly);
out_ds << curTime;
emit writeDatagram(&from, buf);
diff --git a/examples/network/multistreamserver/timeprovider.h b/examples/network/multistreamserver/timeprovider.h
index a4d08fd67c..f1be0290d4 100644
--- a/examples/network/multistreamserver/timeprovider.h
+++ b/examples/network/multistreamserver/timeprovider.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TIMEPROVIDER_H
#define TIMEPROVIDER_H
diff --git a/examples/network/network-chat/CMakeLists.txt b/examples/network/network-chat/CMakeLists.txt
index 923ddec185..127a4c2fb5 100644
--- a/examples/network/network-chat/CMakeLists.txt
+++ b/examples/network/network-chat/CMakeLists.txt
@@ -1,24 +1,12 @@
-# Generated from network-chat.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(network-chat LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/network-chat")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(network-chat
chatdialog.cpp chatdialog.h chatdialog.ui
@@ -28,19 +16,32 @@ qt_add_executable(network-chat
peermanager.cpp peermanager.h
server.cpp server.h
)
+
set_target_properties(network-chat PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(network-chat PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_compile_definitions(network-chat PRIVATE
+ QT_USE_QSTRINGBUILDER
+)
+
+target_link_libraries(network-chat PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS network-chat
- 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 network-chat
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/network-chat/chatdialog.cpp b/examples/network/network-chat/chatdialog.cpp
index ce6e39a8fc..55c98fed0c 100644
--- a/examples/network/network-chat/chatdialog.cpp
+++ b/examples/network/network-chat/chatdialog.cpp
@@ -1,57 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "chatdialog.h"
+#include <QTimer>
+#include <QScrollBar>
+#include <QLineEdit>
+#include <QTextTable>
+#include <QMessageBox>
+
ChatDialog::ChatDialog(QWidget *parent)
: QDialog(parent)
{
@@ -74,7 +31,7 @@ ChatDialog::ChatDialog(QWidget *parent)
myNickName = client.nickName();
newParticipant(myNickName);
tableFormat.setBorder(0);
- QTimer::singleShot(10 * 1000, this, SLOT(showInformation()));
+ QTimer::singleShot(10 * 1000, this, &ChatDialog::showInformation);
}
void ChatDialog::appendMessage(const QString &from, const QString &message)
diff --git a/examples/network/network-chat/chatdialog.h b/examples/network/network-chat/chatdialog.h
index 27ae0ca72a..45a9858822 100644
--- a/examples/network/network-chat/chatdialog.h
+++ b/examples/network/network-chat/chatdialog.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CHATDIALOG_H
#define CHATDIALOG_H
@@ -59,7 +12,7 @@ class ChatDialog : public QDialog, private Ui::ChatDialog
Q_OBJECT
public:
- ChatDialog(QWidget *parent = nullptr);
+ explicit ChatDialog(QWidget *parent = nullptr);
public slots:
void appendMessage(const QString &from, const QString &message);
diff --git a/examples/network/network-chat/client.cpp b/examples/network/network-chat/client.cpp
index fe35d535f4..c637224127 100644
--- a/examples/network/network-chat/client.cpp
+++ b/examples/network/network-chat/client.cpp
@@ -1,62 +1,18 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtNetwork>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "client.h"
#include "connection.h"
#include "peermanager.h"
+#include <QHostInfo>
+
+#include <algorithm>
+#include <functional>
+
Client::Client()
+ : peerManager(new PeerManager(this))
{
- peerManager = new PeerManager(this);
peerManager->setServerPort(server.serverPort());
peerManager->startBroadcasting();
@@ -71,7 +27,7 @@ void Client::sendMessage(const QString &message)
if (message.isEmpty())
return;
- for (Connection *connection : qAsConst(peers))
+ for (Connection *connection : std::as_const(peers))
connection->sendMessage(message);
}
@@ -81,43 +37,35 @@ QString Client::nickName() const
+ ':' + QString::number(server.serverPort());
}
-bool Client::hasConnection(const QHostAddress &senderIp, int senderPort) const
+bool Client::hasConnection(const QByteArray &peerUniqueId) const
{
- if (senderPort == -1)
- return peers.contains(senderIp);
-
- if (!peers.contains(senderIp))
- return false;
-
- const QList<Connection *> connections = peers.values(senderIp);
- for (const Connection *connection : connections) {
- if (connection->peerPort() == senderPort)
- return true;
- }
-
- return false;
+ return peers.contains(peerUniqueId);
}
void Client::newConnection(Connection *connection)
{
- connection->setGreetingMessage(peerManager->userName());
-
- connect(connection, &Connection::errorOccurred, this, &Client::connectionError);
- connect(connection, &Connection::disconnected, this, &Client::disconnected);
+ connection->setGreetingMessage(peerManager->userName(), peerManager->uniqueId());
connect(connection, &Connection::readyForUse, this, &Client::readyForUse);
+ connect(connection, &Connection::errorOccurred, connection, &QObject::deleteLater);
+ connect(connection, &Connection::disconnected, connection, &QObject::deleteLater);
}
void Client::readyForUse()
{
Connection *connection = qobject_cast<Connection *>(sender());
- if (!connection || hasConnection(connection->peerAddress(),
- connection->peerPort()))
+ if (!connection || hasConnection(connection->uniqueId())) {
+ if (connection) {
+ connection->disconnectFromHost();
+ connection->deleteLater();
+ }
return;
+ }
- connect(connection, &Connection::newMessage,
- this, &Client::newMessage);
+ connect(connection, &Connection::errorOccurred, this, &Client::connectionError);
+ connect(connection, &Connection::disconnected, this, &Client::disconnected);
+ connect(connection, &Connection::newMessage, this, &Client::newMessage);
- peers.insert(connection->peerAddress(), connection);
+ peers.insert(connection->uniqueId(), connection);
QString nick = connection->name();
if (!nick.isEmpty())
emit newParticipant(nick);
@@ -137,8 +85,7 @@ void Client::connectionError(QAbstractSocket::SocketError /* socketError */)
void Client::removeConnection(Connection *connection)
{
- if (peers.contains(connection->peerAddress())) {
- peers.remove(connection->peerAddress());
+ if (peers.remove(connection->uniqueId())) {
QString nick = connection->name();
if (!nick.isEmpty())
emit participantLeft(nick);
diff --git a/examples/network/network-chat/client.h b/examples/network/network-chat/client.h
index 986a668aec..a09d0c21f6 100644
--- a/examples/network/network-chat/client.h
+++ b/examples/network/network-chat/client.h
@@ -1,62 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CLIENT_H
#define CLIENT_H
+#include "server.h"
+
#include <QAbstractSocket>
#include <QHash>
#include <QHostAddress>
-#include "server.h"
-
class PeerManager;
class Client : public QObject
@@ -68,7 +21,7 @@ public:
void sendMessage(const QString &message);
QString nickName() const;
- bool hasConnection(const QHostAddress &senderIp, int senderPort = -1) const;
+ bool hasConnection(const QByteArray &peerUniqueId) const;
signals:
void newMessage(const QString &from, const QString &message);
@@ -86,7 +39,7 @@ private:
PeerManager *peerManager;
Server server;
- QMultiHash<QHostAddress, Connection *> peers;
+ QHash<QByteArray, Connection *> peers;
};
#endif
diff --git a/examples/network/network-chat/connection.cpp b/examples/network/network-chat/connection.cpp
index cffd495349..0f59cc91ed 100644
--- a/examples/network/network-chat/connection.cpp
+++ b/examples/network/network-chat/connection.cpp
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "connection.h"
-#include <QtNetwork>
+#include <QTimerEvent>
static const int TransferTimeout = 30 * 1000;
static const int PongTimeout = 60 * 1000;
@@ -68,18 +21,12 @@ static const int PingInterval = 5 * 1000;
* plaintext = { 0 => text }
* ping = { 1 => null }
* pong = { 2 => null }
- * greeting = { 3 => text }
+ * greeting = { 3 => { text, bytes } }
*/
Connection::Connection(QObject *parent)
: QTcpSocket(parent), writer(this)
{
- greetingMessage = tr("undefined");
- username = tr("unknown");
- state = WaitingForGreeting;
- currentDataType = Undefined;
- transferTimerId = -1;
- isGreetingMessageSent = false;
pingTimer.setInterval(PingInterval);
connect(this, &QTcpSocket::readyRead, this,
@@ -101,7 +48,7 @@ Connection::Connection(qintptr socketDescriptor, QObject *parent)
Connection::~Connection()
{
- if (isGreetingMessageSent) {
+ if (isGreetingMessageSent && QAbstractSocket::state() != QAbstractSocket::UnconnectedState) {
// Indicate clean shutdown.
writer.endArray();
waitForBytesWritten(2000);
@@ -113,9 +60,15 @@ QString Connection::name() const
return username;
}
-void Connection::setGreetingMessage(const QString &message)
+void Connection::setGreetingMessage(const QString &message, const QByteArray &uniqueId)
{
greetingMessage = message;
+ localUniqueId = uniqueId;
+}
+
+QByteArray Connection::uniqueId() const
+{
+ return peerUniqueId;
}
bool Connection::sendMessage(const QString &message)
@@ -171,7 +124,29 @@ void Connection::processReadyRead()
reader.next();
} else {
// Current state: read command payload
- if (reader.isString()) {
+ if (currentDataType == Greeting) {
+ if (state == ReadingGreeting) {
+ if (!reader.isContainer() || !reader.isLengthKnown() || reader.length() != 2)
+ break; // protocol error
+ state = ProcessingGreeting;
+ reader.enterContainer();
+ }
+ if (state != ProcessingGreeting)
+ break; // protocol error
+ if (reader.isString()) {
+ auto r = reader.readString();
+ buffer += r.data;
+ } else if (reader.isByteArray()) {
+ auto r = reader.readByteArray();
+ peerUniqueId += r.data;
+ if (r.status == QCborStreamReader::EndOfString) {
+ reader.leaveContainer();
+ processGreeting();
+ }
+ }
+ if (state == ProcessingGreeting)
+ continue;
+ } else if (reader.isString()) {
auto r = reader.readString();
buffer += r.data;
if (r.status != QCborStreamReader::EndOfString)
@@ -179,7 +154,7 @@ void Connection::processReadyRead()
} else if (reader.isNull()) {
reader.next();
} else {
- break; // protocol error
+ break; // protocol error
}
// Next state: no command read
@@ -189,13 +164,7 @@ void Connection::processReadyRead()
transferTimerId = -1;
}
- if (state == ReadingGreeting) {
- if (currentDataType != Greeting)
- break; // protocol error
- processGreeting();
- } else {
- processData();
- }
+ processData();
}
}
@@ -225,7 +194,10 @@ void Connection::sendGreetingMessage()
writer.startMap(1);
writer.append(Greeting);
+ writer.startArray(2);
writer.append(greetingMessage);
+ writer.append(localUniqueId);
+ writer.endArray();
writer.endMap();
isGreetingMessageSent = true;
diff --git a/examples/network/network-chat/connection.h b/examples/network/network-chat/connection.h
index e6f36f7cd9..4b063e7def 100644
--- a/examples/network/network-chat/connection.h
+++ b/examples/network/network-chat/connection.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CONNECTION_H
#define CONNECTION_H
@@ -59,8 +12,6 @@
#include <QTcpSocket>
#include <QTimer>
-static const int MaxBufferSize = 1024000;
-
class Connection : public QTcpSocket
{
Q_OBJECT
@@ -69,6 +20,7 @@ public:
enum ConnectionState {
WaitingForGreeting,
ReadingGreeting,
+ ProcessingGreeting,
ReadyForUse
};
enum DataType {
@@ -79,14 +31,16 @@ public:
Undefined
};
- Connection(QObject *parent = nullptr);
- Connection(qintptr socketDescriptor, QObject *parent = nullptr);
+ explicit Connection(QObject *parent = nullptr);
+ explicit Connection(qintptr socketDescriptor, QObject *parent = nullptr);
~Connection();
QString name() const;
- void setGreetingMessage(const QString &message);
+ void setGreetingMessage(const QString &message, const QByteArray &uniqueId);
bool sendMessage(const QString &message);
+ QByteArray uniqueId() const;
+
signals:
void readyForUse();
void newMessage(const QString &from, const QString &message);
@@ -106,15 +60,17 @@ private:
QCborStreamReader reader;
QCborStreamWriter writer;
- QString greetingMessage;
- QString username;
+ QString greetingMessage = tr("undefined");
+ QString username = tr("unknown");
QTimer pingTimer;
QElapsedTimer pongTime;
QString buffer;
- ConnectionState state;
- DataType currentDataType;
- int transferTimerId;
- bool isGreetingMessageSent;
+ QByteArray localUniqueId;
+ QByteArray peerUniqueId;
+ ConnectionState state = WaitingForGreeting;
+ DataType currentDataType = Undefined;
+ int transferTimerId = -1;
+ bool isGreetingMessageSent = false;
};
#endif
diff --git a/examples/network/network-chat/main.cpp b/examples/network/network-chat/main.cpp
index 029c18f0ff..5d679d284b 100644
--- a/examples/network/network-chat/main.cpp
+++ b/examples/network/network-chat/main.cpp
@@ -1,58 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "chatdialog.h"
-#include <QtCore/QSettings>
+#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
diff --git a/examples/network/network-chat/network-chat.pro b/examples/network/network-chat/network-chat.pro
index 2e3cbbc489..626a710949 100644
--- a/examples/network/network-chat/network-chat.pro
+++ b/examples/network/network-chat/network-chat.pro
@@ -11,6 +11,7 @@ SOURCES = chatdialog.cpp \
server.cpp
FORMS = chatdialog.ui
QT += network widgets
+DEFINES += QT_USE_QSTRINGBUILDER
requires(qtConfig(udpsocket))
requires(qtConfig(listwidget))
diff --git a/examples/network/network-chat/peermanager.cpp b/examples/network/network-chat/peermanager.cpp
index 2c9d182211..a70ed7da73 100644
--- a/examples/network/network-chat/peermanager.cpp
+++ b/examples/network/network-chat/peermanager.cpp
@@ -1,68 +1,20 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2018 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtNetwork>
+// Copyright (C) 2016 The Qt Company Ltd.
+// Copyright (C) 2018 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "client.h"
#include "connection.h"
#include "peermanager.h"
+#include <QNetworkInterface>
+#include <QUuid>
+
static const qint32 BroadcastInterval = 2000;
static const unsigned broadcastPort = 45000;
PeerManager::PeerManager(Client *client)
- : QObject(client)
+ : QObject(client), client(client)
{
- this->client = client;
-
static const char *envVariables[] = {
"USERNAME", "USER", "USERDOMAIN", "HOSTNAME", "DOMAINNAME"
};
@@ -76,8 +28,12 @@ PeerManager::PeerManager(Client *client)
if (username.isEmpty())
username = "unknown";
+ // We generate a unique per-process identifier so we can avoid multiple
+ // connections to/from the same remote peer as well as ignore our own
+ // broadcasts.
+ localUniqueId = QUuid::createUuid().toByteArray();
+
updateAddresses();
- serverPort = 0;
broadcastSocket.bind(QHostAddress::Any, broadcastPort, QUdpSocket::ShareAddress
| QUdpSocket::ReuseAddressHint);
@@ -99,6 +55,11 @@ QString PeerManager::userName() const
return username;
}
+QByteArray PeerManager::uniqueId() const
+{
+ return localUniqueId;
+}
+
void PeerManager::startBroadcasting()
{
broadcastTimer.start();
@@ -106,11 +67,7 @@ void PeerManager::startBroadcasting()
bool PeerManager::isLocalHostAddress(const QHostAddress &address) const
{
- for (const QHostAddress &localAddress : ipAddresses) {
- if (address.isEqual(localAddress))
- return true;
- }
- return false;
+ return ipAddresses.contains(address);
}
void PeerManager::sendBroadcastDatagram()
@@ -119,15 +76,14 @@ void PeerManager::sendBroadcastDatagram()
{
QCborStreamWriter writer(&datagram);
writer.startArray(2);
- writer.append(username);
+ writer.append(localUniqueId);
writer.append(serverPort);
writer.endArray();
}
bool validBroadcastAddresses = true;
- for (const QHostAddress &address : qAsConst(broadcastAddresses)) {
- if (broadcastSocket.writeDatagram(datagram, address,
- broadcastPort) == -1)
+ for (const QHostAddress &address : std::as_const(broadcastAddresses)) {
+ if (broadcastSocket.writeDatagram(datagram, address, broadcastPort) == -1)
validBroadcastAddresses = false;
}
@@ -147,6 +103,7 @@ void PeerManager::readBroadcastDatagram()
continue;
int senderServerPort;
+ QByteArray peerUniqueId;
{
// decode the datagram
QCborStreamReader reader(datagram);
@@ -156,10 +113,12 @@ void PeerManager::readBroadcastDatagram()
continue;
reader.enterContainer();
- if (reader.lastError() != QCborError::NoError || !reader.isString())
+ if (reader.lastError() != QCborError::NoError || !reader.isByteArray())
continue;
- while (reader.readString().status == QCborStreamReader::Ok) {
- // we don't actually need the username right now
+ auto r = reader.readByteArray();
+ while (r.status == QCborStreamReader::Ok) {
+ peerUniqueId = r.data;
+ r = reader.readByteArray();
}
if (reader.lastError() != QCborError::NoError || !reader.isUnsignedInteger())
@@ -167,10 +126,10 @@ void PeerManager::readBroadcastDatagram()
senderServerPort = reader.toInteger();
}
- if (isLocalHostAddress(senderIp) && senderServerPort == serverPort)
+ if (peerUniqueId == localUniqueId)
continue;
- if (!client->hasConnection(senderIp)) {
+ if (!client->hasConnection(peerUniqueId)) {
Connection *connection = new Connection(this);
emit newConnection(connection);
connection->connectToHost(senderIp, senderServerPort);
diff --git a/examples/network/network-chat/peermanager.h b/examples/network/network-chat/peermanager.h
index 6105c83115..fff48540ea 100644
--- a/examples/network/network-chat/peermanager.h
+++ b/examples/network/network-chat/peermanager.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef PEERMANAGER_H
#define PEERMANAGER_H
@@ -65,10 +18,11 @@ class PeerManager : public QObject
Q_OBJECT
public:
- PeerManager(Client *client);
+ explicit PeerManager(Client *client);
void setServerPort(int port);
QString userName() const;
+ QByteArray uniqueId() const;
void startBroadcasting();
bool isLocalHostAddress(const QHostAddress &address) const;
@@ -82,13 +36,14 @@ private slots:
private:
void updateAddresses();
- Client *client;
+ Client *client = nullptr;
QList<QHostAddress> broadcastAddresses;
QList<QHostAddress> ipAddresses;
QUdpSocket broadcastSocket;
QTimer broadcastTimer;
QString username;
- int serverPort;
+ QByteArray localUniqueId;
+ int serverPort = 0;
};
#endif
diff --git a/examples/network/network-chat/server.cpp b/examples/network/network-chat/server.cpp
index b3e4a07f60..afc96717ca 100644
--- a/examples/network/network-chat/server.cpp
+++ b/examples/network/network-chat/server.cpp
@@ -1,54 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtNetwork>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "connection.h"
#include "server.h"
diff --git a/examples/network/network-chat/server.h b/examples/network/network-chat/server.h
index 0a7e6e18c1..0557de30de 100644
--- a/examples/network/network-chat/server.h
+++ b/examples/network/network-chat/server.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SERVER_H
#define SERVER_H
@@ -60,7 +13,7 @@ class Server : public QTcpServer
Q_OBJECT
public:
- Server(QObject *parent = nullptr);
+ explicit Server(QObject *parent = nullptr);
signals:
void newConnection(Connection *connection);
diff --git a/examples/network/network.pro b/examples/network/network.pro
index 3f851d7c71..a0fc95dbf8 100644
--- a/examples/network/network.pro
+++ b/examples/network/network.pro
@@ -2,29 +2,22 @@ requires(qtHaveModule(network))
TEMPLATE = subdirs
QT_FOR_CONFIG += network-private
-SUBDIRS = \
- download \
- downloadmanager
!integrity: SUBDIRS += dnslookup
qtHaveModule(widgets) {
SUBDIRS += \
blockingfortuneclient \
broadcastreceiver \
broadcastsender \
+ fortuneclient \
+ fortuneserver \
http \
- loopback \
- threadedfortuneserver \
- googlesuggest \
- torrent \
multicastreceiver \
- multicastsender
+ multicastsender \
+ rsslisting \
+ threadedfortuneserver \
+ torrent
qtConfig(processenvironment): SUBDIRS += network-chat
-
- SUBDIRS += \
- fortuneclient \
- fortuneserver
-
qtConfig(ssl): SUBDIRS += securesocketclient
qtConfig(dtls): SUBDIRS += secureudpserver secureudpclient
qtConfig(sctp): SUBDIRS += multistreamserver multistreamclient
diff --git a/examples/network/rsslisting/CMakeLists.txt b/examples/network/rsslisting/CMakeLists.txt
new file mode 100644
index 0000000000..58d9edcb92
--- /dev/null
+++ b/examples/network/rsslisting/CMakeLists.txt
@@ -0,0 +1,39 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(rsslisting LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(rsslisting
+ main.cpp
+ rsslisting.cpp rsslisting.h
+)
+
+set_target_properties(rsslisting PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(rsslisting PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
+)
+
+install(TARGETS rsslisting
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET rsslisting
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/rsslisting/main.cpp b/examples/network/rsslisting/main.cpp
new file mode 100644
index 0000000000..7a64db8a0c
--- /dev/null
+++ b/examples/network/rsslisting/main.cpp
@@ -0,0 +1,16 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "rsslisting.h"
+#include <QtWidgets>
+using namespace Qt::StringLiterals;
+
+//! [0]
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ RSSListing rsslisting(u"https://www.qt.io/blog/rss.xml"_s);
+ rsslisting.show();
+ return app.exec();
+}
+//! [0]
diff --git a/examples/network/rsslisting/rsslisting.cpp b/examples/network/rsslisting/rsslisting.cpp
new file mode 100644
index 0000000000..ed7c163c76
--- /dev/null
+++ b/examples/network/rsslisting/rsslisting.cpp
@@ -0,0 +1,126 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "rsslisting.h"
+
+#include <QtCore>
+#include <QtWidgets>
+#include <QtNetwork>
+
+//! [setup]
+RSSListing::RSSListing(const QString &url, QWidget *parent)
+ : QWidget(parent), currentReply(0)
+{
+ connect(&manager, &QNetworkAccessManager::finished, this, &RSSListing::finished);
+
+ lineEdit = new QLineEdit(this);
+ lineEdit->setText(url);
+ connect(lineEdit, &QLineEdit::returnPressed, this, &RSSListing::fetch);
+
+ fetchButton = new QPushButton(tr("Fetch"), this);
+ connect(fetchButton, &QPushButton::clicked, this, &RSSListing::fetch);
+
+ treeWidget = new QTreeWidget(this);
+ connect(treeWidget, &QTreeWidget::itemActivated,
+ // Open the link in the browser:
+ this, [](QTreeWidgetItem *item) { QDesktopServices::openUrl(QUrl(item->text(1))); });
+ treeWidget->setHeaderLabels(QStringList { tr("Title"), tr("Link") });
+ treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
+
+ QHBoxLayout *hboxLayout = new QHBoxLayout;
+ hboxLayout->addWidget(lineEdit);
+ hboxLayout->addWidget(fetchButton);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addLayout(hboxLayout);
+ layout->addWidget(treeWidget);
+
+ setWindowTitle(tr("RSS listing example"));
+ resize(640, 480);
+}
+//! [setup]
+
+//! [slots]
+void RSSListing::fetch()
+{
+ lineEdit->setReadOnly(true);
+ fetchButton->setEnabled(false);
+ treeWidget->clear();
+
+ get(QUrl(lineEdit->text()));
+}
+
+void RSSListing::consumeData()
+{
+ int statusCode = currentReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ if (statusCode >= 200 && statusCode < 300)
+ parseXml();
+}
+
+void RSSListing::error(QNetworkReply::NetworkError)
+{
+ qWarning("error retrieving RSS feed");
+ xml.clear();
+ currentReply->disconnect(this);
+ currentReply->deleteLater();
+ currentReply = nullptr;
+}
+
+void RSSListing::finished(QNetworkReply *reply)
+{
+ Q_UNUSED(reply);
+ lineEdit->setReadOnly(false);
+ fetchButton->setEnabled(true);
+}
+//! [slots]
+
+// Private methods
+
+//! [get]
+void RSSListing::get(const QUrl &url)
+{
+ if (currentReply) {
+ currentReply->disconnect(this);
+ currentReply->deleteLater();
+ }
+ currentReply = url.isValid() ? manager.get(QNetworkRequest(url)) : nullptr;
+ if (currentReply) {
+ connect(currentReply, &QNetworkReply::readyRead, this, &RSSListing::consumeData);
+ connect(currentReply, &QNetworkReply::errorOccurred, this, &RSSListing::error);
+
+ }
+ xml.setDevice(currentReply); // Equivalent to clear() if currentReply is null.
+}
+//! [get]
+
+// TODO: this is a candidate for showing how to use coroutines, once available.
+//! [parse]
+void RSSListing::parseXml()
+{
+ while (!xml.atEnd()) {
+ xml.readNext();
+ if (xml.isStartElement()) {
+ if (xml.name() == u"item") {
+ linkString = xml.attributes().value("rss:about").toString();
+ titleString.clear();
+ }
+ currentTag = xml.name().toString();
+ } else if (xml.isEndElement()) {
+ if (xml.name() == u"item") {
+
+ QTreeWidgetItem *item = new QTreeWidgetItem;
+ item->setText(0, titleString);
+ item->setText(1, linkString);
+ treeWidget->addTopLevelItem(item);
+ }
+ } else if (xml.isCharacters() && !xml.isWhitespace()) {
+ if (currentTag == "title")
+ titleString += xml.text();
+ else if (currentTag == "link")
+ linkString += xml.text();
+ }
+ }
+ if (xml.error() && xml.error() != QXmlStreamReader::PrematureEndOfDocumentError)
+ qWarning() << "XML ERROR:" << xml.lineNumber() << ": " << xml.errorString();
+}
+//! [parse]
diff --git a/examples/network/rsslisting/rsslisting.h b/examples/network/rsslisting/rsslisting.h
new file mode 100644
index 0000000000..499bc5d1d4
--- /dev/null
+++ b/examples/network/rsslisting/rsslisting.h
@@ -0,0 +1,54 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef RSSLISTING_H
+#define RSSLISTING_H
+
+#include <QNetworkAccessManager>
+#include <QNetworkReply>
+#include <QWidget>
+#include <QXmlStreamReader>
+
+QT_BEGIN_NAMESPACE
+class QLineEdit;
+class QPushButton;
+class QTreeWidget;
+class QTreeWidgetItem;
+class QUrl;
+QT_END_NAMESPACE
+
+//! [0]
+class RSSListing : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit RSSListing(const QString &url = QString(), QWidget *widget = nullptr);
+
+public slots:
+ void fetch();
+ void finished(QNetworkReply *reply);
+ void consumeData();
+ void error(QNetworkReply::NetworkError);
+
+private:
+ void parseXml();
+ void get(const QUrl &url);
+
+ // Parser state:
+ QXmlStreamReader xml;
+ QString currentTag;
+ QString linkString;
+ QString titleString;
+
+ // Network state:
+ QNetworkAccessManager manager;
+ QNetworkReply *currentReply;
+
+ // UI elements:
+ QLineEdit *lineEdit;
+ QTreeWidget *treeWidget;
+ QPushButton *fetchButton;
+};
+//! [0]
+
+#endif
diff --git a/examples/network/rsslisting/rsslisting.pro b/examples/network/rsslisting/rsslisting.pro
new file mode 100644
index 0000000000..aacbe3127f
--- /dev/null
+++ b/examples/network/rsslisting/rsslisting.pro
@@ -0,0 +1,8 @@
+HEADERS += rsslisting.h
+SOURCES += main.cpp rsslisting.cpp
+QT += network widgets
+requires(qtConfig(treewidget))
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/network/rsslisting
+INSTALLS += target
diff --git a/examples/network/securesocketclient/CMakeLists.txt b/examples/network/securesocketclient/CMakeLists.txt
index 3af7260c47..8066e5eba7 100644
--- a/examples/network/securesocketclient/CMakeLists.txt
+++ b/examples/network/securesocketclient/CMakeLists.txt
@@ -1,24 +1,12 @@
-# Generated from securesocketclient.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(securesocketclient LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/securesocketclient")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(securesocketclient
certificateinfo.cpp certificateinfo.h certificateinfo.ui
@@ -26,24 +14,25 @@ qt_add_executable(securesocketclient
sslclient.cpp sslclient.h sslclient.ui
sslerrors.ui
)
+
set_target_properties(securesocketclient PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(securesocketclient PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
-)
+target_link_libraries(securesocketclient PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
+)
# Resources:
set(securesocketclient_resource_files
"encrypted.png"
)
-qt6_add_resources(securesocketclient "securesocketclient"
+qt_add_resources(securesocketclient "securesocketclient"
PREFIX
"/"
FILES
@@ -51,7 +40,14 @@ qt6_add_resources(securesocketclient "securesocketclient"
)
install(TARGETS securesocketclient
- 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 securesocketclient
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/securesocketclient/certificateinfo.cpp b/examples/network/securesocketclient/certificateinfo.cpp
index 9d0a674efe..a5778d2e0a 100644
--- a/examples/network/securesocketclient/certificateinfo.cpp
+++ b/examples/network/securesocketclient/certificateinfo.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "certificateinfo.h"
#include "ui_certificateinfo.h"
@@ -86,19 +39,19 @@ void CertificateInfo::updateCertificateInfo(int index)
if (index >= 0 && index < certificateChain.size()) {
const QSslCertificate &cert = certificateChain.at(index);
QStringList lines;
- lines << tr("Organization: %1").arg(cert.subjectInfo(QSslCertificate::Organization).join(QLatin1Char(' ')))
- << tr("Subunit: %1").arg(cert.subjectInfo(QSslCertificate::OrganizationalUnitName).join(QLatin1Char(' ')))
- << tr("Country: %1").arg(cert.subjectInfo(QSslCertificate::CountryName).join(QLatin1Char(' ')))
- << tr("Locality: %1").arg(cert.subjectInfo(QSslCertificate::LocalityName).join(QLatin1Char(' ')))
- << tr("State/Province: %1").arg(cert.subjectInfo(QSslCertificate::StateOrProvinceName).join(QLatin1Char(' ')))
- << tr("Common Name: %1").arg(cert.subjectInfo(QSslCertificate::CommonName).join(QLatin1Char(' ')))
+ lines << tr("Organization: %1").arg(cert.subjectInfo(QSslCertificate::Organization).join(u' '))
+ << tr("Subunit: %1").arg(cert.subjectInfo(QSslCertificate::OrganizationalUnitName).join(u' '))
+ << tr("Country: %1").arg(cert.subjectInfo(QSslCertificate::CountryName).join(u' '))
+ << tr("Locality: %1").arg(cert.subjectInfo(QSslCertificate::LocalityName).join(u' '))
+ << tr("State/Province: %1").arg(cert.subjectInfo(QSslCertificate::StateOrProvinceName).join(u' '))
+ << tr("Common Name: %1").arg(cert.subjectInfo(QSslCertificate::CommonName).join(u' '))
<< QString()
- << tr("Issuer Organization: %1").arg(cert.issuerInfo(QSslCertificate::Organization).join(QLatin1Char(' ')))
- << tr("Issuer Unit Name: %1").arg(cert.issuerInfo(QSslCertificate::OrganizationalUnitName).join(QLatin1Char(' ')))
- << tr("Issuer Country: %1").arg(cert.issuerInfo(QSslCertificate::CountryName).join(QLatin1Char(' ')))
- << tr("Issuer Locality: %1").arg(cert.issuerInfo(QSslCertificate::LocalityName).join(QLatin1Char(' ')))
- << tr("Issuer State/Province: %1").arg(cert.issuerInfo(QSslCertificate::StateOrProvinceName).join(QLatin1Char(' ')))
- << tr("Issuer Common Name: %1").arg(cert.issuerInfo(QSslCertificate::CommonName).join(QLatin1Char(' ')));
+ << tr("Issuer Organization: %1").arg(cert.issuerInfo(QSslCertificate::Organization).join(u' '))
+ << tr("Issuer Unit Name: %1").arg(cert.issuerInfo(QSslCertificate::OrganizationalUnitName).join(u' '))
+ << tr("Issuer Country: %1").arg(cert.issuerInfo(QSslCertificate::CountryName).join(u' '))
+ << tr("Issuer Locality: %1").arg(cert.issuerInfo(QSslCertificate::LocalityName).join(u' '))
+ << tr("Issuer State/Province: %1").arg(cert.issuerInfo(QSslCertificate::StateOrProvinceName).join(u' '))
+ << tr("Issuer Common Name: %1").arg(cert.issuerInfo(QSslCertificate::CommonName).join(u' '));
for (const auto &line : lines)
form->certificateInfoView->addItem(line);
}
diff --git a/examples/network/securesocketclient/certificateinfo.h b/examples/network/securesocketclient/certificateinfo.h
index 9e079c5603..bf1bb4b47d 100644
--- a/examples/network/securesocketclient/certificateinfo.h
+++ b/examples/network/securesocketclient/certificateinfo.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CERTIFICATEINFO_H
#define CERTIFICATEINFO_H
diff --git a/examples/network/securesocketclient/main.cpp b/examples/network/securesocketclient/main.cpp
index 7cda94cc34..7a59e6f774 100644
--- a/examples/network/securesocketclient/main.cpp
+++ b/examples/network/securesocketclient/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QMessageBox>
@@ -58,8 +11,6 @@ QT_REQUIRE_CONFIG(ssl);
int main(int argc, char **argv)
{
- Q_INIT_RESOURCE(securesocketclient);
-
QApplication app(argc, argv);
if (!QSslSocket::supportsSsl()) {
diff --git a/examples/network/securesocketclient/sslclient.cpp b/examples/network/securesocketclient/sslclient.cpp
index 949edd39c7..413038ddd5 100644
--- a/examples/network/securesocketclient/sslclient.cpp
+++ b/examples/network/securesocketclient/sslclient.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "certificateinfo.h"
#include "sslclient.h"
@@ -118,7 +71,7 @@ void SslClient::socketEncrypted()
const QSslCipher cipher = socket->sessionCipher();
const QString cipherInfo = QString("%1, %2 (%3/%4)").arg(cipher.authenticationMethod())
.arg(cipher.name()).arg(cipher.usedBits())
- .arg(cipher.supportedBits());;
+ .arg(cipher.supportedBits());
form->cipherLabel->setText(cipherInfo);
padLock->show();
}
diff --git a/examples/network/securesocketclient/sslclient.h b/examples/network/securesocketclient/sslclient.h
index 63fdbef77d..80e5c1c7df 100644
--- a/examples/network/securesocketclient/sslclient.h
+++ b/examples/network/securesocketclient/sslclient.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SSLCLIENT_H
#define SSLCLIENT_H
diff --git a/examples/network/secureudpclient/CMakeLists.txt b/examples/network/secureudpclient/CMakeLists.txt
index cd88d630df..53a8c1340e 100644
--- a/examples/network/secureudpclient/CMakeLists.txt
+++ b/examples/network/secureudpclient/CMakeLists.txt
@@ -1,24 +1,12 @@
-# Generated from secureudpclient.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(secureudpclient LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/secureudpclient")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS Network)
+qt_standard_project_setup()
qt_add_executable(secureudpclient
addressdialog.cpp addressdialog.h addressdialog.ui
@@ -26,19 +14,28 @@ qt_add_executable(secureudpclient
main.cpp
mainwindow.cpp mainwindow.h mainwindow.ui
)
+
set_target_properties(secureudpclient PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(secureudpclient PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(secureudpclient PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS secureudpclient
- 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 secureudpclient
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/secureudpclient/addressdialog.cpp b/examples/network/secureudpclient/addressdialog.cpp
index ccb58c853c..857ce51f2f 100644
--- a/examples/network/secureudpclient/addressdialog.cpp
+++ b/examples/network/secureudpclient/addressdialog.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "addressdialog.h"
#include "ui_addressdialog.h"
diff --git a/examples/network/secureudpclient/addressdialog.h b/examples/network/secureudpclient/addressdialog.h
index 43792faa4b..4081f44709 100644
--- a/examples/network/secureudpclient/addressdialog.h
+++ b/examples/network/secureudpclient/addressdialog.h
@@ -1,69 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef ADDRESSDIALOG_H
#define ADDRESSDIALOG_H
#include <QDialog>
QT_BEGIN_NAMESPACE
-
namespace Ui {
-
class AddressDialog;
-
}
-
QT_END_NAMESPACE
-QT_USE_NAMESPACE
-
class AddressDialog : public QDialog
{
Q_OBJECT
diff --git a/examples/network/secureudpclient/association.cpp b/examples/network/secureudpclient/association.cpp
index 59df94d5b9..ede8393913 100644
--- a/examples/network/secureudpclient/association.cpp
+++ b/examples/network/secureudpclient/association.cpp
@@ -1,57 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "association.h"
-QT_BEGIN_NAMESPACE
-
DtlsAssociation::DtlsAssociation(const QHostAddress &address, quint16 port,
const QString &connectionName)
: name(connectionName),
@@ -198,5 +149,3 @@ void DtlsAssociation::pingTimeout()
++ping;
}
//! [10]
-
-QT_END_NAMESPACE
diff --git a/examples/network/secureudpclient/association.h b/examples/network/secureudpclient/association.h
index be89ce695e..4822d7c0c9 100644
--- a/examples/network/secureudpclient/association.h
+++ b/examples/network/secureudpclient/association.h
@@ -1,60 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef ASSOCIATION_H
#define ASSOCIATION_H
#include <QtNetwork>
#include <QtCore>
-QT_BEGIN_NAMESPACE
-
//! [0]
class DtlsAssociation : public QObject
{
@@ -92,6 +43,4 @@ private:
};
//! [0]
-QT_END_NAMESPACE
-
#endif // ASSOCIATION_H
diff --git a/examples/network/secureudpclient/main.cpp b/examples/network/secureudpclient/main.cpp
index 2cf35878f2..d0499728c8 100644
--- a/examples/network/secureudpclient/main.cpp
+++ b/examples/network/secureudpclient/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
@@ -54,8 +7,6 @@
int main(int argc, char *argv[])
{
- QT_USE_NAMESPACE
-
QApplication app(argc, argv);
MainWindow window;
window.show();
diff --git a/examples/network/secureudpclient/mainwindow.cpp b/examples/network/secureudpclient/mainwindow.cpp
index 2fbf757c81..987eb739b9 100644
--- a/examples/network/secureudpclient/mainwindow.cpp
+++ b/examples/network/secureudpclient/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtCore>
#include <QtNetwork>
@@ -130,7 +83,7 @@ void MainWindow::on_connectButton_clicked()
return startNewConnection(remoteAddress);
addInfoMessage(tr("Looking up the host ..."));
- lookupId = QHostInfo::lookupHost(hostName, this, SLOT(lookupFinished(QHostInfo)));
+ lookupId = QHostInfo::lookupHost(hostName, this, &MainWindow::lookupFinished);
updateUi();
}
diff --git a/examples/network/secureudpclient/mainwindow.h b/examples/network/secureudpclient/mainwindow.h
index 6f207cecd9..8b68f5787e 100644
--- a/examples/network/secureudpclient/mainwindow.h
+++ b/examples/network/secureudpclient/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@@ -55,21 +8,15 @@
#include <QList>
QT_BEGIN_NAMESPACE
-
namespace Ui {
-
class MainWindow;
-
}
class QHostAddress;
class QHostInfo;
-
-class DtlsAssociation;
-
QT_END_NAMESPACE
-QT_USE_NAMESPACE
+class DtlsAssociation;
class MainWindow : public QMainWindow
{
diff --git a/examples/network/secureudpserver/CMakeLists.txt b/examples/network/secureudpserver/CMakeLists.txt
index c93f8d0139..e92186b574 100644
--- a/examples/network/secureudpserver/CMakeLists.txt
+++ b/examples/network/secureudpserver/CMakeLists.txt
@@ -1,24 +1,12 @@
-# Generated from secureudpserver.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(secureudpserver LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/secureudpserver")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS Network)
+qt_standard_project_setup()
qt_add_executable(secureudpserver
main.cpp
@@ -26,19 +14,28 @@ qt_add_executable(secureudpserver
nicselector.cpp nicselector.h nicselector.ui
server.cpp server.h
)
+
set_target_properties(secureudpserver PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(secureudpserver PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(secureudpserver PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS secureudpserver
- 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 secureudpserver
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/secureudpserver/main.cpp b/examples/network/secureudpserver/main.cpp
index 1a29d9d7ec..7ec6a29aec 100644
--- a/examples/network/secureudpserver/main.cpp
+++ b/examples/network/secureudpserver/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
@@ -54,8 +7,6 @@
int main(int argc, char *argv[])
{
- QT_USE_NAMESPACE
-
QApplication a(argc, argv);
MainWindow w;
w.show();
diff --git a/examples/network/secureudpserver/mainwindow.cpp b/examples/network/secureudpserver/mainwindow.cpp
index ef1974c311..3fed5911b8 100644
--- a/examples/network/secureudpserver/mainwindow.cpp
+++ b/examples/network/secureudpserver/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "nicselector.h"
diff --git a/examples/network/secureudpserver/mainwindow.h b/examples/network/secureudpserver/mainwindow.h
index b39d984d50..7c69a9b414 100644
--- a/examples/network/secureudpserver/mainwindow.h
+++ b/examples/network/secureudpserver/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@@ -55,15 +8,11 @@
#include <QMainWindow>
QT_BEGIN_NAMESPACE
-
namespace Ui {
class MainWindow;
}
-
QT_END_NAMESPACE
-QT_USE_NAMESPACE
-
class MainWindow : public QMainWindow
{
Q_OBJECT
diff --git a/examples/network/secureudpserver/nicselector.cpp b/examples/network/secureudpserver/nicselector.cpp
index ea26439d74..d528cc7270 100644
--- a/examples/network/secureudpserver/nicselector.cpp
+++ b/examples/network/secureudpserver/nicselector.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <limits>
diff --git a/examples/network/secureudpserver/nicselector.h b/examples/network/secureudpserver/nicselector.h
index e3c9d37639..4f8bf9a85f 100644
--- a/examples/network/secureudpserver/nicselector.h
+++ b/examples/network/secureudpserver/nicselector.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef NICSELECTOR_H
#define NICSELECTOR_H
@@ -56,15 +9,11 @@
#include <QList>
QT_BEGIN_NAMESPACE
-
namespace Ui {
class NicSelector;
}
-
QT_END_NAMESPACE
-QT_USE_NAMESPACE
-
class NicSelector : public QDialog
{
Q_OBJECT
diff --git a/examples/network/secureudpserver/server.cpp b/examples/network/secureudpserver/server.cpp
index 450eb9e68d..4aa22c606b 100644
--- a/examples/network/secureudpserver/server.cpp
+++ b/examples/network/secureudpserver/server.cpp
@@ -1,59 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "server.h"
#include <algorithm>
-QT_BEGIN_NAMESPACE
-
namespace {
QString peer_info(const QHostAddress &address, quint16 port)
@@ -69,15 +20,9 @@ QString connection_info(QDtls *connection)
info += DtlsServer::tr("; session protocol: ");
switch (connection->sessionProtocol()) {
- case QSsl::DtlsV1_0:
- info += DtlsServer::tr("DTLS 1.0.");
- break;
case QSsl::DtlsV1_2:
info += DtlsServer::tr("DTLS 1.2.");
break;
- case QSsl::DtlsV1_2OrLater:
- info += DtlsServer::tr("DTLS 1.2 or later.");
- break;
default:
info += DtlsServer::tr("Unknown protocol.");
}
@@ -266,11 +211,9 @@ void DtlsServer::decryptDatagram(QDtls *connection, const QByteArray &clientMess
//! [14]
void DtlsServer::shutdown()
{
- for (const auto &connection : qExchange(knownClients, {}))
+ for (const auto &connection : std::exchange(knownClients, {}))
connection->shutdown(&serverSocket);
serverSocket.close();
}
//! [14]
-
-QT_END_NAMESPACE
diff --git a/examples/network/secureudpserver/server.h b/examples/network/secureudpserver/server.h
index 1af8aef8a2..a8b6a727c8 100644
--- a/examples/network/secureudpserver/server.h
+++ b/examples/network/secureudpserver/server.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SERVER_H
#define SERVER_H
@@ -56,8 +9,6 @@
#include <vector>
#include <memory>
-QT_BEGIN_NAMESPACE
-
//! [0]
class DtlsServer : public QObject
{
@@ -102,6 +53,4 @@ private:
};
//! [0]
-QT_END_NAMESPACE
-
#endif // SERVER_H
diff --git a/examples/network/shared/sctpchannels.h b/examples/network/shared/sctpchannels.h
index f8d78ee33b..3bb920c6a7 100644
--- a/examples/network/shared/sctpchannels.h
+++ b/examples/network/shared/sctpchannels.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SCTPCHANNELS_H
#define SCTPCHANNELS_H
diff --git a/examples/network/threadedfortuneserver/CMakeLists.txt b/examples/network/threadedfortuneserver/CMakeLists.txt
index 12cb2f6610..8fc8cc416d 100644
--- a/examples/network/threadedfortuneserver/CMakeLists.txt
+++ b/examples/network/threadedfortuneserver/CMakeLists.txt
@@ -1,24 +1,12 @@
-# Generated from threadedfortuneserver.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(threadedfortuneserver LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/threadedfortuneserver")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(threadedfortuneserver
dialog.cpp dialog.h
@@ -26,19 +14,28 @@ qt_add_executable(threadedfortuneserver
fortunethread.cpp fortunethread.h
main.cpp
)
+
set_target_properties(threadedfortuneserver PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(threadedfortuneserver PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(threadedfortuneserver PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS threadedfortuneserver
- 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 threadedfortuneserver
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/threadedfortuneserver/dialog.cpp b/examples/network/threadedfortuneserver/dialog.cpp
index e5b389f1e6..9449cab5fa 100644
--- a/examples/network/threadedfortuneserver/dialog.cpp
+++ b/examples/network/threadedfortuneserver/dialog.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include <QtNetwork>
@@ -73,12 +26,12 @@ Dialog::Dialog(QWidget *parent)
}
QString ipAddress;
- QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
+ const QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
// use the first non-localhost IPv4 address
- for (int i = 0; i < ipAddressesList.size(); ++i) {
- if (ipAddressesList.at(i) != QHostAddress::LocalHost &&
- ipAddressesList.at(i).toIPv4Address()) {
- ipAddress = ipAddressesList.at(i).toString();
+
+ for (const QHostAddress &entry : ipAddressesList) {
+ if (entry != QHostAddress::LocalHost && entry.toIPv4Address()) {
+ ipAddress = entry.toString();
break;
}
}
diff --git a/examples/network/threadedfortuneserver/dialog.h b/examples/network/threadedfortuneserver/dialog.h
index 2898c5311c..b8741a54b7 100644
--- a/examples/network/threadedfortuneserver/dialog.h
+++ b/examples/network/threadedfortuneserver/dialog.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DIALOG_H
#define DIALOG_H
diff --git a/examples/network/threadedfortuneserver/fortuneserver.cpp b/examples/network/threadedfortuneserver/fortuneserver.cpp
index a93bbc7058..4ef64cf38c 100644
--- a/examples/network/threadedfortuneserver/fortuneserver.cpp
+++ b/examples/network/threadedfortuneserver/fortuneserver.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "fortuneserver.h"
#include "fortunethread.h"
@@ -72,7 +25,7 @@ FortuneServer::FortuneServer(QObject *parent)
//! [1]
void FortuneServer::incomingConnection(qintptr socketDescriptor)
{
- QString fortune = fortunes.at(QRandomGenerator::global()->bounded(int(fortunes.size())));
+ QString fortune = fortunes.at(QRandomGenerator::global()->bounded(fortunes.size()));
FortuneThread *thread = new FortuneThread(socketDescriptor, fortune, this);
connect(thread, &FortuneThread::finished, thread, &FortuneThread::deleteLater);
thread->start();
diff --git a/examples/network/threadedfortuneserver/fortuneserver.h b/examples/network/threadedfortuneserver/fortuneserver.h
index 26ea3d1cbb..3e544fa396 100644
--- a/examples/network/threadedfortuneserver/fortuneserver.h
+++ b/examples/network/threadedfortuneserver/fortuneserver.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FORTUNESERVER_H
#define FORTUNESERVER_H
diff --git a/examples/network/threadedfortuneserver/fortunethread.cpp b/examples/network/threadedfortuneserver/fortunethread.cpp
index ddde5121a3..8bef57599e 100644
--- a/examples/network/threadedfortuneserver/fortunethread.cpp
+++ b/examples/network/threadedfortuneserver/fortunethread.cpp
@@ -1,59 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "fortunethread.h"
#include <QtNetwork>
//! [0]
-FortuneThread::FortuneThread(int socketDescriptor, const QString &fortune, QObject *parent)
+FortuneThread::FortuneThread(qintptr socketDescriptor, const QString &fortune, QObject *parent)
: QThread(parent), socketDescriptor(socketDescriptor), text(fortune)
{
}
@@ -72,7 +25,7 @@ void FortuneThread::run()
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
- out.setVersion(QDataStream::Qt_4_0);
+ out.setVersion(QDataStream::Qt_6_5);
out << text;
//! [3] //! [4]
diff --git a/examples/network/threadedfortuneserver/fortunethread.h b/examples/network/threadedfortuneserver/fortunethread.h
index 0a4948e1de..7dae6f2e12 100644
--- a/examples/network/threadedfortuneserver/fortunethread.h
+++ b/examples/network/threadedfortuneserver/fortunethread.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FORTUNETHREAD_H
#define FORTUNETHREAD_H
@@ -60,7 +13,7 @@ class FortuneThread : public QThread
Q_OBJECT
public:
- FortuneThread(int socketDescriptor, const QString &fortune, QObject *parent);
+ FortuneThread(qintptr socketDescriptor, const QString &fortune, QObject *parent);
void run() override;
@@ -68,7 +21,7 @@ signals:
void error(QTcpSocket::SocketError socketError);
private:
- int socketDescriptor;
+ qintptr socketDescriptor;
QString text;
};
//! [0]
diff --git a/examples/network/threadedfortuneserver/main.cpp b/examples/network/threadedfortuneserver/main.cpp
index fdacb28945..bdb81c24a4 100644
--- a/examples/network/threadedfortuneserver/main.cpp
+++ b/examples/network/threadedfortuneserver/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QtCore>
diff --git a/examples/network/torrent/.prev_CMakeLists.txt b/examples/network/torrent/.prev_CMakeLists.txt
deleted file mode 100644
index bc3bf6a465..0000000000
--- a/examples/network/torrent/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,73 +0,0 @@
-# Generated from torrent.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(torrent LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/torrent")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(torrent
- addtorrentdialog.cpp addtorrentdialog.h
- bencodeparser.cpp bencodeparser.h
- connectionmanager.cpp connectionmanager.h
- filemanager.cpp filemanager.h
- forms/addtorrentform.ui
- main.cpp
- mainwindow.cpp mainwindow.h
- metainfo.cpp metainfo.h
- peerwireclient.cpp peerwireclient.h
- ratecontroller.cpp ratecontroller.h
- torrentclient.cpp torrentclient.h
- torrentserver.cpp torrentserver.h
- trackerclient.cpp trackerclient.h
-)
-set_target_properties(torrent PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(torrent PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
-)
-
-
-# Resources:
-set(icons_resource_files
- "icons/1downarrow.png"
- "icons/1uparrow.png"
- "icons/bottom.png"
- "icons/exit.png"
- "icons/peertopeer.png"
- "icons/player_pause.png"
- "icons/player_play.png"
- "icons/player_stop.png"
-)
-
-qt6_add_resources(torrent "icons"
- PREFIX
- "/"
- FILES
- ${icons_resource_files}
-)
-
-install(TARGETS torrent
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/network/torrent/CMakeLists.txt b/examples/network/torrent/CMakeLists.txt
index 7eea3d02bc..fbf974efef 100644
--- a/examples/network/torrent/CMakeLists.txt
+++ b/examples/network/torrent/CMakeLists.txt
@@ -1,31 +1,19 @@
-# Generated from torrent.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(torrent LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/torrent")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(torrent
addtorrentdialog.cpp addtorrentdialog.h
+ addtorrentform.ui
bencodeparser.cpp bencodeparser.h
connectionmanager.cpp connectionmanager.h
filemanager.cpp filemanager.h
- forms/addtorrentform.ui
main.cpp
mainwindow.cpp mainwindow.h
metainfo.cpp metainfo.h
@@ -35,32 +23,33 @@ qt_add_executable(torrent
torrentserver.cpp torrentserver.h
trackerclient.cpp trackerclient.h
)
+
set_target_properties(torrent PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_include_directories(torrent PUBLIC forms) # special case
-target_link_libraries(torrent PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
-)
+target_link_libraries(torrent PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
+)
# Resources:
set(icons_resource_files
- "icons/1downarrow.png"
- "icons/1uparrow.png"
- "icons/bottom.png"
- "icons/exit.png"
- "icons/peertopeer.png"
- "icons/player_pause.png"
- "icons/player_play.png"
- "icons/player_stop.png"
+ "icons/1downarrow.svg"
+ "icons/1uparrow.svg"
+ "icons/bottom.svg"
+ "icons/exit.svg"
+ "icons/peertopeer.svg"
+ "icons/player_pause.svg"
+ "icons/player_play.svg"
+ "icons/player_stop.svg"
+ "icons/about.svg"
)
-qt6_add_resources(torrent "icons"
+qt_add_resources(torrent "icons"
PREFIX
"/"
FILES
@@ -68,7 +57,14 @@ qt6_add_resources(torrent "icons"
)
install(TARGETS torrent
- 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 torrent
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/network/torrent/addtorrentdialog.cpp b/examples/network/torrent/addtorrentdialog.cpp
index 129ad8c968..0e389436d4 100644
--- a/examples/network/torrent/addtorrentdialog.cpp
+++ b/examples/network/torrent/addtorrentdialog.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "addtorrentdialog.h"
#include "metainfo.h"
diff --git a/examples/network/torrent/addtorrentdialog.h b/examples/network/torrent/addtorrentdialog.h
index 00546c624c..b645ca8895 100644
--- a/examples/network/torrent/addtorrentdialog.h
+++ b/examples/network/torrent/addtorrentdialog.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef ADDTORRENTDIALOG_H
#define ADDTORRENTDIALOG_H
diff --git a/examples/network/torrent/forms/addtorrentform.ui b/examples/network/torrent/addtorrentform.ui
index 950bb67119..950bb67119 100644
--- a/examples/network/torrent/forms/addtorrentform.ui
+++ b/examples/network/torrent/addtorrentform.ui
diff --git a/examples/network/torrent/bencodeparser.cpp b/examples/network/torrent/bencodeparser.cpp
index b7e28e1c19..df71b15347 100644
--- a/examples/network/torrent/bencodeparser.cpp
+++ b/examples/network/torrent/bencodeparser.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "bencodeparser.h"
diff --git a/examples/network/torrent/bencodeparser.h b/examples/network/torrent/bencodeparser.h
index 1aad2d5494..7e439180a3 100644
--- a/examples/network/torrent/bencodeparser.h
+++ b/examples/network/torrent/bencodeparser.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef BENCODEPARSER_H
#define BENCODEPARSER_H
diff --git a/examples/network/torrent/connectionmanager.cpp b/examples/network/torrent/connectionmanager.cpp
index 87b7a16e28..8e5c322fa8 100644
--- a/examples/network/torrent/connectionmanager.cpp
+++ b/examples/network/torrent/connectionmanager.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "connectionmanager.h"
diff --git a/examples/network/torrent/connectionmanager.h b/examples/network/torrent/connectionmanager.h
index 7c5b7be4f4..0316f9c56a 100644
--- a/examples/network/torrent/connectionmanager.h
+++ b/examples/network/torrent/connectionmanager.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CONNECTIONMANAGER_H
#define CONNECTIONMANAGER_H
diff --git a/examples/network/torrent/filemanager.cpp b/examples/network/torrent/filemanager.cpp
index 69345442c7..054bb1d41c 100644
--- a/examples/network/torrent/filemanager.cpp
+++ b/examples/network/torrent/filemanager.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "filemanager.h"
#include "metainfo.h"
@@ -77,13 +30,13 @@ FileManager::~FileManager()
cond.wakeOne();
wait();
- for (QFile *file : qAsConst(files)) {
+ for (QFile *file : std::as_const(files)) {
file->close();
delete file;
}
}
-int FileManager::read(int pieceIndex, int offset, int length)
+qint32 FileManager::read(qint32 pieceIndex, qint32 offset, qint32 length)
{
ReadRequest request;
request.pieceIndex = pieceIndex;
@@ -102,7 +55,7 @@ int FileManager::read(int pieceIndex, int offset, int length)
return request.id;
}
-void FileManager::write(int pieceIndex, int offset, const QByteArray &data)
+void FileManager::write(qint32 pieceIndex, qint32 offset, const QByteArray &data)
{
WriteRequest request;
request.pieceIndex = pieceIndex;
@@ -118,7 +71,7 @@ void FileManager::write(int pieceIndex, int offset, const QByteArray &data)
}
}
-void FileManager::verifyPiece(int pieceIndex)
+void FileManager::verifyPiece(qint32 pieceIndex)
{
QMutexLocker locker(&mutex);
pendingVerificationRequests << pieceIndex;
@@ -130,7 +83,7 @@ void FileManager::verifyPiece(int pieceIndex)
}
}
-int FileManager::pieceLengthAt(int pieceIndex) const
+qint32 FileManager::pieceLengthAt(qint32 pieceIndex) const
{
QMutexLocker locker(&mutex);
return (sha1s.size() == pieceIndex + 1)
@@ -329,7 +282,7 @@ bool FileManager::generateFiles()
return true;
}
-QByteArray FileManager::readBlock(int pieceIndex, int offset, int length)
+QByteArray FileManager::readBlock(qint32 pieceIndex, qint32 offset, qint32 length)
{
QByteArray block;
qint64 startReadIndex = (quint64(pieceIndex) * pieceLength) + offset;
@@ -367,7 +320,7 @@ QByteArray FileManager::readBlock(int pieceIndex, int offset, int length)
return block;
}
-bool FileManager::writeBlock(int pieceIndex, int offset, const QByteArray &data)
+bool FileManager::writeBlock(qint32 pieceIndex, qint32 offset, const QByteArray &data)
{
qint64 startWriteIndex = (qint64(pieceIndex) * pieceLength) + offset;
qint64 currentIndex = 0;
@@ -420,9 +373,9 @@ void FileManager::verifyFileContents()
int oldPercent = 0;
if (!newFile) {
- int numPieces = sha1s.size();
+ qint32 numPieces = sha1s.size();
- for (int index = 0; index < numPieces; ++index) {
+ for (qint32 index = 0; index < numPieces; ++index) {
verifySinglePiece(index);
int percent = ((index + 1) * 100) / numPieces;
@@ -438,11 +391,11 @@ void FileManager::verifyFileContents()
}
// Verify all pending pieces
- for (int index : qAsConst(newPendingVerificationRequests))
+ for (int index : std::as_const(newPendingVerificationRequests))
emit pieceVerified(index, verifySinglePiece(index));
}
-bool FileManager::verifySinglePiece(int pieceIndex)
+bool FileManager::verifySinglePiece(qint32 pieceIndex)
{
QByteArray block = readBlock(pieceIndex, 0, pieceLength);
QByteArray sha1Sum = QCryptographicHash::hash(block, QCryptographicHash::Sha1);
diff --git a/examples/network/torrent/filemanager.h b/examples/network/torrent/filemanager.h
index 1438ed5404..9eef18a8ab 100644
--- a/examples/network/torrent/filemanager.h
+++ b/examples/network/torrent/filemanager.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FILEMANAGER_H
#define FILEMANAGER_H
@@ -76,13 +29,13 @@ public:
inline void setMetaInfo(const MetaInfo &info) { metaInfo = info; }
inline void setDestinationFolder(const QString &directory) { destinationPath = directory; }
- int read(int pieceIndex, int offset, int length);
- void write(int pieceIndex, int offset, const QByteArray &data);
- void verifyPiece(int pieceIndex);
+ qint32 read(qint32 pieceIndex, qint32 offset, qint32 length);
+ void write(qint32 pieceIndex, qint32 offset, const QByteArray &data);
+ void verifyPiece(qint32 pieceIndex);
inline qint64 totalSize() const { return totalLength; }
- inline int pieceCount() const { return numPieces; }
- int pieceLengthAt(int pieceIndex) const;
+ inline qint32 pieceCount() const { return numPieces; }
+ qint32 pieceLengthAt(qint32 pieceIndex) const;
QBitArray completedPieces() const;
void setCompletedPieces(const QBitArray &pieces);
@@ -93,35 +46,35 @@ public slots:
void startDataVerification();
signals:
- void dataRead(int id, int pieceIndex, int offset, const QByteArray &data);
+ void dataRead(qint32 id, qint32 pieceIndex, qint32 offset, const QByteArray &data);
void error();
void verificationProgress(int percent);
void verificationDone();
- void pieceVerified(int pieceIndex, bool verified);
+ void pieceVerified(qint32 pieceIndex, bool verified);
protected:
void run() override;
private slots:
- bool verifySinglePiece(int pieceIndex);
+ bool verifySinglePiece(qint32 pieceIndex);
void wakeUp();
private:
bool generateFiles();
- QByteArray readBlock(int pieceIndex, int offset, int length);
- bool writeBlock(int pieceIndex, int offset, const QByteArray &data);
+ QByteArray readBlock(qint32 pieceIndex, qint32 offset, qint32 length);
+ bool writeBlock(qint32 pieceIndex, qint32 offset, const QByteArray &data);
void verifyFileContents();
struct WriteRequest {
- int pieceIndex;
- int offset;
+ qint32 pieceIndex;
+ qint32 offset;
QByteArray data;
};
struct ReadRequest {
- int pieceIndex;
- int offset;
- int length;
- int id;
+ qint32 pieceIndex;
+ qint32 offset;
+ qint32 length;
+ qint32 id;
};
QString errString;
diff --git a/examples/network/torrent/icons.qrc b/examples/network/torrent/icons.qrc
index 9541ef7600..5606275d92 100644
--- a/examples/network/torrent/icons.qrc
+++ b/examples/network/torrent/icons.qrc
@@ -1,12 +1,13 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/">
- <file>icons/peertopeer.png</file>
- <file>icons/1uparrow.png</file>
- <file>icons/1downarrow.png</file>
- <file>icons/bottom.png</file>
- <file>icons/player_pause.png</file>
- <file>icons/player_play.png</file>
- <file>icons/player_stop.png</file>
- <file>icons/exit.png</file>
-</qresource>
+<RCC>
+ <qresource prefix="/">
+ <file>icons/peertopeer.svg</file>
+ <file>icons/1uparrow.svg</file>
+ <file>icons/1downarrow.svg</file>
+ <file>icons/bottom.svg</file>
+ <file>icons/player_pause.svg</file>
+ <file>icons/player_play.svg</file>
+ <file>icons/player_stop.svg</file>
+ <file>icons/exit.svg</file>
+ <file>icons/about.svg</file>
+ </qresource>
</RCC>
diff --git a/examples/network/torrent/icons/1downarrow.png b/examples/network/torrent/icons/1downarrow.png
deleted file mode 100644
index 08403b82ba..0000000000
--- a/examples/network/torrent/icons/1downarrow.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/torrent/icons/1downarrow.svg b/examples/network/torrent/icons/1downarrow.svg
new file mode 100644
index 0000000000..fc43085f59
--- /dev/null
+++ b/examples/network/torrent/icons/1downarrow.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M21.7071 7.29289C21.3166 6.90237 20.6834 6.90237 20.2929 7.29289L12 15.5858L3.70711 7.29289C3.31658 6.90237 2.68342 6.90237 2.29289 7.29289C1.90237 7.68342 1.90237 8.31658 2.29289 8.70711L11.2929 17.7071C11.6834 18.0976 12.3166 18.0976 12.7071 17.7071L21.7071 8.70711C22.0976 8.31658 22.0976 7.68342 21.7071 7.29289Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/network/torrent/icons/1uparrow.png b/examples/network/torrent/icons/1uparrow.png
deleted file mode 100644
index f044811787..0000000000
--- a/examples/network/torrent/icons/1uparrow.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/torrent/icons/1uparrow.svg b/examples/network/torrent/icons/1uparrow.svg
new file mode 100644
index 0000000000..aaed789617
--- /dev/null
+++ b/examples/network/torrent/icons/1uparrow.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M21.7071 16.7071C21.3166 17.0976 20.6834 17.0976 20.2929 16.7071L12 8.41421L3.70711 16.7071C3.31658 17.0976 2.68342 17.0976 2.29289 16.7071C1.90237 16.3166 1.90237 15.6834 2.29289 15.2929L11.2929 6.29289C11.6834 5.90237 12.3166 5.90237 12.7071 6.29289L21.7071 15.2929C22.0976 15.6834 22.0976 16.3166 21.7071 16.7071Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/network/torrent/icons/about.svg b/examples/network/torrent/icons/about.svg
new file mode 100644
index 0000000000..2772c4fa31
--- /dev/null
+++ b/examples/network/torrent/icons/about.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12C4 7.58172 7.58172 4 12 4ZM12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M11.8735 14C11.4243 14 11.0305 13.6404 11.0859 13.1913C11.1218 12.9004 11.1938 12.7598 11.2726 12.6061C11.2846 12.5827 11.2968 12.559 11.309 12.5344C11.4537 12.2427 11.8446 11.8125 12.4814 11.2438C12.742 11.025 12.9591 10.788 13.1328 10.5328C13.3065 10.2776 13.3933 10.0042 13.3933 9.7125C13.3933 9.40625 13.2775 9.12552 13.0459 8.87031C12.8143 8.6151 12.467 8.4875 12.0038 8.4875C11.4827 8.4875 11.0955 8.64062 10.8422 8.94687C10.7885 9.0118 10.7473 9.09933 10.7158 9.19697C10.5687 9.65217 10.2209 10.0625 9.74577 10.0625C9.26613 10.0625 8.88562 9.66512 9.03161 9.20479C9.18688 8.71516 9.47937 8.13493 9.99543 7.65625C10.5093 7.21875 11.1787 7 12.0038 7C12.8143 7 13.5164 7.21875 14.1098 7.65625C14.7033 8.09375 15 8.72083 15 9.5375C15 10.0188 14.8914 10.4307 14.6743 10.7734C14.4572 11.1161 14.1605 11.4771 13.7841 11.8562C13.2775 12.3375 12.9699 12.7167 12.8614 12.9938C12.834 13.0635 12.8088 13.1315 12.7863 13.2017C12.65 13.6271 12.3172 14 11.8735 14ZM12 15C12.5523 15 13 15.4477 13 16C13 16.5523 12.5523 17 12 17C11.4477 17 11 16.5523 11 16C11 15.4477 11.4477 15 12 15Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/network/torrent/icons/bottom.png b/examples/network/torrent/icons/bottom.png
deleted file mode 100644
index fe66b5d028..0000000000
--- a/examples/network/torrent/icons/bottom.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/torrent/icons/bottom.svg b/examples/network/torrent/icons/bottom.svg
new file mode 100644
index 0000000000..44395cde25
--- /dev/null
+++ b/examples/network/torrent/icons/bottom.svg
@@ -0,0 +1,6 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g id="File /download_arrow_down">
+<path id="Layer01" fill-rule="evenodd" clip-rule="evenodd" d="M3 21C3 20.4477 3.44772 20 4 20H20C20.5523 20 21 20.4477 21 21C21 21.5523 20.5523 22 20 22H4C3.44772 22 3 21.5523 3 21Z" fill="#0D0D0D"/>
+<path id="Layer02" fill-rule="evenodd" clip-rule="evenodd" d="M12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L7.93679 13.351C7.54626 12.9605 7.54626 12.3273 7.93679 11.9368C8.32731 11.5463 8.96047 11.5463 9.351 11.9368L11 13.5858L11 3.27208C11 2.71979 11.4477 2.27208 12 2.27208C12.5523 2.27208 13 2.71979 13 3.27208L13 13.5858L14.649 11.9368C15.0395 11.5463 15.6727 11.5463 16.0632 11.9368C16.4537 12.3273 16.4537 12.9605 16.0632 13.351L12.7071 16.7071Z" fill="#0D0D0D"/>
+</g>
+</svg>
diff --git a/examples/network/torrent/icons/edit_add.png b/examples/network/torrent/icons/edit_add.png
deleted file mode 100644
index 85b022e7a4..0000000000
--- a/examples/network/torrent/icons/edit_add.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/torrent/icons/edit_add.svg b/examples/network/torrent/icons/edit_add.svg
new file mode 100644
index 0000000000..ec817193f5
--- /dev/null
+++ b/examples/network/torrent/icons/edit_add.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M11 17L11 7.00003L13 7.00003L13 17L11 17Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M7 11L17 11L17 13L7 13L7 11Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/network/torrent/icons/edit_remove.png b/examples/network/torrent/icons/edit_remove.png
deleted file mode 100644
index 93361f5225..0000000000
--- a/examples/network/torrent/icons/edit_remove.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/torrent/icons/edit_remove.svg b/examples/network/torrent/icons/edit_remove.svg
new file mode 100644
index 0000000000..ec18b7da64
--- /dev/null
+++ b/examples/network/torrent/icons/edit_remove.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M7 13V11H17V13H7Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/network/torrent/icons/exit.png b/examples/network/torrent/icons/exit.png
deleted file mode 100644
index 2f7ff43a71..0000000000
--- a/examples/network/torrent/icons/exit.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/torrent/icons/exit.svg b/examples/network/torrent/icons/exit.svg
new file mode 100644
index 0000000000..94f5245c52
--- /dev/null
+++ b/examples/network/torrent/icons/exit.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12C4 7.58172 7.58172 4 12 4ZM12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M8.4644 15.5355C8.07388 15.145 8.07388 14.5118 8.4644 14.1213L10.5857 12L8.46444 9.87868C8.07392 9.48815 8.07392 8.85499 8.46444 8.46446C8.85496 8.07394 9.48813 8.07394 9.87865 8.46446L12 10.5858L14.1213 8.46446C14.5118 8.07394 15.1449 8.07394 15.5355 8.46446C15.926 8.85499 15.926 9.48815 15.5355 9.87868L13.4142 12L15.5355 14.1213C15.926 14.5118 15.926 15.145 15.5355 15.5355C15.145 15.9261 14.5118 15.9261 14.1213 15.5355L12 13.4142L9.87862 15.5355C9.48809 15.9261 8.85493 15.9261 8.4644 15.5355Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/network/torrent/icons/peertopeer.png b/examples/network/torrent/icons/peertopeer.png
deleted file mode 100644
index f4856dcec5..0000000000
--- a/examples/network/torrent/icons/peertopeer.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/torrent/icons/peertopeer.svg b/examples/network/torrent/icons/peertopeer.svg
new file mode 100644
index 0000000000..9498804cb8
--- /dev/null
+++ b/examples/network/torrent/icons/peertopeer.svg
@@ -0,0 +1,62 @@
+<svg width="128" height="128" viewBox="0 0 1024 1024" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g id="App Icon-Apple-1">
+<rect id="App Icon Bg" x="62" y="62" width="900" height="900" rx="180" fill="url(#paint0_linear_1432_187)"/>
+<g id="torrent client">
+<g id="laptop_mac">
+<mask id="mask0_1432_187" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="122" y="344" width="176" height="176">
+<rect id="Bounding box" x="122" y="344" width="176" height="176" fill="#D9D9D9"/>
+</mask>
+<g mask="url(#mask0_1432_187)">
+<path id="laptop_mac_2" d="M136.667 490.667C132.633 490.667 129.181 489.231 126.308 486.358C123.436 483.486 122 480.033 122 476H151.333C147.3 476 143.847 474.564 140.975 471.692C138.103 468.819 136.667 465.367 136.667 461.333V380.667C136.667 376.633 138.103 373.181 140.975 370.308C143.847 367.436 147.3 366 151.333 366H268.667C272.7 366 276.153 367.436 279.025 370.308C281.897 373.181 283.333 376.633 283.333 380.667V461.333C283.333 465.367 281.897 468.819 279.025 471.692C276.153 474.564 272.7 476 268.667 476H298C298 480.033 296.564 483.486 293.692 486.358C290.819 489.231 287.367 490.667 283.333 490.667H136.667ZM210 483.333C212.078 483.333 213.819 482.631 215.225 481.225C216.631 479.819 217.333 478.078 217.333 476C217.333 473.922 216.631 472.181 215.225 470.775C213.819 469.369 212.078 468.667 210 468.667C207.922 468.667 206.181 469.369 204.775 470.775C203.369 472.181 202.667 473.922 202.667 476C202.667 478.078 203.369 479.819 204.775 481.225C206.181 482.631 207.922 483.333 210 483.333ZM151.333 461.333H268.667V380.667H151.333V461.333Z" fill="white"/>
+</g>
+</g>
+<g id="laptop_mac_3">
+<mask id="mask1_1432_187" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="726" y="344" width="176" height="176">
+<rect id="Bounding box_2" x="726" y="344" width="176" height="176" fill="#D9D9D9"/>
+</mask>
+<g mask="url(#mask1_1432_187)">
+<path id="laptop_mac_4" d="M740.667 490.667C736.633 490.667 733.181 489.231 730.308 486.358C727.436 483.486 726 480.033 726 476H755.333C751.3 476 747.847 474.564 744.975 471.692C742.103 468.819 740.667 465.367 740.667 461.333V380.667C740.667 376.633 742.103 373.181 744.975 370.308C747.847 367.436 751.3 366 755.333 366H872.667C876.7 366 880.153 367.436 883.025 370.308C885.897 373.181 887.333 376.633 887.333 380.667V461.333C887.333 465.367 885.897 468.819 883.025 471.692C880.153 474.564 876.7 476 872.667 476H902C902 480.033 900.564 483.486 897.692 486.358C894.819 489.231 891.367 490.667 887.333 490.667H740.667ZM814 483.333C816.078 483.333 817.819 482.631 819.225 481.225C820.631 479.819 821.333 478.078 821.333 476C821.333 473.922 820.631 472.181 819.225 470.775C817.819 469.369 816.078 468.667 814 468.667C811.922 468.667 810.181 469.369 808.775 470.775C807.369 472.181 806.667 473.922 806.667 476C806.667 478.078 807.369 479.819 808.775 481.225C810.181 482.631 811.922 483.333 814 483.333ZM755.333 461.333H872.667V380.667H755.333V461.333Z" fill="white"/>
+</g>
+</g>
+<g id="laptop_mac_5">
+<mask id="mask2_1432_187" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="248" y="682" width="176" height="176">
+<rect id="Bounding box_3" x="248" y="682" width="176" height="176" fill="#D9D9D9"/>
+</mask>
+<g mask="url(#mask2_1432_187)">
+<path id="laptop_mac_6" d="M262.667 828.667C258.633 828.667 255.181 827.231 252.308 824.358C249.436 821.486 248 818.033 248 814H277.333C273.3 814 269.847 812.564 266.975 809.692C264.103 806.819 262.667 803.367 262.667 799.333V718.667C262.667 714.633 264.103 711.181 266.975 708.308C269.847 705.436 273.3 704 277.333 704H394.667C398.7 704 402.153 705.436 405.025 708.308C407.897 711.181 409.333 714.633 409.333 718.667V799.333C409.333 803.367 407.897 806.819 405.025 809.692C402.153 812.564 398.7 814 394.667 814H424C424 818.033 422.564 821.486 419.692 824.358C416.819 827.231 413.367 828.667 409.333 828.667H262.667ZM336 821.333C338.078 821.333 339.819 820.631 341.225 819.225C342.631 817.819 343.333 816.078 343.333 814C343.333 811.922 342.631 810.181 341.225 808.775C339.819 807.369 338.078 806.667 336 806.667C333.922 806.667 332.181 807.369 330.775 808.775C329.369 810.181 328.667 811.922 328.667 814C328.667 816.078 329.369 817.819 330.775 819.225C332.181 820.631 333.922 821.333 336 821.333ZM277.333 799.333H394.667V718.667H277.333V799.333Z" fill="white"/>
+</g>
+</g>
+<g id="laptop_mac_7">
+<mask id="mask3_1432_187" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="600" y="682" width="176" height="176">
+<rect id="Bounding box_4" x="600" y="682" width="176" height="176" fill="#D9D9D9"/>
+</mask>
+<g mask="url(#mask3_1432_187)">
+<path id="laptop_mac_8" d="M614.667 828.667C610.633 828.667 607.181 827.231 604.308 824.358C601.436 821.486 600 818.033 600 814H629.333C625.3 814 621.847 812.564 618.975 809.692C616.103 806.819 614.667 803.367 614.667 799.333V718.667C614.667 714.633 616.103 711.181 618.975 708.308C621.847 705.436 625.3 704 629.333 704H746.667C750.7 704 754.153 705.436 757.025 708.308C759.897 711.181 761.333 714.633 761.333 718.667V799.333C761.333 803.367 759.897 806.819 757.025 809.692C754.153 812.564 750.7 814 746.667 814H776C776 818.033 774.564 821.486 771.692 824.358C768.819 827.231 765.367 828.667 761.333 828.667H614.667ZM688 821.333C690.078 821.333 691.819 820.631 693.225 819.225C694.631 817.819 695.333 816.078 695.333 814C695.333 811.922 694.631 810.181 693.225 808.775C691.819 807.369 690.078 806.667 688 806.667C685.922 806.667 684.181 807.369 682.775 808.775C681.369 810.181 680.667 811.922 680.667 814C680.667 816.078 681.369 817.819 682.775 819.225C684.181 820.631 685.922 821.333 688 821.333ZM629.333 799.333H746.667V718.667H629.333V799.333Z" fill="white"/>
+</g>
+</g>
+<g id="laptop_mac_9">
+<mask id="mask4_1432_187" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="424" y="130" width="176" height="176">
+<rect id="Bounding box_5" x="424" y="130" width="176" height="176" fill="#D9D9D9"/>
+</mask>
+<g mask="url(#mask4_1432_187)">
+<path id="laptop_mac_10" d="M438.667 276.667C434.633 276.667 431.181 275.231 428.308 272.358C425.436 269.486 424 266.033 424 262H453.333C449.3 262 445.847 260.564 442.975 257.692C440.103 254.819 438.667 251.367 438.667 247.333V166.667C438.667 162.633 440.103 159.181 442.975 156.308C445.847 153.436 449.3 152 453.333 152H570.667C574.7 152 578.153 153.436 581.025 156.308C583.897 159.181 585.333 162.633 585.333 166.667V247.333C585.333 251.367 583.897 254.819 581.025 257.692C578.153 260.564 574.7 262 570.667 262H600C600 266.033 598.564 269.486 595.692 272.358C592.819 275.231 589.367 276.667 585.333 276.667H438.667ZM512 269.333C514.078 269.333 515.819 268.631 517.225 267.225C518.631 265.819 519.333 264.078 519.333 262C519.333 259.922 518.631 258.181 517.225 256.775C515.819 255.369 514.078 254.667 512 254.667C509.922 254.667 508.181 255.369 506.775 256.775C505.369 258.181 504.667 259.922 504.667 262C504.667 264.078 505.369 265.819 506.775 267.225C508.181 268.631 509.922 269.333 512 269.333ZM453.333 247.333H570.667V166.667H453.333V247.333Z" fill="white"/>
+</g>
+</g>
+<path id="netweork-big" fill-rule="evenodd" clip-rule="evenodd" d="M268.007 342C302.498 294.803 350.351 257.989 406 237.126V264.006C364.55 281.188 328.176 308.144 299.754 342H268.007ZM724.246 342C695.824 308.144 659.45 281.188 618 264.006V237.126C673.649 257.989 721.502 294.803 755.993 342H724.246ZM789 520C789 576.131 772.304 628.363 743.608 672H773.017C799.072 627.355 814 575.421 814 520H789ZM512 797C534.744 797 556.848 794.259 578 789.089V814.766C556.757 819.502 534.67 822 512 822C489.33 822 467.243 819.502 446 814.766V789.089C467.152 794.259 489.256 797 512 797ZM280.392 672C251.696 628.363 235 576.131 235 520H210C210 575.421 224.928 627.355 250.983 672H280.392Z" fill="white"/>
+<g id="network">
+<path id="Vector 6" d="M512.222 357.923L602.289 630.013C602.596 630.939 601.531 631.711 600.746 631.132L369.446 460.491C368.67 459.918 369.075 458.686 370.04 458.686H653.981C654.944 458.686 655.35 459.914 654.578 460.489L425.204 631.145C424.425 631.725 423.36 630.965 423.655 630.04L510.319 357.934C510.613 357.011 511.917 357.004 512.222 357.923Z" stroke="white" stroke-width="10"/>
+<circle id="Ellipse 3" cx="512" cy="355" r="22" fill="white"/>
+<circle id="Ellipse 4" cx="366" cy="461" r="22" fill="white"/>
+<circle id="Ellipse 5" cx="658" cy="461" r="22" fill="white"/>
+<circle id="Ellipse 6" cx="423" cy="633" r="22" fill="white"/>
+<circle id="Ellipse 7" cx="600" cy="633" r="22" fill="white"/>
+</g>
+</g>
+</g>
+<defs>
+<linearGradient id="paint0_linear_1432_187" x1="131.231" y1="96.0541" x2="967.084" y2="893.654" gradientUnits="userSpaceOnUse">
+<stop stop-color="#00414A"/>
+<stop offset="1" stop-color="#0C1C1F"/>
+</linearGradient>
+</defs>
+</svg>
diff --git a/examples/network/torrent/icons/player_pause.png b/examples/network/torrent/icons/player_pause.png
deleted file mode 100644
index 8c9bcc4556..0000000000
--- a/examples/network/torrent/icons/player_pause.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/torrent/icons/player_pause.svg b/examples/network/torrent/icons/player_pause.svg
new file mode 100644
index 0000000000..6499480ea4
--- /dev/null
+++ b/examples/network/torrent/icons/player_pause.svg
@@ -0,0 +1,6 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g id="Player / pause-symbol">
+<path id="Layer01" fill-rule="evenodd" clip-rule="evenodd" d="M8 7C8 6.44772 8.33579 6 8.75 6H10.25C10.6642 6 11 6.44772 11 7V17C11 17.5523 10.6642 18 10.25 18H8.75C8.33579 18 8 17.5523 8 17V7Z" fill="#0D0D0D"/>
+<path id="Layer02" fill-rule="evenodd" clip-rule="evenodd" d="M13 7C13 6.44772 13.3358 6 13.75 6H15.25C15.6642 6 16 6.44772 16 7V17C16 17.5523 15.6642 18 15.25 18H13.75C13.3358 18 13 17.5523 13 17V7Z" fill="#0D0D0D"/>
+</g>
+</svg>
diff --git a/examples/network/torrent/icons/player_play.png b/examples/network/torrent/icons/player_play.png
deleted file mode 100644
index 70daa339be..0000000000
--- a/examples/network/torrent/icons/player_play.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/torrent/icons/player_play.svg b/examples/network/torrent/icons/player_play.svg
new file mode 100644
index 0000000000..a8cce6f422
--- /dev/null
+++ b/examples/network/torrent/icons/player_play.svg
@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M17.8182 12L7.89091 6.14985L7.89091 17.8501L17.8182 12ZM19.2 13.4143C20.2667 12.7857 20.2667 11.2143 19.2 10.5857L8.4 4.22123C7.33333 3.59264 6 4.37838 6 5.63555L6 18.3644C6 19.6216 7.33333 20.4074 8.4 19.7788L19.2 13.4143Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/network/torrent/icons/player_stop.png b/examples/network/torrent/icons/player_stop.png
deleted file mode 100644
index ce6585ae84..0000000000
--- a/examples/network/torrent/icons/player_stop.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/torrent/icons/player_stop.svg b/examples/network/torrent/icons/player_stop.svg
new file mode 100644
index 0000000000..e220f5a790
--- /dev/null
+++ b/examples/network/torrent/icons/player_stop.svg
@@ -0,0 +1,5 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g id="Player / stop-symbol">
+<path id="Layer01" fill-rule="evenodd" clip-rule="evenodd" d="M17 7H7L7 17H17V7ZM7 5C5.89543 5 5 5.89543 5 7V17C5 18.1046 5.89543 19 7 19H17C18.1046 19 19 18.1046 19 17V7C19 5.89543 18.1046 5 17 5H7Z" fill="#0D0D0D"/>
+</g>
+</svg>
diff --git a/examples/network/torrent/icons/stop.png b/examples/network/torrent/icons/stop.png
deleted file mode 100644
index 52e593ab21..0000000000
--- a/examples/network/torrent/icons/stop.png
+++ /dev/null
Binary files differ
diff --git a/examples/network/torrent/main.cpp b/examples/network/torrent/main.cpp
index 6430d2e5f3..649f33436a 100644
--- a/examples/network/torrent/main.cpp
+++ b/examples/network/torrent/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QtCore>
@@ -56,8 +9,6 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- Q_INIT_RESOURCE(icons);
-
MainWindow window;
window.show();
diff --git a/examples/network/torrent/mainwindow.cpp b/examples/network/torrent/mainwindow.cpp
index 129ded3fa4..9bda5bb05e 100644
--- a/examples/network/torrent/mainwindow.cpp
+++ b/examples/network/torrent/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
@@ -73,27 +26,27 @@ protected:
};
// TorrentViewDelegate is used to draw the progress bars.
-class TorrentViewDelegate : public QItemDelegate
+class TorrentViewDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
- inline TorrentViewDelegate(MainWindow *mainWindow) : QItemDelegate(mainWindow) {}
+ inline TorrentViewDelegate(MainWindow *mainWindow) : QStyledItemDelegate(mainWindow) {}
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index ) const override
{
if (index.column() != 2) {
- QItemDelegate::paint(painter, option, index);
+ QStyledItemDelegate::paint(painter, option, index);
return;
}
// Set up a QStyleOptionProgressBar to precisely mimic the
// environment of a progress bar.
QStyleOptionProgressBar progressBarOption;
- progressBarOption.state = QStyle::State_Enabled;
+ progressBarOption.state |= QStyle::State_Enabled;
progressBarOption.direction = QApplication::layoutDirection();
progressBarOption.rect = option.rect;
- progressBarOption.fontMetrics = QApplication::fontMetrics();
+ progressBarOption.fontMetrics = QFontMetrics(QApplication::font());
progressBarOption.minimum = 0;
progressBarOption.maximum = 100;
progressBarOption.textAlignment = Qt::AlignCenter;
@@ -127,19 +80,19 @@ MainWindow::MainWindow(QWidget *parent)
setCentralWidget(torrentView);
// Set header resize modes and initial section sizes
- QFontMetrics fm = fontMetrics();
+ const QFontMetrics fm = torrentView->fontMetrics();
QHeaderView *header = torrentView->header();
header->resizeSection(0, fm.horizontalAdvance("typical-name-for-a-torrent.torrent"));
- header->resizeSection(1, fm.horizontalAdvance(headers.at(1) + " "));
- header->resizeSection(2, fm.horizontalAdvance(headers.at(2) + " "));
- header->resizeSection(3, qMax(fm.horizontalAdvance(headers.at(3) + " "), fm.horizontalAdvance(" 1234.0 KB/s ")));
- header->resizeSection(4, qMax(fm.horizontalAdvance(headers.at(4) + " "), fm.horizontalAdvance(" 1234.0 KB/s ")));
- header->resizeSection(5, qMax(fm.horizontalAdvance(headers.at(5) + " "), fm.horizontalAdvance(tr("Downloading") + " ")));
+ header->resizeSection(1, fm.horizontalAdvance(headers.at(1) + " "));
+ header->resizeSection(2, fm.horizontalAdvance(headers.at(2) + " "));
+ header->resizeSection(3, qMax(fm.horizontalAdvance(headers.at(3) + " "), fm.horizontalAdvance(" 1234.0 KB/s ")));
+ header->resizeSection(4, qMax(fm.horizontalAdvance(headers.at(4) + " "), fm.horizontalAdvance(" 1234.0 KB/s ")));
+ header->resizeSection(5, qMax(fm.horizontalAdvance(headers.at(5) + " "), fm.horizontalAdvance(tr("Downloading") + " ")));
// Create common actions
- QAction *newTorrentAction = new QAction(QIcon(":/icons/bottom.png"), tr("Add &new torrent"), this);
- pauseTorrentAction = new QAction(QIcon(":/icons/player_pause.png"), tr("&Pause torrent"), this);
- removeTorrentAction = new QAction(QIcon(":/icons/player_stop.png"), tr("&Remove torrent"), this);
+ QAction *newTorrentAction = new QAction(QIcon(":/icons/bottom.svg"), tr("Add &new torrent"), this);
+ pauseTorrentAction = new QAction(QIcon(":/icons/player_pause.svg"), tr("&Pause torrent"), this);
+ removeTorrentAction = new QAction(QIcon(":/icons/player_stop.svg"), tr("&Remove torrent"), this);
// File menu
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
@@ -147,12 +100,12 @@ MainWindow::MainWindow(QWidget *parent)
fileMenu->addAction(pauseTorrentAction);
fileMenu->addAction(removeTorrentAction);
fileMenu->addSeparator();
- fileMenu->addAction(QIcon(":/icons/exit.png"), tr("E&xit"), this, &MainWindow::close);
+ fileMenu->addAction(QIcon(":/icons/exit.svg"), tr("E&xit"), this, &MainWindow::close);
// Help menu
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(tr("&About"), this, &MainWindow::about);
- helpMenu->addAction(tr("About &Qt"), qApp, QApplication::aboutQt);
+ helpMenu->addAction(QIcon(":/icons/about.svg"), tr("&About"), this, &MainWindow::about);
+ helpMenu->addAction(QIcon(":/icons/about.svg"), tr("About &Qt"), qApp, QApplication::aboutQt);
// Top toolbar
QToolBar *topBar = new QToolBar(tr("Tools"));
@@ -162,8 +115,8 @@ MainWindow::MainWindow(QWidget *parent)
topBar->addAction(removeTorrentAction);
topBar->addAction(pauseTorrentAction);
topBar->addSeparator();
- downActionTool = topBar->addAction(QIcon(tr(":/icons/1downarrow.png")), tr("Move down"));
- upActionTool = topBar->addAction(QIcon(tr(":/icons/1uparrow.png")), tr("Move up"));
+ downActionTool = topBar->addAction(QIcon(tr(":/icons/1downarrow.svg")), tr("Move down"));
+ upActionTool = topBar->addAction(QIcon(tr(":/icons/1uparrow.svg")), tr("Move up"));
// Bottom toolbar
QToolBar *bottomBar = new QToolBar(tr("Rate control"));
@@ -358,7 +311,7 @@ bool MainWindow::addTorrent(const QString &fileName, const QString &destinationF
const QByteArray &resumeState)
{
// Check if the torrent is already being downloaded.
- for (const Job &job : qAsConst(jobs)) {
+ for (const Job &job : std::as_const(jobs)) {
if (job.torrentFileName == fileName && job.destinationDirectory == destinationFolder) {
QMessageBox::warning(this, tr("Already downloading"),
tr("The torrent file %1 is "
@@ -509,10 +462,10 @@ void MainWindow::setActionsEnabled()
pauseTorrentAction->setEnabled(item && pauseEnabled);
if (client && client->state() == TorrentClient::Paused) {
- pauseTorrentAction->setIcon(QIcon(":/icons/player_play.png"));
+ pauseTorrentAction->setIcon(QIcon(":/icons/player_play.svg"));
pauseTorrentAction->setText(tr("Resume torrent"));
} else {
- pauseTorrentAction->setIcon(QIcon(":/icons/player_pause.png"));
+ pauseTorrentAction->setIcon(QIcon(":/icons/player_pause.svg"));
pauseTorrentAction->setText(tr("Pause torrent"));
}
@@ -622,7 +575,10 @@ void MainWindow::setDownloadLimit(int value)
void MainWindow::about()
{
QLabel *icon = new QLabel;
- icon->setPixmap(QPixmap(":/icons/peertopeer.png"));
+ QImage img(":/icons/peertopeer.svg");
+ QPixmap pm;
+ pm.convertFromImage(img);
+ icon->setPixmap(pm);
QLabel *text = new QLabel;
text->setWordWrap(true);
@@ -691,7 +647,7 @@ void MainWindow::closeEvent(QCloseEvent *)
// them to signal that they have stopped.
jobsToStop = 0;
jobsStopped = 0;
- for (const Job &job : qAsConst(jobs)) {
+ for (const Job &job : std::as_const(jobs)) {
++jobsToStop;
TorrentClient *client = job.client;
client->disconnect();
diff --git a/examples/network/torrent/mainwindow.h b/examples/network/torrent/mainwindow.h
index 78542b535b..a2a05a8c2a 100644
--- a/examples/network/torrent/mainwindow.h
+++ b/examples/network/torrent/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/network/torrent/metainfo.cpp b/examples/network/torrent/metainfo.cpp
index 29b34b12a0..893ae80260 100644
--- a/examples/network/torrent/metainfo.cpp
+++ b/examples/network/torrent/metainfo.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "bencodeparser.h"
#include "metainfo.h"
diff --git a/examples/network/torrent/metainfo.h b/examples/network/torrent/metainfo.h
index cbdc31c2c7..e2717d6e73 100644
--- a/examples/network/torrent/metainfo.h
+++ b/examples/network/torrent/metainfo.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef METAINFO_H
#define METAINFO_H
@@ -64,7 +17,7 @@ struct MetaInfoSingleFile
qint64 length;
QByteArray md5sum;
QString name;
- int pieceLength;
+ qint32 pieceLength;
QList<QByteArray> sha1Sums;
};
diff --git a/examples/network/torrent/peerwireclient.cpp b/examples/network/torrent/peerwireclient.cpp
index 177568d402..349371afbf 100644
--- a/examples/network/torrent/peerwireclient.cpp
+++ b/examples/network/torrent/peerwireclient.cpp
@@ -1,87 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "peerwireclient.h"
#include <QHostAddress>
#include <QTimerEvent>
+#include <QtEndian>
-static const int PendingRequestTimeout = 60 * 1000;
-static const int ClientTimeout = 120 * 1000;
-static const int ConnectTimeout = 60 * 1000;
-static const int KeepAliveInterval = 30 * 1000;
-static const int RateControlTimerDelay = 2000;
+#include <chrono>
+
+static constexpr std::chrono::seconds PendingRequestTimeout(60);
+static constexpr std::chrono::seconds ClientTimeout(120);
+static constexpr std::chrono::seconds ConnectTimeout(60);
+static constexpr std::chrono::seconds KeepAliveInterval(30);
+static constexpr std::chrono::seconds PeerRateControlTimerDelay(2);
static const int MinimalHeaderSize = 48;
static const char ProtocolId[] = "BitTorrent protocol";
static const char ProtocolIdSize = 19;
-// Reads a 32bit unsigned int from data in network order.
-static inline quint32 fromNetworkData(const char *data)
-{
- const unsigned char *udata = (const unsigned char *)data;
- return (quint32(udata[0]) << 24)
- | (quint32(udata[1]) << 16)
- | (quint32(udata[2]) << 8)
- | (quint32(udata[3]));
-}
-
-// Writes a 32bit unsigned int from num to data in network order.
-static inline void toNetworkData(quint32 num, char *data)
-{
- unsigned char *udata = (unsigned char *)data;
- udata[3] = (num & 0xff);
- udata[2] = (num & 0xff00) >> 8;
- udata[1] = (num & 0xff0000) >> 16;
- udata[0] = (num & 0xff000000) >> 24;
-}
-
// Constructs an unconnected PeerWire client and starts the connect timer.
PeerWireClient::PeerWireClient(const QByteArray &peerId, QObject *parent)
: QTcpSocket(parent), pendingBlockSizes(0),
@@ -92,7 +28,7 @@ PeerWireClient::PeerWireClient(const QByteArray &peerId, QObject *parent)
memset(uploadSpeedData, 0, sizeof(uploadSpeedData));
memset(downloadSpeedData, 0, sizeof(downloadSpeedData));
- transferSpeedTimer = startTimer(RateControlTimerDelay);
+ transferSpeedTimer = startTimer(PeerRateControlTimerDelay);
timeoutTimer = startTimer(ConnectTimeout);
peerIdString = peerId;
@@ -118,7 +54,7 @@ PeerWireClient::PeerWireClient(const QByteArray &peerId, QObject *parent)
// Registers the peer ID and SHA1 sum of the torrent, and initiates
// the handshake.
-void PeerWireClient::initialize(const QByteArray &infoHash, int pieceCount)
+void PeerWireClient::initialize(const QByteArray &infoHash, qint32 pieceCount)
{
this->infoHash = infoHash;
peerPieces.resize(pieceCount);
@@ -206,13 +142,13 @@ void PeerWireClient::sendNotInterested()
// Sends a piece notification / a "have" message, informing the peer
// that we have just downloaded a new piece.
-void PeerWireClient::sendPieceNotification(int piece)
+void PeerWireClient::sendPieceNotification(qint32 piece)
{
if (!sentHandShake)
sendHandShake();
char message[] = {0, 0, 0, 5, 4, 0, 0, 0, 0};
- toNetworkData(piece, &message[5]);
+ qToBigEndian(piece, &message[5]);
write(message, sizeof(message));
}
@@ -241,22 +177,22 @@ void PeerWireClient::sendPieceList(const QBitArray &bitField)
}
char message[] = {0, 0, 0, 1, 5};
- toNetworkData(bits.size() + 1, &message[0]);
+ qToBigEndian<qint32>(bits.size() + 1, &message[0]);
write(message, sizeof(message));
write(bits);
}
// Sends a request for a block.
-void PeerWireClient::requestBlock(int piece, int offset, int length)
+void PeerWireClient::requestBlock(qint32 piece, qint32 offset, qint32 length)
{
char message[] = {0, 0, 0, 1, 6};
- toNetworkData(13, &message[0]);
+ qToBigEndian(13, &message[0]);
write(message, sizeof(message));
char numbers[4 * 3];
- toNetworkData(piece, &numbers[0]);
- toNetworkData(offset, &numbers[4]);
- toNetworkData(length, &numbers[8]);
+ qToBigEndian(piece, &numbers[0]);
+ qToBigEndian(offset, &numbers[4]);
+ qToBigEndian(length, &numbers[8]);
write(numbers, sizeof(numbers));
incoming << TorrentBlock(piece, offset, length);
@@ -270,33 +206,33 @@ void PeerWireClient::requestBlock(int piece, int offset, int length)
}
// Cancels a request for a block.
-void PeerWireClient::cancelRequest(int piece, int offset, int length)
+void PeerWireClient::cancelRequest(qint32 piece, qint32 offset, qint32 length)
{
char message[] = {0, 0, 0, 1, 8};
- toNetworkData(13, &message[0]);
+ qToBigEndian(13, &message[0]);
write(message, sizeof(message));
char numbers[4 * 3];
- toNetworkData(piece, &numbers[0]);
- toNetworkData(offset, &numbers[4]);
- toNetworkData(length, &numbers[8]);
+ qToBigEndian(piece, &numbers[0]);
+ qToBigEndian(offset, &numbers[4]);
+ qToBigEndian(length, &numbers[8]);
write(numbers, sizeof(numbers));
incoming.removeAll(TorrentBlock(piece, offset, length));
}
// Sends a block to the peer.
-void PeerWireClient::sendBlock(int piece, int offset, const QByteArray &data)
+void PeerWireClient::sendBlock(qint32 piece, qint32 offset, const QByteArray &data)
{
QByteArray block;
char message[] = {0, 0, 0, 1, 7};
- toNetworkData(9 + data.size(), &message[0]);
+ qToBigEndian<qint32>(9 + data.size(), &message[0]);
block += QByteArray(message, sizeof(message));
char numbers[4 * 2];
- toNetworkData(piece, &numbers[0]);
- toNetworkData(offset, &numbers[4]);
+ qToBigEndian(piece, &numbers[0]);
+ qToBigEndian(offset, &numbers[4]);
block += QByteArray(numbers, sizeof(numbers));
block += data;
@@ -515,7 +451,7 @@ void PeerWireClient::processIncomingData()
char tmp[4];
read(tmp, sizeof(tmp));
- nextPacketLength = fromNetworkData(tmp);
+ nextPacketLength = qFromBigEndian<qint32>(tmp);
if (nextPacketLength < 0 || nextPacketLength > 200000) {
// Prevent DoS
@@ -567,7 +503,7 @@ void PeerWireClient::processIncomingData()
break;
case HavePacket: {
// The peer has a new piece available.
- quint32 index = fromNetworkData(&packet.data()[1]);
+ quint32 index = qFromBigEndian<quint32>(&packet.data()[1]);
if (index < quint32(peerPieces.size())) {
// Only accept indexes within the valid range.
peerPieces.setBit(int(index));
@@ -580,7 +516,7 @@ void PeerWireClient::processIncomingData()
for (int i = 1; i < packet.size(); ++i) {
for (int bit = 0; bit < 8; ++bit) {
if (packet.at(i) & (1 << (7 - bit))) {
- int bitIndex = int(((i - 1) * 8) + bit);
+ qint32 bitIndex = qint32(((i - 1) * 8) + bit);
if (bitIndex >= 0 && bitIndex < peerPieces.size()) {
// Occasionally, broken clients claim to have
// pieces whose index is outside the valid range.
@@ -595,15 +531,15 @@ void PeerWireClient::processIncomingData()
break;
case RequestPacket: {
// The peer requests a block.
- quint32 index = fromNetworkData(&packet.data()[1]);
- quint32 begin = fromNetworkData(&packet.data()[5]);
- quint32 length = fromNetworkData(&packet.data()[9]);
- emit blockRequested(int(index), int(begin), int(length));
+ quint32 index = qFromBigEndian<quint32>(&packet.data()[1]);
+ quint32 begin = qFromBigEndian<quint32>(&packet.data()[5]);
+ quint32 length = qFromBigEndian<quint32>(&packet.data()[9]);
+ emit blockRequested(qint32(index), qint32(begin), qint32(length));
break;
}
case PiecePacket: {
- int index = int(fromNetworkData(&packet.data()[1]));
- int begin = int(fromNetworkData(&packet.data()[5]));
+ qint32 index = qint32(qFromBigEndian<quint32>(&packet.data()[1]));
+ qint32 begin = qint32(qFromBigEndian<quint32>(&packet.data()[5]));
incoming.removeAll(TorrentBlock(index, begin, packet.size() - 9));
@@ -619,14 +555,14 @@ void PeerWireClient::processIncomingData()
}
case CancelPacket: {
// The peer cancels a block request.
- quint32 index = fromNetworkData(&packet.data()[1]);
- quint32 begin = fromNetworkData(&packet.data()[5]);
- quint32 length = fromNetworkData(&packet.data()[9]);
+ quint32 index = qFromBigEndian<quint32>(&packet.data()[1]);
+ quint32 begin = qFromBigEndian<quint32>(&packet.data()[5]);
+ quint32 length = qFromBigEndian<quint32>(&packet.data()[9]);
for (int i = 0; i < pendingBlocks.size(); ++i) {
const BlockInfo &blockInfo = pendingBlocks.at(i);
- if (blockInfo.pieceIndex == int(index)
- && blockInfo.offset == int(begin)
- && blockInfo.length == int(length)) {
+ if (blockInfo.pieceIndex == qint32(index)
+ && blockInfo.offset == qint32(begin)
+ && blockInfo.length == qint32(length)) {
pendingBlocks.removeAt(i);
break;
}
diff --git a/examples/network/torrent/peerwireclient.h b/examples/network/torrent/peerwireclient.h
index 2d64329854..a605ea1cbf 100644
--- a/examples/network/torrent/peerwireclient.h
+++ b/examples/network/torrent/peerwireclient.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef PEERWIRECLIENT_H
#define PEERWIRECLIENT_H
@@ -63,7 +16,7 @@ class TorrentPeer;
struct TorrentBlock
{
- inline TorrentBlock(int p, int o, int l)
+ inline TorrentBlock(qint32 p, qint32 o, qint32 l)
: pieceIndex(p), offset(o), length(l)
{
}
@@ -74,9 +27,9 @@ struct TorrentBlock
&& length == other.length;
}
- int pieceIndex;
- int offset;
- int length;
+ qint32 pieceIndex;
+ qint32 offset;
+ qint32 length;
};
class PeerWireClient : public QTcpSocket
diff --git a/examples/network/torrent/ratecontroller.cpp b/examples/network/torrent/ratecontroller.cpp
index 18d0737dbb..338bb596c9 100644
--- a/examples/network/torrent/ratecontroller.cpp
+++ b/examples/network/torrent/ratecontroller.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "peerwireclient.h"
#include "ratecontroller.h"
@@ -80,7 +33,7 @@ void RateController::removeSocket(PeerWireClient *socket)
void RateController::setDownloadLimit(int bytesPerSecond)
{
downLimit = bytesPerSecond;
- for (PeerWireClient *socket : qAsConst(sockets))
+ for (PeerWireClient *socket : std::as_const(sockets))
socket->setReadBufferSize(downLimit * 4);
}
@@ -89,7 +42,7 @@ void RateController::scheduleTransfer()
if (transferScheduled)
return;
transferScheduled = true;
- QTimer::singleShot(50, this, SLOT(transfer()));
+ QTimer::singleShot(50, this, &RateController::transfer);
}
void RateController::transfer()
@@ -110,7 +63,7 @@ void RateController::transfer()
}
QSet<PeerWireClient *> pendingSockets;
- for (PeerWireClient *client : qAsConst(sockets)) {
+ for (PeerWireClient *client : std::as_const(sockets)) {
if (client->canTransferMore())
pendingSockets << client;
}
diff --git a/examples/network/torrent/ratecontroller.h b/examples/network/torrent/ratecontroller.h
index 593a76f592..5e4ca0e5d6 100644
--- a/examples/network/torrent/ratecontroller.h
+++ b/examples/network/torrent/ratecontroller.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef RATECONTROLLER_H
#define RATECONTROLLER_H
diff --git a/examples/network/torrent/torrent.pro b/examples/network/torrent/torrent.pro
index c640c3b5d0..929c5cb784 100644
--- a/examples/network/torrent/torrent.pro
+++ b/examples/network/torrent/torrent.pro
@@ -27,7 +27,7 @@ SOURCES += main.cpp \
trackerclient.cpp
# Forms and resources
-FORMS += forms/addtorrentform.ui
+FORMS += addtorrentform.ui
RESOURCES += icons.qrc
# install
diff --git a/examples/network/torrent/torrentclient.cpp b/examples/network/torrent/torrentclient.cpp
index a63e927e09..d9e66b9a17 100644
--- a/examples/network/torrent/torrentclient.cpp
+++ b/examples/network/torrent/torrentclient.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "connectionmanager.h"
#include "filemanager.h"
@@ -61,6 +14,7 @@
#include <QNetworkInterface>
#include <algorithm>
+#include <chrono>
// These constants could also be configurable by the user.
static const int ServerMinPort = 6881;
@@ -70,10 +24,10 @@ static const int MaxBlocksInProgress = 5;
static const int MaxBlocksInMultiMode = 2;
static const int MaxConnectionPerPeer = 1;
static const int RateControlWindowLength = 10;
-static const int RateControlTimerDelay = 1000;
+static const std::chrono::seconds RateControlTimerDelay(1);
static const int MinimumTimeBeforeRevisit = 30;
static const int MaxUploads = 4;
-static const int UploadScheduleInterval = 10000;
+static const std::chrono::seconds UploadScheduleInterval(10);
struct TorrentPiece {
QBitArray completedBlocks;
@@ -116,9 +70,9 @@ public:
int uploadScheduleTimer;
// Pieces
- QMap<int, PeerWireClient *> readIds;
+ QMap<qint32, PeerWireClient *> readIds;
QMultiMap<PeerWireClient *, TorrentPiece *> payloads;
- QMap<int, TorrentPiece *> pendingPieces;
+ QMap<qint32, TorrentPiece *> pendingPieces;
QBitArray completedPieces;
QBitArray incompletePieces;
int pieceCount;
@@ -254,6 +208,10 @@ TorrentClient::TorrentClient(QObject *parent)
TorrentClient::~TorrentClient()
{
+ auto rateController = RateController::instance();
+ const auto childSockets = findChildren<PeerWireClient *>(Qt::FindDirectChildrenOnly);
+ for (PeerWireClient *socket : childSockets)
+ rateController->removeSocket(socket);
qDeleteAll(d->peers);
qDeleteAll(d->pendingPieces);
delete d;
@@ -311,8 +269,8 @@ void TorrentClient::setDumpedState(const QByteArray &dumpedState)
stream >> d->completedPieces;
while (!stream.atEnd()) {
- int index;
- int length;
+ qint32 index;
+ qint32 length;
QBitArray completed;
stream >> index >> length >> completed;
if (stream.status() != QDataStream::Ok) {
@@ -340,7 +298,7 @@ QByteArray TorrentClient::dumpedState() const
// Save the state of all partially downloaded pieces into a format
// suitable for storing in settings.
- QMap<int, TorrentPiece *>::ConstIterator it = d->pendingPieces.constBegin();
+ auto it = d->pendingPieces.constBegin();
while (it != d->pendingPieces.constEnd()) {
TorrentPiece *piece = it.value();
if (blocksLeftForPiece(piece) > 0 && blocksLeftForPiece(piece) < piece->completedBlocks.size()) {
@@ -463,7 +421,7 @@ void TorrentClient::stop()
}
// Abort all existing connections
- for (PeerWireClient *client : qAsConst(d->connections)) {
+ for (PeerWireClient *client : std::as_const(d->connections)) {
RateController::instance()->removeSocket(client);
ConnectionManager::instance()->removeConnection(client);
client->abort();
@@ -486,7 +444,7 @@ void TorrentClient::setPaused(bool paused)
// connections to 0. Keep the list of peers, so we can quickly
// resume later.
d->setState(Paused);
- for (PeerWireClient *client : qAsConst(d->connections))
+ for (PeerWireClient *client : std::as_const(d->connections))
client->abort();
d->connections.clear();
TorrentServer::instance()->removeClient(this);
@@ -539,7 +497,8 @@ void TorrentClient::timerEvent(QTimerEvent *event)
}
}
-void TorrentClient::sendToPeer(int readId, int pieceIndex, int begin, const QByteArray &data)
+void TorrentClient::sendToPeer(qint32 readId, qint32 pieceIndex, qint32 begin,
+ const QByteArray &data)
{
// Send the requested block to the peer if the client connection
// still exists; otherwise do nothing. This slot is called by the
@@ -558,7 +517,7 @@ void TorrentClient::fullVerificationDone()
d->completedPieces = d->fileManager.completedPieces();
d->incompletePieces.resize(d->completedPieces.size());
d->pieceCount = d->completedPieces.size();
- for (int i = 0; i < d->fileManager.pieceCount(); ++i) {
+ for (qint32 i = 0; i < d->fileManager.pieceCount(); ++i) {
if (!d->completedPieces.testBit(i))
d->incompletePieces.setBit(i);
}
@@ -567,7 +526,7 @@ void TorrentClient::fullVerificationDone()
// If the checksums show that what the dumped state thought was
// partial was in fact complete, then we trust the checksums.
- QMap<int, TorrentPiece *>::Iterator it = d->pendingPieces.begin();
+ auto it = d->pendingPieces.begin();
while (it != d->pendingPieces.end()) {
if (d->completedPieces.testBit(it.key()))
it = d->pendingPieces.erase(it);
@@ -597,7 +556,7 @@ void TorrentClient::fullVerificationDone()
d->trackerClient.start(d->metaInfo);
}
-void TorrentClient::pieceVerified(int pieceIndex, bool ok)
+void TorrentClient::pieceVerified(qint32 pieceIndex, bool ok)
{
TorrentPiece *piece = d->pendingPieces.value(pieceIndex);
@@ -621,11 +580,11 @@ void TorrentClient::pieceVerified(int pieceIndex, bool ok)
}
// Update the peer list so we know who's still interesting.
- for (TorrentPeer *peer : qAsConst(d->peers)) {
+ for (TorrentPeer *peer : std::as_const(d->peers)) {
if (!peer->interesting)
continue;
bool interesting = false;
- for (int i = 0; i < d->pieceCount; ++i) {
+ for (qint32 i = 0; i < d->pieceCount; ++i) {
if (peer->pieces.testBit(i) && d->incompletePieces.testBit(i)) {
interesting = true;
break;
@@ -641,7 +600,7 @@ void TorrentClient::pieceVerified(int pieceIndex, bool ok)
d->incompletePieces.clearBit(pieceIndex);
// Notify connected peers.
- for (PeerWireClient *client : qAsConst(d->connections)) {
+ for (PeerWireClient *client : std::as_const(d->connections)) {
if (client->state() == QAbstractSocket::ConnectedState
&& !client->availablePieces().testBit(pieceIndex)) {
client->sendPieceNotification(pieceIndex);
@@ -700,7 +659,7 @@ void TorrentClient::connectToPeers()
d->connections << client;
// Pick a random peer from the list of weighed peers.
- TorrentPeer *peer = weighedPeers.takeAt(QRandomGenerator::global()->bounded(int(weighedPeers.size())));
+ TorrentPeer *peer = weighedPeers.takeAt(QRandomGenerator::global()->bounded(weighedPeers.size()));
weighedPeers.removeAll(peer);
peer->connectStart = QDateTime::currentSecsSinceEpoch();
peer->lastVisited = peer->connectStart;
@@ -719,9 +678,9 @@ QList<TorrentPeer *> TorrentClient::weighedFreePeers() const
qint64 now = QDateTime::currentSecsSinceEpoch();
QList<TorrentPeer *> freePeers;
QMap<QString, int> connectionsPerPeer;
- for (TorrentPeer *peer : qAsConst(d->peers)) {
+ for (TorrentPeer *peer : std::as_const(d->peers)) {
bool busy = false;
- for (PeerWireClient *client : qAsConst(d->connections)) {
+ for (PeerWireClient *client : std::as_const(d->connections)) {
if (client->state() == PeerWireClient::ConnectedState
&& client->peerAddress() == peer->address
&& client->peerPort() == peer->port) {
@@ -741,7 +700,7 @@ QList<TorrentPeer *> TorrentClient::weighedFreePeers() const
// Assign points based on connection speed and pieces available.
QList<QPair<int, TorrentPeer *> > points;
- for (TorrentPeer *peer : qAsConst(freePeers)) {
+ for (TorrentPeer *peer : std::as_const(freePeers)) {
int tmp = 0;
if (peer->interesting) {
tmp += peer->numCompletedPieces;
@@ -764,7 +723,7 @@ QList<TorrentPeer *> TorrentClient::weighedFreePeers() const
QMultiMap<int, TorrentPeer *> pointMap;
int lowestScore = 0;
int lastIndex = 0;
- for (const PointPair &point : qAsConst(points)) {
+ for (const PointPair &point : std::as_const(points)) {
if (point.first > lowestScore) {
lowestScore = point.first;
++lastIndex;
@@ -815,7 +774,7 @@ void TorrentClient::setupOutgoingConnection()
PeerWireClient *client = qobject_cast<PeerWireClient *>(sender());
// Update connection statistics.
- for (TorrentPeer *peer : qAsConst(d->peers)) {
+ for (TorrentPeer *peer : std::as_const(d->peers)) {
if (peer->port == client->peerPort() && peer->address == client->peerAddress()) {
peer->connectTime = peer->lastVisited - peer->connectStart;
break;
@@ -943,8 +902,8 @@ void TorrentClient::peerPiecesAvailable(const QBitArray &pieces)
// Check for interesting pieces, and tell the peer whether we are
// interested or not.
bool interested = false;
- int piecesSize = pieces.size();
- for (int pieceIndex = 0; pieceIndex < piecesSize; ++pieceIndex) {
+ qint32 piecesSize = pieces.size();
+ for (qint32 pieceIndex = 0; pieceIndex < piecesSize; ++pieceIndex) {
if (!pieces.testBit(pieceIndex))
continue;
if (!d->completedPieces.testBit(pieceIndex)) {
@@ -956,7 +915,7 @@ void TorrentClient::peerPiecesAvailable(const QBitArray &pieces)
}
QMultiMap<PeerWireClient *, TorrentPiece *>::Iterator it = d->payloads.find(client);
- int inProgress = 0;
+ qint32 inProgress = 0;
while (it != d->payloads.end() && it.key() == client) {
if (it.value()->inProgress)
inProgress += it.value()->requestedBlocks.count(true);
@@ -974,7 +933,7 @@ void TorrentClient::peerPiecesAvailable(const QBitArray &pieces)
}
}
-void TorrentClient::peerRequestsBlock(int pieceIndex, int begin, int length)
+void TorrentClient::peerRequestsBlock(qint32 pieceIndex, qint32 begin, qint32 length)
{
PeerWireClient *client = qobject_cast<PeerWireClient *>(sender());
@@ -991,7 +950,7 @@ void TorrentClient::peerRequestsBlock(int pieceIndex, int begin, int length)
qobject_cast<PeerWireClient *>(sender()));
}
-void TorrentClient::blockReceived(int pieceIndex, int begin, const QByteArray &data)
+void TorrentClient::blockReceived(qint32 pieceIndex, qint32 begin, const QByteArray &data)
{
PeerWireClient *client = qobject_cast<PeerWireClient *>(sender());
if (data.size() == 0) {
@@ -1000,7 +959,7 @@ void TorrentClient::blockReceived(int pieceIndex, int begin, const QByteArray &d
}
// Ignore it if we already have this block.
- int blockBit = begin / BlockSize;
+ qint32 blockBit = begin / BlockSize;
TorrentPiece *piece = d->pendingPieces.value(pieceIndex);
if (!piece || piece->completedBlocks.testBit(blockBit)) {
// Discard blocks that we already have, and fill up the pipeline.
@@ -1068,15 +1027,9 @@ void TorrentClient::peerWireBytesReceived(qint64 size)
emit dataSent(size);
}
-int TorrentClient::blocksLeftForPiece(const TorrentPiece *piece) const
+qint32 TorrentClient::blocksLeftForPiece(const TorrentPiece *piece) const
{
- int blocksLeft = 0;
- int completedBlocksSize = piece->completedBlocks.size();
- for (int i = 0; i < completedBlocksSize; ++i) {
- if (!piece->completedBlocks.testBit(i))
- ++blocksLeft;
- }
- return blocksLeft;
+ return piece->completedBlocks.count(false);
}
void TorrentClient::scheduleUploads()
@@ -1087,7 +1040,7 @@ void TorrentClient::scheduleUploads()
// no use in unchoking them.
QList<PeerWireClient *> allClients = d->connections;
QList<QPair<qint64, PeerWireClient *>> transferSpeeds;
- for (PeerWireClient *client : qAsConst(allClients)) {
+ for (PeerWireClient *client : std::as_const(allClients)) {
if (client->state() == QAbstractSocket::ConnectedState
&& client->availablePieces().count(true) != d->pieceCount) {
if (d->state == Seeding) {
@@ -1130,7 +1083,7 @@ void TorrentClient::scheduleUploads()
// random peer to allow it to compete for a position among the
// downloaders. (This is known as an "optimistic unchoke".)
if (!allClients.isEmpty()) {
- PeerWireClient *client = allClients[QRandomGenerator::global()->bounded(int(allClients.size()))];
+ PeerWireClient *client = allClients[QRandomGenerator::global()->bounded(allClients.size())];
if (client->peerWireState() & PeerWireClient::ChokingPeer)
client->unchokePeer();
}
@@ -1145,7 +1098,7 @@ void TorrentClient::scheduleDownloads()
// Check what each client is doing, and assign payloads to those
// who are either idle or done.
- for (PeerWireClient *client : qAsConst(d->connections))
+ for (PeerWireClient *client : std::as_const(d->connections))
schedulePieceForClient(client);
}
@@ -1161,7 +1114,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
// Make a list of all the client's pending pieces, and count how
// many blocks have been requested.
- QList<int> currentPieces;
+ QList<qint32> currentPieces;
bool somePiecesAreNotInProgress = false;
TorrentPiece *lastPendingPiece = nullptr;
QMultiMap<PeerWireClient *, TorrentPiece *>::Iterator it = d->payloads.find(client);
@@ -1191,7 +1144,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
piece = d->payloads.value(client);
if (!piece) {
QList<TorrentPiece *> values = d->pendingPieces.values();
- piece = values.value(QRandomGenerator::global()->bounded(int(values.size())));
+ piece = values.value(QRandomGenerator::global()->bounded(values.size()));
piece->inProgress = true;
d->payloads.insert(client, piece);
}
@@ -1212,7 +1165,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
// the same piece. In endgame mode, this only applies to
// clients that are currently uploading (more than 1.0KB/s).
if ((d->state == Endgame && client->uploadSpeed() < 1024) || d->state != WarmingUp) {
- QMap<int, TorrentPiece *>::ConstIterator it = d->pendingPieces.constBegin();
+ auto it = d->pendingPieces.constBegin();
while (it != d->pendingPieces.constEnd()) {
if (it.value()->inProgress)
incompletePiecesAvailableToClient.clearBit(it.key());
@@ -1224,7 +1177,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
incompletePiecesAvailableToClient &= client->availablePieces();
// Remove all pieces that this client has already requested.
- for (int i : qAsConst(currentPieces))
+ for (qint32 i : std::as_const(currentPieces))
incompletePiecesAvailableToClient.clearBit(i);
// Only continue if more pieces can be scheduled. If no pieces
@@ -1236,7 +1189,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
// Check if any of the partially completed pieces can be
// recovered, and if so, pick a random one of them.
QList<TorrentPiece *> partialPieces;
- QMap<int, TorrentPiece *>::ConstIterator it = d->pendingPieces.constBegin();
+ auto it = d->pendingPieces.constBegin();
while (it != d->pendingPieces.constEnd()) {
TorrentPiece *tmp = it.value();
if (incompletePiecesAvailableToClient.testBit(it.key())) {
@@ -1248,7 +1201,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
++it;
}
if (!partialPieces.isEmpty())
- piece = partialPieces.value(QRandomGenerator::global()->bounded(int(partialPieces.size())));
+ piece = partialPieces.value(QRandomGenerator::global()->bounded(partialPieces.size()));
if (!piece) {
// Pick a random piece 3 out of 4 times; otherwise, pick either
@@ -1260,7 +1213,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
memset(occurrences, 0, d->pieceCount * sizeof(int));
// Count how many of each piece are available.
- for (PeerWireClient *peer : qAsConst(d->connections)) {
+ for (PeerWireClient *peer : std::as_const(d->connections)) {
QBitArray peerPieces = peer->availablePieces();
int peerPiecesSize = peerPieces.size();
for (int i = 0; i < peerPiecesSize; ++i) {
@@ -1295,7 +1248,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
}
// Select one piece randomly
- pieceIndex = piecesReadyForDownload.at(QRandomGenerator::global()->bounded(int(piecesReadyForDownload.size())));
+ pieceIndex = piecesReadyForDownload.at(QRandomGenerator::global()->bounded(piecesReadyForDownload.size()));
delete [] occurrences;
} else {
// Make up a list of available piece indices, and pick
@@ -1306,7 +1259,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
if (incompletePiecesAvailableToClient.testBit(i))
values << i;
}
- pieceIndex = values.at(QRandomGenerator::global()->bounded(int(values.size())));
+ pieceIndex = values.at(QRandomGenerator::global()->bounded(values.size()));
}
// Create a new TorrentPiece and fill in all initial
@@ -1358,7 +1311,7 @@ void TorrentClient::requestMore(PeerWireClient *client)
// Starting with the first piece that we're waiting for, request
// blocks until the quota is filled up.
- for (TorrentPiece *piece : qAsConst(piecesInProgress)) {
+ for (TorrentPiece *piece : std::as_const(piecesInProgress)) {
numBlocksInProgress += requestBlocks(client, piece, maxInProgress - numBlocksInProgress);
if (numBlocksInProgress == maxInProgress)
break;
@@ -1398,8 +1351,8 @@ int TorrentClient::requestBlocks(PeerWireClient *client, TorrentPiece *piece, in
// speedup comes from an increased chance of receiving
// different blocks from the different peers.
for (int i = 0; i < bits.size(); ++i) {
- int a = QRandomGenerator::global()->bounded(int(bits.size()));
- int b = QRandomGenerator::global()->bounded(int(bits.size()));
+ int a = QRandomGenerator::global()->bounded(bits.size());
+ int b = QRandomGenerator::global()->bounded(bits.size());
int tmp = bits[a];
bits[a] = bits[b];
bits[b] = tmp;
@@ -1461,7 +1414,7 @@ void TorrentClient::addToPeerList(const QList<TorrentPeer> &peerList)
}
bool known = false;
- for (const TorrentPeer *knownPeer : qAsConst(d->peers)) {
+ for (const TorrentPeer *knownPeer : std::as_const(d->peers)) {
if (knownPeer->port == peer.port
&& knownPeer->address == peer.address) {
known = true;
@@ -1492,7 +1445,7 @@ void TorrentClient::addToPeerList(const QList<TorrentPeer> &peerList)
const auto firstNInactivePeers = [&tooMany, this] (TorrentPeer *peer) {
if (!tooMany)
return false;
- for (const PeerWireClient *client : qAsConst(d->connections)) {
+ for (const PeerWireClient *client : std::as_const(d->connections)) {
if (client->peer() == peer && (client->downloadSpeed() + client->uploadSpeed()) > 1024)
return false;
}
diff --git a/examples/network/torrent/torrentclient.h b/examples/network/torrent/torrentclient.h
index ad77caa66c..c06f0c41d2 100644
--- a/examples/network/torrent/torrentclient.h
+++ b/examples/network/torrent/torrentclient.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TORRENTCLIENT_H
#define TORRENTCLIENT_H
@@ -116,9 +69,6 @@ public:
bool setTorrent(const QByteArray &torrentData);
MetaInfo metaInfo() const;
- void setMaxConnections(int connections);
- int maxConnections() const;
-
void setDestinationFolder(const QString &directory);
QString destinationFolder() const;
diff --git a/examples/network/torrent/torrentserver.cpp b/examples/network/torrent/torrentserver.cpp
index 7af958c27c..9751c25497 100644
--- a/examples/network/torrent/torrentserver.cpp
+++ b/examples/network/torrent/torrentserver.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "connectionmanager.h"
#include "peerwireclient.h"
@@ -102,7 +55,7 @@ void TorrentServer::removeClient()
void TorrentServer::processInfoHash(const QByteArray &infoHash)
{
PeerWireClient *peer = qobject_cast<PeerWireClient *>(sender());
- for (TorrentClient *client : qAsConst(clients)) {
+ for (TorrentClient *client : std::as_const(clients)) {
if (client->state() >= TorrentClient::Searching && client->infoHash() == infoHash) {
peer->disconnect(peer, nullptr, this, nullptr);
client->setupIncomingConnection(peer);
diff --git a/examples/network/torrent/torrentserver.h b/examples/network/torrent/torrentserver.h
index b0d2b3c012..9e975893cd 100644
--- a/examples/network/torrent/torrentserver.h
+++ b/examples/network/torrent/torrentserver.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TORRENTSERVER_H
#define TORRENTSERVER_H
diff --git a/examples/network/torrent/trackerclient.cpp b/examples/network/torrent/trackerclient.cpp
index 264a6cc04c..12110ba0ae 100644
--- a/examples/network/torrent/trackerclient.cpp
+++ b/examples/network/torrent/trackerclient.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "bencodeparser.h"
#include "connectionmanager.h"
@@ -67,7 +20,7 @@ TrackerClient::TrackerClient(TorrentClient *downloader, QObject *parent)
void TrackerClient::start(const MetaInfo &info)
{
metaInfo = info;
- QTimer::singleShot(0, this, SLOT(fetchPeerList()));
+ QTimer::singleShot(0, this, &TrackerClient::fetchPeerList);
if (metaInfo.fileForm() == MetaInfo::SingleFileForm) {
length = metaInfo.singleFile().length;
@@ -101,18 +54,16 @@ void TrackerClient::timerEvent(QTimerEvent *event)
void TrackerClient::fetchPeerList()
{
+ if (metaInfo.announceUrl().isEmpty())
+ return;
QUrl url(metaInfo.announceUrl());
// Base the query on announce url to include a passkey (if any)
QUrlQuery query(url);
// Percent encode the hash
- QByteArray infoHash = torrentDownloader->infoHash();
- QByteArray encodedSum;
- for (int i = 0; i < infoHash.size(); ++i) {
- encodedSum += '%';
- encodedSum += QByteArray::number(infoHash[i], 16).right(2).rightJustified(2, '0');
- }
+ const QByteArray infoHash = torrentDownloader->infoHash();
+ const QByteArray encodedSum = infoHash.toPercentEncoding();
bool seeding = (torrentDownloader->state() == TorrentClient::Seeding);
@@ -202,7 +153,7 @@ void TrackerClient::httpRequestDone(QNetworkReply *reply)
// Mandatory item
if (requestIntervalTimer != -1)
killTimer(requestIntervalTimer);
- requestIntervalTimer = startTimer(dict.value("interval").toInt() * 1000);
+ requestIntervalTimer = startTimer(std::chrono::seconds(dict.value("interval").toInt()));
}
if (dict.contains("peers")) {
diff --git a/examples/network/torrent/trackerclient.h b/examples/network/torrent/trackerclient.h
index b8c169ff22..334ce42332 100644
--- a/examples/network/torrent/trackerclient.h
+++ b/examples/network/torrent/trackerclient.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TRACKERCLIENT_H
#define TRACKERCLIENT_H
@@ -98,7 +51,6 @@ private slots:
private:
TorrentClient *torrentDownloader;
- int requestInterval = 5 * 60;
int requestIntervalTimer = -1;
QNetworkAccessManager http;
MetaInfo metaInfo;
diff --git a/examples/opengl/2dpainting/CMakeLists.txt b/examples/opengl/2dpainting/CMakeLists.txt
index 5978f6a283..b4ae3aa313 100644
--- a/examples/opengl/2dpainting/CMakeLists.txt
+++ b/examples/opengl/2dpainting/CMakeLists.txt
@@ -1,25 +1,12 @@
-# Generated from 2dpainting.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(2dpainting LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL OpenGLWidgets Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/2dpainting")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS OpenGL)
-find_package(Qt6 COMPONENTS OpenGLWidgets)
+qt_standard_project_setup()
qt_add_executable(2dpainting
glwidget.cpp glwidget.h
@@ -28,20 +15,29 @@ qt_add_executable(2dpainting
widget.cpp widget.h
window.cpp window.h
)
+
set_target_properties(2dpainting PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(2dpainting PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
- Qt::OpenGLWidgets
- Qt::Widgets
+
+target_link_libraries(2dpainting PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::OpenGL
+ Qt6::OpenGLWidgets
+ Qt6::Widgets
)
install(TARGETS 2dpainting
- 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 2dpainting
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/opengl/2dpainting/glwidget.cpp b/examples/opengl/2dpainting/glwidget.cpp
index 0f645896cc..9351c657df 100644
--- a/examples/opengl/2dpainting/glwidget.cpp
+++ b/examples/opengl/2dpainting/glwidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "glwidget.h"
#include "helper.h"
diff --git a/examples/opengl/2dpainting/glwidget.h b/examples/opengl/2dpainting/glwidget.h
index 16ad1a95f3..d441954818 100644
--- a/examples/opengl/2dpainting/glwidget.h
+++ b/examples/opengl/2dpainting/glwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef GLWIDGET_H
#define GLWIDGET_H
diff --git a/examples/opengl/2dpainting/helper.cpp b/examples/opengl/2dpainting/helper.cpp
index c0582e1dec..953e3d9b17 100644
--- a/examples/opengl/2dpainting/helper.cpp
+++ b/examples/opengl/2dpainting/helper.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "helper.h"
diff --git a/examples/opengl/2dpainting/helper.h b/examples/opengl/2dpainting/helper.h
index 37058d0a75..288b3d80e1 100644
--- a/examples/opengl/2dpainting/helper.h
+++ b/examples/opengl/2dpainting/helper.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef HELPER_H
#define HELPER_H
diff --git a/examples/opengl/2dpainting/main.cpp b/examples/opengl/2dpainting/main.cpp
index bcc13a14aa..668673caa6 100644
--- a/examples/opengl/2dpainting/main.cpp
+++ b/examples/opengl/2dpainting/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
diff --git a/examples/opengl/2dpainting/widget.cpp b/examples/opengl/2dpainting/widget.cpp
index a1000930f9..3da9f20d7d 100644
--- a/examples/opengl/2dpainting/widget.cpp
+++ b/examples/opengl/2dpainting/widget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "widget.h"
#include "helper.h"
diff --git a/examples/opengl/2dpainting/widget.h b/examples/opengl/2dpainting/widget.h
index 40d20bc0a1..6ab97a4a9d 100644
--- a/examples/opengl/2dpainting/widget.h
+++ b/examples/opengl/2dpainting/widget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WIDGET_H
#define WIDGET_H
diff --git a/examples/opengl/2dpainting/window.cpp b/examples/opengl/2dpainting/window.cpp
index d6d6f8b468..98a06eaff2 100644
--- a/examples/opengl/2dpainting/window.cpp
+++ b/examples/opengl/2dpainting/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "glwidget.h"
#include "widget.h"
diff --git a/examples/opengl/2dpainting/window.h b/examples/opengl/2dpainting/window.h
index be23216d6b..d3d62ce0cf 100644
--- a/examples/opengl/2dpainting/window.h
+++ b/examples/opengl/2dpainting/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
diff --git a/examples/opengl/CMakeLists.txt b/examples/opengl/CMakeLists.txt
index 3d5b055b1a..09e31defe5 100644
--- a/examples/opengl/CMakeLists.txt
+++ b/examples/opengl/CMakeLists.txt
@@ -1,17 +1,12 @@
-# Generated from opengl.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(hellowindow)
-add_subdirectory(paintedwindow)
-add_subdirectory(openglwindow)
-add_subdirectory(qopenglwindow)
-if(TARGET Qt::Widgets)
- add_subdirectory(contextinfo)
- add_subdirectory(threadedqopenglwidget)
- add_subdirectory(2dpainting)
- add_subdirectory(hellogl2)
- add_subdirectory(qopenglwidget)
- add_subdirectory(cube)
- add_subdirectory(textures)
- add_subdirectory(hellogles3)
- add_subdirectory(computegles31)
+qt_internal_add_example(openglwindow)
+qt_internal_add_example(hellogles3)
+if(TARGET Qt6::Widgets)
+ qt_internal_add_example(2dpainting)
+ qt_internal_add_example(hellogl2)
+ qt_internal_add_example(cube)
+ qt_internal_add_example(textures)
+ qt_internal_add_example(stereoqopenglwidget)
endif()
diff --git a/examples/opengl/computegles31/CMakeLists.txt b/examples/opengl/computegles31/CMakeLists.txt
deleted file mode 100644
index d86579d961..0000000000
--- a/examples/opengl/computegles31/CMakeLists.txt
+++ /dev/null
@@ -1,53 +0,0 @@
-# Generated from computegles31.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(computegles31 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/computegles31")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS OpenGL)
-
-qt_add_executable(computegles31
- glwindow.cpp glwindow.h
- main.cpp
-)
-set_target_properties(computegles31 PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(computegles31 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
-)
-
-
-# Resources:
-set(computegles31_resource_files
- "Qt-logo-medium.png"
-)
-
-qt6_add_resources(computegles31 "computegles31"
- PREFIX
- "/"
- FILES
- ${computegles31_resource_files}
-)
-
-install(TARGETS computegles31
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/opengl/computegles31/Qt-logo-medium.png b/examples/opengl/computegles31/Qt-logo-medium.png
deleted file mode 100644
index a1ca1f1830..0000000000
--- a/examples/opengl/computegles31/Qt-logo-medium.png
+++ /dev/null
Binary files differ
diff --git a/examples/opengl/computegles31/computegles31.pro b/examples/opengl/computegles31/computegles31.pro
deleted file mode 100644
index 8d9b00ba83..0000000000
--- a/examples/opengl/computegles31/computegles31.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += opengl
-
-HEADERS = $$PWD/glwindow.h
-
-SOURCES = $$PWD/glwindow.cpp \
- $$PWD/main.cpp
-
-RESOURCES += computegles31.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/opengl/computegles31
-INSTALLS += target
diff --git a/examples/opengl/computegles31/computegles31.qrc b/examples/opengl/computegles31/computegles31.qrc
deleted file mode 100644
index b99eb0a82e..0000000000
--- a/examples/opengl/computegles31/computegles31.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>Qt-logo-medium.png</file>
- </qresource>
-</RCC>
diff --git a/examples/opengl/computegles31/glwindow.cpp b/examples/opengl/computegles31/glwindow.cpp
deleted file mode 100644
index 5e8d45da24..0000000000
--- a/examples/opengl/computegles31/glwindow.cpp
+++ /dev/null
@@ -1,419 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "glwindow.h"
-#include <QImage>
-#include <QOpenGLShaderProgram>
-#include <QOpenGLContext>
-#include <QOpenGLFunctions>
-#include <QOpenGLExtraFunctions>
-#include <QOpenGLVertexArrayObject>
-#include <QtGui/qopengl.h>
-#include <QDebug>
-#include <QTimer>
-#include <math.h>
-
-#ifndef GL_READ_WRITE
-#define GL_READ_WRITE 0x88BA
-#endif
-
-#ifndef GL_RGBA8
-#define GL_RGBA8 0x8058
-#endif
-
-#ifndef GL_SHADER_IMAGE_ACCESS_BARRIER_BIT
-#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
-#endif
-
-GLWindow::GLWindow()
-{
- const float animationStart = 0.0;
- const float animationEnd = 10.0;
- const float animationLength = 1000;
-
- m_animationGroup = new QSequentialAnimationGroup(this);
- m_animationGroup->setLoopCount(-1);
-
- m_animationForward = new QPropertyAnimation(this, QByteArrayLiteral("blurRadius"));
- m_animationForward->setStartValue(animationStart);
- m_animationForward->setEndValue(animationEnd);
- m_animationForward->setDuration(animationLength);
- m_animationGroup->addAnimation(m_animationForward);
-
- m_animationBackward = new QPropertyAnimation(this, QByteArrayLiteral("blurRadius"));
- m_animationBackward->setStartValue(animationEnd);
- m_animationBackward->setEndValue(animationStart);
- m_animationBackward->setDuration(animationLength);
- m_animationGroup->addAnimation(m_animationBackward);
-
- m_animationGroup->start();
-}
-
-GLWindow::~GLWindow()
-{
- makeCurrent();
- delete m_texImageInput;
- delete m_texImageProcessed;
- delete m_texImageTmp;
- delete m_shaderDisplay;
- delete m_shaderComputeH;
- delete m_shaderComputeV;
- delete m_animationGroup;
- delete m_animationForward;
- delete m_animationBackward;
- delete m_vao;
-}
-
-void GLWindow::setBlurRadius(float blurRadius)
-{
- int radius = int(blurRadius);
- if (radius != m_blurRadius) {
- m_blurRadius = radius;
- update();
- }
-}
-
-void GLWindow::setAnimating(bool animate)
-{
- m_animate = animate;
- if (animate)
- m_animationGroup->start();
- else
- m_animationGroup->stop();
-}
-
-void GLWindow::keyPressEvent(QKeyEvent *e)
-{
- if (e->key() == Qt::Key_Space) { // pause
- setAnimating(!m_animate);
- }
- update();
-}
-
-
-
-
-static const char *vsDisplaySource =
- "const vec4 vertices[4] = vec4[4] (\n"
- " vec4( -1.0, 1.0, 0.0, 1.0),\n"
- " vec4( -1.0, -1.0, 0.0, 1.0),\n"
- " vec4( 1.0, 1.0, 0.0, 1.0),\n"
- " vec4( 1.0, -1.0, 0.0, 1.0)\n"
- ");\n"
- "const vec2 texCoords[4] = vec2[4] (\n"
- " vec2( 0.0, 1.0),\n"
- " vec2( 0.0, 0.0),\n"
- " vec2( 1.0, 1.0),\n"
- " vec2( 1.0, 0.0)\n"
- ");\n"
- "out vec2 texCoord;\n"
- "uniform mat4 matProjection;\n"
- "uniform vec2 imageRatio;\n"
- "void main() {\n"
- " gl_Position = matProjection * ( vertices[gl_VertexID] * vec4(imageRatio,0,1) );\n"
- " texCoord = texCoords[gl_VertexID];\n"
- "}\n";
-
-static const char *fsDisplaySource =
- "in lowp vec2 texCoord; \n"
- "uniform sampler2D samImage; \n"
- "layout(location = 0) out lowp vec4 color;\n"
- "void main() {\n"
- " lowp vec4 texColor = texture(samImage,texCoord);\n"
- " color = vec4(texColor.rgb, 1.0);\n"
- "}\n";
-
-static const char *csComputeSourceV =
- "#define COMPUTEPATCHSIZE 10 // Setting this to 10 to comply with MAX_COMPUTE_WORK_GROUP_INVOCATIONS for both OpenGL and OpenGLES - see QTBUG-79374 \n"
- "#define IMGFMT rgba8 \n"
- "layout (local_size_x = COMPUTEPATCHSIZE, local_size_y = COMPUTEPATCHSIZE) in;\n"
- "layout(binding=0, IMGFMT) uniform readonly highp image2D inputImage; // Use a sampler to improve performance \n"
- "layout(binding=1, IMGFMT) uniform writeonly highp image2D resultImage;\n"
- "uniform int radius;\n"
- "const float cutoff = 2.2;\n"
-
- "float expFactor() { // a function, otherwise MESA produces error: initializer of global variable `expFactor' must be a constant expression\n"
- " float sigma = clamp(float(radius) / cutoff,0.02,100.0);\n"
- " return 1.0 / (2.0 * sigma * sigma);\n"
- "}\n"
-
- "float gaussian(float distance, float expfactor) {\n"
- " return exp( -(distance * distance) * expfactor);\n"
- "}\n"
-
- "void main() {\n"
- " ivec2 imgSize = imageSize(resultImage);\n"
- " int x = int(gl_GlobalInvocationID.x);\n"
- " int y = int(gl_GlobalInvocationID.y);\n"
- " if ( (x >= imgSize.x) || (y >= imgSize.y) ) return;\n"
- " vec4 sumPixels = vec4(0.0);\n"
- " float sumWeights = 0.0;\n"
- " int left = clamp(x - radius, 0, imgSize.x - 1);\n"
- " int right = clamp(x + radius, 0, imgSize.x - 1);\n"
- " int top = clamp(y - radius, 0, imgSize.y - 1);\n"
- " int bottom = clamp(y + radius, 0, imgSize.y - 1);\n"
- " float expfactor = expFactor();\n"
- " for (int iY = top; iY <= bottom; iY++) {\n"
- " float dy = float(abs(iY - y));\n"
- " vec4 imgValue = imageLoad(inputImage, ivec2(x,iY));\n"
- " float weight = gaussian(dy, expfactor);\n"
- " sumWeights += weight;\n"
- " sumPixels += (imgValue * weight);\n"
- " }\n"
- " sumPixels /= sumWeights;\n"
- " imageStore(resultImage, ivec2(x,y), sumPixels);\n"
- "}\n";
-
-static const char *csComputeSourceH =
- "#define COMPUTEPATCHSIZE 10 \n"
- "#define IMGFMT rgba8 \n"
- "layout (local_size_x = COMPUTEPATCHSIZE, local_size_y = COMPUTEPATCHSIZE) in;\n"
- "layout(binding=0, IMGFMT) uniform readonly highp image2D inputImage; // Use a sampler to improve performance \n"
- "layout(binding=1, IMGFMT) uniform writeonly highp image2D resultImage;\n"
- "uniform int radius;\n"
- "const float cutoff = 2.2;\n"
-
- "float expFactor() { // a function, otherwise MESA produces error: initializer of global variable `expFactor' must be a constant expression\n"
- " float sigma = clamp(float(radius) / cutoff,0.02,100.0);\n"
- " return 1.0 / (2.0 * sigma * sigma);\n"
- "}\n"
-
- "float gaussian(float distance, float expfactor) {\n"
- " return exp( -(distance * distance) * expfactor);\n"
- "}\n"
-
- "void main() {\n"
- " ivec2 imgSize = imageSize(resultImage);\n"
- " int x = int(gl_GlobalInvocationID.x);\n"
- " int y = int(gl_GlobalInvocationID.y);\n"
- " if ( (x >= imgSize.x) || (y >= imgSize.y) ) return;\n"
- " vec4 sumPixels = vec4(0.0);\n"
- " float sumWeights = 0.0;\n"
- " int left = clamp(x - radius, 0, imgSize.x - 1);\n"
- " int right = clamp(x + radius, 0, imgSize.x - 1);\n"
- " int top = clamp(y - radius, 0, imgSize.y - 1);\n"
- " int bottom = clamp(y + radius, 0, imgSize.y - 1);\n"
- " float expfactor = expFactor();\n"
- " for (int iX = left; iX <= right; iX++) {\n"
- " float dx = float(abs(iX - x));\n"
- " vec4 imgValue = imageLoad(inputImage, ivec2(iX,y));\n"
- " float weight = gaussian(dx, expfactor);\n"
- " sumWeights += weight;\n"
- " sumPixels += (imgValue * weight);\n"
- " }\n"
- " sumPixels /= sumWeights;\n"
- " imageStore(resultImage, ivec2(x,y), sumPixels);\n"
- "}\n";
-
-
-
-QByteArray versionedShaderCode(const char *src)
-{
- QByteArray versionedSrc;
-
- if (QOpenGLContext::currentContext()->isOpenGLES())
- versionedSrc.append(QByteArrayLiteral("#version 310 es\n"));
- else
- versionedSrc.append(QByteArrayLiteral("#version 430 core\n"));
-
- versionedSrc.append(src);
- return versionedSrc;
-}
-
-void computeProjection(int winWidth, int winHeight, int imgWidth, int imgHeight, QMatrix4x4 &outProjection, QSizeF &outQuadSize)
-{
- float ratioImg = float(imgWidth) / float(imgHeight);
- float ratioCanvas = float(winWidth) / float(winHeight);
-
- float correction = ratioImg / ratioCanvas;
- float rescaleFactor = 1.0f;
- float quadWidth = 1.0f;
- float quadHeight = 1.0f;
-
- if (correction < 1.0f) // canvas larger than image -- height = 1.0, vertical black bands
- {
- quadHeight = 1.0f;
- quadWidth = 1.0f * ratioImg;
- rescaleFactor = ratioCanvas;
- correction = 1.0f / rescaleFactor;
- }
- else // image larger than canvas -- width = 1.0, horizontal black bands
- {
- quadWidth = 1.0f;
- quadHeight = 1.0f / ratioImg;
- correction = 1.0f / ratioCanvas;
- }
-
- const float frustumWidth = 1.0f * rescaleFactor;
- const float frustumHeight = 1.0f * rescaleFactor * correction;
-
- outProjection = QMatrix4x4();
- outProjection.ortho(
- -frustumWidth,
- frustumWidth,
- -frustumHeight,
- frustumHeight,
- -1.0f,
- 1.0f);
- outQuadSize = QSizeF(quadWidth,quadHeight);
-}
-
-void GLWindow::initializeGL()
-{
- QOpenGLContext *ctx = QOpenGLContext::currentContext();
- qDebug() << "Got a "
- << ctx->format().majorVersion()
- << "."
- << ctx->format().minorVersion()
- << ((ctx->format().renderableType() == QSurfaceFormat::OpenGLES) ? (" GLES") : (" GL"))
- << " context";
-
- QImage img(":/Qt-logo-medium.png");
- Q_ASSERT(!img.isNull());
- delete m_texImageInput;
- m_texImageInput = new QOpenGLTexture(img.convertToFormat(QImage::Format_RGBA8888).mirrored());
-
- delete m_texImageTmp;
- m_texImageTmp = new QOpenGLTexture(QOpenGLTexture::Target2D);
- m_texImageTmp->setFormat(m_texImageInput->format());
- m_texImageTmp->setSize(m_texImageInput->width(),m_texImageInput->height());
- m_texImageTmp->allocateStorage(QOpenGLTexture::RGBA,QOpenGLTexture::UInt8); // WTF?
-
- delete m_texImageProcessed;
- m_texImageProcessed = new QOpenGLTexture(QOpenGLTexture::Target2D);
- m_texImageProcessed->setFormat(m_texImageInput->format());
- m_texImageProcessed->setSize(m_texImageInput->width(),m_texImageInput->height());
- m_texImageProcessed->allocateStorage(QOpenGLTexture::RGBA,QOpenGLTexture::UInt8);
-
- m_texImageProcessed->setMagnificationFilter(QOpenGLTexture::Linear);
- m_texImageProcessed->setMinificationFilter(QOpenGLTexture::Linear);
- m_texImageProcessed->setWrapMode(QOpenGLTexture::ClampToEdge);
-
- delete m_shaderDisplay;
- m_shaderDisplay = new QOpenGLShaderProgram;
- // Prepend the correct version directive to the sources. The rest is the
- // same, thanks to the common GLSL syntax.
- m_shaderDisplay->addShaderFromSourceCode(QOpenGLShader::Vertex, versionedShaderCode(vsDisplaySource));
- m_shaderDisplay->addShaderFromSourceCode(QOpenGLShader::Fragment, versionedShaderCode(fsDisplaySource));
- m_shaderDisplay->link();
-
- delete m_shaderComputeV;
- m_shaderComputeV = new QOpenGLShaderProgram;
- m_shaderComputeV->addShaderFromSourceCode(QOpenGLShader::Compute, versionedShaderCode(csComputeSourceV));
- m_shaderComputeV->link();
-
- delete m_shaderComputeH;
- m_shaderComputeH = new QOpenGLShaderProgram;
- m_shaderComputeH->addShaderFromSourceCode(QOpenGLShader::Compute, versionedShaderCode(csComputeSourceH));
- m_shaderComputeH->link();
-
- // Create a VAO. Not strictly required for ES 3, but it is for plain OpenGL core context.
- m_vao = new QOpenGLVertexArrayObject;
- m_vao->create();
-}
-
-void GLWindow::resizeGL(int w, int h)
-{
- computeProjection(w,h,m_texImageInput->width(),m_texImageInput->height(),m_proj,m_quadSize);
-}
-
-QSize getWorkGroups(int workGroupSize, const QSize &imageSize)
-{
- int x = imageSize.width();
- x = (x % workGroupSize) ? (x / workGroupSize) + 1 : (x / workGroupSize);
- int y = imageSize.height();
- y = (y % workGroupSize) ? (y / workGroupSize) + 1 : (y / workGroupSize);
- return QSize(x,y);
-}
-
-void GLWindow::paintGL()
-{
- // Now use QOpenGLExtraFunctions instead of QOpenGLFunctions as we want to
- // do more than what GL(ES) 2.0 offers.
- QOpenGLExtraFunctions *f = QOpenGLContext::currentContext()->extraFunctions();
-
-
- // Process input image
- QSize workGroups = getWorkGroups(10, QSize(m_texImageInput->width(), m_texImageInput->height()));
- // Pass 1
- f->glBindImageTexture(0, m_texImageInput->textureId(), 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
- f->glBindImageTexture(1, m_texImageTmp->textureId(), 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
- m_shaderComputeV->bind();
- m_shaderComputeV->setUniformValue("radius",m_blurRadius);
- f->glDispatchCompute(workGroups.width(),workGroups.height(),1);
- f->glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
- m_shaderComputeV->release();
- // Pass 2
- f->glBindImageTexture(0, m_texImageTmp->textureId(), 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
- f->glBindImageTexture(1, m_texImageProcessed->textureId(), 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
- m_shaderComputeH->bind();
- m_shaderComputeH->setUniformValue("radius",m_blurRadius);
- f->glDispatchCompute(workGroups.width(),workGroups.height(),1);
- f->glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
- m_shaderComputeH->release();
- // Compute cleanup
- f->glBindImageTexture(0, 0, 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
- f->glBindImageTexture(1, 0, 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
-
- // Display processed image
- f->glClearColor(0, 0, 0, 1);
- f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- m_texImageProcessed->bind(0);
- m_shaderDisplay->bind();
- m_shaderDisplay->setUniformValue("matProjection",m_proj);
- m_shaderDisplay->setUniformValue("imageRatio",m_quadSize);
- m_shaderDisplay->setUniformValue("samImage",0);
- m_vao->bind();
- f->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- m_vao->release();
- m_shaderDisplay->release();
- m_texImageProcessed->release(0);
-}
-
diff --git a/examples/opengl/computegles31/glwindow.h b/examples/opengl/computegles31/glwindow.h
deleted file mode 100644
index 5375fbb488..0000000000
--- a/examples/opengl/computegles31/glwindow.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef GLWIDGET_H
-#define GLWIDGET_H
-
-#include <QOpenGLWindow>
-#include <QOpenGLTexture>
-#include <QMatrix4x4>
-#include <QVector3D>
-#include <QKeyEvent>
-#include <QPropertyAnimation>
-#include <QSequentialAnimationGroup>
-#include <QRectF>
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLTexture;
-class QOpenGLShaderProgram;
-class QOpenGLBuffer;
-class QOpenGLVertexArrayObject;
-
-QT_END_NAMESPACE
-
-class GLWindow : public QOpenGLWindow
-{
- Q_OBJECT
- Q_PROPERTY(float blurRadius READ blurRadius WRITE setBlurRadius)
-
-public:
- GLWindow();
- ~GLWindow();
-
- void initializeGL() override;
- void resizeGL(int w, int h) override;
- void paintGL() override;
-
- float blurRadius() const { return m_blurRadius; }
- void setBlurRadius(float blurRadius);
-
-protected:
- void keyPressEvent(QKeyEvent *e) override;
- void setAnimating(bool animate);
-
-private:
- QPropertyAnimation *m_animationForward = nullptr;
- QPropertyAnimation *m_animationBackward = nullptr;
- QSequentialAnimationGroup *m_animationGroup;
- QOpenGLTexture *m_texImageInput = nullptr;
- QOpenGLTexture *m_texImageTmp = nullptr;
- QOpenGLTexture *m_texImageProcessed = nullptr;
- QOpenGLShaderProgram *m_shaderDisplay = nullptr;
- QOpenGLShaderProgram *m_shaderComputeV = nullptr;
- QOpenGLShaderProgram *m_shaderComputeH = nullptr;
- QMatrix4x4 m_proj;
- QSizeF m_quadSize;
-
- int m_blurRadius = 0;
- bool m_animate = true;
- QOpenGLVertexArrayObject *m_vao = nullptr;
-};
-
-#endif
diff --git a/examples/opengl/computegles31/main.cpp b/examples/opengl/computegles31/main.cpp
deleted file mode 100644
index 88f0f36115..0000000000
--- a/examples/opengl/computegles31/main.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include <QSurfaceFormat>
-#include <QOffscreenSurface>
-#include <QOpenGLContext>
-#include <QDebug>
-#include <QPair>
-#include "glwindow.h"
-
-bool OGLSupports(int major, int minor, bool gles = false, QSurfaceFormat::OpenGLContextProfile profile = QSurfaceFormat::NoProfile)
-{
- QOpenGLContext ctx;
- QSurfaceFormat fmt;
- fmt.setVersion(major, minor);
- if (gles) {
- fmt.setRenderableType(QSurfaceFormat::OpenGLES);
- } else {
- fmt.setRenderableType(QSurfaceFormat::OpenGL);
- fmt.setProfile(profile);
- }
-
- ctx.setFormat(fmt);
- ctx.create();
- if (!ctx.isValid())
- return false;
- int ctxMajor = ctx.format().majorVersion();
- int ctxMinor = ctx.format().minorVersion();
- bool isGles = (ctx.format().renderableType() == QSurfaceFormat::OpenGLES);
-
- if (isGles != gles) return false;
- if (ctxMajor < major) return false;
- if (ctxMajor == major && ctxMinor < minor)
- return false;
- if (!gles && ctx.format().profile() != profile)
- return false;
- return true;
-}
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- qDebug() << "Support for GL 2.0 noprof "<<( OGLSupports(2,0,false) ? "yes" : "no");
- qDebug() << "Support for GL 2.0 core "<<( OGLSupports(2,0,false, QSurfaceFormat::CoreProfile) ? "yes" : "no");
- qDebug() << "Support for GL 2.0 compat "<<( OGLSupports(2,0,false, QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
- qDebug() << "Support for GL 2.1 noprof "<<( OGLSupports(2,1,false) ? "yes" : "no");
- qDebug() << "Support for GL 2.1 core "<<( OGLSupports(2,1,false, QSurfaceFormat::CoreProfile) ? "yes" : "no");
- qDebug() << "Support for GL 2.1 compat "<<( OGLSupports(2,1,false, QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
- qDebug() << "Support for GL 3.0 noprof "<<( OGLSupports(3,0,false) ? "yes" : "no");
- qDebug() << "Support for GL 3.0 core "<<( OGLSupports(3,0,false, QSurfaceFormat::CoreProfile) ? "yes" : "no");
- qDebug() << "Support for GL 3.0 compat "<<( OGLSupports(3,0,false, QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
- qDebug() << "Support for GL 3.1 noprof "<<( OGLSupports(3,1,false) ? "yes" : "no");
- qDebug() << "Support for GL 3.1 core "<<( OGLSupports(3,1,false, QSurfaceFormat::CoreProfile) ? "yes" : "no");
- qDebug() << "Support for GL 3.1 compat "<<( OGLSupports(3,1,false, QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
- qDebug() << "Support for GL 3.2 core "<<( OGLSupports(3,2,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
- qDebug() << "Support for GL 3.2 compat "<<( OGLSupports(3,2,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
- qDebug() << "Support for GL 3.3 core "<<( OGLSupports(3,3,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
- qDebug() << "Support for GL 3.3 compat "<<( OGLSupports(3,3,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
- qDebug() << "Support for GL 4.0 core "<<( OGLSupports(4,0,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
- qDebug() << "Support for GL 4.0 compat "<<( OGLSupports(4,0,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
- qDebug() << "Support for GL 4.1 core "<<( OGLSupports(4,1,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
- qDebug() << "Support for GL 4.1 compat "<<( OGLSupports(4,1,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
- qDebug() << "Support for GL 4.2 core "<<( OGLSupports(4,2,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
- qDebug() << "Support for GL 4.2 compat "<<( OGLSupports(4,2,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
- qDebug() << "Support for GL 4.3 core "<<( OGLSupports(4,3,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
- qDebug() << "Support for GL 4.3 compat "<<( OGLSupports(4,3,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
- qDebug() << "Support for GL 4.4 core "<<( OGLSupports(4,4,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
- qDebug() << "Support for GL 4.4 compat "<<( OGLSupports(4,4,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
- qDebug() << "Support for GL 4.5 core "<<( OGLSupports(4,5,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
- qDebug() << "Support for GL 4.5 compat "<<( OGLSupports(4,5,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
- qDebug() << "Support for GLES 2.0 "<<( OGLSupports(2,0,true) ? "yes" : "no");
- qDebug() << "Support for GLES 3.0 "<<( OGLSupports(3,0,true) ? "yes" : "no");
- qDebug() << "Support for GLES 3.1 "<<( OGLSupports(3,1,true) ? "yes" : "no");
- qDebug() << "Support for GLES 3.2 "<<( OGLSupports(3,2,true) ? "yes" : "no");
-
- QSurfaceFormat fmt;
- fmt.setDepthBufferSize(24);
-
- // Request OpenGL ES 3.1 context, as this is a GLES example. If not available, go for OpenGL 4.3 core.
- if (OGLSupports(3,1,true)) {
- qDebug("Requesting 3.1 GLES context");
- fmt.setVersion(3, 1);
- fmt.setRenderableType(QSurfaceFormat::OpenGLES);
- } else if (OGLSupports(4,3,false,QSurfaceFormat::CoreProfile)) {
- qDebug("Requesting 4.3 core context");
- fmt.setVersion(4, 3);
- fmt.setRenderableType(QSurfaceFormat::OpenGL);
- fmt.setProfile(QSurfaceFormat::CoreProfile);
- } else {
- qWarning("Error: This system does not support OpenGL Compute Shaders! Exiting.");
- return -1;
- }
- QSurfaceFormat::setDefaultFormat(fmt);
-
- GLWindow glWindow;
- glWindow.showMaximized();
-
- return app.exec();
-}
diff --git a/examples/opengl/contextinfo/CMakeLists.txt b/examples/opengl/contextinfo/CMakeLists.txt
deleted file mode 100644
index 81daeedc5f..0000000000
--- a/examples/opengl/contextinfo/CMakeLists.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-# Generated from contextinfo.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(contextinfo LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/contextinfo")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS OpenGL)
-
-qt_add_executable(contextinfo
- main.cpp
- renderwindow.cpp renderwindow.h
- widget.cpp widget.h
-)
-set_target_properties(contextinfo PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(contextinfo PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
- Qt::Widgets
-)
-
-install(TARGETS contextinfo
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/opengl/contextinfo/contextinfo.pro b/examples/opengl/contextinfo/contextinfo.pro
deleted file mode 100644
index ae8f4067b6..0000000000
--- a/examples/opengl/contextinfo/contextinfo.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TEMPLATE = app
-QT += widgets opengl
-requires(qtConfig(filedialog))
-
-SOURCES += main.cpp \
- widget.cpp \
- renderwindow.cpp
-
-HEADERS += widget.h \
- renderwindow.h
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/opengl/contextinfo
-INSTALLS += target
diff --git a/examples/opengl/contextinfo/main.cpp b/examples/opengl/contextinfo/main.cpp
deleted file mode 100644
index 88ab4a7334..0000000000
--- a/examples/opengl/contextinfo/main.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include "widget.h"
-
-int main(int argc, char **argv)
-{
- for (int i = 1; i < argc; ++i) {
- if (!qstrcmp(argv[i], "-g"))
- QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
- else if (!qstrcmp(argv[i], "-s"))
- QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
- else if (!qstrcmp(argv[i], "-d"))
- QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
- }
-
- QApplication app(argc, argv);
-
- Widget w;
- w.resize(700, 800);
- w.show();
-
- return app.exec();
-}
diff --git a/examples/opengl/contextinfo/renderwindow.cpp b/examples/opengl/contextinfo/renderwindow.cpp
deleted file mode 100644
index b778fd1d89..0000000000
--- a/examples/opengl/contextinfo/renderwindow.cpp
+++ /dev/null
@@ -1,238 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "renderwindow.h"
-#include <QTimer>
-#include <QMatrix4x4>
-#include <QOpenGLContext>
-#include <QtOpenGL/QOpenGLShaderProgram>
-#include <QOpenGLFunctions>
-
-RenderWindow::RenderWindow(const QSurfaceFormat &format)
- : m_context(nullptr),
- m_initialized(false),
- m_forceGLSL110(false),
- m_angle(0.0f)
-{
- setSurfaceType(QWindow::OpenGLSurface);
- setFormat(format);
- m_context = new QOpenGLContext(this);
- m_context->setFormat(requestedFormat());
- if (!m_context->create()) {
- delete m_context;
- m_context = nullptr;
- }
-}
-
-void RenderWindow::exposeEvent(QExposeEvent *)
-{
- if (isExposed())
- render();
-}
-
-// ES needs the precision qualifiers.
-// On desktop GL QOpenGLShaderProgram inserts dummy defines for highp/mediump/lowp.
-static const char *vertexShaderSource110 =
- "attribute highp vec4 posAttr;\n"
- "attribute lowp vec4 colAttr;\n"
- "varying lowp vec4 col;\n"
- "uniform highp mat4 matrix;\n"
- "void main() {\n"
- " col = colAttr;\n"
- " gl_Position = matrix * posAttr;\n"
- "}\n";
-
-static const char *fragmentShaderSource110 =
- "varying lowp vec4 col;\n"
- "void main() {\n"
- " gl_FragColor = col;\n"
- "}\n";
-
-static const char *vertexShaderSource =
- "#version 150\n"
- "in vec4 posAttr;\n"
- "in vec4 colAttr;\n"
- "out vec4 col;\n"
- "uniform mat4 matrix;\n"
- "void main() {\n"
- " col = colAttr;\n"
- " gl_Position = matrix * posAttr;\n"
- "}\n";
-
-static const char *fragmentShaderSource =
- "#version 150\n"
- "in vec4 col;\n"
- "out vec4 fragColor;\n"
- "void main() {\n"
- " fragColor = col;\n"
- "}\n";
-
-static GLfloat vertices[] = {
- 0.0f, 0.707f,
- -0.5f, -0.5f,
- 0.5f, -0.5f
-};
-
-static GLfloat colors[] = {
- 1.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 1.0f
-};
-
-void RenderWindow::init()
-{
- m_program = new QOpenGLShaderProgram(this);
-
- QSurfaceFormat format = m_context->format();
- bool useNewStyleShader = format.profile() == QSurfaceFormat::CoreProfile;
- // Try to handle 3.0 & 3.1 that do not have the core/compatibility profile concept 3.2+ has.
- // This may still fail since version 150 (3.2) is specified in the sources but it's worth a try.
- if (format.renderableType() == QSurfaceFormat::OpenGL && format.majorVersion() == 3 && format.minorVersion() <= 1)
- useNewStyleShader = !format.testOption(QSurfaceFormat::DeprecatedFunctions);
- if (m_forceGLSL110)
- useNewStyleShader = false;
-
- const char *vsrc = useNewStyleShader ? vertexShaderSource : vertexShaderSource110;
- const char *fsrc = useNewStyleShader ? fragmentShaderSource : fragmentShaderSource110;
- qDebug("Using version %s shader", useNewStyleShader ? "150" : "110");
-
- if (!m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vsrc)) {
- emit error(m_program->log());
- return;
- }
- if (!m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fsrc)) {
- emit error(m_program->log());
- return;
- }
- if (!m_program->link()) {
- emit error(m_program->log());
- return;
- }
-
- m_posAttr = m_program->attributeLocation("posAttr");
- m_colAttr = m_program->attributeLocation("colAttr");
- m_matrixUniform = m_program->uniformLocation("matrix");
-
- m_vbo.create();
- m_vbo.bind();
- m_vbo.allocate(vertices, sizeof(vertices) + sizeof(colors));
- m_vbo.write(sizeof(vertices), colors, sizeof(colors));
- m_vbo.release();
-
- QOpenGLVertexArrayObject::Binder vaoBinder(&m_vao);
- if (m_vao.isCreated()) // have VAO support, use it
- setupVertexAttribs();
-}
-
-void RenderWindow::setupVertexAttribs()
-{
- m_vbo.bind();
- m_program->setAttributeBuffer(m_posAttr, GL_FLOAT, 0, 2);
- m_program->setAttributeBuffer(m_colAttr, GL_FLOAT, sizeof(vertices), 3);
- m_program->enableAttributeArray(m_posAttr);
- m_program->enableAttributeArray(m_colAttr);
- m_vbo.release();
-}
-
-bool RenderWindow::event(QEvent *ev)
-{
- if (ev->type() == QEvent::UpdateRequest)
- render();
- return QWindow::event(ev);
-}
-
-void RenderWindow::render()
-{
- if (!m_context->makeCurrent(this)) {
- emit error(tr("makeCurrent() failed"));
- return;
- }
-
- QOpenGLFunctions *f = m_context->functions();
- if (!m_initialized) {
- m_initialized = true;
- f->glEnable(GL_DEPTH_TEST);
- f->glClearColor(0, 0, 0, 1);
- init();
- emit ready();
- }
-
- if (!m_vbo.isCreated()) // init() failed, don't bother with trying to render
- return;
-
- const qreal retinaScale = devicePixelRatio();
- f->glViewport(0, 0, width() * retinaScale, height() * retinaScale);
- f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- m_program->bind();
- QMatrix4x4 matrix;
- matrix.perspective(60.0f, 4.0f / 3.0f, 0.1f, 100.0f);
- matrix.translate(0.0f, 0.0f, -2.0f);
- matrix.rotate(m_angle, 0.0f, 1.0f, 0.0f);
- m_program->setUniformValue(m_matrixUniform, matrix);
-
- if (m_vao.isCreated())
- m_vao.bind();
- else // no VAO support, set the vertex attribute arrays now
- setupVertexAttribs();
-
- f->glDrawArrays(GL_TRIANGLES, 0, 3);
-
- m_vao.release();
- m_program->release();
-
- // swapInterval is 1 by default which means that swapBuffers() will (hopefully) block
- // and wait for vsync.
- m_context->swapBuffers(this);
-
- m_angle += 1.0f;
-
- requestUpdate();
-}
diff --git a/examples/opengl/contextinfo/renderwindow.h b/examples/opengl/contextinfo/renderwindow.h
deleted file mode 100644
index 1b4a79dfcf..0000000000
--- a/examples/opengl/contextinfo/renderwindow.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef RENDERWINDOW_H
-#define RENDERWINDOW_H
-
-#include <QWindow>
-#include <QOpenGLVertexArrayObject>
-#include <QOpenGLBuffer>
-
-QT_FORWARD_DECLARE_CLASS(QOpenGLContext)
-QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
-
-class RenderWindow : public QWindow
-{
- Q_OBJECT
-
-public:
- RenderWindow(const QSurfaceFormat &format);
- QOpenGLContext *context() { return m_context; }
- void exposeEvent(QExposeEvent *) override;
- void setForceGLSL110(bool enable) { m_forceGLSL110 = enable; }
-
-signals:
- void ready();
- void error(const QString &msg);
-
-protected:
- bool event(QEvent *ev) override;
-
-private slots:
- void render();
-
-private:
- void init();
- void setupVertexAttribs();
-
- QOpenGLContext *m_context;
- bool m_initialized;
- bool m_forceGLSL110;
- QOpenGLShaderProgram *m_program;
- int m_posAttr, m_colAttr, m_matrixUniform;
- QOpenGLVertexArrayObject m_vao;
- QOpenGLBuffer m_vbo;
- float m_angle;
-};
-
-#endif // RENDERWINDOW_H
diff --git a/examples/opengl/contextinfo/widget.cpp b/examples/opengl/contextinfo/widget.cpp
deleted file mode 100644
index df1e6a6f7b..0000000000
--- a/examples/opengl/contextinfo/widget.cpp
+++ /dev/null
@@ -1,403 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "widget.h"
-#include "renderwindow.h"
-#include <QVBoxLayout>
-#include <QComboBox>
-#include <QGroupBox>
-#include <QRadioButton>
-#include <QCheckBox>
-#include <QHBoxLayout>
-#include <QLabel>
-#include <QPushButton>
-#include <QTextEdit>
-#include <QSplitter>
-#include <QGuiApplication>
-#include <QSurfaceFormat>
-#include <QOpenGLContext>
-#include <QOpenGLFunctions>
-#include <QDebug>
-#include <QTextStream>
-
-struct Version {
- const char *str;
- int major;
- int minor;
-};
-
-static struct Version versions[] = {
- { "1.0", 1, 0 },
- { "1.1", 1, 1 },
- { "1.2", 1, 2 },
- { "1.3", 1, 3 },
- { "1.4", 1, 4 },
- { "1.5", 1, 5 },
- { "2.0", 2, 0 },
- { "2.1", 2, 1 },
- { "3.0", 3, 0 },
- { "3.1", 3, 1 },
- { "3.2", 3, 2 },
- { "3.3", 3, 3 },
- { "4.0", 4, 0 },
- { "4.1", 4, 1 },
- { "4.2", 4, 2 },
- { "4.3", 4, 3 },
- { "4.4", 4, 4 },
- { "4.5", 4, 5 }
-};
-
-struct Profile {
- const char *str;
- QSurfaceFormat::OpenGLContextProfile profile;
-};
-
-static struct Profile profiles[] = {
- { "none", QSurfaceFormat::NoProfile },
- { "core", QSurfaceFormat::CoreProfile },
- { "compatibility", QSurfaceFormat::CompatibilityProfile }
-};
-
-struct Option {
- const char *str;
- QSurfaceFormat::FormatOption option;
-};
-
-static struct Option options[] = {
- { "deprecated functions (not forward compatible)", QSurfaceFormat::DeprecatedFunctions },
- { "debug context", QSurfaceFormat::DebugContext },
- { "stereo buffers", QSurfaceFormat::StereoBuffers },
- // This is not a QSurfaceFormat option but is helpful to determine if the driver
- // allows compiling old-style shaders with core profile.
- { "force version 110 shaders", QSurfaceFormat::FormatOption(0) }
-};
-
-struct Renderable {
- const char *str;
- QSurfaceFormat::RenderableType renderable;
-};
-
-static struct Renderable renderables[] = {
- { "default", QSurfaceFormat::DefaultRenderableType },
- { "OpenGL", QSurfaceFormat::OpenGL },
- { "OpenGL ES", QSurfaceFormat::OpenGLES }
-};
-
-void Widget::addVersions(QLayout *layout)
-{
- QHBoxLayout *hbox = new QHBoxLayout;
- hbox->setSpacing(20);
- QLabel *label = new QLabel(tr("Context &version: "));
- hbox->addWidget(label);
- m_version = new QComboBox;
- m_version->setMinimumWidth(60);
- label->setBuddy(m_version);
- hbox->addWidget(m_version);
- for (size_t i = 0; i < sizeof(versions) / sizeof(Version); ++i) {
- m_version->addItem(QString::fromLatin1(versions[i].str));
- if (versions[i].major == 2 && versions[i].minor == 0)
- m_version->setCurrentIndex(m_version->count() - 1);
- }
-
- QPushButton *btn = new QPushButton(tr("Create context"));
- connect(btn, &QPushButton::clicked, this, &Widget::start);
- btn->setMinimumSize(120, 40);
- hbox->addWidget(btn);
-
- layout->addItem(hbox);
-}
-
-void Widget::addProfiles(QLayout *layout)
-{
- QGroupBox *groupBox = new QGroupBox(tr("Profile"));
- QVBoxLayout *vbox = new QVBoxLayout;
- for (size_t i = 0; i < sizeof(profiles) / sizeof(Profile); ++i)
- vbox->addWidget(new QRadioButton(QString::fromLatin1(profiles[i].str)));
- static_cast<QRadioButton *>(vbox->itemAt(0)->widget())->setChecked(true);
- groupBox->setLayout(vbox);
- layout->addWidget(groupBox);
- m_profiles = vbox;
-}
-
-void Widget::addOptions(QLayout *layout)
-{
- QGroupBox *groupBox = new QGroupBox(tr("Options"));
- QVBoxLayout *vbox = new QVBoxLayout;
- for (size_t i = 0; i < sizeof(options) / sizeof(Option); ++i)
- vbox->addWidget(new QCheckBox(QString::fromLatin1(options[i].str)));
- groupBox->setLayout(vbox);
- layout->addWidget(groupBox);
- m_options = vbox;
-}
-
-void Widget::addRenderableTypes(QLayout *layout)
-{
- QGroupBox *groupBox = new QGroupBox(tr("Renderable type"));
- QVBoxLayout *vbox = new QVBoxLayout;
- for (size_t i = 0; i < sizeof(renderables) / sizeof(Renderable); ++i)
- vbox->addWidget(new QRadioButton(QString::fromLatin1(renderables[i].str)));
- static_cast<QRadioButton *>(vbox->itemAt(0)->widget())->setChecked(true);
- groupBox->setLayout(vbox);
- layout->addWidget(groupBox);
- m_renderables = vbox;
-}
-
-void Widget::addRenderWindow()
-{
- m_renderWindowLayout->addWidget(m_renderWindowContainer);
-}
-
-static QWidget *widgetWithLayout(QLayout *layout)
-{
- QWidget *w = new QWidget;
- w->setLayout(layout);
- return w;
-}
-
-Widget::Widget(QWidget *parent)
- : QWidget(parent)
-{
- QVBoxLayout *layout = new QVBoxLayout;
- QSplitter *vsplit = new QSplitter(Qt::Vertical);
- layout->addWidget(vsplit);
-
- QSplitter *hsplit = new QSplitter;
-
- QVBoxLayout *settingsLayout = new QVBoxLayout;
- addVersions(settingsLayout);
- addProfiles(settingsLayout);
- addOptions(settingsLayout);
- addRenderableTypes(settingsLayout);
- hsplit->addWidget(widgetWithLayout(settingsLayout));
-
- QVBoxLayout *outputLayout = new QVBoxLayout;
- m_output = new QTextEdit;
- m_output->setReadOnly(true);
- outputLayout->addWidget(m_output);
- m_extensions = new QTextEdit;
- m_extensions->setReadOnly(true);
- outputLayout->addWidget(m_extensions);
- hsplit->addWidget(widgetWithLayout(outputLayout));
-
- hsplit->setStretchFactor(0, 4);
- hsplit->setStretchFactor(1, 6);
- vsplit->addWidget(hsplit);
-
- m_renderWindowLayout = new QVBoxLayout;
- vsplit->addWidget(widgetWithLayout(m_renderWindowLayout));
- vsplit->setStretchFactor(1, 5);
-
- m_renderWindowContainer = new QWidget;
- addRenderWindow();
-
- QString description;
- QTextStream str(&description);
- str << "Qt " << QT_VERSION_STR << ' ' << QGuiApplication::platformName();
- const char *openGlVariables[] =
- {"QT_ANGLE_PLATFORM", "QT_OPENGL", "QT_OPENGL_BUGLIST", "QT_OPENGL_DLL"};
- const size_t variableCount = sizeof(openGlVariables) / sizeof(openGlVariables[0]);
- for (size_t v = 0; v < variableCount; ++v) {
- if (qEnvironmentVariableIsSet(openGlVariables[v]))
- str << ' ' << openGlVariables[v] << '=' << qgetenv(openGlVariables[v]);
- }
- if (QCoreApplication::testAttribute(Qt::AA_UseOpenGLES))
- str << " Qt::AA_UseOpenGLES";
- if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL))
- str << " Qt::AA_UseSoftwareOpenGL";
- if (QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL))
- str << " Qt::AA_UseDesktopOpenGL";
- layout->addWidget(new QLabel(description));
-
- setLayout(layout);
-}
-
-void Widget::start()
-{
- QSurfaceFormat fmt;
-
- int idx = m_version->currentIndex();
- if (idx < 0)
- return;
- fmt.setVersion(versions[idx].major, versions[idx].minor);
-
- for (size_t i = 0; i < sizeof(profiles) / sizeof(Profile); ++i)
- if (static_cast<QRadioButton *>(m_profiles->itemAt(int(i))->widget())->isChecked()) {
- fmt.setProfile(profiles[i].profile);
- break;
- }
-
- bool forceGLSL110 = false;
- for (size_t i = 0; i < sizeof(options) / sizeof(Option); ++i)
- if (static_cast<QCheckBox *>(m_options->itemAt(int(i))->widget())->isChecked()) {
- if (options[i].option)
- fmt.setOption(options[i].option);
- else if (i == 3)
- forceGLSL110 = true;
- }
-
- for (size_t i = 0; i < sizeof(renderables) / sizeof(Renderable); ++i)
- if (static_cast<QRadioButton *>(m_renderables->itemAt(int(i))->widget())->isChecked()) {
- fmt.setRenderableType(renderables[i].renderable);
- break;
- }
-
- // The example rendering will need a depth buffer.
- fmt.setDepthBufferSize(16);
-
- m_output->clear();
- m_extensions->clear();
- qDebug() << "Requesting surface format" << fmt;
-
- m_renderWindowLayout->removeWidget(m_renderWindowContainer);
- delete m_renderWindowContainer;
-
- RenderWindow *renderWindow = new RenderWindow(fmt);
- if (!renderWindow->context()) {
- m_output->append(tr("Failed to create context"));
- delete renderWindow;
- m_renderWindowContainer = new QWidget;
- addRenderWindow();
- return;
- }
- m_surface = renderWindow;
-
- renderWindow->setForceGLSL110(forceGLSL110);
- connect(renderWindow, &RenderWindow::ready, this, &Widget::renderWindowReady);
- connect(renderWindow, &RenderWindow::error, this, &Widget::renderWindowError);
-
- m_renderWindowContainer = QWidget::createWindowContainer(renderWindow);
- addRenderWindow();
-}
-
-void Widget::printFormat(const QSurfaceFormat &format)
-{
- m_output->append(tr("OpenGL version: %1.%2").arg(format.majorVersion()).arg(format.minorVersion()));
-
- for (size_t i = 0; i < sizeof(profiles) / sizeof(Profile); ++i)
- if (profiles[i].profile == format.profile()) {
- m_output->append(tr("Profile: %1").arg(QString::fromLatin1(profiles[i].str)));
- break;
- }
-
- QString opts;
- for (size_t i = 0; i < sizeof(options) / sizeof(Option); ++i)
- if (format.testOption(options[i].option))
- opts += QString::fromLatin1(options[i].str) + QLatin1Char(' ');
- m_output->append(tr("Options: %1").arg(opts));
-
- for (size_t i = 0; i < sizeof(renderables) / sizeof(Renderable); ++i)
- if (renderables[i].renderable == format.renderableType()) {
- m_output->append(tr("Renderable type: %1").arg(QString::fromLatin1(renderables[i].str)));
- break;
- }
-
- m_output->append(tr("Depth buffer size: %1").arg(QString::number(format.depthBufferSize())));
- m_output->append(tr("Stencil buffer size: %1").arg(QString::number(format.stencilBufferSize())));
- m_output->append(tr("Samples: %1").arg(QString::number(format.samples())));
- m_output->append(tr("Red buffer size: %1").arg(QString::number(format.redBufferSize())));
- m_output->append(tr("Green buffer size: %1").arg(QString::number(format.greenBufferSize())));
- m_output->append(tr("Blue buffer size: %1").arg(QString::number(format.blueBufferSize())));
- m_output->append(tr("Alpha buffer size: %1").arg(QString::number(format.alphaBufferSize())));
- m_output->append(tr("Swap interval: %1").arg(QString::number(format.swapInterval())));
-}
-
-void Widget::renderWindowReady()
-{
- QOpenGLContext *context = QOpenGLContext::currentContext();
- Q_ASSERT(context);
-
- QString vendor, renderer, version, glslVersion;
- const GLubyte *p;
- QOpenGLFunctions *f = context->functions();
- if ((p = f->glGetString(GL_VENDOR)))
- vendor = QString::fromLatin1(reinterpret_cast<const char *>(p));
- if ((p = f->glGetString(GL_RENDERER)))
- renderer = QString::fromLatin1(reinterpret_cast<const char *>(p));
- if ((p = f->glGetString(GL_VERSION)))
- version = QString::fromLatin1(reinterpret_cast<const char *>(p));
- if ((p = f->glGetString(GL_SHADING_LANGUAGE_VERSION)))
- glslVersion = QString::fromLatin1(reinterpret_cast<const char *>(p));
-
- m_output->append(tr("*** Context information ***"));
- m_output->append(tr("Vendor: %1").arg(vendor));
- m_output->append(tr("Renderer: %1").arg(renderer));
- m_output->append(tr("OpenGL version: %1").arg(version));
- m_output->append(tr("GLSL version: %1").arg(glslVersion));
-
- m_output->append(tr("\n*** QSurfaceFormat from context ***"));
- printFormat(context->format());
-
- m_output->append(tr("\n*** QSurfaceFormat from window surface ***"));
- printFormat(m_surface->format());
-
- m_output->append(tr("\n*** Qt build information ***"));
- const char *gltype[] = { "Desktop", "GLES 2", "GLES 1" };
- m_output->append(tr("Qt OpenGL configuration: %1")
- .arg(QString::fromLatin1(gltype[QOpenGLContext::openGLModuleType()])));
-#if defined(Q_OS_WIN)
- using namespace QNativeInterface;
- m_output->append(tr("Qt OpenGL library handle: %1")
- .arg(QString::number(qintptr(QWGLContext::openGLModuleHandle()), 16)));
-#endif
-
- QList<QByteArray> extensionList = context->extensions().values();
- std::sort(extensionList.begin(), extensionList.end());
- m_extensions->append(tr("Found %1 extensions:").arg(extensionList.count()));
- for (const QByteArray &ext : qAsConst(extensionList))
- m_extensions->append(QString::fromLatin1(ext));
-
- m_output->moveCursor(QTextCursor::Start);
- m_extensions->moveCursor(QTextCursor::Start);
-}
-
-void Widget::renderWindowError(const QString &msg)
-{
- m_output->append(tr("An error has occurred:\n%1").arg(msg));
-}
diff --git a/examples/opengl/contextinfo/widget.h b/examples/opengl/contextinfo/widget.h
deleted file mode 100644
index 85d181a229..0000000000
--- a/examples/opengl/contextinfo/widget.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WIDGET_H
-#define WIDGET_H
-
-#include <QWidget>
-
-QT_FORWARD_DECLARE_CLASS(QComboBox)
-QT_FORWARD_DECLARE_CLASS(QTextEdit)
-QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
-QT_FORWARD_DECLARE_CLASS(QSurfaceFormat)
-QT_FORWARD_DECLARE_CLASS(QSurface)
-
-class Widget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit Widget(QWidget *parent = nullptr);
-
-private slots:
- void start();
- void renderWindowReady();
- void renderWindowError(const QString &msg);
-
-private:
- void addVersions(QLayout *layout);
- void addProfiles(QLayout *layout);
- void addOptions(QLayout *layout);
- void addRenderableTypes(QLayout *layout);
- void addRenderWindow();
- void printFormat(const QSurfaceFormat &format);
-
- QComboBox *m_version;
- QLayout *m_profiles;
- QLayout *m_options;
- QLayout *m_renderables;
- QTextEdit *m_output;
- QTextEdit *m_extensions;
- QVBoxLayout *m_renderWindowLayout;
- QWidget *m_renderWindowContainer;
- QSurface *m_surface;
-};
-
-#endif // WIDGET_H
diff --git a/examples/opengl/cube/CMakeLists.txt b/examples/opengl/cube/CMakeLists.txt
index da7db67ef9..7486d058a4 100644
--- a/examples/opengl/cube/CMakeLists.txt
+++ b/examples/opengl/cube/CMakeLists.txt
@@ -1,43 +1,31 @@
-# Generated from cube.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(cube LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL OpenGLWidgets Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/cube")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS OpenGL)
-find_package(Qt6 COMPONENTS OpenGLWidgets)
+qt_standard_project_setup()
qt_add_executable(cube
geometryengine.cpp geometryengine.h
main.cpp
mainwidget.cpp mainwidget.h
)
+
set_target_properties(cube PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(cube PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
- Qt::OpenGLWidgets
- Qt::Widgets
-)
+target_link_libraries(cube PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::OpenGL
+ Qt6::OpenGLWidgets
+ Qt6::Widgets
+)
# Resources:
set(shaders_resource_files
@@ -51,6 +39,7 @@ qt6_add_resources(cube "shaders"
FILES
${shaders_resource_files}
)
+
set(textures_resource_files
"cube.png"
)
@@ -63,7 +52,14 @@ qt6_add_resources(cube "textures"
)
install(TARGETS cube
- 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 cube
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/opengl/cube/cube.png b/examples/opengl/cube/cube.png
index 42c8c51b3a..c3abbfe84d 100644
--- a/examples/opengl/cube/cube.png
+++ b/examples/opengl/cube/cube.png
Binary files differ
diff --git a/examples/opengl/cube/geometryengine.cpp b/examples/opengl/cube/geometryengine.cpp
index 24e014201e..0e673b84d3 100644
--- a/examples/opengl/cube/geometryengine.cpp
+++ b/examples/opengl/cube/geometryengine.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "geometryengine.h"
diff --git a/examples/opengl/cube/geometryengine.h b/examples/opengl/cube/geometryengine.h
index 36f7797d16..d1e34b7f93 100644
--- a/examples/opengl/cube/geometryengine.h
+++ b/examples/opengl/cube/geometryengine.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef GEOMETRYENGINE_H
#define GEOMETRYENGINE_H
diff --git a/examples/opengl/cube/main.cpp b/examples/opengl/cube/main.cpp
index 0134387ebd..c5c77d3d5b 100644
--- a/examples/opengl/cube/main.cpp
+++ b/examples/opengl/cube/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QLabel>
diff --git a/examples/opengl/cube/mainwidget.cpp b/examples/opengl/cube/mainwidget.cpp
index 0b44ecfcea..e67c93da5a 100644
--- a/examples/opengl/cube/mainwidget.cpp
+++ b/examples/opengl/cube/mainwidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwidget.h"
@@ -119,14 +72,6 @@ void MainWidget::initializeGL()
initShaders();
initTextures();
-//! [2]
- // Enable depth buffer
- glEnable(GL_DEPTH_TEST);
-
- // Enable back face culling
- glEnable(GL_CULL_FACE);
-//! [2]
-
geometries = new GeometryEngine;
// Use QBasicTimer because its faster than QTimer
@@ -194,7 +139,16 @@ void MainWidget::paintGL()
// Clear color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+//! [2]
+ // Enable depth buffer
+ glEnable(GL_DEPTH_TEST);
+
+ // Enable back face culling
+ glEnable(GL_CULL_FACE);
+//! [2]
+
texture->bind();
+ program.bind();
//! [6]
// Calculate model view transformation
diff --git a/examples/opengl/cube/mainwidget.h b/examples/opengl/cube/mainwidget.h
index b6a03d454a..fd5dc5612b 100644
--- a/examples/opengl/cube/mainwidget.h
+++ b/examples/opengl/cube/mainwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWIDGET_H
#define MAINWIDGET_H
diff --git a/examples/opengl/hellogles3/doc/images/hellogles3-example.png b/examples/opengl/doc/images/hellogles3-example.png
index e089b9470a..e089b9470a 100644
--- a/examples/opengl/hellogles3/doc/images/hellogles3-example.png
+++ b/examples/opengl/doc/images/hellogles3-example.png
Binary files differ
diff --git a/examples/opengl/doc/images/stereoexample-leftbuffer.png b/examples/opengl/doc/images/stereoexample-leftbuffer.png
new file mode 100644
index 0000000000..6ae7d5118b
--- /dev/null
+++ b/examples/opengl/doc/images/stereoexample-leftbuffer.png
Binary files differ
diff --git a/examples/opengl/doc/images/stereoexample-rightbuffer.png b/examples/opengl/doc/images/stereoexample-rightbuffer.png
new file mode 100644
index 0000000000..3e2dc3c671
--- /dev/null
+++ b/examples/opengl/doc/images/stereoexample-rightbuffer.png
Binary files differ
diff --git a/examples/opengl/doc/src/2dpainting.qdoc b/examples/opengl/doc/src/2dpainting.qdoc
index 32b332fa8a..5196c78937 100644
--- a/examples/opengl/doc/src/2dpainting.qdoc
+++ b/examples/opengl/doc/src/2dpainting.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example 2dpainting
\title 2D Painting Example
\ingroup examples-widgets-opengl
+ \examplecategory {Graphics}
\brief The 2D Painting example shows how QPainter and QOpenGLWidget can be
used together to display accelerated 2D graphics on supported hardware.
diff --git a/examples/opengl/doc/src/cube.qdoc b/examples/opengl/doc/src/cube.qdoc
index 05014173c5..d01985701c 100644
--- a/examples/opengl/doc/src/cube.qdoc
+++ b/examples/opengl/doc/src/cube.qdoc
@@ -1,39 +1,18 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example cube
\ingroup examples-widgets-opengl
\title Cube OpenGL ES 2.0 example
+ \examplecategory {3D}
- \brief The Cube OpenGL ES 2.0 example shows how to write mouse rotateable
- textured 3D cube using OpenGL ES 2.0 with Qt. It shows how to handle
- polygon geometries efficiently and how to write simple vertex and
- fragment shader for programmable graphics pipeline. In addition it
+ \brief Shows how to manually rotate a textured 3D cube with user input.
+
+ The Cube OpenGL ES 2.0 example shows how to manually rotate a textured 3D
+ cube with user input, using OpenGL ES 2.0 with Qt. It shows how to
+ handle polygon geometries efficiently and how to write a simple vertex and
+ fragment shader for a programmable graphics pipeline. In addition it
shows how to use quaternions for representing 3D object orientation.
This example has been written for OpenGL ES 2.0 but it works also on
diff --git a/examples/opengl/doc/src/hellogl2.qdoc b/examples/opengl/doc/src/hellogl2.qdoc
index 2fb2e22e0b..29e8ef85cd 100644
--- a/examples/opengl/doc/src/hellogl2.qdoc
+++ b/examples/opengl/doc/src/hellogl2.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example hellogl2
\title Hello GL2 Example
\ingroup examples-widgets-opengl
+ \examplecategory {3D}
\brief The Hello GL2 example demonstrates the basic use of the OpenGL-related classes
provided with Qt.
diff --git a/examples/opengl/doc/src/hellogles3.qdoc b/examples/opengl/doc/src/hellogles3.qdoc
new file mode 100644
index 0000000000..d85f40a29f
--- /dev/null
+++ b/examples/opengl/doc/src/hellogles3.qdoc
@@ -0,0 +1,149 @@
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example hellogles3
+ \title Hello GLES3 Example
+ \ingroup examples-widgets-opengl
+ \examplecategory {Graphics}
+ \examplecategory {Mobile}
+
+ \brief Demonstrates OpenGL ES 3.0 functions via QOpenGLExtraFunctions.
+
+ \image hellogles3-example.png
+ \section1 Overview
+
+ This example demonstrates easy, cross-platform usage of OpenGL ES 3.0
+ functions via QOpenGLExtraFunctions in an application that
+ works identically on desktop platforms with OpenGL 3.3 and mobile/embedded
+ devices with OpenGL ES 3.0.
+
+ This example has no QWidget dependencies, it uses QOpenGLWindow, a
+ convenience subclass of QWindow that allows easy implementation of windows
+ that contain OpenGL-rendered content. In this sense it complements the
+ \l{OpenGL Window Example}, which shows the implementation of an OpenGL-based
+ QWindow without using the convenience subclass.
+
+ The Qt logo shape implementation is included from the \l{Hello GL2 Example}.
+
+ In other aspects pertaining to using OpenGL there are the following
+ differences.
+
+ \list
+ \li The OpenGL context creation has to have a sufficiently high version
+ number for the features that are in use.
+ \li The shader's version directive is different.
+ \endlist
+
+ \section1 Setting up in main.cpp
+
+ Here we instantiate our QGuiApplication, QSurfaceformat and set its
+ \l{QSurfaceFormat::depthBufferSize()}{depth buffer size}:
+
+ \quotefromfile hellogles3/main.cpp
+ \skipto int main(int argc, char *argv[])
+ \printuntil fmt.setDepthBufferSize(24);
+
+ We request an OpenGL 3.3 core or OpenGL ES 3.0 context, depending on
+ QOpenGLContext::openGLModuleType():
+
+ \skipto if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
+ \printuntil QSurfaceFormat::setDefaultFormat(fmt);
+
+ We set the default surface format and instantiate our GLWindow \c glWindow.
+
+ \section1 Implementing GLWindow
+
+ This class delivers the features of the example application.
+
+ To start, \c GLWindow is declared by implementing a subclass of
+ QOpenGLWindow:
+
+ \quotefromfile hellogles3/glwindow.h
+ \skipto class GLWindow : public QOpenGLWindow
+ \printto {
+
+ The following properties are declared using Q_PROPERTY:
+
+ \printto public:
+
+ The following public functions are declared:
+
+ \printto private slots:
+
+ The following private objects are declared:
+
+ \printto };
+
+ On the implementation side, those functions that are not declared inline are
+ implemented (or re-implemented) in \c{glwindow.cpp}. The following selections
+ will cover implementation particulars pertaining to the use of OpenGL ES 3.0.
+
+ \section2 Animations
+
+ The following code pertains to the animations, and won't be explored here:
+
+ \quotefromfile hellogles3/glwindow.cpp
+ \skipto GLWindow::GLWindow()
+ \printto static const char *vertexShaderSource =
+
+ For more information see the documentation for \l QPropertyAnimation,
+ \l QSequentialAnimationGroup.
+
+ \section2 Shaders
+ The shaders are defined like so:
+
+ \printto QByteArray versionedShaderCode(const char *src)
+
+ \note These are OpenGL version agnostic. We take this and append
+ the version like so:
+
+ \printto void GLWindow::initializeGL()
+
+ \section2 Initializing OpenGL
+
+ Initializing the shader program in handled by \c initializeGL():
+
+ \printuntil m_program = new QOpenGLShaderProgram;
+ \skipto m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, versionedShaderCode(vertexShaderSource));
+
+ Now the OpenGL version is prepended and the various matrices and light
+ position is set:
+
+ \printuntil m_lightPosLoc = m_program->uniformLocation("lightPos");
+
+ While not strictly required for ES 3, a vertex array object is created.
+
+ \skipto delete m_vao;
+ \printuntil f->glEnable(GL_CULL_FACE);
+
+ \section2 Resizing the window
+
+ The perspective needs to be aligned with the new window size as so:
+
+ \skipto void GLWindow::resizeGL(int w, int h)
+ \printto void GLWindow::paintGL()
+
+ \section2 Painting
+
+ We use QOpenGLExtraFunctions instead of QOpenGLFunctions as we want to
+ do more than what GL(ES) 2.0 offers:
+
+ \printuntil QOpenGLExtraFunctions *f = QOpenGLContext::currentContext()->extraFunctions();
+
+ We clear the screen and buffers and bind our shader program and texture:
+
+ \printuntil m_texture->bind();
+
+ Logic for handling an initial \c paintGL() call or a call after a
+ \c resizeGL() call is implemented like so:
+
+ \printuntil }
+
+ Last, we demonstrate a function introduced in OpenGL 3.1 or OpenGL ES 3.0:
+
+ \skipto f->glDrawArraysInstanced(GL_TRIANGLES, 0, m_logo.vertexCount(), 32 * 36);
+ \printuntil }
+
+ This works because we earlier requested 3.3 or 3.0 context.
+*/
diff --git a/examples/opengl/doc/src/openglwindow.qdoc b/examples/opengl/doc/src/openglwindow.qdoc
index f283c7cfc0..cade2f009a 100644
--- a/examples/opengl/doc/src/openglwindow.qdoc
+++ b/examples/opengl/doc/src/openglwindow.qdoc
@@ -1,33 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example openglwindow
\title OpenGL Window Example
+ \ingroup examples-widgets-opengl
+ \examplecategory {Graphics}
\brief This example shows how to create a minimal QWindow based application
for the purpose of using OpenGL.
@@ -36,6 +14,8 @@
\note This is a low level example of how to use QWindow with OpenGL.
In practice you should consider using the higher level QOpenGLWindow class.
+ See the \l{Hello GLES3 Example} for a demonstration of the QOpenGLWindow
+ convenience class.
\section1 OpenGLWindow Super Class
diff --git a/examples/opengl/doc/src/stereoqopenglwidget.qdoc b/examples/opengl/doc/src/stereoqopenglwidget.qdoc
new file mode 100644
index 0000000000..0cb45b9808
--- /dev/null
+++ b/examples/opengl/doc/src/stereoqopenglwidget.qdoc
@@ -0,0 +1,46 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example stereoqopenglwidget
+ \title QOpenGLWidget Stereoscopic Rendering Example
+ \examplecategory {Graphics}
+ \ingroup examples-widgets-opengl
+ \brief This example shows how to create a minimal QOpenGLWidget based
+ application with stereoscopic rendering support.
+
+ \note Support for stereoscopic rendering has certain hardware requirements,
+ such as, a graphics card with stereo support, 3D glasses and specific
+ monitors.
+
+ \note This example renders two images to two separate buffers. When you
+ view the images through 3D glasses, they give a 3D holographic effect.
+
+ \image stereoexample-leftbuffer.png
+
+ The above image is what will be rendered to the left buffer.
+
+ \image stereoexample-rightbuffer.png
+
+ The above image is what will be rendered to the right buffer.
+
+ \section1 Setting the correct surface flag
+ To enable stereoscopic rendering you need to set the flag
+ QSurfaceFormat::StereoBuffers globally. Just doing it on the widget is not enough
+ because of how the flag is handled internally. The safest is to do it on
+ QSurfaceFormat::SetDefaultFormat prior to starting the application.
+
+ \snippet stereoqopenglwidget/main.cpp 1
+
+ \section1 Rendering twice
+ After QSurfaceFormat::StereoBuffers is set, then paintGL() will be called twice,
+ once for each buffer. In paintGL() you can call currentTargetBuffer() to query
+ which TargetBuffer is currently active.
+
+ In the following snippet we slightly translate the matrix to not render the
+ vertices on top of each other. This is a simple example just too see that if the
+ necessary support is there, at runtime you should see two objects, one on the left
+ and one on the right.
+
+ \snippet stereoqopenglwidget/glwidget.cpp 1
+*/
diff --git a/examples/opengl/doc/src/textures.qdoc b/examples/opengl/doc/src/textures.qdoc
index 34c92b8f6e..b7dd6bca80 100644
--- a/examples/opengl/doc/src/textures.qdoc
+++ b/examples/opengl/doc/src/textures.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example textures
diff --git a/examples/opengl/hellogl2/CMakeLists.txt b/examples/opengl/hellogl2/CMakeLists.txt
index dcf66be4b9..74ef4a8c24 100644
--- a/examples/opengl/hellogl2/CMakeLists.txt
+++ b/examples/opengl/hellogl2/CMakeLists.txt
@@ -1,25 +1,12 @@
-# Generated from hellogl2.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(hellogl2 LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL OpenGLWidgets Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/hellogl2")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS OpenGL)
-find_package(Qt6 COMPONENTS OpenGLWidgets)
+qt_standard_project_setup()
qt_add_executable(hellogl2
glwidget.cpp glwidget.h
@@ -28,20 +15,29 @@ qt_add_executable(hellogl2
mainwindow.cpp mainwindow.h
window.cpp window.h
)
+
set_target_properties(hellogl2 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(hellogl2 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
- Qt::OpenGLWidgets
- Qt::Widgets
+
+target_link_libraries(hellogl2 PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::OpenGL
+ Qt6::OpenGLWidgets
+ Qt6::Widgets
)
install(TARGETS hellogl2
- 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 hellogl2
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/opengl/hellogl2/glwidget.cpp b/examples/opengl/hellogl2/glwidget.cpp
index 9988902071..6d2ffb3b58 100644
--- a/examples/opengl/hellogl2/glwidget.cpp
+++ b/examples/opengl/hellogl2/glwidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "glwidget.h"
#include <QMouseEvent>
@@ -131,6 +84,7 @@ void GLWidget::cleanup()
delete m_program;
m_program = nullptr;
doneCurrent();
+ QObject::disconnect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &GLWidget::cleanup);
}
static const char *vertexShaderSourceCore =
diff --git a/examples/opengl/hellogl2/glwidget.h b/examples/opengl/hellogl2/glwidget.h
index f8526fb7ae..985d8a4afa 100644
--- a/examples/opengl/hellogl2/glwidget.h
+++ b/examples/opengl/hellogl2/glwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef GLWIDGET_H
#define GLWIDGET_H
diff --git a/examples/opengl/hellogl2/logo.cpp b/examples/opengl/hellogl2/logo.cpp
index 6fcece16d4..b924ba043d 100644
--- a/examples/opengl/hellogl2/logo.cpp
+++ b/examples/opengl/hellogl2/logo.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "logo.h"
#include <qmath.h>
diff --git a/examples/opengl/hellogl2/logo.h b/examples/opengl/hellogl2/logo.h
index 5b6c3973f7..0eed3f6978 100644
--- a/examples/opengl/hellogl2/logo.h
+++ b/examples/opengl/hellogl2/logo.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef LOGO_H
#define LOGO_H
diff --git a/examples/opengl/hellogl2/main.cpp b/examples/opengl/hellogl2/main.cpp
index 96b96e77ee..6ecd4cfe1a 100644
--- a/examples/opengl/hellogl2/main.cpp
+++ b/examples/opengl/hellogl2/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QSurfaceFormat>
diff --git a/examples/opengl/hellogl2/mainwindow.cpp b/examples/opengl/hellogl2/mainwindow.cpp
index aa20cd678c..5ee2b738c2 100644
--- a/examples/opengl/hellogl2/mainwindow.cpp
+++ b/examples/opengl/hellogl2/mainwindow.cpp
@@ -1,68 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "window.h"
+#include <QApplication>
+#include <QKeySequence>
#include <QMenuBar>
#include <QMenu>
#include <QMessageBox>
MainWindow::MainWindow()
{
- QMenuBar *menuBar = new QMenuBar;
- QMenu *menuWindow = menuBar->addMenu(tr("&Window"));
- QAction *addNew = new QAction(menuWindow);
- addNew->setText(tr("Add new"));
- menuWindow->addAction(addNew);
- connect(addNew, &QAction::triggered, this, &MainWindow::onAddNew);
- setMenuBar(menuBar);
+ QMenu *menuWindow = menuBar()->addMenu(tr("&Window"));
+ menuWindow->addAction(tr("Add new"), QKeySequence(Qt::CTRL | Qt::Key_N),
+ this, &MainWindow::onAddNew);
+ menuWindow->addAction(tr("Quit"), QKeySequence(Qt::CTRL | Qt::Key_Q),
+ qApp, QApplication::closeAllWindows);
onAddNew();
}
@@ -70,8 +23,8 @@ MainWindow::MainWindow()
void MainWindow::onAddNew()
{
if (!centralWidget())
- setCentralWidget(new Window(this));
+ setCentralWidget(new Window);
else
- QMessageBox::information(nullptr, tr("Cannot add new window"),
+ QMessageBox::information(this, tr("Cannot Add New Window"),
tr("Already occupied. Undock first."));
}
diff --git a/examples/opengl/hellogl2/mainwindow.h b/examples/opengl/hellogl2/mainwindow.h
index 625bffc86e..8b3c2508f6 100644
--- a/examples/opengl/hellogl2/mainwindow.h
+++ b/examples/opengl/hellogl2/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/opengl/hellogl2/window.cpp b/examples/opengl/hellogl2/window.cpp
index 59570c83ca..5a7ddf826f 100644
--- a/examples/opengl/hellogl2/window.cpp
+++ b/examples/opengl/hellogl2/window.cpp
@@ -1,56 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include "glwidget.h"
#include "window.h"
-#include "mainwindow.h"
+#include "glwidget.h"
#include <QSlider>
#include <QVBoxLayout>
#include <QHBoxLayout>
@@ -58,9 +10,18 @@
#include <QPushButton>
#include <QApplication>
#include <QMessageBox>
+#include <QMainWindow>
-Window::Window(MainWindow *mw)
- : mainWindow(mw)
+static QMainWindow *findMainWindow()
+{
+ for (auto *w : QApplication::topLevelWidgets()) {
+ if (auto *mw = qobject_cast<QMainWindow *>(w))
+ return mw;
+ }
+ return nullptr;
+}
+
+Window::Window()
{
glWidget = new GLWidget;
@@ -75,22 +36,19 @@ Window::Window(MainWindow *mw)
connect(zSlider, &QSlider::valueChanged, glWidget, &GLWidget::setZRotation);
connect(glWidget, &GLWidget::zRotationChanged, zSlider, &QSlider::setValue);
- QVBoxLayout *mainLayout = new QVBoxLayout;
- QHBoxLayout *container = new QHBoxLayout;
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ QWidget *w = new QWidget;
+ QHBoxLayout *container = new QHBoxLayout(w);
container->addWidget(glWidget);
container->addWidget(xSlider);
container->addWidget(ySlider);
container->addWidget(zSlider);
- QWidget *w = new QWidget;
- w->setLayout(container);
mainLayout->addWidget(w);
dockBtn = new QPushButton(tr("Undock"), this);
connect(dockBtn, &QPushButton::clicked, this, &Window::dockUndock);
mainLayout->addWidget(dockBtn);
- setLayout(mainLayout);
-
xSlider->setValue(15 * 16);
ySlider->setValue(345 * 16);
zSlider->setValue(0 * 16);
@@ -111,7 +69,7 @@ QSlider *Window::createSlider()
void Window::keyPressEvent(QKeyEvent *e)
{
- if (e->key() == Qt::Key_Escape)
+ if (isWindow() && e->key() == Qt::Key_Escape)
close();
else
QWidget::keyPressEvent(e);
@@ -119,26 +77,37 @@ void Window::keyPressEvent(QKeyEvent *e)
void Window::dockUndock()
{
- if (parent()) {
- setParent(nullptr);
- setAttribute(Qt::WA_DeleteOnClose);
- move(QGuiApplication::primaryScreen()->size().width() / 2 - width() / 2,
- QGuiApplication::primaryScreen()->size().height() / 2 - height() / 2);
- dockBtn->setText(tr("Dock"));
- show();
- } else {
- if (!mainWindow->centralWidget()) {
- if (mainWindow->isVisible()) {
- setAttribute(Qt::WA_DeleteOnClose, false);
- dockBtn->setText(tr("Undock"));
- mainWindow->setCentralWidget(this);
- } else {
- QMessageBox::information(nullptr, tr("Cannot dock"),
- tr("Main window already closed"));
- }
- } else {
- QMessageBox::information(nullptr, tr("Cannot dock"),
- tr("Main window already occupied"));
- }
+ if (parent())
+ undock();
+ else
+ dock();
+}
+
+void Window::dock()
+{
+ auto *mainWindow = findMainWindow();
+ if (mainWindow == nullptr || !mainWindow->isVisible()) {
+ QMessageBox::information(this, tr("Cannot Dock"),
+ tr("Main window already closed"));
+ return;
}
+ if (mainWindow->centralWidget()) {
+ QMessageBox::information(this, tr("Cannot Dock"),
+ tr("Main window already occupied"));
+ return;
+ }
+ setAttribute(Qt::WA_DeleteOnClose, false);
+ dockBtn->setText(tr("Undock"));
+ mainWindow->setCentralWidget(this);
+}
+
+void Window::undock()
+{
+ setParent(nullptr);
+ setAttribute(Qt::WA_DeleteOnClose);
+ const auto geometry = screen()->availableGeometry();
+ move(geometry.x() + (geometry.width() - width()) / 2,
+ geometry.y() + (geometry.height() - height()) / 2);
+ dockBtn->setText(tr("Dock"));
+ show();
}
diff --git a/examples/opengl/hellogl2/window.h b/examples/opengl/hellogl2/window.h
index 5cec60ff06..edbd643ae2 100644
--- a/examples/opengl/hellogl2/window.h
+++ b/examples/opengl/hellogl2/window.h
@@ -1,72 +1,22 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 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 QSlider;
-class QPushButton;
-QT_END_NAMESPACE
+QT_FORWARD_DECLARE_CLASS(QSlider)
+QT_FORWARD_DECLARE_CLASS(QPushButton)
class GLWidget;
-class MainWindow;
class Window : public QWidget
{
Q_OBJECT
public:
- Window(MainWindow *mw);
+ Window();
protected:
void keyPressEvent(QKeyEvent *event) override;
@@ -75,6 +25,8 @@ private slots:
void dockUndock();
private:
+ void dock();
+ void undock();
QSlider *createSlider();
GLWidget *glWidget;
@@ -82,7 +34,6 @@ private:
QSlider *ySlider;
QSlider *zSlider;
QPushButton *dockBtn;
- MainWindow *mainWindow;
};
#endif
diff --git a/examples/opengl/hellogles3/CMakeLists.txt b/examples/opengl/hellogles3/CMakeLists.txt
index b26dfe059f..07df173a47 100644
--- a/examples/opengl/hellogles3/CMakeLists.txt
+++ b/examples/opengl/hellogles3/CMakeLists.txt
@@ -1,46 +1,36 @@
-# Generated from hellogles3.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(hellogles3 LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/hellogles3")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS OpenGL)
+qt_standard_project_setup()
qt_add_executable(hellogles3
../hellogl2/logo.cpp ../hellogl2/logo.h
glwindow.cpp glwindow.h
main.cpp
)
+
set_target_properties(hellogles3 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(hellogles3 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
-)
+target_link_libraries(hellogles3 PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::OpenGL
+)
# Resources:
set(hellogles3_resource_files
"qtlogo.png"
)
-qt6_add_resources(hellogles3 "hellogles3"
+qt_add_resources(hellogles3 "hellogles3"
PREFIX
"/"
FILES
@@ -48,7 +38,14 @@ qt6_add_resources(hellogles3 "hellogles3"
)
install(TARGETS hellogles3
- 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 hellogles3
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/opengl/hellogles3/doc/src/hellogles3.qdoc b/examples/opengl/hellogles3/doc/src/hellogles3.qdoc
deleted file mode 100644
index fbe071f143..0000000000
--- a/examples/opengl/hellogles3/doc/src/hellogles3.qdoc
+++ /dev/null
@@ -1,46 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example hellogles3
- \title Hello GLES3 Example
- \ingroup examples-widgets-opengl
-
- \brief The Hello GLES3 example demonstrates easy, cross-platform usage of
- OpenGL ES 3.0 functions via QOpenGLExtraFunctions in an application that
- works identically on desktop platforms with OpenGL 3.3 and mobile/embedded
- devices with OpenGL ES 3.0.
-
- The code is always the same, with the exception of two places:
- \list
- \li The OpenGL context creation has to have a sufficiently high version
- number for the features that are in use.
- \li The shader code's version directive is different.
- \endlist
-
- \image hellogles3-example.png
-*/
diff --git a/examples/opengl/hellogles3/glwindow.cpp b/examples/opengl/hellogles3/glwindow.cpp
index c644faa9a6..921230fb44 100644
--- a/examples/opengl/hellogles3/glwindow.cpp
+++ b/examples/opengl/hellogles3/glwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "glwindow.h"
#include <QImage>
diff --git a/examples/opengl/hellogles3/glwindow.h b/examples/opengl/hellogles3/glwindow.h
index dfa0680714..54bc531af8 100644
--- a/examples/opengl/hellogles3/glwindow.h
+++ b/examples/opengl/hellogles3/glwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef GLWIDGET_H
#define GLWIDGET_H
@@ -56,14 +9,10 @@
#include <QVector3D>
#include "../hellogl2/logo.h"
-QT_BEGIN_NAMESPACE
-
-class QOpenGLTexture;
-class QOpenGLShaderProgram;
-class QOpenGLBuffer;
-class QOpenGLVertexArrayObject;
-
-QT_END_NAMESPACE
+QT_FORWARD_DECLARE_CLASS(QOpenGLTexture)
+QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
+QT_FORWARD_DECLARE_CLASS(QOpenGLBuffer)
+QT_FORWARD_DECLARE_CLASS(QOpenGLVertexArrayObject)
class GLWindow : public QOpenGLWindow
{
diff --git a/examples/opengl/hellogles3/main.cpp b/examples/opengl/hellogles3/main.cpp
index 9451b2882f..09f3d95041 100644
--- a/examples/opengl/hellogles3/main.cpp
+++ b/examples/opengl/hellogles3/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QGuiApplication>
#include <QSurfaceFormat>
diff --git a/examples/opengl/hellowindow/CMakeLists.txt b/examples/opengl/hellowindow/CMakeLists.txt
deleted file mode 100644
index cd77a5b765..0000000000
--- a/examples/opengl/hellowindow/CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-# Generated from hellowindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(hellowindow LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/hellowindow")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS OpenGL)
-
-qt_add_executable(hellowindow
- hellowindow.cpp hellowindow.h
- main.cpp
-)
-set_target_properties(hellowindow PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(hellowindow PUBLIC
- Qt::Core
- Qt::CorePrivate
- Qt::Gui
- Qt::GuiPrivate
- Qt::OpenGL
-)
-
-install(TARGETS hellowindow
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp
deleted file mode 100644
index bde763dd70..0000000000
--- a/examples/opengl/hellowindow/hellowindow.cpp
+++ /dev/null
@@ -1,352 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "hellowindow.h"
-
-#include <QOpenGLContext>
-#include <QOpenGLFunctions>
-#include <QRandomGenerator>
-#include <qmath.h>
-#include <QElapsedTimer>
-
-Renderer::Renderer(const QSurfaceFormat &format, Renderer *share, QScreen *screen)
- : m_initialized(false)
- , m_format(format)
-{
- m_context = new QOpenGLContext(this);
- if (screen)
- m_context->setScreen(screen);
- m_context->setFormat(format);
- if (share)
- m_context->setShareContext(share->m_context);
- m_context->create();
-
- m_backgroundColor = QColor::fromRgbF(0.1f, 0.1f, 0.2f, 1.0f);
- m_backgroundColor.setRed(QRandomGenerator::global()->bounded(64));
- m_backgroundColor.setGreen(QRandomGenerator::global()->bounded(128));
- m_backgroundColor.setBlue(QRandomGenerator::global()->bounded(256));
-}
-
-HelloWindow::HelloWindow(const QSharedPointer<Renderer> &renderer, QScreen *screen)
- : m_colorIndex(0), m_renderer(renderer)
-{
- setSurfaceType(QWindow::OpenGLSurface);
- setFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
-
- setGeometry(QRect(10, 10, 640, 480));
-
- setFormat(renderer->format());
- if (screen)
- setScreen(screen);
-
- create();
-
- updateColor();
-
- connect(renderer.data(), &Renderer::requestUpdate, this, &QWindow::requestUpdate);
-}
-
-void HelloWindow::exposeEvent(QExposeEvent *)
-{
- if (isExposed())
- render();
-}
-
-bool HelloWindow::event(QEvent *ev)
-{
- if (ev->type() == QEvent::UpdateRequest && isExposed())
- render();
- return QWindow::event(ev);
-}
-
-void HelloWindow::render()
-{
- static QElapsedTimer timer;
- if (!timer.isValid())
- timer.start();
- qreal a = (qreal)(((timer.elapsed() * 3) % 36000) / 100.0);
- auto call = [this, r = m_renderer.data(), a, c = color()]() { r->render(this, a, c); };
- QMetaObject::invokeMethod(m_renderer.data(), call);
-}
-
-void HelloWindow::mousePressEvent(QMouseEvent *)
-{
- updateColor();
-}
-
-QColor HelloWindow::color() const
-{
- return m_color;
-}
-
-void HelloWindow::updateColor()
-{
- QColor colors[] =
- {
- QColor(100, 255, 0),
- QColor(0, 100, 255)
- };
-
- m_color = colors[m_colorIndex];
- m_colorIndex = 1 - m_colorIndex;
-}
-
-void Renderer::render(HelloWindow *surface, qreal angle, const QColor &color)
-{
- if (!m_context->makeCurrent(surface))
- return;
-
- QSize viewSize = surface->size();
-
- if (!m_initialized) {
- initialize();
- m_initialized = true;
- }
-
- QOpenGLFunctions *f = m_context->functions();
- f->glViewport(0, 0, viewSize.width() * surface->devicePixelRatio(), viewSize.height() * surface->devicePixelRatio());
- f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- f->glClearColor(m_backgroundColor.redF(), m_backgroundColor.greenF(), m_backgroundColor.blueF(), m_backgroundColor.alphaF());
- f->glFrontFace(GL_CW);
- f->glCullFace(GL_FRONT);
- f->glEnable(GL_CULL_FACE);
- f->glEnable(GL_DEPTH_TEST);
-
- m_program->bind();
- m_vbo.bind();
-
- m_program->enableAttributeArray(vertexAttr);
- m_program->enableAttributeArray(normalAttr);
- m_program->setAttributeBuffer(vertexAttr, GL_FLOAT, 0, 3);
- const int verticesSize = vertices.count() * 3 * sizeof(GLfloat);
- m_program->setAttributeBuffer(normalAttr, GL_FLOAT, verticesSize, 3);
-
- QMatrix4x4 modelview;
- modelview.rotate(angle, 0.0f, 1.0f, 0.0f);
- modelview.rotate(angle, 1.0f, 0.0f, 0.0f);
- modelview.rotate(angle, 0.0f, 0.0f, 1.0f);
- modelview.translate(0.0f, -0.2f, 0.0f);
-
- m_program->setUniformValue(matrixUniform, modelview);
- m_program->setUniformValue(colorUniform, color);
-
- m_context->functions()->glDrawArrays(GL_TRIANGLES, 0, vertices.size());
-
- m_context->swapBuffers(surface);
-
- emit requestUpdate();
-}
-
-Q_GLOBAL_STATIC(QMutex, initMutex)
-
-void Renderer::initialize()
-{
- // Threaded shader compilation can confuse some drivers. Avoid it.
- QMutexLocker lock(initMutex());
-
- QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, this);
- vshader->compileSourceCode(
- "attribute highp vec4 vertex;"
- "attribute mediump vec3 normal;"
- "uniform mediump mat4 matrix;"
- "uniform lowp vec4 sourceColor;"
- "varying mediump vec4 color;"
- "void main(void)"
- "{"
- " vec3 toLight = normalize(vec3(0.0, 0.3, 1.0));"
- " float angle = max(dot(normal, toLight), 0.0);"
- " vec3 col = sourceColor.rgb;"
- " color = vec4(col * 0.2 + col * 0.8 * angle, 1.0);"
- " color = clamp(color, 0.0, 1.0);"
- " gl_Position = matrix * vertex;"
- "}");
-
- QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, this);
- fshader->compileSourceCode(
- "varying mediump vec4 color;"
- "void main(void)"
- "{"
- " gl_FragColor = color;"
- "}");
-
- m_program = new QOpenGLShaderProgram(this);
- m_program->addShader(vshader);
- m_program->addShader(fshader);
- m_program->link();
- m_program->bind();
-
- vertexAttr = m_program->attributeLocation("vertex");
- normalAttr = m_program->attributeLocation("normal");
- matrixUniform = m_program->uniformLocation("matrix");
- colorUniform = m_program->uniformLocation("sourceColor");
-
- createGeometry();
-
- m_vbo.create();
- m_vbo.bind();
- const int verticesSize = vertices.count() * 3 * sizeof(GLfloat);
- m_vbo.allocate(verticesSize * 2);
- m_vbo.write(0, vertices.constData(), verticesSize);
- m_vbo.write(verticesSize, normals.constData(), verticesSize);
-}
-
-void Renderer::createGeometry()
-{
- vertices.clear();
- normals.clear();
-
- qreal x1 = +0.06f;
- qreal y1 = -0.14f;
- qreal x2 = +0.14f;
- qreal y2 = -0.06f;
- qreal x3 = +0.08f;
- qreal y3 = +0.00f;
- qreal x4 = +0.30f;
- qreal y4 = +0.22f;
-
- quad(x1, y1, x2, y2, y2, x2, y1, x1);
- quad(x3, y3, x4, y4, y4, x4, y3, x3);
-
- extrude(x1, y1, x2, y2);
- extrude(x2, y2, y2, x2);
- extrude(y2, x2, y1, x1);
- extrude(y1, x1, x1, y1);
- extrude(x3, y3, x4, y4);
- extrude(x4, y4, y4, x4);
- extrude(y4, x4, y3, x3);
-
- const int NumSectors = 100;
- const qreal sectorAngle = 2 * qreal(M_PI) / NumSectors;
- for (int i = 0; i < NumSectors; ++i) {
- qreal angle = i * sectorAngle;
- qreal x5 = 0.30 * qSin(angle);
- qreal y5 = 0.30 * qCos(angle);
- qreal x6 = 0.20 * qSin(angle);
- qreal y6 = 0.20 * qCos(angle);
-
- angle += sectorAngle;
- qreal x7 = 0.20 * qSin(angle);
- qreal y7 = 0.20 * qCos(angle);
- qreal x8 = 0.30 * qSin(angle);
- qreal y8 = 0.30 * qCos(angle);
-
- quad(x5, y5, x6, y6, x7, y7, x8, y8);
-
- extrude(x6, y6, x7, y7);
- extrude(x8, y8, x5, y5);
- }
-
- for (int i = 0;i < vertices.size();i++)
- vertices[i] *= 2.0f;
-}
-
-void Renderer::quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4)
-{
- vertices << QVector3D(x1, y1, -0.05f);
- vertices << QVector3D(x2, y2, -0.05f);
- vertices << QVector3D(x4, y4, -0.05f);
-
- vertices << QVector3D(x3, y3, -0.05f);
- vertices << QVector3D(x4, y4, -0.05f);
- vertices << QVector3D(x2, y2, -0.05f);
-
- QVector3D n = QVector3D::normal
- (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(x4 - x1, y4 - y1, 0.0f));
-
- normals << n;
- normals << n;
- normals << n;
-
- normals << n;
- normals << n;
- normals << n;
-
- vertices << QVector3D(x4, y4, 0.05f);
- vertices << QVector3D(x2, y2, 0.05f);
- vertices << QVector3D(x1, y1, 0.05f);
-
- vertices << QVector3D(x2, y2, 0.05f);
- vertices << QVector3D(x4, y4, 0.05f);
- vertices << QVector3D(x3, y3, 0.05f);
-
- n = QVector3D::normal
- (QVector3D(x2 - x4, y2 - y4, 0.0f), QVector3D(x1 - x4, y1 - y4, 0.0f));
-
- normals << n;
- normals << n;
- normals << n;
-
- normals << n;
- normals << n;
- normals << n;
-}
-
-void Renderer::extrude(qreal x1, qreal y1, qreal x2, qreal y2)
-{
- vertices << QVector3D(x1, y1, +0.05f);
- vertices << QVector3D(x2, y2, +0.05f);
- vertices << QVector3D(x1, y1, -0.05f);
-
- vertices << QVector3D(x2, y2, -0.05f);
- vertices << QVector3D(x1, y1, -0.05f);
- vertices << QVector3D(x2, y2, +0.05f);
-
- QVector3D n = QVector3D::normal
- (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(0.0f, 0.0f, -0.1f));
-
- normals << n;
- normals << n;
- normals << n;
-
- normals << n;
- normals << n;
- normals << n;
-}
diff --git a/examples/opengl/hellowindow/hellowindow.h b/examples/opengl/hellowindow/hellowindow.h
deleted file mode 100644
index d4dcbcf3db..0000000000
--- a/examples/opengl/hellowindow/hellowindow.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QWindow>
-
-#include <QColor>
-#include <QMutex>
-#include <QOpenGLShaderProgram>
-#include <QOpenGLBuffer>
-#include <QSharedPointer>
-#include <QTimer>
-
-class HelloWindow;
-
-class Renderer : public QObject
-{
- Q_OBJECT
-
-public:
- explicit Renderer(const QSurfaceFormat &format, Renderer *share = nullptr,
- QScreen *screen = nullptr);
-
- QSurfaceFormat format() const { return m_format; }
-
-public slots:
- void render(HelloWindow *surface, qreal angle, const QColor &color);
-
-signals:
- void requestUpdate();
-
-private:
- void initialize();
-
- void createGeometry();
- void createBubbles(int number);
- void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4);
- void extrude(qreal x1, qreal y1, qreal x2, qreal y2);
-
- QList<QVector3D> vertices;
- QList<QVector3D> normals;
- int vertexAttr;
- int normalAttr;
- int matrixUniform;
- int colorUniform;
-
- bool m_initialized;
- QSurfaceFormat m_format;
- QOpenGLContext *m_context;
- QOpenGLShaderProgram *m_program;
- QOpenGLBuffer m_vbo;
- QColor m_backgroundColor;
-};
-
-class HelloWindow : public QWindow
-{
-public:
- explicit HelloWindow(const QSharedPointer<Renderer> &renderer, QScreen *screen = nullptr);
-
- QColor color() const;
- void updateColor();
-
-protected:
- bool event(QEvent *ev) override;
- void exposeEvent(QExposeEvent *event) override;
- void mousePressEvent(QMouseEvent *) override;
- void render();
-
-private:
- int m_colorIndex;
- QColor m_color;
- const QSharedPointer<Renderer> m_renderer;
-};
diff --git a/examples/opengl/hellowindow/hellowindow.pro b/examples/opengl/hellowindow/hellowindow.pro
deleted file mode 100644
index 27c274a378..0000000000
--- a/examples/opengl/hellowindow/hellowindow.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QT += gui-private core-private opengl
-
-HEADERS += hellowindow.h
-SOURCES += hellowindow.cpp main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/opengl/hellowindow
-INSTALLS += target
-
diff --git a/examples/opengl/hellowindow/main.cpp b/examples/opengl/hellowindow/main.cpp
deleted file mode 100644
index 7f0be39f5d..0000000000
--- a/examples/opengl/hellowindow/main.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "hellowindow.h"
-
-#include <qpa/qplatformintegration.h>
-
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-#include <QGuiApplication>
-#include <QScreen>
-#include <QThread>
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- QCoreApplication::setApplicationName("Qt HelloWindow GL Example");
- QCoreApplication::setOrganizationName("QtProject");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription(QCoreApplication::applicationName());
- parser.addHelpOption();
- parser.addVersionOption();
- QCommandLineOption multipleOption("multiple", "Create multiple windows");
- parser.addOption(multipleOption);
- QCommandLineOption multipleSampleOption("multisample", "Multisampling");
- parser.addOption(multipleSampleOption);
- QCommandLineOption multipleScreenOption("multiscreen", "Run on multiple screens");
- parser.addOption(multipleScreenOption);
- QCommandLineOption timeoutOption("timeout", "Close after 10s");
- parser.addOption(timeoutOption);
- parser.process(app);
-
- // Some platforms can only have one window per screen. Therefore we need to differentiate.
- const bool multipleWindows = parser.isSet(multipleOption);
- const bool multipleScreens = parser.isSet(multipleScreenOption);
-
- QScreen *screen = QGuiApplication::primaryScreen();
-
- QRect screenGeometry = screen->availableGeometry();
-
- QSurfaceFormat format;
- format.setDepthBufferSize(16);
- if (parser.isSet(multipleSampleOption))
- format.setSamples(4);
-
- QPoint center = QPoint(screenGeometry.center().x(), screenGeometry.top() + 80);
- QSize windowSize(400, 320);
- int delta = 40;
-
- QList<QWindow *> windows;
- QSharedPointer<Renderer> rendererA(new Renderer(format));
-
- HelloWindow *windowA = new HelloWindow(rendererA);
- windowA->setGeometry(QRect(center, windowSize).translated(-windowSize.width() - delta / 2, 0));
- windowA->setTitle(QStringLiteral("Thread A - Context A"));
- windowA->setVisible(true);
- windows.prepend(windowA);
-
- QList<QThread *> renderThreads;
- if (multipleWindows) {
- QSharedPointer<Renderer> rendererB(new Renderer(format, rendererA.data()));
-
- QThread *renderThread = new QThread;
- rendererB->moveToThread(renderThread);
- renderThreads << renderThread;
-
- HelloWindow *windowB = new HelloWindow(rendererA);
- windowB->setGeometry(QRect(center, windowSize).translated(delta / 2, 0));
- windowB->setTitle(QStringLiteral("Thread A - Context A"));
- windowB->setVisible(true);
- windows.prepend(windowB);
-
- HelloWindow *windowC = new HelloWindow(rendererB);
- windowC->setGeometry(QRect(center, windowSize).translated(-windowSize.width() / 2, windowSize.height() + delta));
- windowC->setTitle(QStringLiteral("Thread B - Context B"));
- windowC->setVisible(true);
- windows.prepend(windowC);
- }
- if (multipleScreens) {
- for (int i = 1; i < QGuiApplication::screens().size(); ++i) {
- QScreen *screen = QGuiApplication::screens().at(i);
- QSharedPointer<Renderer> renderer(new Renderer(format, rendererA.data(), screen));
-
- QThread *renderThread = new QThread;
- renderer->moveToThread(renderThread);
- renderThreads.prepend(renderThread);
-
- QRect screenGeometry = screen->availableGeometry();
- QPoint center = screenGeometry.center();
-
- QSize windowSize = screenGeometry.size() * 0.8;
-
- HelloWindow *window = new HelloWindow(renderer, screen);
- window->setGeometry(QRect(center, windowSize).translated(-windowSize.width() / 2, -windowSize.height() / 2));
-
- QChar id = QChar('B' + i);
- window->setTitle(QStringLiteral("Thread ") + id + QStringLiteral(" - Context ") + id);
- window->setVisible(true);
- windows.prepend(window);
- }
- }
-
- for (int i = 0; i < renderThreads.size(); ++i) {
- QObject::connect(qGuiApp, &QGuiApplication::lastWindowClosed, renderThreads.at(i), &QThread::quit);
- renderThreads.at(i)->start();
- }
-
- // Quit after 10 seconds. For platforms that do not have windows that are closeable.
- if (parser.isSet(timeoutOption))
- QTimer::singleShot(10000, qGuiApp, &QCoreApplication::quit);
-
- const int exitValue = app.exec();
-
- for (int i = 0; i < renderThreads.size(); ++i) {
- renderThreads.at(i)->quit(); // some platforms may not have windows to close so ensure quit()
- renderThreads.at(i)->wait();
- }
-
- qDeleteAll(windows);
- qDeleteAll(renderThreads);
-
- return exitValue;
-}
diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro
index 907930d7ac..6ee57c7018 100644
--- a/examples/opengl/opengl.pro
+++ b/examples/opengl/opengl.pro
@@ -1,18 +1,12 @@
TEMPLATE = subdirs
-SUBDIRS = hellowindow \
- paintedwindow \
- openglwindow \
- qopenglwindow
+SUBDIRS = openglwindow \
+ hellogles3
qtHaveModule(widgets) {
- SUBDIRS += contextinfo \
- threadedqopenglwidget \
- 2dpainting \
+ SUBDIRS += 2dpainting \
hellogl2 \
- qopenglwidget \
cube \
textures \
- hellogles3 \
- computegles31
+ stereoqopenglwidget
}
diff --git a/examples/opengl/openglwindow/.prev_CMakeLists.txt b/examples/opengl/openglwindow/.prev_CMakeLists.txt
deleted file mode 100644
index 9780e18c7f..0000000000
--- a/examples/opengl/openglwindow/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated from openglwindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(openglwindow LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-set(INSTALL_EXAMPLEDIR "examples/opengl/openglwindow")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS OpenGL)
-
-add_qt_gui_executable(openglwindow
- main.cpp
- openglwindow.cpp openglwindow.h
-)
-target_include_directories(openglwindow PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}
-)
-
-target_link_libraries(openglwindow PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
-)
-
-install(TARGETS openglwindow
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/opengl/openglwindow/CMakeLists.txt b/examples/opengl/openglwindow/CMakeLists.txt
index d0a825aafc..0258a42822 100644
--- a/examples/opengl/openglwindow/CMakeLists.txt
+++ b/examples/opengl/openglwindow/CMakeLists.txt
@@ -1,44 +1,38 @@
-# Generated from openglwindow.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(openglwindow LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/openglwindow")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS OpenGL)
+qt_standard_project_setup()
qt_add_executable(openglwindow
main.cpp
openglwindow.cpp openglwindow.h
)
+
set_target_properties(openglwindow PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_include_directories(openglwindow PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}
-)
-target_link_libraries(openglwindow PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
+target_link_libraries(openglwindow PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::OpenGL
)
install(TARGETS openglwindow
- 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 openglwindow
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/opengl/openglwindow/main.cpp b/examples/opengl/openglwindow/main.cpp
index 03a6ece06f..89933fa379 100644
--- a/examples/opengl/openglwindow/main.cpp
+++ b/examples/opengl/openglwindow/main.cpp
@@ -1,62 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "openglwindow.h"
#include <QGuiApplication>
#include <QMatrix4x4>
#include <QOpenGLShaderProgram>
+#include <QOpenGLBuffer>
#include <QScreen>
#include <QtMath>
-
//! [1]
class TriangleWindow : public OpenGLWindow
{
@@ -67,10 +20,8 @@ public:
void render() override;
private:
- GLint m_posAttr = 0;
- GLint m_colAttr = 0;
GLint m_matrixUniform = 0;
-
+ QOpenGLBuffer m_vbo;
QOpenGLShaderProgram *m_program = nullptr;
int m_frame = 0;
};
@@ -95,36 +46,48 @@ int main(int argc, char **argv)
}
//! [2]
-
//! [3]
-static const char *vertexShaderSource =
- "attribute highp vec4 posAttr;\n"
- "attribute lowp vec4 colAttr;\n"
- "varying lowp vec4 col;\n"
- "uniform highp mat4 matrix;\n"
- "void main() {\n"
- " col = colAttr;\n"
- " gl_Position = matrix * posAttr;\n"
- "}\n";
-
-static const char *fragmentShaderSource =
- "varying lowp vec4 col;\n"
- "void main() {\n"
- " gl_FragColor = col;\n"
- "}\n";
+static const char *vertexShaderSource = "attribute highp vec4 posAttr;\n"
+ "attribute lowp vec4 colAttr;\n"
+ "varying lowp vec4 col;\n"
+ "uniform highp mat4 matrix;\n"
+ "void main() {\n"
+ " col = colAttr;\n"
+ " gl_Position = matrix * posAttr;\n"
+ "}\n";
+
+static const char *fragmentShaderSource = "varying lowp vec4 col;\n"
+ "void main() {\n"
+ " gl_FragColor = col;\n"
+ "}\n";
//! [3]
//! [4]
void TriangleWindow::initialize()
{
+ static const GLfloat vertices_colors[] = { +0.0f, +0.707f, 1.0f, 0.0f, 0.0f,
+ -0.5f, -0.500f, 0.0f, 1.0f, 0.0f,
+ +0.5f, -0.500f, 0.0f, 0.0f, 1.0f };
+
+ m_vbo.create();
+ m_vbo.bind();
+ m_vbo.allocate(vertices_colors, sizeof(vertices_colors));
+
+ glEnableVertexAttribArray(0);
+ glEnableVertexAttribArray(1);
+
+ glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), nullptr);
+ glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat),
+ reinterpret_cast<void *>(2 * sizeof(GLfloat)));
+
m_program = new QOpenGLShaderProgram(this);
m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
+ m_program->bindAttributeLocation("posAttr", 0);
+ m_program->bindAttributeLocation("colAttr", 1);
m_program->link();
- m_posAttr = m_program->attributeLocation("posAttr");
- Q_ASSERT(m_posAttr != -1);
- m_colAttr = m_program->attributeLocation("colAttr");
- Q_ASSERT(m_colAttr != -1);
+ m_program->bind();
+
m_matrixUniform = m_program->uniformLocation("matrix");
Q_ASSERT(m_matrixUniform != -1);
}
@@ -147,28 +110,13 @@ void TriangleWindow::render()
m_program->setUniformValue(m_matrixUniform, matrix);
- static const GLfloat vertices[] = {
- 0.0f, 0.707f,
- -0.5f, -0.5f,
- 0.5f, -0.5f
- };
-
- static const GLfloat colors[] = {
- 1.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 1.0f
- };
-
- glVertexAttribPointer(m_posAttr, 2, GL_FLOAT, GL_FALSE, 0, vertices);
- glVertexAttribPointer(m_colAttr, 3, GL_FLOAT, GL_FALSE, 0, colors);
-
- glEnableVertexAttribArray(m_posAttr);
- glEnableVertexAttribArray(m_colAttr);
+ glEnableVertexAttribArray(0);
+ glEnableVertexAttribArray(1);
glDrawArrays(GL_TRIANGLES, 0, 3);
- glDisableVertexAttribArray(m_colAttr);
- glDisableVertexAttribArray(m_posAttr);
+ glDisableVertexAttribArray(0);
+ glDisableVertexAttribArray(1);
m_program->release();
diff --git a/examples/opengl/openglwindow/openglwindow.cpp b/examples/opengl/openglwindow/openglwindow.cpp
index bac887dca0..4869f45e4c 100644
--- a/examples/opengl/openglwindow/openglwindow.cpp
+++ b/examples/opengl/openglwindow/openglwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "openglwindow.h"
diff --git a/examples/opengl/openglwindow/openglwindow.h b/examples/opengl/openglwindow/openglwindow.h
index 8db943ddde..41bcbab9c4 100644
--- a/examples/opengl/openglwindow/openglwindow.h
+++ b/examples/opengl/openglwindow/openglwindow.h
@@ -1,61 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef OPENGLWINDOW_H
+#define OPENGLWINDOW_H
#include <QWindow>
#include <QOpenGLFunctions>
-QT_BEGIN_NAMESPACE
-class QPainter;
-class QOpenGLContext;
-class QOpenGLPaintDevice;
-QT_END_NAMESPACE
+QT_FORWARD_DECLARE_CLASS(QPainter)
+QT_FORWARD_DECLARE_CLASS(QOpenGLContext)
+QT_FORWARD_DECLARE_CLASS(QOpenGLPaintDevice)
//! [1]
class OpenGLWindow : public QWindow, protected QOpenGLFunctions
@@ -89,3 +43,4 @@ private:
};
//! [1]
+#endif // OPENGLWINDOW_H
diff --git a/examples/opengl/paintedwindow/CMakeLists.txt b/examples/opengl/paintedwindow/CMakeLists.txt
deleted file mode 100644
index 496cc52b6f..0000000000
--- a/examples/opengl/paintedwindow/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from paintedwindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(paintedwindow LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/paintedwindow")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS OpenGL)
-
-qt_add_executable(paintedwindow
- main.cpp
- paintedwindow.cpp paintedwindow.h
-)
-set_target_properties(paintedwindow PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(paintedwindow PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
-)
-
-install(TARGETS paintedwindow
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/opengl/paintedwindow/main.cpp b/examples/opengl/paintedwindow/main.cpp
deleted file mode 100644
index 7e3e64d98c..0000000000
--- a/examples/opengl/paintedwindow/main.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include <QRect>
-
-#include "paintedwindow.h"
-
-int main(int argc, char **argv)
-{
- QGuiApplication app(argc, argv);
-
- PaintedWindow window;
- window.show();
-
- return app.exec();
-}
-
diff --git a/examples/opengl/paintedwindow/paintedwindow.cpp b/examples/opengl/paintedwindow/paintedwindow.cpp
deleted file mode 100644
index 94aa215288..0000000000
--- a/examples/opengl/paintedwindow/paintedwindow.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "paintedwindow.h"
-
-#include <QGuiApplication>
-#include <QOpenGLContext>
-#include <QOpenGLPaintDevice>
-#include <QPainter>
-#include <QPainterPath>
-#include <QScreen>
-#include <QTimer>
-
-#include <qmath.h>
-
-PaintedWindow::PaintedWindow()
-{
- QSurfaceFormat format;
- format.setStencilBufferSize(8);
- format.setSamples(4);
-
- setSurfaceType(QWindow::OpenGLSurface);
- setFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
- setFormat(format);
-
- create();
-
- m_context = new QOpenGLContext(this);
- m_context->setFormat(format);
- m_context->create();
-
- m_animation = new QPropertyAnimation(this, "rotation");
- m_animation->setStartValue(qreal(0));
- m_animation->setEndValue(qreal(1));
- m_animation->setDuration(500);
-
- QRect screenGeometry = screen()->availableGeometry();
-
- QPoint center = screenGeometry.center();
- QRect windowRect = screen()->isLandscape(screen()->orientation()) ? QRect(0, 0, 640, 480) : QRect(0, 0, 480, 640);
- setGeometry(QRect(center - windowRect.center(), windowRect.size()));
-
- m_rotation = 0;
-
- reportContentOrientationChange(screen()->orientation());
-
- m_targetOrientation = contentOrientation();
- m_nextTargetOrientation = Qt::PrimaryOrientation;
-
- connect(screen(), &QScreen::orientationChanged, this, &PaintedWindow::orientationChanged);
- connect(m_animation, &QAbstractAnimation::finished, this, &PaintedWindow::rotationDone);
- connect(this, &PaintedWindow::rotationChanged, this, QOverload<>::of(&PaintedWindow::paint));
-}
-
-void PaintedWindow::exposeEvent(QExposeEvent *)
-{
- if (isExposed())
- paint();
-}
-
-void PaintedWindow::mousePressEvent(QMouseEvent *)
-{
- Qt::ScreenOrientation o = contentOrientation();
- switch (o) {
- case Qt::LandscapeOrientation:
- orientationChanged(Qt::PortraitOrientation);
- break;
- case Qt::PortraitOrientation:
- orientationChanged(Qt::InvertedLandscapeOrientation);
- break;
- case Qt::InvertedLandscapeOrientation:
- orientationChanged(Qt::InvertedPortraitOrientation);
- break;
- case Qt::InvertedPortraitOrientation:
- orientationChanged(Qt::LandscapeOrientation);
- break;
- default:
- Q_ASSERT(false);
- }
-
- paint();
-}
-
-void PaintedWindow::orientationChanged(Qt::ScreenOrientation newOrientation)
-{
- if (contentOrientation() == newOrientation)
- return;
-
- if (m_animation->state() == QAbstractAnimation::Running) {
- m_nextTargetOrientation = newOrientation;
- return;
- }
-
- QRect rect(0, 0, width(), height());
-
- m_prevImage = QImage(width(), height(), QImage::Format_ARGB32_Premultiplied);
- m_nextImage = QImage(width(), height(), QImage::Format_ARGB32_Premultiplied);
- m_prevImage.fill(0);
- m_nextImage.fill(0);
-
- QPainter p;
- p.begin(&m_prevImage);
- p.setTransform(screen()->transformBetween(contentOrientation(), screen()->orientation(), rect));
- paint(&p, screen()->mapBetween(contentOrientation(), screen()->orientation(), rect));
- p.end();
-
- p.begin(&m_nextImage);
- p.setTransform(screen()->transformBetween(newOrientation, screen()->orientation(), rect));
- paint(&p, screen()->mapBetween(newOrientation, screen()->orientation(), rect));
- p.end();
-
- m_deltaRotation = screen()->angleBetween(newOrientation, contentOrientation());
- if (m_deltaRotation > 180)
- m_deltaRotation = 180 - m_deltaRotation;
-
- m_targetOrientation = newOrientation;
- m_animation->start();
-}
-
-void PaintedWindow::rotationDone()
-{
- reportContentOrientationChange(m_targetOrientation);
- if (m_nextTargetOrientation != Qt::PrimaryOrientation) {
- Q_ASSERT(m_animation->state() != QAbstractAnimation::Running);
- orientationChanged(m_nextTargetOrientation);
- m_nextTargetOrientation = Qt::PrimaryOrientation;
- }
-}
-
-void PaintedWindow::setRotation(qreal r)
-{
- if (r != m_rotation) {
- m_rotation = r;
- emit rotationChanged(r);
- }
-}
-
-void PaintedWindow::paint()
-{
- m_context->makeCurrent(this);
-
- QRect rect(0, 0, width() * devicePixelRatio(), height() * devicePixelRatio());
-
- QOpenGLPaintDevice device(size() * devicePixelRatio());
- QPainter painter(&device);
-
- QPainterPath path;
- path.addEllipse(rect);
- painter.setCompositionMode(QPainter::CompositionMode_Source);
- painter.fillRect(rect, Qt::transparent);
- painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
- painter.fillPath(path, Qt::blue);
-
- if (contentOrientation() != m_targetOrientation) {
- painter.setRenderHint(QPainter::SmoothPixmapTransform);
- painter.save();
- painter.translate(width() / 2, height() / 2);
- painter.rotate(m_deltaRotation * m_rotation);
- painter.translate(-width() / 2, -height() / 2);
- painter.drawImage(0, 0, m_prevImage);
- painter.restore();
- painter.translate(width() / 2, height() / 2);
- painter.rotate(m_deltaRotation * m_rotation - m_deltaRotation);
- painter.translate(-width() / 2, -height() / 2);
- painter.setOpacity(m_rotation);
- painter.drawImage(0, 0, m_nextImage);
- } else {
- QRect mapped = screen()->mapBetween(contentOrientation(), screen()->orientation(), rect);
-
- painter.setTransform(screen()->transformBetween(contentOrientation(), screen()->orientation(), rect));
- paint(&painter, mapped);
- painter.end();
- }
-
- m_context->swapBuffers(this);
-}
-
-void PaintedWindow::paint(QPainter *painter, const QRect &rect)
-{
- painter->setRenderHint(QPainter::Antialiasing);
- QFont font;
- font.setPixelSize(64);
- painter->setFont(font);
- painter->drawText(rect, Qt::AlignCenter, "Hello");
-}
diff --git a/examples/opengl/paintedwindow/paintedwindow.h b/examples/opengl/paintedwindow/paintedwindow.h
deleted file mode 100644
index 972d8d10bd..0000000000
--- a/examples/opengl/paintedwindow/paintedwindow.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QWindow>
-
-#include <QtGui/qopengl.h>
-#include <QtOpenGL/qopenglshaderprogram.h>
-#include <QtOpenGL/qopenglframebufferobject.h>
-
-#include <QPropertyAnimation>
-
-#include <QColor>
-#include <QImage>
-#include <QTime>
-
-QT_BEGIN_NAMESPACE
-class QOpenGLContext;
-QT_END_NAMESPACE
-
-class PaintedWindow : public QWindow
-{
- Q_OBJECT
- Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
-
-public:
- PaintedWindow();
-
- qreal rotation() const { return m_rotation; }
-
-signals:
- void rotationChanged(qreal rotation);
-
-private slots:
- void paint();
- void setRotation(qreal r);
- void orientationChanged(Qt::ScreenOrientation newOrientation);
- void rotationDone();
-
-private:
- void exposeEvent(QExposeEvent *) override;
- void mousePressEvent(QMouseEvent *) override;
-
- void paint(QPainter *painter, const QRect &rect);
-
- QOpenGLContext *m_context;
- qreal m_rotation;
-
- QImage m_prevImage;
- QImage m_nextImage;
- qreal m_deltaRotation;
-
- Qt::ScreenOrientation m_targetOrientation;
- Qt::ScreenOrientation m_nextTargetOrientation;
-
- QPropertyAnimation *m_animation;
- QTimer *m_paintTimer;
-};
diff --git a/examples/opengl/paintedwindow/paintedwindow.pro b/examples/opengl/paintedwindow/paintedwindow.pro
deleted file mode 100644
index 569eebe674..0000000000
--- a/examples/opengl/paintedwindow/paintedwindow.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-QT += opengl
-
-HEADERS += paintedwindow.h
-SOURCES += paintedwindow.cpp main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/opengl/paintedwindow
-INSTALLS += target
diff --git a/examples/opengl/qopenglwidget/CMakeLists.txt b/examples/opengl/qopenglwidget/CMakeLists.txt
deleted file mode 100644
index c5ca16a33b..0000000000
--- a/examples/opengl/qopenglwidget/CMakeLists.txt
+++ /dev/null
@@ -1,59 +0,0 @@
-# Generated from qopenglwidget.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(qopenglwidget LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/qopenglwidget")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS OpenGL)
-find_package(Qt6 COMPONENTS OpenGLWidgets)
-
-qt_add_executable(qopenglwidget
- bubble.cpp bubble.h
- glwidget.cpp glwidget.h
- main.cpp
- mainwindow.cpp mainwindow.h
-)
-set_target_properties(qopenglwidget PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(qopenglwidget PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
- Qt::OpenGLWidgets
- Qt::Widgets
-)
-
-
-# Resources:
-set(texture_resource_files
- "qt.png"
-)
-
-qt6_add_resources(qopenglwidget "texture"
- PREFIX
- "/"
- FILES
- ${texture_resource_files}
-)
-
-install(TARGETS qopenglwidget
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/opengl/qopenglwidget/bubble.cpp b/examples/opengl/qopenglwidget/bubble.cpp
deleted file mode 100644
index 7e69aac3e7..0000000000
--- a/examples/opengl/qopenglwidget/bubble.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "bubble.h"
-
-Bubble::Bubble(const QPointF &position, qreal radius, const QPointF &velocity)
- : position(position), vel(velocity), radius(radius)
-{
- innerColor = randomColor();
- outerColor = randomColor();
- updateBrush();
-}
-
-//! [0]
-void Bubble::updateCache()
-{
- delete cache;
- cache = new QImage(qRound(radius * 2 + 2), qRound(radius * 2 + 2), QImage::Format_ARGB32_Premultiplied);
- cache->fill(0x00000000);
- QPainter p(cache);
- p.setRenderHint(QPainter::Antialiasing);
- QPen pen(Qt::white);
- pen.setWidth(2);
- p.setPen(pen);
- p.setBrush(brush);
- p.drawEllipse(1, 1, int(2*radius), int(2*radius));
-}
-//! [0]
-
-Bubble::~Bubble()
-{
- delete cache;
-}
-
-void Bubble::updateBrush()
-{
- QRadialGradient gradient(QPointF(radius, radius), radius,
- QPointF(radius*0.5, radius*0.5));
-
- gradient.setColorAt(0, QColor(255, 255, 255, 255));
- gradient.setColorAt(0.25, innerColor);
- gradient.setColorAt(1, outerColor);
- brush = QBrush(gradient);
- updateCache();
-}
-
-//! [1]
-void Bubble::drawBubble(QPainter *painter)
-{
- painter->save();
- painter->translate(position.x() - radius, position.y() - radius);
- painter->setOpacity(0.8);
- painter->drawImage(0, 0, *cache);
- painter->restore();
-}
-//! [1]
-
-QColor Bubble::randomColor()
-{
- int red = int(185 + QRandomGenerator::global()->bounded(70));
- int green = int(185 + QRandomGenerator::global()->bounded(70));
- int blue = int(205 + QRandomGenerator::global()->bounded(50));
- int alpha = int(91 + QRandomGenerator::global()->bounded(100));
-
- return QColor(red, green, blue, alpha);
-}
-
-void Bubble::move(const QRect &bbox)
-{
- position += vel;
- qreal leftOverflow = position.x() - radius - bbox.left();
- qreal rightOverflow = position.x() + radius - bbox.right();
- qreal topOverflow = position.y() - radius - bbox.top();
- qreal bottomOverflow = position.y() + radius - bbox.bottom();
-
- if (leftOverflow < 0.0) {
- position.setX(position.x() - 2 * leftOverflow);
- vel.setX(-vel.x());
- } else if (rightOverflow > 0.0) {
- position.setX(position.x() - 2 * rightOverflow);
- vel.setX(-vel.x());
- }
-
- if (topOverflow < 0.0) {
- position.setY(position.y() - 2 * topOverflow);
- vel.setY(-vel.y());
- } else if (bottomOverflow > 0.0) {
- position.setY(position.y() - 2 * bottomOverflow);
- vel.setY(-vel.y());
- }
-}
-
-QRectF Bubble::rect()
-{
- return QRectF(position.x() - radius, position.y() - radius,
- 2 * radius, 2 * radius);
-}
diff --git a/examples/opengl/qopenglwidget/bubble.h b/examples/opengl/qopenglwidget/bubble.h
deleted file mode 100644
index 833ea02288..0000000000
--- a/examples/opengl/qopenglwidget/bubble.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef BUBBLE_H
-#define BUBBLE_H
-
-#include <QBrush>
-#include <QColor>
-#include <QPointF>
-#include <QRect>
-#include <QRectF>
-
-QT_FORWARD_DECLARE_CLASS(QPainter)
-
-class Bubble
-{
-public:
- Bubble(const QPointF &position, qreal radius, const QPointF &velocity);
- ~Bubble();
-
- void drawBubble(QPainter *painter);
- void updateBrush();
- void move(const QRect &bbox);
- void updateCache();
- QRectF rect();
-
-private:
- QColor randomColor();
-
- QBrush brush;
- QPointF position;
- QPointF vel;
- qreal radius;
- QColor innerColor;
- QColor outerColor;
- QImage *cache = nullptr;
-};
-
-#endif
diff --git a/examples/opengl/qopenglwidget/glwidget.cpp b/examples/opengl/qopenglwidget/glwidget.cpp
deleted file mode 100644
index a480fe5726..0000000000
--- a/examples/opengl/qopenglwidget/glwidget.cpp
+++ /dev/null
@@ -1,560 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2016 The Qt Company Ltd.
- ** Contact: https://www.qt.io/licensing/
- **
- ** This file is part of the examples of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:BSD$
- ** Commercial License Usage
- ** Licensees holding valid commercial Qt licenses may use this file in
- ** accordance with the commercial license agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and The Qt Company. For licensing terms
- ** and conditions see https://www.qt.io/terms-conditions. For further
- ** information use the contact form at https://www.qt.io/contact-us.
- **
- ** BSD License Usage
- ** Alternatively, you may use this file under the terms of the BSD license
- ** as follows:
- **
- ** "Redistribution and use in source and binary forms, with or without
- ** modification, are permitted provided that the following conditions are
- ** met:
- ** * Redistributions of source code must retain the above copyright
- ** notice, this list of conditions and the following disclaimer.
- ** * Redistributions in binary form must reproduce the above copyright
- ** notice, this list of conditions and the following disclaimer in
- ** the documentation and/or other materials provided with the
- ** distribution.
- ** * Neither the name of The Qt Company Ltd nor the names of its
- ** contributors may be used to endorse or promote products derived
- ** from this software without specific prior written permission.
- **
- **
- ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- **
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
-
-#include "glwidget.h"
-#include <QPainter>
-#include <QPaintEngine>
-#include <QOpenGLShaderProgram>
-#include <QOpenGLTexture>
-#include <QRandomGenerator>
-#include <QCoreApplication>
-#include <qmath.h>
-
-#include "mainwindow.h"
-#include "bubble.h"
-
-const int bubbleNum = 8;
-
-#ifndef GL_SRGB8_ALPHA8
-#define GL_SRGB8_ALPHA8 0x8C43
-#endif
-
-GLWidget::GLWidget(MainWindow *mw, bool button, const QColor &background)
- : m_mainWindow(mw),
- m_hasButton(button),
- m_background(background)
-{
- setMinimumSize(300, 250);
- if (QCoreApplication::arguments().contains(QStringLiteral("--srgb")))
- setTextureFormat(GL_SRGB8_ALPHA8);
-}
-
-GLWidget::~GLWidget()
-{
- qDeleteAll(m_bubbles);
-
- // And now release all OpenGL resources.
- makeCurrent();
- delete m_texture;
- delete m_program1;
- delete m_program2;
- delete m_vshader1;
- delete m_fshader1;
- delete m_vshader2;
- delete m_fshader2;
- m_vbo1.destroy();
- m_vbo2.destroy();
- doneCurrent();
-}
-
-void GLWidget::setScaling(int scale)
-{
- if (scale > 30)
- m_fScale = 1 + qreal(scale - 30) / 30 * 0.25;
- else if (scale < 30)
- m_fScale = 1 - (qreal(30 - scale) / 30 * 0.25);
- else
- m_fScale = 1;
-}
-
-void GLWidget::setLogo()
-{
- m_qtLogo = true;
-}
-
-void GLWidget::setTexture()
-{
- m_qtLogo = false;
-}
-
-void GLWidget::setShowBubbles(bool bubbles)
-{
- m_showBubbles = bubbles;
-}
-
-void GLWidget::paintQtLogo()
-{
- m_program1->enableAttributeArray(m_vertexAttr1);
- m_program1->enableAttributeArray(m_normalAttr1);
-
- m_vbo1.bind();
- // The data in the buffer is placed like this:
- // vertex1.x, vertex1.y, vertex1.z, normal1.x, normal1.y, normal1.z, vertex2.x, ...
- m_program1->setAttributeBuffer(m_vertexAttr1, GL_FLOAT, 0, 3, 6 * sizeof(GLfloat));
- m_program1->setAttributeBuffer(m_normalAttr1, GL_FLOAT, 3 * sizeof(GLfloat), 3, 6 * sizeof(GLfloat));
- m_vbo1.release();
-
- glDrawArrays(GL_TRIANGLES, 0, m_vertices.size());
-
- m_program1->disableAttributeArray(m_normalAttr1);
- m_program1->disableAttributeArray(m_vertexAttr1);
-}
-
-void GLWidget::paintTexturedCube()
-{
- m_texture->bind();
-
- if (!m_vbo2.isCreated()) {
- static GLfloat afVertices[] = {
- -0.5, 0.5, 0.5, 0.5,-0.5,0.5,-0.5,-0.5,0.5,
- 0.5, -0.5, 0.5, -0.5,0.5,0.5,0.5,0.5,0.5,
- -0.5, -0.5, -0.5, 0.5,-0.5,-0.5,-0.5,0.5,-0.5,
- 0.5, 0.5, -0.5, -0.5,0.5,-0.5,0.5,-0.5,-0.5,
-
- 0.5, -0.5, -0.5, 0.5,-0.5,0.5,0.5,0.5,-0.5,
- 0.5, 0.5, 0.5, 0.5,0.5,-0.5,0.5,-0.5,0.5,
- -0.5, 0.5, -0.5, -0.5,-0.5,0.5,-0.5,-0.5,-0.5,
- -0.5, -0.5, 0.5, -0.5,0.5,-0.5,-0.5,0.5,0.5,
-
- 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5,
- -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5,
- -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5,
- 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5
- };
-
- static GLfloat afTexCoord[] = {
- 0.0f,0.0f, 1.0f,1.0f, 1.0f,0.0f,
- 1.0f,1.0f, 0.0f,0.0f, 0.0f,1.0f,
- 1.0f,1.0f, 1.0f,0.0f, 0.0f,1.0f,
- 0.0f,0.0f, 0.0f,1.0f, 1.0f,0.0f,
-
- 1.0f,1.0f, 1.0f,0.0f, 0.0f,1.0f,
- 0.0f,0.0f, 0.0f,1.0f, 1.0f,0.0f,
- 0.0f,0.0f, 1.0f,1.0f, 1.0f,0.0f,
- 1.0f,1.0f, 0.0f,0.0f, 0.0f,1.0f,
-
- 0.0f,1.0f, 1.0f,0.0f, 1.0f,1.0f,
- 1.0f,0.0f, 0.0f,1.0f, 0.0f,0.0f,
- 1.0f,0.0f, 1.0f,1.0f, 0.0f,0.0f,
- 0.0f,1.0f, 0.0f,0.0f, 1.0f,1.0f
- };
-
- GLfloat afNormals[] = {
-
- 0,0,-1, 0,0,-1, 0,0,-1,
- 0,0,-1, 0,0,-1, 0,0,-1,
- 0,0,1, 0,0,1, 0,0,1,
- 0,0,1, 0,0,1, 0,0,1,
-
- -1,0,0, -1,0,0, -1,0,0,
- -1,0,0, -1,0,0, -1,0,0,
- 1,0,0, 1,0,0, 1,0,0,
- 1,0,0, 1,0,0, 1,0,0,
-
- 0,-1,0, 0,-1,0, 0,-1,0,
- 0,-1,0, 0,-1,0, 0,-1,0,
- 0,1,0, 0,1,0, 0,1,0,
- 0,1,0, 0,1,0, 0,1,0
- };
-
- m_vbo2.create();
- m_vbo2.bind();
- m_vbo2.allocate(36 * 8 * sizeof(GLfloat));
- m_vbo2.write(0, afVertices, sizeof(afVertices));
- m_vbo2.write(sizeof(afVertices), afTexCoord, sizeof(afTexCoord));
- m_vbo2.write(sizeof(afVertices) + sizeof(afTexCoord), afNormals, sizeof(afNormals));
- m_vbo2.release();
- }
-
- m_program2->setUniformValue(m_textureUniform2, 0); // use texture unit 0
-
- m_program2->enableAttributeArray(m_vertexAttr2);
- m_program2->enableAttributeArray(m_normalAttr2);
- m_program2->enableAttributeArray(m_texCoordAttr2);
-
- m_vbo2.bind();
- // In the buffer we first have 36 vertices (3 floats for each), then 36 texture
- // coordinates (2 floats for each), then 36 normals (3 floats for each).
- m_program2->setAttributeBuffer(m_vertexAttr2, GL_FLOAT, 0, 3);
- m_program2->setAttributeBuffer(m_texCoordAttr2, GL_FLOAT, 36 * 3 * sizeof(GLfloat), 2);
- m_program2->setAttributeBuffer(m_normalAttr2, GL_FLOAT, 36 * 5 * sizeof(GLfloat), 3);
- m_vbo2.release();
-
- glDrawArrays(GL_TRIANGLES, 0, 36);
-
- m_program2->disableAttributeArray(m_vertexAttr2);
- m_program2->disableAttributeArray(m_normalAttr2);
- m_program2->disableAttributeArray(m_texCoordAttr2);
-}
-
-void GLWidget::initializeGL()
-{
- initializeOpenGLFunctions();
-
- m_texture = new QOpenGLTexture(QImage(":/qt.png"));
-
- m_vshader1 = new QOpenGLShader(QOpenGLShader::Vertex);
- const char *vsrc1 =
- "attribute highp vec4 vertex;\n"
- "attribute mediump vec3 normal;\n"
- "uniform mediump mat4 matrix;\n"
- "varying mediump vec4 color;\n"
- "void main(void)\n"
- "{\n"
- " vec3 toLight = normalize(vec3(0.0, 0.3, 1.0));\n"
- " float angle = max(dot(normal, toLight), 0.0);\n"
- " vec3 col = vec3(0.40, 1.0, 0.0);\n"
- " color = vec4(col * 0.2 + col * 0.8 * angle, 1.0);\n"
- " color = clamp(color, 0.0, 1.0);\n"
- " gl_Position = matrix * vertex;\n"
- "}\n";
- m_vshader1->compileSourceCode(vsrc1);
-
- m_fshader1 = new QOpenGLShader(QOpenGLShader::Fragment);
- const char *fsrc1 =
- "varying mediump vec4 color;\n"
- "void main(void)\n"
- "{\n"
- " gl_FragColor = color;\n"
- "}\n";
- m_fshader1->compileSourceCode(fsrc1);
-
- m_program1 = new QOpenGLShaderProgram;
- m_program1->addShader(m_vshader1);
- m_program1->addShader(m_fshader1);
- m_program1->link();
-
- m_vertexAttr1 = m_program1->attributeLocation("vertex");
- m_normalAttr1 = m_program1->attributeLocation("normal");
- m_matrixUniform1 = m_program1->uniformLocation("matrix");
-
- m_vshader2 = new QOpenGLShader(QOpenGLShader::Vertex);
- const char *vsrc2 =
- "attribute highp vec4 vertex;\n"
- "attribute highp vec4 texCoord;\n"
- "attribute mediump vec3 normal;\n"
- "uniform mediump mat4 matrix;\n"
- "varying highp vec4 texc;\n"
- "varying mediump float angle;\n"
- "void main(void)\n"
- "{\n"
- " vec3 toLight = normalize(vec3(0.0, 0.3, 1.0));\n"
- " angle = max(dot(normal, toLight), 0.0);\n"
- " gl_Position = matrix * vertex;\n"
- " texc = texCoord;\n"
- "}\n";
- m_vshader2->compileSourceCode(vsrc2);
-
- m_fshader2 = new QOpenGLShader(QOpenGLShader::Fragment);
- const char *fsrc2 =
- "varying highp vec4 texc;\n"
- "uniform sampler2D tex;\n"
- "varying mediump float angle;\n"
- "void main(void)\n"
- "{\n"
- " highp vec3 color = texture2D(tex, texc.st).rgb;\n"
- " color = color * 0.2 + color * 0.8 * angle;\n"
- " gl_FragColor = vec4(clamp(color, 0.0, 1.0), 1.0);\n"
- "}\n";
- m_fshader2->compileSourceCode(fsrc2);
-
- m_program2 = new QOpenGLShaderProgram;
- m_program2->addShader(m_vshader2);
- m_program2->addShader(m_fshader2);
- m_program2->link();
-
- m_vertexAttr2 = m_program2->attributeLocation("vertex");
- m_normalAttr2 = m_program2->attributeLocation("normal");
- m_texCoordAttr2 = m_program2->attributeLocation("texCoord");
- m_matrixUniform2 = m_program2->uniformLocation("matrix");
- m_textureUniform2 = m_program2->uniformLocation("tex");
-
- m_fAngle = 0;
- m_fScale = 1;
-
- createGeometry();
-
- // Use a vertex buffer object. Client-side pointers are old-school and should be avoided.
- m_vbo1.create();
- m_vbo1.bind();
- // For the cube all the data belonging to the texture coordinates and
- // normals is placed separately, after the vertices. Here, for the Qt logo,
- // let's do something different and potentially more efficient: create a
- // properly interleaved data set.
- const int vertexCount = m_vertices.count();
- QList<GLfloat> buf;
- buf.resize(vertexCount * 3 * 2);
- GLfloat *p = buf.data();
- for (int i = 0; i < vertexCount; ++i) {
- *p++ = m_vertices[i].x();
- *p++ = m_vertices[i].y();
- *p++ = m_vertices[i].z();
- *p++ = m_normals[i].x();
- *p++ = m_normals[i].y();
- *p++ = m_normals[i].z();
- }
- m_vbo1.allocate(buf.constData(), buf.count() * sizeof(GLfloat));
- m_vbo1.release();
-
- createBubbles(bubbleNum - m_bubbles.count());
-}
-
-void GLWidget::paintGL()
-{
- createBubbles(bubbleNum - m_bubbles.count());
-
- QPainter painter;
- painter.begin(this);
-
- painter.beginNativePainting();
-
- glClearColor(m_background.redF(), m_background.greenF(), m_background.blueF(), m_transparent ? 0.0f : 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- glFrontFace(GL_CW);
- glCullFace(GL_FRONT);
- glEnable(GL_CULL_FACE);
- glEnable(GL_DEPTH_TEST);
-
- QMatrix4x4 modelview;
- modelview.rotate(m_fAngle, 0.0f, 1.0f, 0.0f);
- modelview.rotate(m_fAngle, 1.0f, 0.0f, 0.0f);
- modelview.rotate(m_fAngle, 0.0f, 0.0f, 1.0f);
- modelview.scale(m_fScale);
- modelview.translate(0.0f, -0.2f, 0.0f);
-
- if (m_qtLogo) {
- m_program1->bind();
- m_program1->setUniformValue(m_matrixUniform1, modelview);
- paintQtLogo();
- m_program1->release();
- } else {
- m_program2->bind();
- m_program2->setUniformValue(m_matrixUniform2, modelview);
- paintTexturedCube();
- m_program2->release();
- }
-
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_CULL_FACE);
-
- painter.endNativePainting();
-
- if (m_showBubbles) {
- for (Bubble *bubble : qAsConst(m_bubbles))
- bubble->drawBubble(&painter);
- }
-
- if (const int elapsed = m_time.elapsed()) {
- QString framesPerSecond;
- framesPerSecond.setNum(m_frames /(elapsed / 1000.0), 'f', 2);
- painter.setPen(m_transparent ? Qt::black : Qt::white);
- painter.drawText(20, 40, framesPerSecond + " paintGL calls / s");
- }
-
- painter.end();
-
- for (Bubble *bubble : qAsConst(m_bubbles))
- bubble->move(rect());
-
- if (!(m_frames % 100)) {
- m_time.start();
- m_frames = 0;
- }
- m_fAngle += 1.0f;
- ++m_frames;
-
- // When requested, follow the ideal way to animate: Rely on
- // blocking swap and just schedule updates continuously.
- if (!m_mainWindow->timerEnabled())
- update();
-}
-
-void GLWidget::createBubbles(int number)
-{
- for (int i = 0; i < number; ++i) {
- QPointF position(width()*(0.1 + QRandomGenerator::global()->bounded(0.8)),
- height()*(0.1 + QRandomGenerator::global()->bounded(0.8)));
- qreal radius = qMin(width(), height())*(0.0175 + QRandomGenerator::global()->bounded(0.0875));
- QPointF velocity(width()*0.0175*(-0.5 + QRandomGenerator::global()->bounded(1.0)),
- height()*0.0175*(-0.5 + QRandomGenerator::global()->bounded(1.0)));
-
- m_bubbles.append(new Bubble(position, radius, velocity));
- }
-}
-
-void GLWidget::createGeometry()
-{
- m_vertices.clear();
- m_normals.clear();
-
- qreal x1 = +0.06f;
- qreal y1 = -0.14f;
- qreal x2 = +0.14f;
- qreal y2 = -0.06f;
- qreal x3 = +0.08f;
- qreal y3 = +0.00f;
- qreal x4 = +0.30f;
- qreal y4 = +0.22f;
-
- quad(x1, y1, x2, y2, y2, x2, y1, x1);
- quad(x3, y3, x4, y4, y4, x4, y3, x3);
-
- extrude(x1, y1, x2, y2);
- extrude(x2, y2, y2, x2);
- extrude(y2, x2, y1, x1);
- extrude(y1, x1, x1, y1);
- extrude(x3, y3, x4, y4);
- extrude(x4, y4, y4, x4);
- extrude(y4, x4, y3, x3);
-
- const int NumSectors = 100;
- const qreal sectorAngle = 2 * qreal(M_PI) / NumSectors;
-
- for (int i = 0; i < NumSectors; ++i) {
- qreal angle = i * sectorAngle;
- qreal x5 = 0.30 * sin(angle);
- qreal y5 = 0.30 * cos(angle);
- qreal x6 = 0.20 * sin(angle);
- qreal y6 = 0.20 * cos(angle);
-
- angle += sectorAngle;
- qreal x7 = 0.20 * sin(angle);
- qreal y7 = 0.20 * cos(angle);
- qreal x8 = 0.30 * sin(angle);
- qreal y8 = 0.30 * cos(angle);
-
- quad(x5, y5, x6, y6, x7, y7, x8, y8);
-
- extrude(x6, y6, x7, y7);
- extrude(x8, y8, x5, y5);
- }
-
- for (int i = 0;i < m_vertices.size();i++)
- m_vertices[i] *= 2.0f;
-}
-
-void GLWidget::quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4)
-{
- m_vertices << QVector3D(x1, y1, -0.05f);
- m_vertices << QVector3D(x2, y2, -0.05f);
- m_vertices << QVector3D(x4, y4, -0.05f);
-
- m_vertices << QVector3D(x3, y3, -0.05f);
- m_vertices << QVector3D(x4, y4, -0.05f);
- m_vertices << QVector3D(x2, y2, -0.05f);
-
- QVector3D n = QVector3D::normal
- (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(x4 - x1, y4 - y1, 0.0f));
-
- m_normals << n;
- m_normals << n;
- m_normals << n;
-
- m_normals << n;
- m_normals << n;
- m_normals << n;
-
- m_vertices << QVector3D(x4, y4, 0.05f);
- m_vertices << QVector3D(x2, y2, 0.05f);
- m_vertices << QVector3D(x1, y1, 0.05f);
-
- m_vertices << QVector3D(x2, y2, 0.05f);
- m_vertices << QVector3D(x4, y4, 0.05f);
- m_vertices << QVector3D(x3, y3, 0.05f);
-
- n = QVector3D::normal
- (QVector3D(x2 - x4, y2 - y4, 0.0f), QVector3D(x1 - x4, y1 - y4, 0.0f));
-
- m_normals << n;
- m_normals << n;
- m_normals << n;
-
- m_normals << n;
- m_normals << n;
- m_normals << n;
-}
-
-void GLWidget::extrude(qreal x1, qreal y1, qreal x2, qreal y2)
-{
- m_vertices << QVector3D(x1, y1, +0.05f);
- m_vertices << QVector3D(x2, y2, +0.05f);
- m_vertices << QVector3D(x1, y1, -0.05f);
-
- m_vertices << QVector3D(x2, y2, -0.05f);
- m_vertices << QVector3D(x1, y1, -0.05f);
- m_vertices << QVector3D(x2, y2, +0.05f);
-
- QVector3D n = QVector3D::normal
- (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(0.0f, 0.0f, -0.1f));
-
- m_normals << n;
- m_normals << n;
- m_normals << n;
-
- m_normals << n;
- m_normals << n;
- m_normals << n;
-}
-
-void GLWidget::setTransparent(bool transparent)
-{
- setAttribute(Qt::WA_AlwaysStackOnTop, transparent);
- m_transparent = transparent;
- // Call update() on the top-level window after toggling AlwayStackOnTop to make sure
- // the entire backingstore is updated accordingly.
- window()->update();
-}
-
-void GLWidget::resizeGL(int, int)
-{
- if (m_hasButton) {
- if (!m_btn) {
- m_btn = new QPushButton("A widget on top.\nPress for more widgets.", this);
- connect(m_btn, &QPushButton::clicked, this, &GLWidget::handleButtonPress);
- }
- m_btn->move(20, 80);
- }
-}
-
-void GLWidget::handleButtonPress()
-{
- m_mainWindow->addNew();
-}
diff --git a/examples/opengl/qopenglwidget/glwidget.h b/examples/opengl/qopenglwidget/glwidget.h
deleted file mode 100644
index 50f8aa9be5..0000000000
--- a/examples/opengl/qopenglwidget/glwidget.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef GLWIDGET_H
-#define GLWIDGET_H
-
-#include <QOpenGLWidget>
-#include <QOpenGLFunctions>
-#include <QOpenGLBuffer>
-#include <QVector3D>
-#include <QMatrix4x4>
-#include <QElapsedTimer>
-#include <QList>
-#include <QPushButton>
-
-class Bubble;
-class MainWindow;
-
-QT_FORWARD_DECLARE_CLASS(QOpenGLTexture)
-QT_FORWARD_DECLARE_CLASS(QOpenGLShader)
-QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
-
-class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
-{
- Q_OBJECT
-public:
- GLWidget(MainWindow *mw, bool button, const QColor &background);
- ~GLWidget();
-
-public slots:
- void setScaling(int scale);
- void setLogo();
- void setTexture();
- void setShowBubbles(bool);
- void setTransparent(bool transparent);
-
-private slots:
- void handleButtonPress();
-
-protected:
- void resizeGL(int w, int h) override;
- void paintGL() override;
- void initializeGL() override;
-
-private:
- void paintTexturedCube();
- void paintQtLogo();
- void createGeometry();
- void createBubbles(int number);
- void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4);
- void extrude(qreal x1, qreal y1, qreal x2, qreal y2);
-
- MainWindow *m_mainWindow;
- qreal m_fAngle = 0;
- qreal m_fScale = 1;
- bool m_showBubbles = true;
- QList<QVector3D> m_vertices;
- QList<QVector3D> m_normals;
- bool m_qtLogo = true;
- QList<Bubble *> m_bubbles;
- int m_frames = 0;
- QElapsedTimer m_time;
- QOpenGLShader *m_vshader1 = nullptr;
- QOpenGLShader *m_fshader1 = nullptr;
- QOpenGLShader *m_vshader2 = nullptr;
- QOpenGLShader *m_fshader2 = nullptr;
- QOpenGLShaderProgram *m_program1 = nullptr;
- QOpenGLShaderProgram *m_program2 = nullptr;
- QOpenGLTexture *m_texture = nullptr;
- QOpenGLBuffer m_vbo1;
- QOpenGLBuffer m_vbo2;
- int m_vertexAttr1 = 0;
- int m_normalAttr1 = 0;
- int m_matrixUniform1 = 0;
- int m_vertexAttr2 = 0;
- int m_normalAttr2 = 0;
- int m_texCoordAttr2 = 0;
- int m_matrixUniform2 = 0;
- int m_textureUniform2 = 0;
- bool m_transparent = false;
- QPushButton *m_btn = nullptr;
- bool m_hasButton;
- QColor m_background;
-};
-
-#endif
diff --git a/examples/opengl/qopenglwidget/main.cpp b/examples/opengl/qopenglwidget/main.cpp
deleted file mode 100644
index 968b2a7258..0000000000
--- a/examples/opengl/qopenglwidget/main.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <QMainWindow>
-#include <QColorSpace>
-#include <QSurfaceFormat>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-#include "mainwindow.h"
-
-int main( int argc, char ** argv )
-{
- Q_INIT_RESOURCE(texture);
- QApplication a( argc, argv );
-
- QCoreApplication::setApplicationName("Qt QOpenGLWidget Example");
- QCoreApplication::setOrganizationName("QtProject");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription(QCoreApplication::applicationName());
- parser.addHelpOption();
- parser.addVersionOption();
- QCommandLineOption multipleSampleOption("multisample", "Multisampling");
- parser.addOption(multipleSampleOption);
- QCommandLineOption srgbOption("srgb", "Use sRGB Color Space");
- parser.addOption(srgbOption);
- parser.process(a);
-
- QSurfaceFormat format;
- format.setDepthBufferSize(24);
- format.setStencilBufferSize(8);
- if (parser.isSet(srgbOption))
- format.setColorSpace(QColorSpace::SRgb);
- if (parser.isSet(multipleSampleOption))
- format.setSamples(4);
- QSurfaceFormat::setDefaultFormat(format);
-
- MainWindow mw;
- mw.showMaximized();
- return a.exec();
-}
diff --git a/examples/opengl/qopenglwidget/mainwindow.cpp b/examples/opengl/qopenglwidget/mainwindow.cpp
deleted file mode 100644
index eb34f87cb7..0000000000
--- a/examples/opengl/qopenglwidget/mainwindow.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mainwindow.h"
-
-#include <QApplication>
-#include <QMenuBar>
-#include <QGroupBox>
-#include <QSlider>
-#include <QLabel>
-#include <QCheckBox>
-#include <QRandomGenerator>
-#include <QSpinBox>
-#include <QScrollArea>
-
-#include "glwidget.h"
-
-MainWindow::MainWindow()
- : m_nextX(1), m_nextY(1)
-{
- GLWidget *glwidget = new GLWidget(this, true, qRgb(20, 20, 50));
- m_glWidgets << glwidget;
- QLabel *label = new QLabel(this);
- m_timer = new QTimer(this);
- QSlider *slider = new QSlider(this);
- slider->setOrientation(Qt::Horizontal);
-
- QLabel *updateLabel = new QLabel("Update interval");
- QSpinBox *updateInterval = new QSpinBox(this);
- updateInterval->setSuffix(" ms");
- updateInterval->setValue(10);
- updateInterval->setToolTip("Interval for the timer that calls update().\n"
- "Note that on most systems the swap will block to wait for vsync\n"
- "and therefore an interval < 16 ms will likely lead to a 60 FPS update rate.");
- QGroupBox *updateGroupBox = new QGroupBox(this);
- QCheckBox *timerBased = new QCheckBox("Use timer", this);
- timerBased->setChecked(false);
- timerBased->setToolTip("Toggles using a timer to trigger update().\n"
- "When not set, each paintGL() schedules the next update immediately,\n"
- "expecting the blocking swap to throttle the thread.\n"
- "This shows how unnecessary the timer is in most cases.");
- QCheckBox *transparent = new QCheckBox("Transparent background", this);
- transparent->setToolTip("Toggles Qt::WA_AlwaysStackOnTop and transparent clear color for glClear().\n"
- "Note how the button on top stacks incorrectly when enabling this.");
- QHBoxLayout *updateLayout = new QHBoxLayout;
- updateLayout->addWidget(updateLabel);
- updateLayout->addWidget(updateInterval);
- updateLayout->addWidget(timerBased);
- updateLayout->addWidget(transparent);
- updateGroupBox->setLayout(updateLayout);
-
- slider->setRange(0, 50);
- slider->setSliderPosition(30);
- m_timer->setInterval(10);
- label->setText("A scrollable QOpenGLWidget");
- label->setAlignment(Qt::AlignHCenter);
-
- QGroupBox * groupBox = new QGroupBox(this);
- setCentralWidget(groupBox);
- groupBox->setTitle("QOpenGLWidget Example");
-
- m_layout = new QGridLayout(groupBox);
-
- QScrollArea *scrollArea = new QScrollArea;
- scrollArea->setWidget(glwidget);
-
- m_layout->addWidget(scrollArea,1,0,8,1);
- m_layout->addWidget(label,9,0,1,1);
- m_layout->addWidget(updateGroupBox, 10, 0, 1, 1);
- m_layout->addWidget(slider, 11,0,1,1);
-
- groupBox->setLayout(m_layout);
-
-
- QMenu *fileMenu = menuBar()->addMenu("&File");
- fileMenu->addAction("E&xit", this, &QWidget::close);
- QMenu *showMenu = menuBar()->addMenu("&Show");
- showMenu->addAction("Show 3D Logo", glwidget, &GLWidget::setLogo);
- showMenu->addAction("Show 2D Texture", glwidget, &GLWidget::setTexture);
- QAction *showBubbles = showMenu->addAction("Show bubbles", glwidget, &GLWidget::setShowBubbles);
- showBubbles->setCheckable(true);
- showBubbles->setChecked(true);
- QMenu *helpMenu = menuBar()->addMenu("&Help");
- helpMenu->addAction("About Qt", qApp, &QApplication::aboutQt);
-
- connect(m_timer, &QTimer::timeout, glwidget, QOverload<>::of(&QWidget::update));
-
- connect(slider, &QAbstractSlider::valueChanged, glwidget, &GLWidget::setScaling);
- connect(transparent, &QCheckBox::toggled, glwidget, &GLWidget::setTransparent);
- connect(updateInterval, &QSpinBox::valueChanged,
- this, &MainWindow::updateIntervalChanged);
- connect(timerBased, &QCheckBox::toggled, this, &MainWindow::timerUsageChanged);
- connect(timerBased, &QCheckBox::toggled, updateInterval, &QWidget::setEnabled);
-
- if (timerBased->isChecked())
- m_timer->start();
- else
- updateInterval->setEnabled(false);
-}
-
-void MainWindow::updateIntervalChanged(int value)
-{
- m_timer->setInterval(value);
- if (m_timer->isActive())
- m_timer->start();
-}
-
-void MainWindow::addNew()
-{
- if (m_nextY == 4)
- return;
- GLWidget *w = new GLWidget(this, false, qRgb(QRandomGenerator::global()->bounded(256),
- QRandomGenerator::global()->bounded(256),
- QRandomGenerator::global()->bounded(256)));
- m_glWidgets << w;
- connect(m_timer, &QTimer::timeout, w, QOverload<>::of(&QWidget::update));
- m_layout->addWidget(w, m_nextY, m_nextX, 1, 1);
- if (m_nextX == 3) {
- m_nextX = 1;
- ++m_nextY;
- } else {
- ++m_nextX;
- }
-}
-
-void MainWindow::timerUsageChanged(bool enabled)
-{
- if (enabled) {
- m_timer->start();
- } else {
- m_timer->stop();
- for (QOpenGLWidget *w : qAsConst(m_glWidgets))
- w->update();
- }
-}
-
-void MainWindow::resizeEvent(QResizeEvent *)
-{
- m_glWidgets[0]->setMinimumSize(size() + QSize(128, 128));
-}
diff --git a/examples/opengl/qopenglwidget/mainwindow.h b/examples/opengl/qopenglwidget/mainwindow.h
deleted file mode 100644
index 43cc55100e..0000000000
--- a/examples/opengl/qopenglwidget/mainwindow.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include <QTimer>
-#include <QGridLayout>
-
-QT_FORWARD_DECLARE_CLASS(QOpenGLWidget)
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
- void addNew();
- bool timerEnabled() const { return m_timer->isActive(); }
-
- void resizeEvent(QResizeEvent *);
-
-private slots:
- void updateIntervalChanged(int value);
- void timerUsageChanged(bool enabled);
-
-private:
- QTimer *m_timer;
- QGridLayout *m_layout;
- int m_nextX;
- int m_nextY;
- QList<QOpenGLWidget *> m_glWidgets;
-};
-
-#endif
diff --git a/examples/opengl/qopenglwidget/qopenglwidget.pro b/examples/opengl/qopenglwidget/qopenglwidget.pro
deleted file mode 100644
index 7ac546d7ce..0000000000
--- a/examples/opengl/qopenglwidget/qopenglwidget.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-QT += widgets opengl openglwidgets
-
-SOURCES += main.cpp \
- glwidget.cpp \
- mainwindow.cpp \
- bubble.cpp
-
-HEADERS += glwidget.h \
- mainwindow.h \
- bubble.h
-
-RESOURCES += texture.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/opengl/qopenglwidget
-INSTALLS += target
diff --git a/examples/opengl/qopenglwidget/qt.png b/examples/opengl/qopenglwidget/qt.png
deleted file mode 100644
index 4f68e162de..0000000000
--- a/examples/opengl/qopenglwidget/qt.png
+++ /dev/null
Binary files differ
diff --git a/examples/opengl/qopenglwidget/texture.qrc b/examples/opengl/qopenglwidget/texture.qrc
deleted file mode 100644
index ff1d0e535f..0000000000
--- a/examples/opengl/qopenglwidget/texture.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>qt.png</file>
-</qresource>
-</RCC>
diff --git a/examples/opengl/qopenglwindow/CMakeLists.txt b/examples/opengl/qopenglwindow/CMakeLists.txt
deleted file mode 100644
index 93909b516e..0000000000
--- a/examples/opengl/qopenglwindow/CMakeLists.txt
+++ /dev/null
@@ -1,57 +0,0 @@
-# Generated from qopenglwindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(qopenglwindow LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/qopenglwindow")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS OpenGL)
-
-qt_add_executable(qopenglwindow
- background_renderer.cpp background_renderer.h
- main.cpp
-)
-set_target_properties(qopenglwindow PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_include_directories(qopenglwindow PUBLIC
- .
-)
-
-target_link_libraries(qopenglwindow PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
-)
-
-
-# Resources:
-set(shaders_resource_files
- "background.frag"
-)
-
-qt6_add_resources(qopenglwindow "shaders"
- PREFIX
- "/"
- FILES
- ${shaders_resource_files}
-)
-
-install(TARGETS qopenglwindow
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/opengl/qopenglwindow/background.frag b/examples/opengl/qopenglwindow/background.frag
deleted file mode 100644
index 4af85aae8e..0000000000
--- a/examples/opengl/qopenglwindow/background.frag
+++ /dev/null
@@ -1,30 +0,0 @@
-#define M_PI 3.14159265358979323846
-#define SPEED 10000.0
-
-uniform int currentTime;
-uniform highp vec2 windowSize;
-
-highp float noise(highp vec2 co)
-{
- return 0.5 * fract(sin(dot(co.xy, vec2(12.9898,78.233))) * 43758.5453);
-}
-
-highp float curvSpeed()
-{
- return (mod(float(currentTime), SPEED) / SPEED) * (2.0 * M_PI);
-}
-
-highp float curv(int curvCount)
-{
- highp float curv_y = 0.1 *(cos((gl_FragCoord.x / windowSize.x) * (float(curvCount * 2) * M_PI) - curvSpeed())) + 0.5;
- highp float frag_y = gl_FragCoord.y / windowSize.y;
- return 1.0 - abs(curv_y - frag_y);
-}
-
-void main()
-{
- highp float coordNoise = noise(gl_FragCoord.xy);
- highp float proximity = smoothstep(0.85, 1.0, (curv(6) + 1.0) * (coordNoise ));
- highp vec3 color = vec3(coordNoise) * proximity;
- gl_FragColor = vec4(color, 1.0);
-}
diff --git a/examples/opengl/qopenglwindow/background_renderer.cpp b/examples/opengl/qopenglwindow/background_renderer.cpp
deleted file mode 100644
index acbbe74841..0000000000
--- a/examples/opengl/qopenglwindow/background_renderer.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "background_renderer.h"
-
-#include <qmath.h>
-#include <QFileInfo>
-#include <QTime>
-
-#include <QOpenGLShaderProgram>
-#include <QOpenGLContext>
-#include <QOpenGLFunctions>
-
-#include <math.h>
-
-static const char vertex_shader[] =
- "attribute highp vec3 vertexCoord;"
- "void main() {"
- " gl_Position = vec4(vertexCoord,1.0);"
- "}";
-
-static const char fragment_shader[] =
- "void main() {"
- " gl_FragColor = vec4(0.0,1.0,0.0,1.0);"
- "}";
-
-static const float vertices[] = { -1, -1, 0,
- -1, 1, 0,
- 1, -1, 0,
- 1, 1, 0 };
-
-FragmentToy::FragmentToy(const QString &fragmentSource, QObject *parent)
- : QObject(parent)
- , m_recompile_shaders(true)
-{
- if (QFile::exists(fragmentSource)) {
- QFileInfo info(fragmentSource);
- m_fragment_file_last_modified = info.lastModified();
- m_fragment_file = fragmentSource;
-#if QT_CONFIG(filesystemwatcher)
- m_watcher.addPath(info.canonicalPath());
- QObject::connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &FragmentToy::fileChanged);
-#endif
- }
-}
-
-FragmentToy::~FragmentToy()
- = default;
-
-void FragmentToy::draw(const QSize &windowSize)
-{
- if (!m_program)
- initializeOpenGLFunctions();
-
- glDisable(GL_STENCIL_TEST);
- glDisable(GL_DEPTH_TEST);
-
- glClearColor(0, 0, 0, 1);
- glClear(GL_COLOR_BUFFER_BIT);
- if (!m_vao.isCreated())
- m_vao.create();
-
- QOpenGLVertexArrayObject::Binder binder(&m_vao);
-
- if (!m_vertex_buffer.isCreated()) {
- m_vertex_buffer.create();
- m_vertex_buffer.bind();
- m_vertex_buffer.allocate(vertices, sizeof(vertices));
- m_vertex_buffer.release();
- }
-
- if (!m_program) {
- m_program.reset(new QOpenGLShaderProgram);
- m_program->create();
- m_vertex_shader.reset(new QOpenGLShader(QOpenGLShader::Vertex));
- if (!m_vertex_shader->compileSourceCode(vertex_shader)) {
- qWarning() << "Failed to compile the vertex shader:" << m_vertex_shader->log();
- }
- if (!m_program->addShader(m_vertex_shader.get())) {
- qWarning() << "Failed to add vertex shader to program:" << m_program->log();
- }
- }
-
- if (!m_fragment_shader && m_recompile_shaders) {
- QByteArray data;
- if (m_fragment_file.size()) {
- QFile file(m_fragment_file);
- if (file.open(QIODevice::ReadOnly)) {
- data = file.readAll();
- } else {
- qWarning() << "Failed to load input file, falling back to default";
- data = QByteArray::fromRawData(fragment_shader, sizeof(fragment_shader));
- }
- } else {
- QFile qrcFile(":/background.frag");
- if (qrcFile.open(QIODevice::ReadOnly))
- data = qrcFile.readAll();
- else
- data = QByteArray::fromRawData(fragment_shader, sizeof(fragment_shader));
- }
- if (data.size()) {
- m_fragment_shader.reset(new QOpenGLShader(QOpenGLShader::Fragment));
- if (!m_fragment_shader->compileSourceCode(data)) {
- qWarning() << "Failed to compile fragment shader:" << m_fragment_shader->log();
- m_fragment_shader.reset(nullptr);
- }
- } else {
- qWarning() << "Unknown error, no fragment shader";
- }
-
- if (m_fragment_shader) {
- if (!m_program->addShader(m_fragment_shader.get())) {
- qWarning() << "Failed to add fragment shader to program:" << m_program->log();
- }
- }
- }
-
- if (m_recompile_shaders) {
- m_recompile_shaders = false;
-
- if (m_program->link()) {
- m_vertex_coord_pos = m_program->attributeLocation("vertexCoord");
- } else {
- qWarning() << "Failed to link shader program" << m_program->log();
- }
-
- }
-
- if (!m_program->isLinked())
- return;
-
- m_program->bind();
-
- m_vertex_buffer.bind();
- m_program->setAttributeBuffer("vertexCoord", GL_FLOAT, 0, 3, 0);
- m_program->enableAttributeArray("vertexCoord");
- m_vertex_buffer.release();
-
- m_program->setUniformValue("currentTime", (uint) QDateTime::currentMSecsSinceEpoch());
- m_program->setUniformValue("windowSize", windowSize);
-
- QOpenGLContext::currentContext()->functions()->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- m_program->release();
-}
-
-void FragmentToy::fileChanged(const QString &path)
-{
- Q_UNUSED(path);
- if (QFile::exists(m_fragment_file)) {
- QFileInfo fragment_source(m_fragment_file);
- if (fragment_source.lastModified() > m_fragment_file_last_modified) {
- m_fragment_file_last_modified = fragment_source.lastModified();
- m_recompile_shaders = true;
- if (m_program) {
- m_program->removeShader(m_fragment_shader.get());
- m_fragment_shader.reset(nullptr);
- }
- }
- } else {
- m_recompile_shaders = true;
- if (m_program) {
- m_program->removeShader(m_fragment_shader.get());
- m_fragment_shader.reset(nullptr);
- }
- }
-}
diff --git a/examples/opengl/qopenglwindow/background_renderer.h b/examples/opengl/qopenglwindow/background_renderer.h
deleted file mode 100644
index 0e3caf5981..0000000000
--- a/examples/opengl/qopenglwindow/background_renderer.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef FRAGMENT_TOY_H
-#define FRAGMENT_TOY_H
-
-#include <QObject>
-#include <QFile>
-#include <QDateTime>
-#if QT_CONFIG(filesystemwatcher)
-#include <QFileSystemWatcher>
-#endif
-#include <QOpenGLVertexArrayObject>
-#include <QOpenGLBuffer>
-#include <QOpenGLShaderProgram>
-#include <QOpenGLFunctions>
-
-#include <memory>
-
-class FragmentToy : public QObject, protected QOpenGLFunctions
-{
- Q_OBJECT
-public:
- explicit FragmentToy(const QString &fragmentSource, QObject *parent = nullptr);
- ~FragmentToy();
-
- void draw(const QSize &windowSize);
-
-private:
- void fileChanged(const QString &path);
- bool m_recompile_shaders;
-#if QT_CONFIG(filesystemwatcher)
- QFileSystemWatcher m_watcher;
-#endif
- QString m_fragment_file;
- QDateTime m_fragment_file_last_modified;
-
- std::unique_ptr<QOpenGLShaderProgram> m_program;
- std::unique_ptr<QOpenGLShader> m_vertex_shader;
- std::unique_ptr<QOpenGLShader> m_fragment_shader;
- QOpenGLVertexArrayObject m_vao;
- QOpenGLBuffer m_vertex_buffer;
- GLuint m_vertex_coord_pos;
-};
-
-#endif //FRAGMENT_TOY_H
diff --git a/examples/opengl/qopenglwindow/main.cpp b/examples/opengl/qopenglwindow/main.cpp
deleted file mode 100644
index 7ce4dd0977..0000000000
--- a/examples/opengl/qopenglwindow/main.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QOpenGLWindow>
-#include <QScreen>
-#include <QPainter>
-#include <QPainterPath>
-#include <QGuiApplication>
-#include <QMatrix4x4>
-#include <QStaticText>
-#include <QKeyEvent>
-
-#include "background_renderer.h"
-
-static QPainterPath painterPathForTriangle()
-{
- static const QPointF bottomLeft(-1.0, -1.0);
- static const QPointF top(0.0, 1.0);
- static const QPointF bottomRight(1.0, -1.0);
-
- QPainterPath path(bottomLeft);
- path.lineTo(top);
- path.lineTo(bottomRight);
- path.closeSubpath();
- return path;
-}
-
-class OpenGLWindow : public QOpenGLWindow
-{
- Q_OBJECT
-
-public:
- OpenGLWindow();
-
-protected:
- void paintGL() override;
- void resizeGL(int w, int h) override;
- void keyPressEvent(QKeyEvent *e) override;
-
-private:
- void setAnimating(bool enabled);
-
- QMatrix4x4 m_window_normalised_matrix;
- QMatrix4x4 m_window_painter_matrix;
- QMatrix4x4 m_projection;
- QMatrix4x4 m_view;
- QMatrix4x4 m_model_triangle;
- QMatrix4x4 m_model_text;
-
- FragmentToy m_fragment_toy;
- QStaticText m_text_layout;
- bool m_animate;
-};
-
-// Use NoPartialUpdate. This means that all the rendering goes directly to
-// the window surface, no additional framebuffer object stands in the
-// middle. This is fine since we will clear the entire framebuffer on each
-// paint. Under the hood this means that the behavior is equivalent to the
-// manual makeCurrent - perform OpenGL calls - swapBuffers loop that is
-// typical in pure QWindow-based applications.
-OpenGLWindow::OpenGLWindow()
- : QOpenGLWindow(QOpenGLWindow::NoPartialUpdate)
- , m_fragment_toy("./background.frag")
- , m_text_layout("The triangle and this text is rendered with QPainter")
- , m_animate(true)
-{
- setGeometry(300, 300, 500, 500);
-
- m_view.lookAt(QVector3D(3,1,1),
- QVector3D(0,0,0),
- QVector3D(0,1,0));
-
- setAnimating(m_animate);
-}
-
-void OpenGLWindow::paintGL()
-{
- m_fragment_toy.draw(size());
-
- QPainter p(this);
- p.setWorldTransform(m_window_normalised_matrix.toTransform());
-
- QMatrix4x4 mvp = m_projection * m_view * m_model_triangle;
- p.setTransform(mvp.toTransform(), true);
-
- p.fillPath(painterPathForTriangle(), QBrush(QGradient(QGradient::NightFade)));
-
- QTransform text_transform = (m_window_painter_matrix * m_view * m_model_text).toTransform();
- p.setTransform(text_transform, false);
- p.setPen(QPen(Qt::black));
- m_text_layout.prepare(text_transform);
- qreal x = - (m_text_layout.size().width() / 2);
- qreal y = 0;
- p.drawStaticText(x, y, m_text_layout);
-
- m_model_triangle.rotate(-1, 0, 1, 0);
- m_model_text.rotate(1, 0, 1, 0);
-}
-
-void OpenGLWindow::resizeGL(int w, int h)
-{
- m_window_normalised_matrix.setToIdentity();
- m_window_normalised_matrix.translate(w / 2.0, h / 2.0);
- m_window_normalised_matrix.scale(w / 2.0, -h / 2.0);
-
- m_window_painter_matrix.setToIdentity();
- m_window_painter_matrix.translate(w / 2.0, h / 2.0);
-
- m_text_layout.setTextWidth(std::max(w * 0.2, 80.0));
-
- m_projection.setToIdentity();
- m_projection.perspective(45.f, qreal(w) / qreal(h), 0.1f, 100.f);
-}
-
-void OpenGLWindow::keyPressEvent(QKeyEvent *e)
-{
- if (e->key() == Qt::Key_P) { // pause
- m_animate = !m_animate;
- setAnimating(m_animate);
- }
-}
-
-void OpenGLWindow::setAnimating(bool enabled)
-{
- if (enabled) {
- // Animate continuously, throttled by the blocking swapBuffers() call the
- // QOpenGLWindow internally executes after each paint. Once that is done
- // (frameSwapped signal is emitted), we schedule a new update. This
- // obviously assumes that the swap interval (see
- // QSurfaceFormat::setSwapInterval()) is non-zero.
- connect(this, &QOpenGLWindow::frameSwapped,
- this, QOverload<>::of(&QPaintDeviceWindow::update));
- update();
- } else {
- disconnect(this, &QOpenGLWindow::frameSwapped,
- this, QOverload<>::of(&QPaintDeviceWindow::update));
- }
-}
-
-int main(int argc, char **argv)
-{
- QGuiApplication app(argc, argv);
-
- OpenGLWindow window;
- QSurfaceFormat fmt;
- fmt.setDepthBufferSize(24);
- fmt.setStencilBufferSize(8);
- window.setFormat(fmt);
- window.show();
-
- return app.exec();
-}
-
-#include "main.moc"
diff --git a/examples/opengl/qopenglwindow/qopenglwindow.pro b/examples/opengl/qopenglwindow/qopenglwindow.pro
deleted file mode 100644
index e7073a324b..0000000000
--- a/examples/opengl/qopenglwindow/qopenglwindow.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TEMPLATE = app
-TARGET = qopenglwindow
-INCLUDEPATH += .
-QT += opengl
-
-RESOURCES += shaders.qrc
-
-SOURCES += \
- main.cpp \
- background_renderer.cpp
-
-HEADERS += \
- background_renderer.h
-
-target.path = $$[QT_INSTALL_EXAMPLES]/opengl/qopenglwindow
-INSTALLS += target
diff --git a/examples/opengl/qopenglwindow/shaders.qrc b/examples/opengl/qopenglwindow/shaders.qrc
deleted file mode 100644
index 64eefe2c70..0000000000
--- a/examples/opengl/qopenglwindow/shaders.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>background.frag</file>
-</qresource>
-</RCC>
diff --git a/examples/opengl/stereoqopenglwidget/CMakeLists.txt b/examples/opengl/stereoqopenglwidget/CMakeLists.txt
new file mode 100644
index 0000000000..d0fb7a0345
--- /dev/null
+++ b/examples/opengl/stereoqopenglwidget/CMakeLists.txt
@@ -0,0 +1,42 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(stereoqopenglwidget LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL OpenGLWidgets Widgets)
+
+qt_add_executable(stereoqopenglwidget
+ glwidget.cpp glwidget.h
+ main.cpp
+ mainwindow.cpp mainwindow.h
+)
+
+set_target_properties(stereoqopenglwidget PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(stereoqopenglwidget PUBLIC
+ Qt6::Core
+ Qt6::Gui
+ Qt6::OpenGL
+ Qt6::OpenGLWidgets
+ Qt6::Widgets
+)
+
+
+install(TARGETS stereoqopenglwidget
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET stereoqopenglwidget
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/opengl/stereoqopenglwidget/glwidget.cpp b/examples/opengl/stereoqopenglwidget/glwidget.cpp
new file mode 100644
index 0000000000..36a6300348
--- /dev/null
+++ b/examples/opengl/stereoqopenglwidget/glwidget.cpp
@@ -0,0 +1,277 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "glwidget.h"
+#include <QPainter>
+#include <QPaintEngine>
+#include <QOpenGLShaderProgram>
+#include <QOpenGLTexture>
+#include <QRandomGenerator>
+#include <QCoreApplication>
+#include <QFileDialog>
+#include <qmath.h>
+
+GLWidget::GLWidget(const QColor &background)
+ : m_background(background)
+{
+ setMinimumSize(300, 250);
+}
+
+GLWidget::~GLWidget()
+{
+ reset();
+}
+
+void GLWidget::saveImage(TargetBuffer targetBuffer)
+{
+ QImage img = grabFramebuffer(targetBuffer);
+ if (img.isNull()) {
+ qFatal("Failed to grab framebuffer");
+ }
+
+ const char *fn =
+ targetBuffer == TargetBuffer::LeftBuffer
+ ? "leftBuffer.png" : "rightBuffer.png";
+
+ QFileDialog fd(this);
+ fd.setAcceptMode(QFileDialog::AcceptSave);
+ fd.setDefaultSuffix("png");
+ fd.selectFile(fn);
+ if (fd.exec() == QDialog::Accepted)
+ img.save(fd.selectedFiles().first());
+}
+
+void GLWidget::reset()
+{
+ // And now release all OpenGL resources.
+ makeCurrent();
+ delete m_program;
+ m_program = nullptr;
+ delete m_vshader;
+ m_vshader = nullptr;
+ delete m_fshader;
+ m_fshader = nullptr;
+ m_vbo.destroy();
+ doneCurrent();
+
+ // We are done with the current QOpenGLContext, forget it. If there is a
+ // subsequent initialize(), that will then connect to the new context.
+ QObject::disconnect(m_contextWatchConnection);
+}
+void GLWidget::initializeGL()
+{
+ initializeOpenGLFunctions();
+
+ m_vshader = new QOpenGLShader(QOpenGLShader::Vertex);
+ const char *vsrc1 =
+ "attribute highp vec4 vertex;\n"
+ "attribute mediump vec3 normal;\n"
+ "uniform mediump mat4 matrix;\n"
+ "varying mediump vec4 color;\n"
+ "void main(void)\n"
+ "{\n"
+ " vec3 toLight = normalize(vec3(0.0, 0.3, 1.0));\n"
+ " float angle = max(dot(normal, toLight), 0.0);\n"
+ " vec3 col = vec3(0.40, 1.0, 0.0);\n"
+ " color = vec4(col * 0.2 + col * 0.8 * angle, 1.0);\n"
+ " color = clamp(color, 0.0, 1.0);\n"
+ " gl_Position = matrix * vertex;\n"
+ "}\n";
+ m_vshader->compileSourceCode(vsrc1);
+
+ m_fshader = new QOpenGLShader(QOpenGLShader::Fragment);
+ const char *fsrc1 =
+ "varying mediump vec4 color;\n"
+ "void main(void)\n"
+ "{\n"
+ " gl_FragColor = color;\n"
+ "}\n";
+ m_fshader->compileSourceCode(fsrc1);
+
+ m_program = new QOpenGLShaderProgram;
+ m_program->addShader(m_vshader);
+ m_program->addShader(m_fshader);
+ m_program->link();
+
+
+ m_vertexAttr = m_program->attributeLocation("vertex");
+ m_normalAttr = m_program->attributeLocation("normal");
+ m_matrixUniform = m_program->uniformLocation("matrix");
+
+ createGeometry();
+
+ m_vbo.create();
+ m_vbo.bind();
+ const int vertexCount = m_vertices.count();
+ QList<GLfloat> buf;
+ buf.resize(vertexCount * 3 * 2);
+ GLfloat *p = buf.data();
+ for (int i = 0; i < vertexCount; ++i) {
+ *p++ = m_vertices[i].x();
+ *p++ = m_vertices[i].y();
+ *p++ = m_vertices[i].z();
+ *p++ = m_normals[i].x();
+ *p++ = m_normals[i].y();
+ *p++ = m_normals[i].z();
+ }
+ m_vbo.allocate(buf.constData(), (int)buf.count() * sizeof(GLfloat));
+ m_vbo.release();
+
+ m_contextWatchConnection = QObject::connect(context(), &QOpenGLContext::aboutToBeDestroyed, context(), [this] { reset(); });
+
+ glFrontFace(GL_CW);
+ glCullFace(GL_FRONT);
+ glEnable(GL_CULL_FACE);
+ glEnable(GL_DEPTH_TEST);
+}
+
+void GLWidget::paintGL()
+{
+ // When QSurfaceFormat::StereoBuffers is enabled, this function is called twice.
+ // Once where currentTargetBuffer() == QOpenGLWidget::LeftBuffer,
+ // and once where currentTargetBuffer() == QOpenGLWidget::RightBuffer.
+
+ glClearColor(m_background.redF(), m_background.greenF(), m_background.blueF(), 1.0f);
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ //! [1]
+ // Slightly translate the model, so that there's a visible difference in each buffer.
+ QMatrix4x4 modelview;
+ if (currentTargetBuffer() == QOpenGLWidget::LeftBuffer)
+ modelview.translate(-0.4f, 0.0f, 0.0f);
+ else if (currentTargetBuffer() == QOpenGLWidget::RightBuffer)
+ modelview.translate(0.4f, 0.0f, 0.0f);
+ //! [1]
+
+ m_program->bind();
+ m_program->setUniformValue(m_matrixUniform, modelview);
+ m_program->enableAttributeArray(m_vertexAttr);
+ m_program->enableAttributeArray(m_normalAttr);
+
+ m_vbo.bind();
+ m_program->setAttributeBuffer(m_vertexAttr, GL_FLOAT, 0, 3, 6 * sizeof(GLfloat));
+ m_program->setAttributeBuffer(m_normalAttr, GL_FLOAT, 3 * sizeof(GLfloat), 3, 6 * sizeof(GLfloat));
+ m_vbo.release();
+
+ glDrawArrays(GL_TRIANGLES, 0, m_vertices.size());
+
+ m_program->disableAttributeArray(m_normalAttr);
+ m_program->disableAttributeArray(m_vertexAttr);
+ m_program->release();
+ update();
+}
+
+void GLWidget::createGeometry()
+{
+ m_vertices.clear();
+ m_normals.clear();
+
+ qreal x1 = +0.06f;
+ qreal y1 = -0.14f;
+ qreal x2 = +0.14f;
+ qreal y2 = -0.06f;
+ qreal x3 = +0.08f;
+ qreal y3 = +0.00f;
+ qreal x4 = +0.30f;
+ qreal y4 = +0.22f;
+
+ quad(x1, y1, x2, y2, y2, x2, y1, x1);
+ quad(x3, y3, x4, y4, y4, x4, y3, x3);
+
+ extrude(x1, y1, x2, y2);
+ extrude(x2, y2, y2, x2);
+ extrude(y2, x2, y1, x1);
+ extrude(y1, x1, x1, y1);
+ extrude(x3, y3, x4, y4);
+ extrude(x4, y4, y4, x4);
+ extrude(y4, x4, y3, x3);
+
+ const int NumSectors = 100;
+ const qreal sectorAngle = 2 * qreal(M_PI) / NumSectors;
+
+ for (int i = 0; i < NumSectors; ++i) {
+ qreal angle = i * sectorAngle;
+ qreal x5 = 0.30 * sin(angle);
+ qreal y5 = 0.30 * cos(angle);
+ qreal x6 = 0.20 * sin(angle);
+ qreal y6 = 0.20 * cos(angle);
+
+ angle += sectorAngle;
+ qreal x7 = 0.20 * sin(angle);
+ qreal y7 = 0.20 * cos(angle);
+ qreal x8 = 0.30 * sin(angle);
+ qreal y8 = 0.30 * cos(angle);
+
+ quad(x5, y5, x6, y6, x7, y7, x8, y8);
+
+ extrude(x6, y6, x7, y7);
+ extrude(x8, y8, x5, y5);
+ }
+
+ for (int i = 0;i < m_vertices.size();i++)
+ m_vertices[i] *= 2.0f;
+}
+
+void GLWidget::quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4)
+{
+ m_vertices << QVector3D(x1, y1, -0.05f);
+ m_vertices << QVector3D(x2, y2, -0.05f);
+ m_vertices << QVector3D(x4, y4, -0.05f);
+
+ m_vertices << QVector3D(x3, y3, -0.05f);
+ m_vertices << QVector3D(x4, y4, -0.05f);
+ m_vertices << QVector3D(x2, y2, -0.05f);
+
+ QVector3D n = QVector3D::normal
+ (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(x4 - x1, y4 - y1, 0.0f));
+
+ m_normals << n;
+ m_normals << n;
+ m_normals << n;
+
+ m_normals << n;
+ m_normals << n;
+ m_normals << n;
+
+ m_vertices << QVector3D(x4, y4, 0.05f);
+ m_vertices << QVector3D(x2, y2, 0.05f);
+ m_vertices << QVector3D(x1, y1, 0.05f);
+
+ m_vertices << QVector3D(x2, y2, 0.05f);
+ m_vertices << QVector3D(x4, y4, 0.05f);
+ m_vertices << QVector3D(x3, y3, 0.05f);
+
+ n = QVector3D::normal
+ (QVector3D(x2 - x4, y2 - y4, 0.0f), QVector3D(x1 - x4, y1 - y4, 0.0f));
+
+ m_normals << n;
+ m_normals << n;
+ m_normals << n;
+
+ m_normals << n;
+ m_normals << n;
+ m_normals << n;
+}
+
+void GLWidget::extrude(qreal x1, qreal y1, qreal x2, qreal y2)
+{
+ m_vertices << QVector3D(x1, y1, +0.05f);
+ m_vertices << QVector3D(x2, y2, +0.05f);
+ m_vertices << QVector3D(x1, y1, -0.05f);
+
+ m_vertices << QVector3D(x2, y2, -0.05f);
+ m_vertices << QVector3D(x1, y1, -0.05f);
+ m_vertices << QVector3D(x2, y2, +0.05f);
+
+ QVector3D n = QVector3D::normal
+ (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(0.0f, 0.0f, -0.1f));
+
+ m_normals << n;
+ m_normals << n;
+ m_normals << n;
+
+ m_normals << n;
+ m_normals << n;
+ m_normals << n;
+}
diff --git a/examples/opengl/stereoqopenglwidget/glwidget.h b/examples/opengl/stereoqopenglwidget/glwidget.h
new file mode 100644
index 0000000000..0014ee37c1
--- /dev/null
+++ b/examples/opengl/stereoqopenglwidget/glwidget.h
@@ -0,0 +1,53 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef GLWIDGET_H
+#define GLWIDGET_H
+
+#include <QOpenGLWidget>
+#include <QOpenGLFunctions>
+#include <QOpenGLBuffer>
+#include <QVector3D>
+#include <QMatrix4x4>
+#include <QElapsedTimer>
+#include <QList>
+#include <QPushButton>
+
+
+QT_FORWARD_DECLARE_CLASS(QOpenGLTexture)
+QT_FORWARD_DECLARE_CLASS(QOpenGLShader)
+QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
+
+class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
+{
+ Q_OBJECT
+public:
+ GLWidget(const QColor &background);
+ ~GLWidget();
+
+ void saveImage(QOpenGLWidget::TargetBuffer targetBuffer);
+
+protected:
+ void paintGL() override;
+ void initializeGL() override;
+
+private:
+ void createGeometry();
+ void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4);
+ void extrude(qreal x1, qreal y1, qreal x2, qreal y2);
+ void reset();
+
+ QList<QVector3D> m_vertices;
+ QList<QVector3D> m_normals;
+ QOpenGLShader *m_vshader = nullptr;
+ QOpenGLShader *m_fshader = nullptr;
+ QOpenGLShaderProgram *m_program = nullptr;
+ QOpenGLBuffer m_vbo;
+ int m_vertexAttr;
+ int m_normalAttr;
+ int m_matrixUniform;
+ QColor m_background;
+ QMetaObject::Connection m_contextWatchConnection;
+};
+
+#endif
diff --git a/examples/opengl/stereoqopenglwidget/main.cpp b/examples/opengl/stereoqopenglwidget/main.cpp
new file mode 100644
index 0000000000..8aad756eca
--- /dev/null
+++ b/examples/opengl/stereoqopenglwidget/main.cpp
@@ -0,0 +1,31 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QApplication>
+#include <QSurfaceFormat>
+#include "mainwindow.h"
+
+int main( int argc, char ** argv )
+{
+ QApplication a( argc, argv );
+
+ QCoreApplication::setApplicationName("Qt QOpenGLWidget Stereoscopic Rendering Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+
+ //! [1]
+ QSurfaceFormat format;
+ format.setDepthBufferSize(24);
+ format.setStencilBufferSize(8);
+
+ // Enable stereoscopic rendering support
+ format.setStereo(true);
+
+ QSurfaceFormat::setDefaultFormat(format);
+ //! [1]
+
+ MainWindow mw;
+ mw.resize(1280, 720);
+ mw.show();
+ return a.exec();
+}
diff --git a/examples/opengl/stereoqopenglwidget/mainwindow.cpp b/examples/opengl/stereoqopenglwidget/mainwindow.cpp
new file mode 100644
index 0000000000..33f93ba7de
--- /dev/null
+++ b/examples/opengl/stereoqopenglwidget/mainwindow.cpp
@@ -0,0 +1,25 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "mainwindow.h"
+#include <QApplication>
+#include <QMenuBar>
+#include "glwidget.h"
+
+MainWindow::MainWindow()
+{
+ GLWidget *glwidget = new GLWidget(qRgb(20, 20, 50));
+ setCentralWidget(glwidget);
+
+ QMenu *screenShotMenu = menuBar()->addMenu("&Screenshot");
+ screenShotMenu->addAction("Left buffer", this, [glwidget](){
+ glwidget->saveImage(QOpenGLWidget::LeftBuffer);
+ });
+
+ screenShotMenu->addAction("Right buffer", this, [glwidget](){
+ glwidget->saveImage(QOpenGLWidget::RightBuffer);
+ });
+
+ QMenu *helpMenu = menuBar()->addMenu("&Help");
+ helpMenu->addAction("About Qt", qApp, &QApplication::aboutQt);
+}
diff --git a/examples/opengl/stereoqopenglwidget/mainwindow.h b/examples/opengl/stereoqopenglwidget/mainwindow.h
new file mode 100644
index 0000000000..aa6f722e59
--- /dev/null
+++ b/examples/opengl/stereoqopenglwidget/mainwindow.h
@@ -0,0 +1,21 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QTimer>
+#include <QGridLayout>
+
+QT_FORWARD_DECLARE_CLASS(QOpenGLWidget)
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow();
+};
+
+#endif
diff --git a/examples/opengl/stereoqopenglwidget/stereoqopenglwidget.pro b/examples/opengl/stereoqopenglwidget/stereoqopenglwidget.pro
new file mode 100644
index 0000000000..197afff571
--- /dev/null
+++ b/examples/opengl/stereoqopenglwidget/stereoqopenglwidget.pro
@@ -0,0 +1,11 @@
+QT += widgets opengl openglwidgets
+
+SOURCES += main.cpp \
+ glwidget.cpp \
+ mainwindow.cpp
+
+HEADERS += glwidget.h \
+ mainwindow.h
+
+target.path = $$[QT_INSTALL_EXAMPLES]/opengl/stereoqopenglwidget
+INSTALLS += target
diff --git a/examples/opengl/textures/CMakeLists.txt b/examples/opengl/textures/CMakeLists.txt
index 64ae075ce0..2765355c5a 100644
--- a/examples/opengl/textures/CMakeLists.txt
+++ b/examples/opengl/textures/CMakeLists.txt
@@ -1,43 +1,31 @@
-# Generated from textures.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(textures LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL OpenGLWidgets Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/textures")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS OpenGL)
-find_package(Qt6 COMPONENTS OpenGLWidgets)
+qt_standard_project_setup()
qt_add_executable(textures
glwidget.cpp glwidget.h
main.cpp
window.cpp window.h
)
+
set_target_properties(textures PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(textures PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
- Qt::OpenGLWidgets
- Qt::Widgets
-)
+target_link_libraries(textures PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::OpenGL
+ Qt6::OpenGLWidgets
+ Qt6::Widgets
+)
# Resources:
set(textures_resource_files
@@ -57,7 +45,14 @@ qt6_add_resources(textures "textures"
)
install(TARGETS textures
- 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 textures
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/opengl/textures/glwidget.cpp b/examples/opengl/textures/glwidget.cpp
index 2ef17c511c..cca08f4c91 100644
--- a/examples/opengl/textures/glwidget.cpp
+++ b/examples/opengl/textures/glwidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "glwidget.h"
#include <QOpenGLShaderProgram>
@@ -93,9 +46,6 @@ void GLWidget::initializeGL()
makeObject();
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_CULL_FACE);
-
#define PROGRAM_VERTEX_ATTRIBUTE 0
#define PROGRAM_TEXCOORD_ATTRIBUTE 1
@@ -138,6 +88,9 @@ void GLWidget::paintGL()
glClearColor(clearColor.redF(), clearColor.greenF(), clearColor.blueF(), clearColor.alphaF());
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_CULL_FACE);
+
QMatrix4x4 m;
m.ortho(-0.5f, +0.5f, +0.5f, -0.5f, 4.0f, 15.0f);
m.translate(0.0f, 0.0f, -10.0f);
@@ -145,6 +98,8 @@ void GLWidget::paintGL()
m.rotate(yRot / 16.0f, 0.0f, 1.0f, 0.0f);
m.rotate(zRot / 16.0f, 0.0f, 0.0f, 1.0f);
+ vbo.bind();
+ program->bind();
program->setUniformValue("matrix", m);
program->enableAttributeArray(PROGRAM_VERTEX_ATTRIBUTE);
program->enableAttributeArray(PROGRAM_TEXCOORD_ATTRIBUTE);
diff --git a/examples/opengl/textures/glwidget.h b/examples/opengl/textures/glwidget.h
index 585d44dbfe..ff81f9faae 100644
--- a/examples/opengl/textures/glwidget.h
+++ b/examples/opengl/textures/glwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef GLWIDGET_H
#define GLWIDGET_H
diff --git a/examples/opengl/textures/main.cpp b/examples/opengl/textures/main.cpp
index ad611e7016..7e5f0646cb 100644
--- a/examples/opengl/textures/main.cpp
+++ b/examples/opengl/textures/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QSurfaceFormat>
@@ -55,8 +8,6 @@
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(textures);
-
QApplication app(argc, argv);
QSurfaceFormat format;
diff --git a/examples/opengl/textures/window.cpp b/examples/opengl/textures/window.cpp
index 642435c333..c86fa089d5 100644
--- a/examples/opengl/textures/window.cpp
+++ b/examples/opengl/textures/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
diff --git a/examples/opengl/textures/window.h b/examples/opengl/textures/window.h
index 19b114b798..ad9b01e704 100644
--- a/examples/opengl/textures/window.h
+++ b/examples/opengl/textures/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
diff --git a/examples/opengl/threadedqopenglwidget/CMakeLists.txt b/examples/opengl/threadedqopenglwidget/CMakeLists.txt
deleted file mode 100644
index dc5bdb85c1..0000000000
--- a/examples/opengl/threadedqopenglwidget/CMakeLists.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-# Generated from threadedqopenglwidget.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(threadedqopenglwidget LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/opengl/threadedqopenglwidget")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS OpenGL)
-find_package(Qt6 COMPONENTS OpenGLWidgets)
-
-qt_add_executable(threadedqopenglwidget
- glwidget.cpp glwidget.h
- main.cpp
- mainwindow.cpp mainwindow.h
-)
-set_target_properties(threadedqopenglwidget PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(threadedqopenglwidget PUBLIC
- Qt::Core
- Qt::Gui
- Qt::OpenGL
- Qt::OpenGLWidgets
- Qt::Widgets
-)
-
-install(TARGETS threadedqopenglwidget
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/opengl/threadedqopenglwidget/glwidget.cpp b/examples/opengl/threadedqopenglwidget/glwidget.cpp
deleted file mode 100644
index 2101575fd4..0000000000
--- a/examples/opengl/threadedqopenglwidget/glwidget.cpp
+++ /dev/null
@@ -1,367 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "glwidget.h"
-#include <qmath.h>
-#include <QGuiApplication>
-
-GLWidget::GLWidget(QWidget *parent)
- : QOpenGLWidget(parent)
-{
- setMinimumSize(300, 250);
-
- connect(this, &QOpenGLWidget::aboutToCompose, this, &GLWidget::onAboutToCompose);
- connect(this, &QOpenGLWidget::frameSwapped, this, &GLWidget::onFrameSwapped);
- connect(this, &QOpenGLWidget::aboutToResize, this, &GLWidget::onAboutToResize);
- connect(this, &QOpenGLWidget::resized, this, &GLWidget::onResized);
-
- m_thread = new QThread;
- m_renderer = new Renderer(this);
- m_renderer->moveToThread(m_thread);
- connect(m_thread, &QThread::finished, m_renderer, &QObject::deleteLater);
-
- connect(this, &GLWidget::renderRequested, m_renderer, &Renderer::render);
- connect(m_renderer, &Renderer::contextWanted, this, &GLWidget::grabContext);
-
- m_thread->start();
-}
-
-GLWidget::~GLWidget()
-{
- m_renderer->prepareExit();
- m_thread->quit();
- m_thread->wait();
- delete m_thread;
-}
-
-void GLWidget::onAboutToCompose()
-{
- // We are on the gui thread here. Composition is about to
- // begin. Wait until the render thread finishes.
- m_renderer->lockRenderer();
-}
-
-void GLWidget::onFrameSwapped()
-{
- m_renderer->unlockRenderer();
- // Assuming a blocking swap, our animation is driven purely by the
- // vsync in this example.
- emit renderRequested();
-}
-
-void GLWidget::onAboutToResize()
-{
- m_renderer->lockRenderer();
-}
-
-void GLWidget::onResized()
-{
- m_renderer->unlockRenderer();
-}
-
-void GLWidget::grabContext()
-{
- m_renderer->lockRenderer();
- QMutexLocker lock(m_renderer->grabMutex());
- context()->moveToThread(m_thread);
- m_renderer->grabCond()->wakeAll();
- m_renderer->unlockRenderer();
-}
-
-Renderer::Renderer(GLWidget *w) : m_glwidget(w) {}
-
-void Renderer::paintQtLogo()
-{
- vbo.bind();
- program.setAttributeBuffer(vertexAttr, GL_FLOAT, 0, 3);
- program.setAttributeBuffer(normalAttr, GL_FLOAT, vertices.count() * 3 * sizeof(GLfloat), 3);
- vbo.release();
-
- program.enableAttributeArray(vertexAttr);
- program.enableAttributeArray(normalAttr);
-
- glDrawArrays(GL_TRIANGLES, 0, vertices.size());
-
- program.disableAttributeArray(normalAttr);
- program.disableAttributeArray(vertexAttr);
-}
-
-// Some OpenGL implementations have serious issues with compiling and linking
-// shaders on multiple threads concurrently. Avoid this.
-Q_GLOBAL_STATIC(QMutex, initMutex)
-
-void Renderer::render()
-{
- if (m_exiting)
- return;
-
- QOpenGLContext *ctx = m_glwidget->context();
- if (!ctx) // QOpenGLWidget not yet initialized
- return;
-
- // Grab the context.
- m_grabMutex.lock();
- emit contextWanted();
- m_grabCond.wait(&m_grabMutex);
- QMutexLocker lock(&m_renderMutex);
- m_grabMutex.unlock();
-
- if (m_exiting)
- return;
-
- Q_ASSERT(ctx->thread() == QThread::currentThread());
-
- // Make the context (and an offscreen surface) current for this thread. The
- // QOpenGLWidget's fbo is bound in the context.
- m_glwidget->makeCurrent();
-
- if (!m_inited) {
- m_inited = true;
- initializeOpenGLFunctions();
-
- QMutexLocker initLock(initMutex());
- QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, this);
- const char *vsrc =
- "attribute highp vec4 vertex;\n"
- "attribute mediump vec3 normal;\n"
- "uniform mediump mat4 matrix;\n"
- "varying mediump vec4 color;\n"
- "void main(void)\n"
- "{\n"
- " vec3 toLight = normalize(vec3(0.0, 0.3, 1.0));\n"
- " float angle = max(dot(normal, toLight), 0.0);\n"
- " vec3 col = vec3(0.40, 1.0, 0.0);\n"
- " color = vec4(col * 0.2 + col * 0.8 * angle, 1.0);\n"
- " color = clamp(color, 0.0, 1.0);\n"
- " gl_Position = matrix * vertex;\n"
- "}\n";
- vshader->compileSourceCode(vsrc);
-
- QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, this);
- const char *fsrc =
- "varying mediump vec4 color;\n"
- "void main(void)\n"
- "{\n"
- " gl_FragColor = color;\n"
- "}\n";
- fshader->compileSourceCode(fsrc);
-
- program.addShader(vshader);
- program.addShader(fshader);
- program.link();
-
- vertexAttr = program.attributeLocation("vertex");
- normalAttr = program.attributeLocation("normal");
- matrixUniform = program.uniformLocation("matrix");
-
- m_fAngle = 0;
- m_fScale = 1;
- createGeometry();
-
- vbo.create();
- vbo.bind();
- const int verticesSize = vertices.count() * 3 * sizeof(GLfloat);
- vbo.allocate(verticesSize * 2);
- vbo.write(0, vertices.constData(), verticesSize);
- vbo.write(verticesSize, normals.constData(), verticesSize);
-
- m_elapsed.start();
- }
-
- //qDebug("%p elapsed %lld", QThread::currentThread(), m_elapsed.restart());
-
- glClearColor(0.1f, 0.2f, 0.2f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- glFrontFace(GL_CW);
- glCullFace(GL_FRONT);
- glEnable(GL_CULL_FACE);
- glEnable(GL_DEPTH_TEST);
-
- QMatrix4x4 modelview;
- modelview.rotate(m_fAngle, 0.0f, 1.0f, 0.0f);
- modelview.rotate(m_fAngle, 1.0f, 0.0f, 0.0f);
- modelview.rotate(m_fAngle, 0.0f, 0.0f, 1.0f);
- modelview.scale(m_fScale);
- modelview.translate(0.0f, -0.2f, 0.0f);
-
- program.bind();
- program.setUniformValue(matrixUniform, modelview);
- paintQtLogo();
- program.release();
-
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_CULL_FACE);
-
- m_fAngle += 1.0f;
-
- // Make no context current on this thread and move the QOpenGLWidget's
- // context back to the gui thread.
- m_glwidget->doneCurrent();
- ctx->moveToThread(qGuiApp->thread());
-
- // Schedule composition. Note that this will use QueuedConnection, meaning
- // that update() will be invoked on the gui thread.
- QMetaObject::invokeMethod(m_glwidget, "update");
-}
-
-void Renderer::createGeometry()
-{
- vertices.clear();
- normals.clear();
-
- qreal x1 = +0.06f;
- qreal y1 = -0.14f;
- qreal x2 = +0.14f;
- qreal y2 = -0.06f;
- qreal x3 = +0.08f;
- qreal y3 = +0.00f;
- qreal x4 = +0.30f;
- qreal y4 = +0.22f;
-
- quad(x1, y1, x2, y2, y2, x2, y1, x1);
- quad(x3, y3, x4, y4, y4, x4, y3, x3);
-
- extrude(x1, y1, x2, y2);
- extrude(x2, y2, y2, x2);
- extrude(y2, x2, y1, x1);
- extrude(y1, x1, x1, y1);
- extrude(x3, y3, x4, y4);
- extrude(x4, y4, y4, x4);
- extrude(y4, x4, y3, x3);
-
- const int NumSectors = 100;
- const qreal sectorAngle = 2 * qreal(M_PI) / NumSectors;
-
- for (int i = 0; i < NumSectors; ++i) {
- qreal angle = i * sectorAngle;
- qreal x5 = 0.30 * sin(angle);
- qreal y5 = 0.30 * cos(angle);
- qreal x6 = 0.20 * sin(angle);
- qreal y6 = 0.20 * cos(angle);
-
- angle += sectorAngle;
- qreal x7 = 0.20 * sin(angle);
- qreal y7 = 0.20 * cos(angle);
- qreal x8 = 0.30 * sin(angle);
- qreal y8 = 0.30 * cos(angle);
-
- quad(x5, y5, x6, y6, x7, y7, x8, y8);
-
- extrude(x6, y6, x7, y7);
- extrude(x8, y8, x5, y5);
- }
-
- for (int i = 0;i < vertices.size();i++)
- vertices[i] *= 2.0f;
-}
-
-void Renderer::quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4)
-{
- vertices << QVector3D(x1, y1, -0.05f);
- vertices << QVector3D(x2, y2, -0.05f);
- vertices << QVector3D(x4, y4, -0.05f);
-
- vertices << QVector3D(x3, y3, -0.05f);
- vertices << QVector3D(x4, y4, -0.05f);
- vertices << QVector3D(x2, y2, -0.05f);
-
- QVector3D n = QVector3D::normal
- (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(x4 - x1, y4 - y1, 0.0f));
-
- normals << n;
- normals << n;
- normals << n;
-
- normals << n;
- normals << n;
- normals << n;
-
- vertices << QVector3D(x4, y4, 0.05f);
- vertices << QVector3D(x2, y2, 0.05f);
- vertices << QVector3D(x1, y1, 0.05f);
-
- vertices << QVector3D(x2, y2, 0.05f);
- vertices << QVector3D(x4, y4, 0.05f);
- vertices << QVector3D(x3, y3, 0.05f);
-
- n = QVector3D::normal
- (QVector3D(x2 - x4, y2 - y4, 0.0f), QVector3D(x1 - x4, y1 - y4, 0.0f));
-
- normals << n;
- normals << n;
- normals << n;
-
- normals << n;
- normals << n;
- normals << n;
-}
-
-void Renderer::extrude(qreal x1, qreal y1, qreal x2, qreal y2)
-{
- vertices << QVector3D(x1, y1, +0.05f);
- vertices << QVector3D(x2, y2, +0.05f);
- vertices << QVector3D(x1, y1, -0.05f);
-
- vertices << QVector3D(x2, y2, -0.05f);
- vertices << QVector3D(x1, y1, -0.05f);
- vertices << QVector3D(x2, y2, +0.05f);
-
- QVector3D n = QVector3D::normal
- (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(0.0f, 0.0f, -0.1f));
-
- normals << n;
- normals << n;
- normals << n;
-
- normals << n;
- normals << n;
- normals << n;
-}
diff --git a/examples/opengl/threadedqopenglwidget/glwidget.h b/examples/opengl/threadedqopenglwidget/glwidget.h
deleted file mode 100644
index 2bff56c471..0000000000
--- a/examples/opengl/threadedqopenglwidget/glwidget.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef GLWIDGET_H
-#define GLWIDGET_H
-
-#include <QOpenGLWidget>
-#include <QOpenGLFunctions>
-#include <QOpenGLShaderProgram>
-#include <QOpenGLBuffer>
-#include <QVector3D>
-#include <QMatrix4x4>
-#include <QThread>
-#include <QMutex>
-#include <QWaitCondition>
-#include <QElapsedTimer>
-
-class GLWidget;
-
-class Renderer : public QObject, protected QOpenGLFunctions
-{
- Q_OBJECT
-
-public:
- Renderer(GLWidget *w);
- void lockRenderer() { m_renderMutex.lock(); }
- void unlockRenderer() { m_renderMutex.unlock(); }
- QMutex *grabMutex() { return &m_grabMutex; }
- QWaitCondition *grabCond() { return &m_grabCond; }
- void prepareExit() { m_exiting = true; m_grabCond.wakeAll(); }
-
-signals:
- void contextWanted();
-
-public slots:
- void render();
-
-private:
- void paintQtLogo();
- void createGeometry();
- void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4);
- void extrude(qreal x1, qreal y1, qreal x2, qreal y2);
-
- bool m_inited = false;
- qreal m_fAngle = 0;
- qreal m_fScale = 1;
- QList<QVector3D> vertices;
- QList<QVector3D> normals;
- QOpenGLShaderProgram program;
- QOpenGLBuffer vbo;
- int vertexAttr = 0;
- int normalAttr = 0;
- int matrixUniform = 0;
- GLWidget *m_glwidget = nullptr;
- QMutex m_renderMutex;
- QElapsedTimer m_elapsed;
- QMutex m_grabMutex;
- QWaitCondition m_grabCond;
- bool m_exiting = false;
-};
-
-class GLWidget : public QOpenGLWidget
-{
- Q_OBJECT
-public:
- explicit GLWidget(QWidget *parent = nullptr);
- ~GLWidget();
-
-protected:
- void paintEvent(QPaintEvent *) override { }
-
-signals:
- void renderRequested();
-
-public slots:
- void grabContext();
-
-private slots:
- void onAboutToCompose();
- void onFrameSwapped();
- void onAboutToResize();
- void onResized();
-
-private:
- QThread *m_thread;
- Renderer *m_renderer;
-};
-
-#endif
diff --git a/examples/opengl/threadedqopenglwidget/main.cpp b/examples/opengl/threadedqopenglwidget/main.cpp
deleted file mode 100644
index 975def030b..0000000000
--- a/examples/opengl/threadedqopenglwidget/main.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <QMainWindow>
-#include <QScreen>
-#include <QSurfaceFormat>
-#include <QOpenGLContext>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
-#include "mainwindow.h"
-#include "glwidget.h"
-
-#include <memory>
-
-static QString getGlString(QOpenGLFunctions *functions, GLenum name)
-{
- if (const GLubyte *p = functions->glGetString(name))
- return QString::fromLatin1(reinterpret_cast<const char *>(p));
- return QString();
-}
-
-int main( int argc, char ** argv )
-{
- QApplication a( argc, argv );
-
- QCoreApplication::setApplicationName("Qt Threaded QOpenGLWidget Example");
- QCoreApplication::setOrganizationName("QtProject");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
- QCommandLineParser parser;
- parser.setApplicationDescription(QCoreApplication::applicationName());
- parser.addHelpOption();
- parser.addVersionOption();
- QCommandLineOption singleOption("single", "Single thread");
- parser.addOption(singleOption);
- parser.process(a);
-
- QSurfaceFormat format;
- format.setDepthBufferSize(16);
- QSurfaceFormat::setDefaultFormat(format);
-
- // Two top-level windows with two QOpenGLWidget children in each.
- // The rendering for the four QOpenGLWidgets happens on four separate threads.
-
- GLWidget topLevelGlWidget;
- QPoint pos = topLevelGlWidget.screen()->availableGeometry().topLeft() + QPoint(200, 200);
- topLevelGlWidget.setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example top level"));
- topLevelGlWidget.resize(200, 200);
- topLevelGlWidget.move(pos);
- topLevelGlWidget.show();
-
- const QString glInfo = getGlString(topLevelGlWidget.context()->functions(), GL_VENDOR)
- + QLatin1Char('/') + getGlString(topLevelGlWidget.context()->functions(), GL_RENDERER);
-
- const bool supportsThreading = !glInfo.contains(QLatin1String("nouveau"), Qt::CaseInsensitive)
- && !glInfo.contains(QLatin1String("ANGLE"), Qt::CaseInsensitive)
- && !glInfo.contains(QLatin1String("llvmpipe"), Qt::CaseInsensitive);
-
- const QString toolTip = supportsThreading ? glInfo : glInfo + QStringLiteral("\ndoes not support threaded OpenGL.");
- topLevelGlWidget.setToolTip(toolTip);
-
- std::unique_ptr<MainWindow> mw1;
- std::unique_ptr<MainWindow> mw2;
- if (!parser.isSet(singleOption)) {
- if (supportsThreading) {
- pos += QPoint(100, 100);
- mw1.reset(new MainWindow);
- mw1->setToolTip(toolTip);
- mw1->move(pos);
- mw1->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #1"));
- mw1->show();
- pos += QPoint(100, 100);
- mw2.reset(new MainWindow);
- mw2->setToolTip(toolTip);
- mw2->move(pos);
- mw2->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #2"));
- mw2->show();
- } else {
- qWarning() << toolTip;
- }
- }
-
- return a.exec();
-}
diff --git a/examples/opengl/threadedqopenglwidget/mainwindow.cpp b/examples/opengl/threadedqopenglwidget/mainwindow.cpp
deleted file mode 100644
index 60367c91d8..0000000000
--- a/examples/opengl/threadedqopenglwidget/mainwindow.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mainwindow.h"
-#include "glwidget.h"
-
-MainWindow::MainWindow()
-{
- setMinimumSize(800, 400);
- GLWidget *glwidget1 = new GLWidget(this);
- glwidget1->resize(400, 400);
-
- GLWidget *glwidget2 = new GLWidget(this);
- glwidget2->resize(400, 400);
- glwidget2->move(400, 0);
-}
diff --git a/examples/opengl/threadedqopenglwidget/mainwindow.h b/examples/opengl/threadedqopenglwidget/mainwindow.h
deleted file mode 100644
index 6e7b17467f..0000000000
--- a/examples/opengl/threadedqopenglwidget/mainwindow.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QWidget>
-
-class MainWindow : public QWidget
-{
- Q_OBJECT
-
-public:
- MainWindow();
-};
-
-#endif
diff --git a/examples/opengl/threadedqopenglwidget/threadedqopenglwidget.pro b/examples/opengl/threadedqopenglwidget/threadedqopenglwidget.pro
deleted file mode 100644
index a62fbeb9c2..0000000000
--- a/examples/opengl/threadedqopenglwidget/threadedqopenglwidget.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += widgets opengl openglwidgets
-
-SOURCES += main.cpp \
- glwidget.cpp \
- mainwindow.cpp
-
-HEADERS += glwidget.h \
- mainwindow.h
-
-target.path = $$[QT_INSTALL_EXAMPLES]/opengl/threadedqopenglwidget
-INSTALLS += target
diff --git a/examples/qmake/precompile/main.cpp b/examples/qmake/precompile/main.cpp
index 86cf440560..58050df603 100644
--- a/examples/qmake/precompile/main.cpp
+++ b/examples/qmake/precompile/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [0]
#include <QApplication>
@@ -62,7 +15,8 @@ int main(int argc, char **argv)
MyObject obj;
MyDialog dialog;
- dialog.connect(dialog.aButton, SIGNAL(clicked()), SLOT(close()));
+ QObject::connect(dialog.aButton, &QPushButton::clicked,
+ &dialog, &MyDialog::close);
dialog.show();
return app.exec();
diff --git a/examples/qmake/precompile/mydialog.cpp b/examples/qmake/precompile/mydialog.cpp
index 692b3ca253..9993f1f64c 100644
--- a/examples/qmake/precompile/mydialog.cpp
+++ b/examples/qmake/precompile/mydialog.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mydialog.h"
diff --git a/examples/qmake/precompile/mydialog.h b/examples/qmake/precompile/mydialog.h
index ed4028fe53..dfc8179b41 100644
--- a/examples/qmake/precompile/mydialog.h
+++ b/examples/qmake/precompile/mydialog.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MYDIALOG_H
#define MYDIALOG_H
diff --git a/examples/qmake/precompile/myobject.cpp b/examples/qmake/precompile/myobject.cpp
index 8c4967660b..9fb28d5847 100644
--- a/examples/qmake/precompile/myobject.cpp
+++ b/examples/qmake/precompile/myobject.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [0]
#include <iostream>
diff --git a/examples/qmake/precompile/myobject.h b/examples/qmake/precompile/myobject.h
index a1e57e2eb1..a893e27e4c 100644
--- a/examples/qmake/precompile/myobject.h
+++ b/examples/qmake/precompile/myobject.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MYOBJECT_H
#define MYOBJECT_H
diff --git a/examples/qmake/precompile/stable.h b/examples/qmake/precompile/stable.h
index 400fd5abd8..d0b993c158 100644
--- a/examples/qmake/precompile/stable.h
+++ b/examples/qmake/precompile/stable.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [0]
/* Add C includes here */
diff --git a/examples/qmake/precompile/util.cpp b/examples/qmake/precompile/util.cpp
index 6b10bdcda7..9220718252 100644
--- a/examples/qmake/precompile/util.cpp
+++ b/examples/qmake/precompile/util.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [0]
void util_function_does_nothing()
diff --git a/examples/qmake/tutorial/hello.cpp b/examples/qmake/tutorial/hello.cpp
index 12e15c00bd..b88a39858b 100644
--- a/examples/qmake/tutorial/hello.cpp
+++ b/examples/qmake/tutorial/hello.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QDebug>
#include "hello.h"
diff --git a/examples/qmake/tutorial/hello.h b/examples/qmake/tutorial/hello.h
index e986d0640e..1357bf3fce 100644
--- a/examples/qmake/tutorial/hello.h
+++ b/examples/qmake/tutorial/hello.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QPushButton>
diff --git a/examples/qmake/tutorial/hellounix.cpp b/examples/qmake/tutorial/hellounix.cpp
index e9c18566de..7a96b5fbf1 100644
--- a/examples/qmake/tutorial/hellounix.cpp
+++ b/examples/qmake/tutorial/hellounix.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
// This file does nothing, but check your Makefile to see if there is a
// reference to hello_win.cpp - there shouldn't be if qmake is used on X11.
diff --git a/examples/qmake/tutorial/hellowin.cpp b/examples/qmake/tutorial/hellowin.cpp
index 4c67b910d7..f297a78046 100644
--- a/examples/qmake/tutorial/hellowin.cpp
+++ b/examples/qmake/tutorial/hellowin.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
// This file does nothing, but check your Makefile to see if there is a
// reference to hello_x11.cpp - there shouldn't be if qmake is used on Windows.
diff --git a/examples/qmake/tutorial/main.cpp b/examples/qmake/tutorial/main.cpp
index e2ee46c105..db55e4ed05 100644
--- a/examples/qmake/tutorial/main.cpp
+++ b/examples/qmake/tutorial/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include "hello.h"
diff --git a/examples/qpa/CMakeLists.txt b/examples/qpa/CMakeLists.txt
deleted file mode 100644
index 6768aa052d..0000000000
--- a/examples/qpa/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-# Generated from qpa.pro.
-
-if(NOT TARGET Qt::Gui)
- return()
-endif()
-add_subdirectory(windows)
-add_subdirectory(qrasterwindow)
diff --git a/examples/qpa/qpa.pro b/examples/qpa/qpa.pro
deleted file mode 100644
index 85b51dc5f4..0000000000
--- a/examples/qpa/qpa.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-requires(qtHaveModule(gui))
-
-TEMPLATE = subdirs
-SUBDIRS = windows \
- qrasterwindow
diff --git a/examples/qpa/qrasterwindow/.prev_CMakeLists.txt b/examples/qpa/qrasterwindow/.prev_CMakeLists.txt
deleted file mode 100644
index 8fd75f1079..0000000000
--- a/examples/qpa/qrasterwindow/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-# Generated from qrasterwindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(qrasterwindow LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-set(INSTALL_EXAMPLEDIR "examples/qpa/qrasterwindow")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-
-add_qt_gui_executable(qrasterwindow
- main.cpp
-)
-target_link_libraries(qrasterwindow PUBLIC
- Qt::Core
- Qt::Gui
-)
-
-install(TARGETS qrasterwindow
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/qpa/qrasterwindow/CMakeLists.txt b/examples/qpa/qrasterwindow/CMakeLists.txt
deleted file mode 100644
index 94af7b6de5..0000000000
--- a/examples/qpa/qrasterwindow/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Generated from qrasterwindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(qrasterwindow LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qpa/qrasterwindow")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-
-qt_add_executable(qrasterwindow
- main.cpp
-)
-set_target_properties(qrasterwindow PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(qrasterwindow PUBLIC
- Qt::Core
- Qt::Gui
-)
-
-install(TARGETS qrasterwindow
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/qpa/qrasterwindow/main.cpp b/examples/qpa/qrasterwindow/main.cpp
deleted file mode 100644
index 699c950c27..0000000000
--- a/examples/qpa/qrasterwindow/main.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2016 The Qt Company Ltd.
- ** Contact: https://www.qt.io/licensing/
- **
- ** This file is part of the examples of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:BSD$
- ** Commercial License Usage
- ** Licensees holding valid commercial Qt licenses may use this file in
- ** accordance with the commercial license agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and The Qt Company. For licensing terms
- ** and conditions see https://www.qt.io/terms-conditions. For further
- ** information use the contact form at https://www.qt.io/contact-us.
- **
- ** BSD License Usage
- ** Alternatively, you may use this file under the terms of the BSD license
- ** as follows:
- **
- ** "Redistribution and use in source and binary forms, with or without
- ** modification, are permitted provided that the following conditions are
- ** met:
- ** * Redistributions of source code must retain the above copyright
- ** notice, this list of conditions and the following disclaimer.
- ** * Redistributions in binary form must reproduce the above copyright
- ** notice, this list of conditions and the following disclaimer in
- ** the documentation and/or other materials provided with the
- ** distribution.
- ** * Neither the name of The Qt Company Ltd nor the names of its
- ** contributors may be used to endorse or promote products derived
- ** from this software without specific prior written permission.
- **
- **
- ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- **
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
-
-#include <QRasterWindow>
-#include <QPainter>
-#include <QPainterPath>
-#include <QGuiApplication>
-#include <QMatrix4x4>
-#include <QTimer>
-
-static QPainterPath painterPathForTriangle()
-{
- static const QPointF bottomLeft(-1.0, -1.0);
- static const QPointF top(0.0, 1.0);
- static const QPointF bottomRight(1.0, -1.0);
-
- QPainterPath path(bottomLeft);
- path.lineTo(top);
- path.lineTo(bottomRight);
- path.closeSubpath();
- return path;
-}
-
-class PaintedWindow : public QRasterWindow
-{
- Q_OBJECT
-
-public:
- PaintedWindow()
- {
- m_view.lookAt(QVector3D(3,1,1),
- QVector3D(0,0,0),
- QVector3D(0,1,0));
- m_timer.setInterval(16);
- connect(&m_timer, SIGNAL(timeout()), this, SLOT(update()));
- m_timer.start();
- }
-
-protected:
- void paintEvent(QPaintEvent *)
- {
- QPainter p(this);
- p.fillRect(QRect(0,0,width(),height()),Qt::gray);
-
- p.setWorldTransform(m_window_matrix.toTransform());
-
- QMatrix4x4 mvp = m_projection * m_view * m_model;
- p.setTransform(mvp.toTransform(), true);
-
- p.fillPath(painterPathForTriangle(), m_brush);
-
- m_model.rotate(1, 0, 1, 0);
- }
-
- void resizeEvent(QResizeEvent *)
- {
- m_window_matrix = QTransform();
- m_window_matrix.translate(width() / 2.0, height() / 2.0);
- m_window_matrix.scale(width() / 2.0, -height() / 2.0);
-
- m_projection.setToIdentity();
- m_projection.perspective(45.f, qreal(width()) / qreal(height()), 0.1f, 100.f);
-
- QLinearGradient gradient(QPointF(-1,-1), QPointF(1,1));
- gradient.setColorAt(0, Qt::red);
- gradient.setColorAt(1, Qt::green);
-
- m_brush = QBrush(gradient);
- }
-
-private:
- QMatrix4x4 m_window_matrix;
- QMatrix4x4 m_projection;
- QMatrix4x4 m_view;
- QMatrix4x4 m_model;
- QBrush m_brush;
- QTimer m_timer;
-};
-
-int main (int argc, char **argv)
-{
- QGuiApplication app(argc, argv);
-
- PaintedWindow window;
- window.create();
- window.show();
-
- return app.exec();
-}
-
-#include "main.moc"
diff --git a/examples/qpa/qrasterwindow/qrasterwindow.pro b/examples/qpa/qrasterwindow/qrasterwindow.pro
deleted file mode 100644
index e5bf34f25c..0000000000
--- a/examples/qpa/qrasterwindow/qrasterwindow.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-SOURCES += main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/qpa/qrasterwindow
-INSTALLS += target
diff --git a/examples/qpa/windows/CMakeLists.txt b/examples/qpa/windows/CMakeLists.txt
deleted file mode 100644
index e644be537c..0000000000
--- a/examples/qpa/windows/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from windows.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(windows LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qpa/windows")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-
-qt_add_executable(windows
- main.cpp
- window.cpp window.h
-)
-set_target_properties(windows PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(windows PUBLIC
- Qt::Core
- Qt::CorePrivate
- Qt::Gui
- Qt::GuiPrivate
-)
-
-install(TARGETS windows
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/qpa/windows/main.cpp b/examples/qpa/windows/main.cpp
deleted file mode 100644
index 80f44ae0dc..0000000000
--- a/examples/qpa/windows/main.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include <QScreen>
-#include <QRect>
-#include <QSharedPointer>
-
-#include "window.h"
-
-int main(int argc, char **argv)
-{
- typedef QSharedPointer<QWindow> WindowPtr;
-
- QGuiApplication app(argc, argv);
-
- Window a;
- a.setFramePosition(QPoint(10, 10));
- a.setTitle(QStringLiteral("Window A"));
- a.setObjectName(a.title());
- a.setVisible(true);
-
- Window b;
- b.setFramePosition(QPoint(100, 100));
- b.setTitle(QStringLiteral("Window B"));
- b.setObjectName(b.title());
- b.setVisible(true);
-
- Window child(&b);
- child.setObjectName(QStringLiteral("ChildOfB"));
- child.setVisible(true);
-
- // create one window on each additional screen as well
-
- QList<WindowPtr> windows;
- const QList<QScreen *> screens = app.screens();
- for (QScreen *screen : screens) {
- if (screen == app.primaryScreen())
- continue;
- WindowPtr window(new Window(screen));
- QRect geometry = window->geometry();
- geometry.moveCenter(screen->availableGeometry().center());
- window->setGeometry(geometry);
- window->setVisible(true);
- window->setTitle(screen->name());
- window->setObjectName(window->title());
- windows.push_back(window);
- }
- return app.exec();
-}
diff --git a/examples/qpa/windows/window.cpp b/examples/qpa/windows/window.cpp
deleted file mode 100644
index b4e4cf05f7..0000000000
--- a/examples/qpa/windows/window.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "window.h"
-
-#include <private/qguiapplication_p.h>
-
-#include <QBackingStore>
-#include <QPainter>
-
-static int colorIndexId = 0;
-
-QColor colorTable[] =
-{
- QColor("#f09f8f"),
- QColor("#a2bff2"),
- QColor("#c0ef8f")
-};
-
-Window::Window(QScreen *screen)
- : QWindow(screen)
- , m_backgroundColorIndex(colorIndexId++)
-{
- initialize();
-}
-
-Window::Window(QWindow *parent)
- : QWindow(parent)
- , m_backgroundColorIndex(colorIndexId++)
-{
- initialize();
-}
-
-void Window::initialize()
-{
- if (parent())
- setGeometry(QRect(160, 120, 320, 240));
- else {
- setFlags(flags() | Qt::WindowTitleHint | Qt::WindowSystemMenuHint
- | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
- const QSize baseSize = QSize(640, 480);
- setGeometry(QRect(geometry().topLeft(), baseSize));
-
- setSizeIncrement(QSize(10, 10));
- setBaseSize(baseSize);
- setMinimumSize(QSize(240, 160));
- setMaximumSize(QSize(800, 600));
- }
-
- create();
- m_backingStore = new QBackingStore(this);
-
- m_image = QImage(geometry().size(), QImage::Format_RGB32);
- m_image.fill(colorTable[m_backgroundColorIndex % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba());
-
- m_lastPos = QPoint(-1, -1);
- m_renderTimer = 0;
-}
-
-void Window::mousePressEvent(QMouseEvent *event)
-{
- m_lastPos = event->position().toPoint();
-}
-
-void Window::mouseMoveEvent(QMouseEvent *event)
-{
- if (m_lastPos != QPoint(-1, -1)) {
- QPainter p(&m_image);
- p.setRenderHint(QPainter::Antialiasing);
- p.drawLine(m_lastPos, event->position().toPoint());
- m_lastPos = event->position().toPoint();
-
- scheduleRender();
- }
-}
-
-void Window::mouseReleaseEvent(QMouseEvent *event)
-{
- if (m_lastPos != QPoint(-1, -1)) {
- QPainter p(&m_image);
- p.setRenderHint(QPainter::Antialiasing);
- p.drawLine(m_lastPos, event->position().toPoint());
- m_lastPos = QPoint(-1, -1);
-
- scheduleRender();
- }
-}
-
-void Window::exposeEvent(QExposeEvent *)
-{
- scheduleRender();
-}
-
-void Window::resizeEvent(QResizeEvent *)
-{
- QImage old = m_image;
-
- int width = qMax(geometry().width(), old.width());
- int height = qMax(geometry().height(), old.height());
-
- if (width > old.width() || height > old.height()) {
- m_image = QImage(width, height, QImage::Format_RGB32);
- m_image.fill(colorTable[(m_backgroundColorIndex) % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba());
-
- QPainter p(&m_image);
- p.drawImage(0, 0, old);
- }
- scheduleRender();
-}
-
-void Window::keyPressEvent(QKeyEvent *event)
-{
- switch (event->key()) {
- case Qt::Key_Backspace:
- m_text.chop(1);
- break;
- case Qt::Key_Enter:
- case Qt::Key_Return:
- m_text.append('\n');
- break;
- default:
- m_text.append(event->text());
- break;
- }
- scheduleRender();
-}
-
-void Window::scheduleRender()
-{
- if (!m_renderTimer)
- m_renderTimer = startTimer(1);
-}
-
-void Window::timerEvent(QTimerEvent *)
-{
- if (isExposed())
- render();
- killTimer(m_renderTimer);
- m_renderTimer = 0;
-}
-
-void Window::render()
-{
- QRect rect(QPoint(), geometry().size());
- m_backingStore->resize(rect.size());
-
- m_backingStore->beginPaint(rect);
-
- QPaintDevice *device = m_backingStore->paintDevice();
-
- QPainter p(device);
- p.drawImage(0, 0, m_image);
-
- QFont font;
- font.setPixelSize(32);
-
- p.setFont(font);
- p.drawText(rect, 0, m_text);
-
- m_backingStore->endPaint();
- m_backingStore->flush(rect);
-}
-
-
diff --git a/examples/qpa/windows/window.h b/examples/qpa/windows/window.h
deleted file mode 100644
index 438be413b8..0000000000
--- a/examples/qpa/windows/window.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QWindow>
-#include <QImage>
-
-class Window : public QWindow
-{
-public:
- Window(QWindow *parent = nullptr);
- Window(QScreen *screen);
-
-protected:
- void mousePressEvent(QMouseEvent *) override;
- void mouseMoveEvent(QMouseEvent *) override;
- void mouseReleaseEvent(QMouseEvent *) override;
-
- void keyPressEvent(QKeyEvent *) override;
-
- void exposeEvent(QExposeEvent *) override;
- void resizeEvent(QResizeEvent *) override;
-
- void timerEvent(QTimerEvent *) override;
-
-private:
- void render();
- void scheduleRender();
- void initialize();
-
- QString m_text;
- QImage m_image;
- QPoint m_lastPos;
- int m_backgroundColorIndex;
- QBackingStore *m_backingStore;
- int m_renderTimer;
-};
diff --git a/examples/qpa/windows/windows.pro b/examples/qpa/windows/windows.pro
deleted file mode 100644
index cf2b7ab200..0000000000
--- a/examples/qpa/windows/windows.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += console
-QT += gui-private core-private
-
-HEADERS += window.h
-SOURCES += window.cpp main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/qpa/windows
-INSTALLS += target
diff --git a/examples/qtconcurrent/CMakeLists.txt b/examples/qtconcurrent/CMakeLists.txt
index ed1be7ec4d..13e78678d8 100644
--- a/examples/qtconcurrent/CMakeLists.txt
+++ b/examples/qtconcurrent/CMakeLists.txt
@@ -1,14 +1,11 @@
-# Generated from qtconcurrent.pro.
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-if(NOT TARGET Qt::Concurrent)
+if(NOT TARGET Qt6::Concurrent)
return()
endif()
-if(TARGET Qt::Widgets)
- add_subdirectory(imagescaling)
- add_subdirectory(progressdialog)
- add_subdirectory(runfunction)
- add_subdirectory(wordcount)
-endif()
-if(TARGET Qt::Gui)
- add_subdirectory(map)
+if(TARGET Qt6::Widgets)
+ qt_internal_add_example(imagescaling)
+ qt_internal_add_example(primecounter)
+ qt_internal_add_example(wordcount)
endif()
diff --git a/examples/qtconcurrent/imagescaling/CMakeLists.txt b/examples/qtconcurrent/imagescaling/CMakeLists.txt
index caca16da12..d053d04fc1 100644
--- a/examples/qtconcurrent/imagescaling/CMakeLists.txt
+++ b/examples/qtconcurrent/imagescaling/CMakeLists.txt
@@ -1,45 +1,41 @@
-# Generated from imagescaling.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(imagescaling LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Concurrent Core Gui Network Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qtconcurrent/imagescaling")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Concurrent)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS Network)
+qt_standard_project_setup()
qt_add_executable(imagescaling
downloaddialog.cpp downloaddialog.h downloaddialog.ui
imagescaling.cpp imagescaling.h
main.cpp
)
+
set_target_properties(imagescaling PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(imagescaling PUBLIC
- Qt::Concurrent
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
+
+target_link_libraries(imagescaling PRIVATE
+ Qt6::Concurrent
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Network
+ Qt6::Widgets
)
install(TARGETS imagescaling
- 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 imagescaling
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/qtconcurrent/imagescaling/doc/images/imagescaling.webp b/examples/qtconcurrent/imagescaling/doc/images/imagescaling.webp
new file mode 100644
index 0000000000..56999faaa7
--- /dev/null
+++ b/examples/qtconcurrent/imagescaling/doc/images/imagescaling.webp
Binary files differ
diff --git a/examples/qtconcurrent/imagescaling/doc/images/imagescaling_example.png b/examples/qtconcurrent/imagescaling/doc/images/imagescaling_example.png
deleted file mode 100644
index a3860e1974..0000000000
--- a/examples/qtconcurrent/imagescaling/doc/images/imagescaling_example.png
+++ /dev/null
Binary files differ
diff --git a/examples/qtconcurrent/imagescaling/doc/src/qtconcurrent-imagescaling.qdoc b/examples/qtconcurrent/imagescaling/doc/src/qtconcurrent-imagescaling.qdoc
index 8814c826ed..499cb165c8 100644
--- a/examples/qtconcurrent/imagescaling/doc/src/qtconcurrent-imagescaling.qdoc
+++ b/examples/qtconcurrent/imagescaling/doc/src/qtconcurrent-imagescaling.qdoc
@@ -1,41 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example imagescaling
- \title Image Scaling Example
- \brief Demonstrates how to asynchronously download and scale images.
+ \meta tags {widgets, threads, network}
+ \title Image Scaling
\ingroup qtconcurrentexamples
- \image imagescaling_example.png
+ \examplecategory {Networking}
+ \brief Demonstrates how to asynchronously download and scale images.
- This example shows how to use the QFuture and QPromise classes to download a
- collection of images from the network and scale them, without blocking the UI.
+ This example shows how to use the QFuture, QPromise, and QFutureWatcher
+ classes to download a collection of images from the network and scale them,
+ without blocking the UI.
- The application consists of the the following steps:
+ \image imagescaling.webp
+
+ The application consists of the following steps:
\list 1
\li Download images form the list of URLs specified by the user.
@@ -68,7 +48,6 @@
And here starts the interesting part:
- \dots
\snippet imagescaling/imagescaling.cpp 11
\dots
@@ -78,12 +57,14 @@
QNetworkReply::finished() signal is emitted. This allows us to attach continuations
and failure handlers, as it is done in the example.
- In the continuation attached via \b{.then()}, we check if the user has requested to
- cancel the download. If that's the case, we stop processing the request. By calling
- the \c QPromise::finish() method, we notify the user that processing has been finished.
+ In the continuation attached via \l{QFuture::then}{.then()}, we check if the
+ user has requested to cancel the download. If that's the case, we stop
+ processing the request. By calling the \l QPromise::finish() method, we notify
+ the user that processing has been finished.
In case the network request has ended with an error, we throw an exception. The
- exception will be handled in the failure handler attached using the \b{.onFailed()}
- method. Note that we have two failure handlers: the first one captures the network
+ exception will be handled in the failure handler attached using the
+ \l{QFuture::onFailed}{.onFailed()} method.
+ Note that we have two failure handlers: the first one captures the network
errors, the second one all other exceptions thrown during the execution. Both handlers
save the exception inside the promise object (to be handled by the caller of the
\c download() method) and report that the computation has finished. Also note that,
@@ -105,7 +86,7 @@
we need to copy and use the promise object in multiple places simultaneously. Hence,
a QSharedPointer is used.
- \c download() method is called from the \c QImage::process method. It is invoked
+ The \c download() method is called from the \c Images::process method. It is invoked
when the user presses the \e {"Add URLs"} button:
\dots
@@ -121,38 +102,20 @@
\snippet imagescaling/imagescaling.cpp 3
\dots
- Next, we attach a continuation to handle the scaling step:
+ Next, we attach a continuation to handle the scaling step.
+ More on that later:
\snippet imagescaling/imagescaling.cpp 4
\dots
- Since the scaling may be computationally heavy, and we don't want to block the main
- thread, we pass the \c QtFuture::Launch::Async option, to launch the scaling step in
- a new thread. The \c scaled() method returns a list of the scaled images to the next
- step, which takes care of showing images in the layout.
+ After that we attach \l {QFuture::}{onCanceled()} and \l {QFuture::}{onFailed()}
+ handlers:
- Note that \c updateStatus() is called through QMetaObject::invokeMethod(),
- because it updates the UI and needs to be invoked from the main thread.
-
- \dots
\snippet imagescaling/imagescaling.cpp 5
\dots
- For the same reason \c showImages() also needs to be invoked from the main thread, so
- we pass \c this as a context to \c .then(). By default, \c .then() is launched in the
- parent's thread, but if a context object is specified, it is launched in the context
- object's thread.
-
- Then we add cancellation and failure handlers:
-
- \dots
- \snippet imagescaling/imagescaling.cpp 6
-
- We don't need to specify the context anymore, because \c .onCanceled() and the next
- handlers will be launched in their parent's context.
-
- The handler attached via the \c .onCanceled() method will be called if the user has
- pressed the \e "Cancel" button:
+ The handler attached via the \l {QFuture::onCanceled}{.onCanceled()} method
+ will be called if the user has pressed the \e "Cancel" button:
\dots
\snippet imagescaling/imagescaling.cpp 2
@@ -162,14 +125,57 @@
\snippet imagescaling/imagescaling.cpp 7
- The handlers attached via \c .onFailed() method will be called in case an
- error occurred during one of the previous steps. For example, if a network error
- has been saved inside the promise during the download step, it will be propagated to
- the handler that takes \c QNetworkReply::NetworkError as argument. A failure can
- happen also during the scaling step:
+ The handlers attached via \l {QFuture::onFailed}{.onFailed()} method will be
+ called in case an error occurred during one of the previous steps.
+ For example, if a network error has been saved inside the promise during the
+ download step, it will be propagated to the handler that takes
+ \l QNetworkReply::NetworkError as argument.
+
+ If the \c downloadFuture is not canceled, and didn't report any error, the
+ scaling continuation is executed.
+
+ Since the scaling may be computationally heavy, and we don't want to block
+ the main thread, we use \l QtConcurrent::run(), to launch the scaling step
+ in a new thread.
+
+ \snippet imagescaling/imagescaling.cpp 16
+
+ Since the scaling is launched in a separate thread, the user can potentially
+ decide to close the application while the scaling operation is in progress.
+ To handle such situations gracefully, we pass the \l QFuture returned by
+ \l QtConcurrent::run() to the \l QFutureWatcher instance.
+
+ The watcher's \l QFutureWatcher::finished signal is connected to the
+ \c Images::scaleFinished slot:
+
+ \snippet imagescaling/imagescaling.cpp 6
+
+ This slot is responsible for showing the scaled images in the UI, and also
+ for handling the errors that could potentially happen during scaling:
+
+ \snippet imagescaling/imagescaling.cpp 15
+
+ The error reporting is implemented by returning an optional from the
+ \c Images::scaled() method:
\snippet imagescaling/imagescaling.cpp 14
+ The \c Images::OptionalImages type here is simply a typedef for \c std::optional:
+
+ \snippet imagescaling/imagescaling.h 1
+
+ \note We cannot handle the errors from the async scaling operation using
+ the \l {QFuture::onFailed}{.onFailed()} handler, because the handler needs
+ to be executed in the context of \c Images object in the UI thread.
+ If the user closes the application while the async computation is done,
+ the \c Images object will be destroyed, and accessing its members from the
+ continuation will lead to a crash. Using \l QFutureWatcher and its signals
+ allows us to avoid the problem, because the signals are disconnected when
+ the \l QFutureWatcher is destroyed, so the related slots will never be
+ executed in a destroyed context.
+
The rest of the code is straightforward, you can check the example project for
more details.
+
+ \include examples-run.qdocinc
*/
diff --git a/examples/qtconcurrent/imagescaling/downloaddialog.cpp b/examples/qtconcurrent/imagescaling/downloaddialog.cpp
index 2f2f901b0e..c3ec550038 100644
--- a/examples/qtconcurrent/imagescaling/downloaddialog.cpp
+++ b/examples/qtconcurrent/imagescaling/downloaddialog.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "downloaddialog.h"
#include "ui_downloaddialog.h"
diff --git a/examples/qtconcurrent/imagescaling/downloaddialog.h b/examples/qtconcurrent/imagescaling/downloaddialog.h
index 9e5d478d7d..e4a6482907 100644
--- a/examples/qtconcurrent/imagescaling/downloaddialog.h
+++ b/examples/qtconcurrent/imagescaling/downloaddialog.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DOWNLOADDIALOG_H
#define DOWNLOADDIALOG_H
diff --git a/examples/qtconcurrent/imagescaling/imagescaling.cpp b/examples/qtconcurrent/imagescaling/imagescaling.cpp
index 66bb0686c3..f380ae9d90 100644
--- a/examples/qtconcurrent/imagescaling/imagescaling.cpp
+++ b/examples/qtconcurrent/imagescaling/imagescaling.cpp
@@ -1,64 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
#include "imagescaling.h"
#include "downloaddialog.h"
#include <QNetworkReply>
-#include <qmath.h>
-
-#include <functional>
-
-Images::Images(QWidget *parent) : QWidget(parent), downloadDialog(new DownloadDialog())
+Images::Images(QWidget *parent) : QWidget(parent), downloadDialog(new DownloadDialog(this))
{
- setWindowTitle(tr("Image downloading and scaling example"));
resize(800, 600);
addUrlsButton = new QPushButton(tr("Add URLs"));
@@ -87,6 +36,11 @@ Images::Images(QWidget *parent) : QWidget(parent), downloadDialog(new DownloadDi
mainLayout->addStretch();
mainLayout->addWidget(statusBar);
setLayout(mainLayout);
+
+//! [6]
+ connect(&scalingWatcher, &QFutureWatcher<QList<QImage>>::finished,
+ this, &Images::scaleFinished);
+//! [6]
}
Images::~Images()
@@ -99,6 +53,7 @@ void Images::process()
{
// Clean previous state
replies.clear();
+ addUrlsButton->setEnabled(false);
if (downloadDialog->exec() == QDialog::Accepted) {
@@ -114,33 +69,34 @@ void Images::process()
statusBar->showMessage(tr("Downloading..."));
//! [3]
-//! [4]
- downloadFuture.then([this](auto) { cancelButton->setEnabled(false); })
- .then(QtFuture::Launch::Async,
- [this] {
- QMetaObject::invokeMethod(this,
- [this] { updateStatus(tr("Scaling...")); });
- return scaled();
- })
-//! [4]
-//! [5]
- .then(this, [this](const QList<QImage> &scaled) {
- showImages(scaled);
- updateStatus(tr("Finished"));
+ //! [4]
+ downloadFuture
+ .then([this](auto) {
+ cancelButton->setEnabled(false);
+ updateStatus(tr("Scaling..."));
+ //! [16]
+ scalingWatcher.setFuture(QtConcurrent::run(Images::scaled,
+ downloadFuture.results()));
+ //! [16]
+ })
+ //! [4]
+ //! [5]
+ .onCanceled([this] {
+ updateStatus(tr("Download has been canceled."));
})
-//! [5]
-//! [6]
- .onCanceled([this] { updateStatus(tr("Download has been canceled.")); })
.onFailed([this](QNetworkReply::NetworkError error) {
updateStatus(tr("Download finished with error: %1").arg(error));
-
// Abort all pending requests
abortDownload();
})
- .onFailed([this](const std::exception& ex) {
+ .onFailed([this](const std::exception &ex) {
updateStatus(tr(ex.what()));
+ })
+ //! [5]
+ .then([this]() {
+ cancelButton->setEnabled(false);
+ addUrlsButton->setEnabled(true);
});
-//! [6]
}
}
@@ -154,22 +110,37 @@ void Images::cancel()
}
//! [7]
+//! [15]
+void Images::scaleFinished()
+{
+ const OptionalImages result = scalingWatcher.result();
+ if (result.has_value()) {
+ const auto scaled = result.value();
+ showImages(scaled);
+ updateStatus(tr("Finished"));
+ } else {
+ updateStatus(tr("Failed to extract image data."));
+ }
+ addUrlsButton->setEnabled(true);
+}
+//! [15]
+
//! [8]
QFuture<QByteArray> Images::download(const QList<QUrl> &urls)
-//! [8]
{
+//! [8]
//! [9]
QSharedPointer<QPromise<QByteArray>> promise(new QPromise<QByteArray>());
promise->start();
//! [9]
-//! [10]
- for (auto url : urls) {
+ //! [10]
+ for (const auto &url : urls) {
QSharedPointer<QNetworkReply> reply(qnam.get(QNetworkRequest(url)));
replies.push_back(reply);
-//! [10]
+ //! [10]
-//! [11]
+ //! [11]
QtFuture::connect(reply.get(), &QNetworkReply::finished).then([=] {
if (promise->isCanceled()) {
if (!promise->future().isFinished())
@@ -181,25 +152,24 @@ QFuture<QByteArray> Images::download(const QList<QUrl> &urls)
if (!promise->future().isFinished())
throw reply->error();
}
-//! [12]
+ //! [12]
promise->addResult(reply->readAll());
// Report finished on the last download
- if (promise->future().resultCount() == urls.size()) {
+ if (promise->future().resultCount() == urls.size())
promise->finish();
- }
-//! [12]
- }).onFailed([=] (QNetworkReply::NetworkError error) {
+ //! [12]
+ }).onFailed([promise] (QNetworkReply::NetworkError error) {
promise->setException(std::make_exception_ptr(error));
promise->finish();
- }).onFailed([=] {
+ }).onFailed([promise] {
const auto ex = std::make_exception_ptr(
std::runtime_error("Unknown error occurred while downloading."));
promise->setException(ex);
promise->finish();
});
}
-//! [11]
+ //! [11]
//! [13]
return promise->future();
@@ -207,15 +177,14 @@ QFuture<QByteArray> Images::download(const QList<QUrl> &urls)
//! [13]
//! [14]
-QList<QImage> Images::scaled() const
+Images::OptionalImages Images::scaled(const QList<QByteArray> &data)
{
QList<QImage> scaled;
- const auto data = downloadFuture.results();
- for (auto imgData : data) {
+ for (const auto &imgData : data) {
QImage image;
image.loadFromData(imgData);
if (image.isNull())
- throw std::runtime_error("Failed to load image.");
+ return std::nullopt;
scaled.push_back(image.scaled(100, 100, Qt::KeepAspectRatio));
}
@@ -238,6 +207,7 @@ void Images::initLayout(qsizetype count)
QLayoutItem *child;
while ((child = imagesLayout->takeAt(0)) != nullptr) {
child->widget()->setParent(nullptr);
+ delete child->widget();
delete child;
}
labels.clear();
diff --git a/examples/qtconcurrent/imagescaling/imagescaling.h b/examples/qtconcurrent/imagescaling/imagescaling.h
index 0c0d90870e..bc25161a85 100644
--- a/examples/qtconcurrent/imagescaling/imagescaling.h
+++ b/examples/qtconcurrent/imagescaling/imagescaling.h
@@ -1,58 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef IMAGESCALING_H
#define IMAGESCALING_H
#include <QtWidgets>
#include <QtConcurrent>
#include <QNetworkAccessManager>
+#include <optional>
class DownloadDialog;
class Images : public QWidget
@@ -65,7 +19,6 @@ public:
void initLayout(qsizetype count);
QFuture<QByteArray> download(const QList<QUrl> &urls);
- QList<QImage> scaled() const;
void updateStatus(const QString &msg);
void showImages(const QList<QImage> &images);
void abortDownload();
@@ -74,7 +27,15 @@ public slots:
void process();
void cancel();
+private slots:
+ void scaleFinished();
+
private:
+ //! [1]
+ using OptionalImages = std::optional<QList<QImage>>;
+ //! [1]
+ static OptionalImages scaled(const QList<QByteArray> &data);
+
QPushButton *addUrlsButton;
QPushButton *cancelButton;
QVBoxLayout *mainLayout;
@@ -86,6 +47,7 @@ private:
QNetworkAccessManager qnam;
QList<QSharedPointer<QNetworkReply>> replies;
QFuture<QByteArray> downloadFuture;
+ QFutureWatcher<OptionalImages> scalingWatcher;
};
#endif // IMAGESCALING_H
diff --git a/examples/qtconcurrent/imagescaling/main.cpp b/examples/qtconcurrent/imagescaling/main.cpp
index 01390499f5..67b543a961 100644
--- a/examples/qtconcurrent/imagescaling/main.cpp
+++ b/examples/qtconcurrent/imagescaling/main.cpp
@@ -1,62 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtWidgets>
-#include <QtConcurrent>
-
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "imagescaling.h"
+#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
+ app.setOrganizationName("QtProject");
+ app.setApplicationName(QObject::tr("Image Downloading and Scaling"));
Images imageView;
+ imageView.setWindowTitle(QObject::tr("Image Downloading and Scaling"));
imageView.show();
return app.exec();
diff --git a/examples/qtconcurrent/map/.prev_CMakeLists.txt b/examples/qtconcurrent/map/.prev_CMakeLists.txt
deleted file mode 100644
index 0e3215c225..0000000000
--- a/examples/qtconcurrent/map/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated from map.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(mapdemo LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qtconcurrent/map")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Concurrent)
-
-qt_add_executable(mapdemo
- main.cpp
-)
-set_target_properties(mapdemo PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(mapdemo PUBLIC
- Qt::Concurrent
- Qt::Core
- Qt::Gui
-)
-
-install(TARGETS mapdemo
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/qtconcurrent/map/CMakeLists.txt b/examples/qtconcurrent/map/CMakeLists.txt
deleted file mode 100644
index 08589f1b3f..0000000000
--- a/examples/qtconcurrent/map/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Generated from map.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(mapdemo LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qtconcurrent/map")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Concurrent)
-
-qt_add_executable(mapdemo
- main.cpp
-)
-set_target_properties(mapdemo PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(mapdemo PUBLIC
- Qt::Concurrent
- Qt::Core
- Qt::Gui
-)
-install(TARGETS mapdemo
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/qtconcurrent/map/doc/src/qtconcurrent-map.qdoc b/examples/qtconcurrent/map/doc/src/qtconcurrent-map.qdoc
deleted file mode 100644
index 2cc66e932e..0000000000
--- a/examples/qtconcurrent/map/doc/src/qtconcurrent-map.qdoc
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example map
- \title Map Example
- \brief Demonstrates how to scale images synchronously.
- \ingroup qtconcurrentexamples
-
- The QtConcurrent Map example shows how to use the synchronous (blocking)
- QtConcurrent API to scale a collection of images.
-
- This is a command-line application.
-*/
diff --git a/examples/qtconcurrent/map/main.cpp b/examples/qtconcurrent/map/main.cpp
deleted file mode 100644
index 8fc670b64b..0000000000
--- a/examples/qtconcurrent/map/main.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QImage>
-#include <QList>
-#include <QThread>
-#include <QDebug>
-#include <QGuiApplication>
-#include <qtconcurrentmap.h>
-
-#include <functional>
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- const int imageCount = 20;
-
- // Create a list containing imageCount images.
- QList<QImage> images;
- for (int i = 0; i < imageCount; ++i)
- images.append(QImage(1600, 1200, QImage::Format_ARGB32_Premultiplied));
-
- std::function<QImage(const QImage&)> scale = [](const QImage &image) -> QImage
- {
- qDebug() << "Scaling image in thread" << QThread::currentThread();
- return image.scaled(QSize(100, 100), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- };
-
- // Use QtConcurrentBlocking::mapped to apply the scale function to all the
- // images in the list.
- QList<QImage> thumbnails = QtConcurrent::blockingMapped(images, scale);
-
- return 0;
-}
diff --git a/examples/qtconcurrent/map/map.pro b/examples/qtconcurrent/map/map.pro
deleted file mode 100644
index 7f267beb22..0000000000
--- a/examples/qtconcurrent/map/map.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-TEMPLATE = app
-TARGET = mapdemo
-QT += concurrent
-CONFIG += cmdline
-
-SOURCES += main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/map
-INSTALLS += target
diff --git a/examples/qtconcurrent/primecounter/CMakeLists.txt b/examples/qtconcurrent/primecounter/CMakeLists.txt
new file mode 100644
index 0000000000..c8ac5f20e8
--- /dev/null
+++ b/examples/qtconcurrent/primecounter/CMakeLists.txt
@@ -0,0 +1,41 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(primecounter LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Concurrent Core Gui Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(primecounter
+ main.cpp
+ primecounter.ui
+ primecounter.cpp
+ primecounter.h
+)
+
+set_target_properties(primecounter PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(primecounter PRIVATE
+ Qt6::Concurrent
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+)
+
+install(TARGETS primecounter
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+qt_generate_deploy_app_script(
+ TARGET primecounter
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
+)
+install(SCRIPT ${deploy_script})
diff --git a/examples/qtconcurrent/primecounter/doc/images/primecounter.png b/examples/qtconcurrent/primecounter/doc/images/primecounter.png
new file mode 100644
index 0000000000..d611a507b5
--- /dev/null
+++ b/examples/qtconcurrent/primecounter/doc/images/primecounter.png
Binary files differ
diff --git a/examples/qtconcurrent/primecounter/doc/src/qtconcurrent-primecounter.qdoc b/examples/qtconcurrent/primecounter/doc/src/qtconcurrent-primecounter.qdoc
new file mode 100644
index 0000000000..de6c94b0cf
--- /dev/null
+++ b/examples/qtconcurrent/primecounter/doc/src/qtconcurrent-primecounter.qdoc
@@ -0,0 +1,89 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example primecounter
+ \meta tags {widgets, threads}
+ \title Prime Counter
+ \ingroup qtconcurrentexamples
+ \examplecategory {Data Processing & I/O}
+ \brief Demonstrates how to monitor the progress of concurrent operations.
+
+ The following example demonstrates how to create an interactive and
+ non-blocking QtWidgets application using the QFutureWatcher class and the
+ \l {Concurrent Filter-Reduce} {filteredReduced} functions from
+ \l {Qt Concurrent}. With this example, the user can create a QList of
+ integers that can be resized. The list will be automatically filled with
+ natural numbers starting from 1 up to n. The program will then check for
+ prime numbers within the list and display the total count of prime numbers
+ found.
+
+ \image primecounter.png
+
+ \include examples-run.qdocinc
+
+ \section1 Setting up the connections
+
+ The \l {Qt Concurrent} library provides the
+ \l {Concurrent Filter-Reduce} {filteredReduced} functions, which can operate
+ in two modes:
+ \l {QtConcurrent::ReduceOption} {OrderedReduce and UnorderedReduce}. In
+ \c OrderedReduce mode, the reducing function is called in the order of the
+ original sequence, whereas in \c UnorderedReduce mode, the elements are
+ accessed randomly.
+
+ After configuring the UI with the desired elements, it is necessary to
+ connect them to the signals of the concurrent operations using the Qt
+ \l {Signals & Slots} mechanism. In this example, we use the QFutureWatcher
+ class to monitor the progress of the concurrent operations and provide the
+ signals required to implement the interactive GUI.
+
+ \dots
+ \snippet primecounter/primecounter.cpp 1
+ \dots
+
+ The QFutureWatcher class plays a vital role in this example as it provides
+ the signals required to update the UI in response to changes in the
+ concurrent operations.
+
+ \section1 Starting the concurrent operation
+
+ After connecting all the \l {Signals & Slots}, and when the user presses
+ the QPushButton, the \c {start()} function is called.
+
+ In the \c {start()} function, we call the
+ \l {Concurrent Filter-Reduce} {filteredReduced} function from Qt Concurrent
+ and set the future on the QFutureWatcher member. To ensure that this
+ operation runs truly concurrently, we specify a separate QThreadPool as the
+ first parameter. This approach also avoids any possible blocking in the
+ global thread pool. We pass the QList of integers as the container, a
+ static filter and reduce function, and finally the
+ \l {QtConcurrent::} {ReduceOption} flag.
+
+ \dots
+ \snippet primecounter/primecounter.cpp 2
+ \dots
+
+ Let's examine the filter and reduce functions. These functions are declared
+ static in this example since they do not depend on any member variable.
+ However, they could easily be specified as lambdas or member functions.
+
+ The filter function marks elements for subsequent reduction with the reduce
+ function. This implementation is a simple prime filter. As this function
+ takes a const reference as an argument, it allows thread-safe operation on
+ the container it operates on.
+
+ \dots
+ \snippet primecounter/primecounter.cpp 3
+ \dots
+
+ The reduce function takes a modifiable reference of the same type as the
+ container it operates on as its first parameter. The second parameter is the
+ previously filtered element from the filter function. In this example, we
+ count the number of primes.
+
+ \dots
+ \snippet primecounter/primecounter.cpp 4
+ \dots
+
+*/
diff --git a/examples/qtconcurrent/primecounter/main.cpp b/examples/qtconcurrent/primecounter/main.cpp
new file mode 100644
index 0000000000..acfd581341
--- /dev/null
+++ b/examples/qtconcurrent/primecounter/main.cpp
@@ -0,0 +1,18 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtWidgets/qapplication.h>
+#include "primecounter.h"
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ app.setOrganizationName("QtProject");
+ app.setApplicationName(QApplication::translate("main", "Prime Counter"));
+
+ PrimeCounter dialog;
+ dialog.setWindowTitle(QApplication::translate("main", "Prime Counter"));
+ dialog.show();
+
+ return app.exec();
+}
diff --git a/examples/qtconcurrent/primecounter/primecounter.cpp b/examples/qtconcurrent/primecounter/primecounter.cpp
new file mode 100644
index 0000000000..01bde5d87f
--- /dev/null
+++ b/examples/qtconcurrent/primecounter/primecounter.cpp
@@ -0,0 +1,139 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "primecounter.h"
+#include "ui_primecounter.h"
+
+PrimeCounter::PrimeCounter(QWidget *parent)
+ : QDialog(parent), stepSize(100000), ui(setupUi())
+{
+ // Control the concurrent operation with the QFutureWatcher
+ //! [1]
+ connect(ui->pushButton, &QPushButton::clicked,
+ this, [this] { start(); });
+ connect(&watcher, &QFutureWatcher<Element>::finished,
+ this, [this] { finish(); });
+ connect(&watcher, &QFutureWatcher<Element>::progressRangeChanged,
+ ui->progressBar, &QProgressBar::setRange);
+ connect(&watcher, &QFutureWatcher<Element>::progressValueChanged,
+ ui->progressBar, &QProgressBar::setValue);
+ //! [1]
+}
+
+PrimeCounter::~PrimeCounter()
+{
+ watcher.cancel();
+ delete ui;
+}
+
+//! [3]
+bool PrimeCounter::filterFunction(const Element &element)
+{
+ // Filter for primes
+ if (element <= 1)
+ return false;
+ for (Element i = 2; i*i <= element; ++i) {
+ if (element % i == 0)
+ return false;
+ }
+ return true;
+}
+//! [3]
+
+//! [4]
+void PrimeCounter::reduceFunction(Element &out, const Element &value)
+{
+ // Count the amount of primes.
+ Q_UNUSED(value);
+ ++out;
+}
+//! [4]
+
+//! [2]
+void PrimeCounter::start()
+{
+ if (ui->pushButton->isChecked()) {
+ ui->comboBox->setEnabled(false);
+ ui->pushButton->setText(tr("Cancel"));
+ ui->labelResult->setText(tr("Calculating ..."));
+ ui->labelFilter->setText(tr("Selected Reduce Option: %1").arg(ui->comboBox->currentText()));
+ fillElementList(ui->horizontalSlider->value() * stepSize);
+
+ timer.start();
+ watcher.setFuture(
+ QtConcurrent::filteredReduced(
+ &pool,
+ elementList,
+ filterFunction,
+ reduceFunction,
+ currentReduceOpt | QtConcurrent::SequentialReduce));
+//! [2]
+ } else {
+ watcher.cancel();
+ ui->progressBar->setValue(0);
+ ui->comboBox->setEnabled(true);
+ ui->labelResult->setText(tr(""));
+ ui->pushButton->setText(tr("Start"));
+ ui->labelFilter->setText(tr("Operation Canceled"));
+ }
+}
+
+void PrimeCounter::finish()
+{
+ // The finished signal from the QFutureWatcher is also emitted when cancelling.
+ if (watcher.isCanceled())
+ return;
+
+ auto elapsedTime = timer.elapsed();
+ ui->progressBar->setValue(0);
+ ui->comboBox->setEnabled(true);
+ ui->pushButton->setChecked(false);
+ ui->pushButton->setText(tr("Start"));
+ ui->labelFilter->setText(
+ tr("Filter '%1' took %2 ms to calculate").arg(ui->comboBox->currentText())
+ .arg(elapsedTime));
+ ui->labelResult->setText(
+ tr("Found %1 primes in the range of elements").arg(watcher.result()));
+}
+
+void PrimeCounter::fillElementList(unsigned int count)
+{
+ // Fill elementList with values from [1, count] when starting the calculations.
+ auto prevSize = elementList.size();
+ if (prevSize == count)
+ return; // Nothing to do here.
+
+ auto startVal = elementList.empty() ? 1 : elementList.back() + 1;
+ elementList.resize(count);
+ if (elementList.begin() + prevSize < elementList.end())
+ std::iota(elementList.begin() + prevSize, elementList.end(), startVal);
+}
+
+Ui::PrimeCounter* PrimeCounter::setupUi()
+{
+ Ui::PrimeCounter *setupUI = new Ui::PrimeCounter;
+ setupUI->setupUi(this);
+ setModal(true);
+
+ // Set up the slider
+ connect(setupUI->horizontalSlider, &QSlider::valueChanged,
+ this, [setupUI, this] (const int &pos) {
+ setupUI->labelResult->setText("");
+ setupUI->labelSize->setText(tr("Elements in list: %1").arg(pos * stepSize));
+ });
+ setupUI->horizontalSlider->setValue(30);
+
+ // Set up the combo box
+ setupUI->comboBox->insertItem(0, tr("Unordered Reduce"), QtConcurrent::UnorderedReduce);
+ setupUI->comboBox->insertItem(1, tr("Ordered Reduce"), QtConcurrent::OrderedReduce);
+
+ auto comboBoxChange = [this, setupUI](int pos) {
+ currentReduceOpt = setupUI->comboBox->itemData(pos).value<QtConcurrent::ReduceOptions>();
+ setupUI->labelFilter->setText(tr("Selected Reduce Option: %1")
+ .arg(setupUI->comboBox->currentText()));
+ };
+ comboBoxChange(setupUI->comboBox->currentIndex());
+ connect(setupUI->comboBox, &QComboBox::currentIndexChanged, this, comboBoxChange);
+
+ return setupUI;
+}
diff --git a/examples/qtconcurrent/primecounter/primecounter.h b/examples/qtconcurrent/primecounter/primecounter.h
new file mode 100644
index 0000000000..5b6d442cc8
--- /dev/null
+++ b/examples/qtconcurrent/primecounter/primecounter.h
@@ -0,0 +1,49 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef PRIMECOUNTER_H
+#define PRIMECOUNTER_H
+
+#include <QtWidgets/qdialog.h>
+#include <QtCore/qfuturewatcher.h>
+#include <QtConcurrent/qtconcurrentfilter.h>
+#include <QtConcurrent/qtconcurrentreducekernel.h>
+
+QT_BEGIN_NAMESPACE
+class QLabel;
+class QProgressBar;
+namespace Ui {
+class PrimeCounter;
+}
+
+QT_END_NAMESPACE
+
+class PrimeCounter : public QDialog
+{
+ Q_OBJECT
+ using Element = unsigned long long;
+public:
+ explicit PrimeCounter(QWidget* parent = nullptr);
+ ~PrimeCounter() override;
+
+private:
+ static bool filterFunction(const Element &element);
+ static void reduceFunction(Element &out, const Element &value);
+ void fillElementList(unsigned int count);
+ Ui::PrimeCounter* setupUi();
+
+private slots:
+ void start();
+ void finish();
+
+private:
+ QList<Element> elementList;
+ QFutureWatcher<Element> watcher;
+ QtConcurrent::ReduceOptions currentReduceOpt;
+ QElapsedTimer timer;
+ QThreadPool pool;
+ unsigned int stepSize;
+ Ui::PrimeCounter *ui;
+};
+
+#endif //PRIMECOUNTER_H
diff --git a/examples/qtconcurrent/primecounter/primecounter.pro b/examples/qtconcurrent/primecounter/primecounter.pro
new file mode 100644
index 0000000000..bb5a740688
--- /dev/null
+++ b/examples/qtconcurrent/primecounter/primecounter.pro
@@ -0,0 +1,9 @@
+QT += concurrent widgets
+
+SOURCES += main.cpp primecounter.cpp
+HEADERS += primecounter.h
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/primecounter
+INSTALLS += target
+
+FORMS += primecounter.ui
diff --git a/examples/qtconcurrent/primecounter/primecounter.ui b/examples/qtconcurrent/primecounter/primecounter.ui
new file mode 100644
index 0000000000..625462e05e
--- /dev/null
+++ b/examples/qtconcurrent/primecounter/primecounter.ui
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PrimeCounter</class>
+ <widget class="QDialog" name="PrimeCounter">
+ <property name="windowModality">
+ <enum>Qt::WindowModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>454</width>
+ <height>320</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <property name="leftMargin">
+ <number>20</number>
+ </property>
+ <property name="topMargin">
+ <number>20</number>
+ </property>
+ <property name="rightMargin">
+ <number>20</number>
+ </property>
+ <property name="bottomMargin">
+ <number>20</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="labelInfo">
+ <property name="font">
+ <font>
+ <pointsize>11</pointsize>
+ <bold>false</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Select a reducing option and measure the speed</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer1">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>30</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout2">
+ <property name="topMargin">
+ <number>10</number>
+ </property>
+ <property name="bottomMargin">
+ <number>10</number>
+ </property>
+ <item>
+ <widget class="QComboBox" name="comboBox"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout1">
+ <property name="topMargin">
+ <number>10</number>
+ </property>
+ <property name="bottomMargin">
+ <number>10</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="pushButton">
+ <property name="text">
+ <string>Start</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelFilter">
+ <property name="text">
+ <string>Filter Label</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout3">
+ <item>
+ <widget class="QSlider" name="horizontalSlider">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelSize">
+ <property name="text">
+ <string>size</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ <property name="margin">
+ <number>5</number>
+ </property>
+ <property name="indent">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelResult">
+ <property name="text">
+ <string>Result Label</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/qtconcurrent/progressdialog/CMakeLists.txt b/examples/qtconcurrent/progressdialog/CMakeLists.txt
deleted file mode 100644
index 00dd8215ef..0000000000
--- a/examples/qtconcurrent/progressdialog/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from progressdialog.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(progressdialog LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qtconcurrent/progressdialog")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Concurrent)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(progressdialog
- main.cpp
-)
-set_target_properties(progressdialog PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(progressdialog PUBLIC
- Qt::Concurrent
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS progressdialog
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/qtconcurrent/progressdialog/doc/images/qtconcurrent-progressdialog.png b/examples/qtconcurrent/progressdialog/doc/images/qtconcurrent-progressdialog.png
deleted file mode 100644
index 2e8b7735ad..0000000000
--- a/examples/qtconcurrent/progressdialog/doc/images/qtconcurrent-progressdialog.png
+++ /dev/null
Binary files differ
diff --git a/examples/qtconcurrent/progressdialog/doc/src/qtconcurrent-progressdialog.qdoc b/examples/qtconcurrent/progressdialog/doc/src/qtconcurrent-progressdialog.qdoc
deleted file mode 100644
index 816bbd5170..0000000000
--- a/examples/qtconcurrent/progressdialog/doc/src/qtconcurrent-progressdialog.qdoc
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example progressdialog
- \title QtConcurrent Progress Dialog Example
- \brief Demonstrates how to monitor the progress of the active processes.
- \ingroup qtconcurrentexamples
-
- The QtConcurrent Progress Dialog example shows how to use the
- QFutureWatcher class to monitor the progress of a long-running operation.
-
- \image qtconcurrent-progressdialog.png
-*/
diff --git a/examples/qtconcurrent/progressdialog/main.cpp b/examples/qtconcurrent/progressdialog/main.cpp
deleted file mode 100644
index cf4fd7e456..0000000000
--- a/examples/qtconcurrent/progressdialog/main.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-#include <QtConcurrent>
-
-#include <functional>
-
-using namespace QtConcurrent;
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- const int iterations = 20;
-
- // Prepare the list.
- QList<int> list;
- for (int i = 0; i < iterations; ++i)
- list.append(i);
-
- // Create a progress dialog.
- QProgressDialog dialog;
- dialog.setLabelText(QString("Progressing using %1 thread(s)...").arg(QThread::idealThreadCount()));
-
- // Create a QFutureWatcher and connect signals and slots.
- QFutureWatcher<void> futureWatcher;
- QObject::connect(&futureWatcher, &QFutureWatcher<void>::finished, &dialog, &QProgressDialog::reset);
- QObject::connect(&dialog, &QProgressDialog::canceled, &futureWatcher, &QFutureWatcher<void>::cancel);
- QObject::connect(&futureWatcher, &QFutureWatcher<void>::progressRangeChanged, &dialog, &QProgressDialog::setRange);
- QObject::connect(&futureWatcher, &QFutureWatcher<void>::progressValueChanged, &dialog, &QProgressDialog::setValue);
-
- // Our function to compute
- std::function<void(int&)> spin = [](int &iteration) {
- const int work = 1000 * 1000 * 40;
- volatile int v = 0;
- for (int j = 0; j < work; ++j)
- ++v;
-
- qDebug() << "iteration" << iteration << "in thread" << QThread::currentThreadId();
- };
-
- // Start the computation.
- futureWatcher.setFuture(QtConcurrent::map(list, spin));
-
- // Display the dialog and start the event loop.
- dialog.exec();
-
- futureWatcher.waitForFinished();
-
- // Query the future to check if was canceled.
- qDebug() << "Canceled?" << futureWatcher.future().isCanceled();
-}
diff --git a/examples/qtconcurrent/progressdialog/progressdialog.pro b/examples/qtconcurrent/progressdialog/progressdialog.pro
deleted file mode 100644
index 8a5b3aabb7..0000000000
--- a/examples/qtconcurrent/progressdialog/progressdialog.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-QT += concurrent widgets
-CONFIG += console
-
-SOURCES += main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/progressdialog
-INSTALLS += target
diff --git a/examples/qtconcurrent/qtconcurrent.pro b/examples/qtconcurrent/qtconcurrent.pro
index bdf41b03ea..ea7618fa00 100644
--- a/examples/qtconcurrent/qtconcurrent.pro
+++ b/examples/qtconcurrent/qtconcurrent.pro
@@ -2,21 +2,12 @@ requires(qtHaveModule(concurrent))
TEMPLATE = subdirs
SUBDIRS = imagescaling \
- map \
- progressdialog \
- runfunction \
+ primecounter \
wordcount
-
-!qtHaveModule(gui) {
- SUBDIRS -= \
- map
-}
-
!qtHaveModule(widgets) {
SUBDIRS -= \
imagescaling \
- progressdialog \
- runfunction \
+ primecounter \
wordcount
}
diff --git a/examples/qtconcurrent/runfunction/CMakeLists.txt b/examples/qtconcurrent/runfunction/CMakeLists.txt
deleted file mode 100644
index d1f0321648..0000000000
--- a/examples/qtconcurrent/runfunction/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from runfunction.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(runfunction LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qtconcurrent/runfunction")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Concurrent)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(runfunction
- main.cpp
-)
-set_target_properties(runfunction PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(runfunction PUBLIC
- Qt::Concurrent
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS runfunction
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/qtconcurrent/runfunction/doc/src/qtconcurrent-runfunction.qdoc b/examples/qtconcurrent/runfunction/doc/src/qtconcurrent-runfunction.qdoc
deleted file mode 100644
index 4459976a2c..0000000000
--- a/examples/qtconcurrent/runfunction/doc/src/qtconcurrent-runfunction.qdoc
+++ /dev/null
@@ -1,39 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example runfunction
- \title Run Function Example
- \brief Demonstrates how to run standard functions concurrently.
- \ingroup qtconcurrentexamples
-
- The QtConcurrent Run Function example shows how to apply concurrency to
- a standard function, using QFuture instances to retrieve return values
- at a later time.
-
- This is a command-line application.
-*/
diff --git a/examples/qtconcurrent/runfunction/main.cpp b/examples/qtconcurrent/runfunction/main.cpp
deleted file mode 100644
index b349f886ba..0000000000
--- a/examples/qtconcurrent/runfunction/main.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDebug>
-#include <QThread>
-#include <QString>
-#include <qtconcurrentrun.h>
-#include <QApplication>
-
-using namespace QtConcurrent;
-
-void hello(QString name)
-{
- qDebug() << "Hello" << name << "from" << QThread::currentThread();
-}
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
- QFuture<void> f1 = run(hello, QString("Alice"));
- QFuture<void> f2 = run(hello, QString("Bob"));
- f1.waitForFinished();
- f2.waitForFinished();
-}
diff --git a/examples/qtconcurrent/runfunction/runfunction.pro b/examples/qtconcurrent/runfunction/runfunction.pro
deleted file mode 100644
index 42c05551ba..0000000000
--- a/examples/qtconcurrent/runfunction/runfunction.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-QT += concurrent widgets
-CONFIG += cmdline
-
-SOURCES += main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/runfunction
-INSTALLS += target
diff --git a/examples/qtconcurrent/wordcount/CMakeLists.txt b/examples/qtconcurrent/wordcount/CMakeLists.txt
index 10e09bf0f6..0be10c3f35 100644
--- a/examples/qtconcurrent/wordcount/CMakeLists.txt
+++ b/examples/qtconcurrent/wordcount/CMakeLists.txt
@@ -1,41 +1,33 @@
-# Generated from wordcount.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(wordcount LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Concurrent Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qtconcurrent/wordcount")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Concurrent)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(wordcount
main.cpp
)
-set_target_properties(wordcount PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(wordcount PUBLIC
- Qt::Concurrent
- Qt::Core
- Qt::Gui
- Qt::Widgets
+
+target_link_libraries(wordcount PRIVATE
+ Qt6::Concurrent
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
)
install(TARGETS wordcount
- 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 wordcount
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/qtconcurrent/wordcount/doc/src/qtconcurrent-wordcount.qdoc b/examples/qtconcurrent/wordcount/doc/src/qtconcurrent-wordcount.qdoc
index 7486340c7b..adefdfdc59 100644
--- a/examples/qtconcurrent/wordcount/doc/src/qtconcurrent-wordcount.qdoc
+++ b/examples/qtconcurrent/wordcount/doc/src/qtconcurrent-wordcount.qdoc
@@ -1,39 +1,45 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example wordcount
- \title QtConcurrent Word Count Example
- \brief Demonstrates how to use the map-reduce algorithm.
+ \meta tags {threads, console}
+ \title Word Count
\ingroup qtconcurrentexamples
+ \examplecategory {Data Processing & I/O}
+ \brief Demonstrates how to use the map-reduce algorithm.
+
+ The Qt Concurrent \e {Word Count} example demonstrates the use of the
+ map-reduce algorithm when applied to the problem of counting words in a
+ collection of files.
+
+ First, the Application starts a QFileDialog to select a starting
+ path, and then prints the output to the console.
+
+ \include examples-run.qdocinc
+
+ \section1 Comparing the operations
+
+ Compare a single-threaded, sequential approach to counting the words in
+ the text files to a multithreaded approach with mappedReduced():
+
+ \dots
+ \snippet wordcount/main.cpp 1
+ \dots
+ \snippet wordcount/main.cpp 2
+ \dots
+
+ The first argument to the \l {QtConcurrent::}{mappedReduced} function is the
+ container to operate on. The second argument is the mapping function
+ \c {countWords()}. It is called in parallel by multiple threads. The
+ third argument is the reducing function \c {reduce()}. It is called
+ once for each result returned by the mapping function, and generates the
+ final computation result.
- The QtConcurrent Word Count example demonstrates the use of the map-reduce
- algorithm when applied to the problem of counting words in a collection
- of files.
+ The function returns a QFuture object of type \c WordCount. Call the
+ \l {QFuture::}{result} function immediately on this QFuture to block further
+ execution until the result becomes available.
- This is a command-line application.
+ \note The mapping function must be thread-safe since it is called from
+ multiple threads.
*/
diff --git a/examples/qtconcurrent/wordcount/main.cpp b/examples/qtconcurrent/wordcount/main.cpp
index f4de2886a8..4175641ce9 100644
--- a/examples/qtconcurrent/wordcount/main.cpp
+++ b/examples/qtconcurrent/wordcount/main.cpp
@@ -1,90 +1,18 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QList>
-#include <QMap>
-#include <QTextStream>
-#include <QString>
-#include <QStringList>
-#include <QDir>
-#include <QElapsedTimer>
-#include <QApplication>
-#include <QDebug>
-
-#include <qtconcurrentmap.h>
-
-using namespace QtConcurrent;
-
-/*
- Utility function that recursivily searches for files.
-*/
-QStringList findFiles(const QString &startDir, const QStringList &filters)
-{
- QStringList names;
- QDir dir(startDir);
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
- const auto files = dir.entryList(filters, QDir::Files);
- for (const QString &file : files)
- names += startDir + '/' + file;
-
- const auto subdirs = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
- for (const QString &subdir : subdirs)
- names += findFiles(startDir + '/' + subdir, filters);
- return names;
-}
+#include <QtWidgets/qfiledialog.h>
+#include <QtWidgets/qapplication.h>
+#include <QtCore/qmimedatabase.h>
+#include <QtCore/qelapsedtimer.h>
+#include <QtConcurrent/qtconcurrentmap.h>
typedef QMap<QString, int> WordCount;
-/*
- Single threaded word counter function.
-*/
+void printHighestResult(const WordCount &, qsizetype);
+QStringList findFiles(const QString &);
+
+// Single threaded word counter function.
WordCount singleThreadedWordCount(const QStringList &files)
{
WordCount wordCount;
@@ -93,7 +21,7 @@ WordCount singleThreadedWordCount(const QStringList &files)
f.open(QIODevice::ReadOnly);
QTextStream textStream(&f);
while (!textStream.atEnd()) {
- const auto words = textStream.readLine().split(' ');
+ const auto words = textStream.readLine().split(' ', Qt::SkipEmptyParts);
for (const QString &word : words)
wordCount[word] += 1;
}
@@ -101,7 +29,6 @@ WordCount singleThreadedWordCount(const QStringList &files)
return wordCount;
}
-
// countWords counts the words in a single file. This function is
// called in parallel by several threads and must be thread
// safe.
@@ -113,7 +40,7 @@ WordCount countWords(const QString &file)
WordCount wordCount;
while (!textStream.atEnd()) {
- const auto words = textStream.readLine().split(' ');
+ const auto words = textStream.readLine().split(' ', Qt::SkipEmptyParts);
for (const QString &word : words)
wordCount[word] += 1;
}
@@ -133,33 +60,93 @@ void reduce(WordCount &result, const WordCount &w)
int main(int argc, char** argv)
{
QApplication app(argc, argv);
- qDebug() << "finding files...";
- QStringList files = findFiles("../../", QStringList() << "*.cpp" << "*.h");
- qDebug() << files.count() << "files";
-
- qDebug() << "warmup";
- {
- WordCount total = singleThreadedWordCount(files);
- }
-
- qDebug() << "warmup done";
-
- int singleThreadTime = 0;
+ app.setOrganizationName("QtProject");
+ app.setApplicationName(QCoreApplication::translate("main", "Word Count"));
+
+ QFileDialog fileDialog;
+ fileDialog.setOption(QFileDialog::ReadOnly);
+ // Grab the directory path from the dialog
+ auto dirPath = QFileDialog::getExistingDirectory(nullptr,
+ QCoreApplication::translate("main","Select a Folder"),
+ QDir::currentPath());
+
+ QStringList files = findFiles(dirPath);
+ qDebug() << QCoreApplication::translate("main", "Indexing %1 files in %2")
+ .arg(files.size()).arg(dirPath);
+
+ // Start the single threaded operation
+ qint64 singleThreadTime;
{
QElapsedTimer timer;
timer.start();
+ //! [1]
WordCount total = singleThreadedWordCount(files);
+ //! [1]
singleThreadTime = timer.elapsed();
- qDebug() << "single thread" << singleThreadTime;
+ qDebug() << QCoreApplication::translate("main", "Single threaded scanning took %1 ms")
+ .arg(singleThreadTime);
}
-
- int mapReduceTime = 0;
+ // Start the multithreaded mappedReduced operation.
+ qint64 mapReduceTime;
{
QElapsedTimer timer;
timer.start();
- WordCount total = mappedReduced(files, countWords, reduce).result();
+ //! [2]
+ WordCount total = QtConcurrent::mappedReduced(files, countWords, reduce).result();
+ //! [2]
mapReduceTime = timer.elapsed();
- qDebug() << "MapReduce" << mapReduceTime;
+ qDebug() << QCoreApplication::translate("main", "MapReduce scanning took %1 ms")
+ .arg(mapReduceTime);
+ qDebug() << QCoreApplication::translate("main", "MapReduce speedup: %1")
+ .arg(((double)singleThreadTime - (double)mapReduceTime) / (double)mapReduceTime + 1);
+ printHighestResult(total, 10);
}
- qDebug() << "MapReduce speedup x" << ((double)singleThreadTime - (double)mapReduceTime) / (double)mapReduceTime + 1;
+}
+
+// Utility function that recursively searches for text files.
+QStringList findFiles(const QString &startDir)
+{
+ QStringList names;
+ QDir dir(startDir);
+ static const QMimeDatabase db;
+
+ const auto files = dir.entryList(QDir::Files);
+ for (const QString &file : files) {
+ const auto path = startDir + QDir::separator() + file;
+ const QMimeType mime = db.mimeTypeForFile(QFileInfo(path));
+ const auto mimeTypesForFile = mime.parentMimeTypes();
+
+ for (const auto &i : mimeTypesForFile) {
+ if (i.contains("text", Qt::CaseInsensitive)
+ || mime.comment().contains("text", Qt::CaseInsensitive)) {
+ names += startDir + QDir::separator() + file;
+ }
+ }
+ }
+
+ const auto subdirs = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
+ for (const QString &subdir : subdirs) {
+ if (names.length() >= 20000) {
+ qDebug() << QCoreApplication::translate("main", "Too many files! Aborting ...");
+ exit(-1);
+ }
+ names += findFiles(startDir + QDir::separator() + subdir);
+ }
+ return names;
+}
+
+// Utility function that prints the results of the map in decreasing order based on the value.
+void printHighestResult(const WordCount &countedWords, qsizetype nResults)
+{
+ using pair = QPair<QString, int>;
+ QList<pair> vec;
+
+ std::copy(countedWords.keyValueBegin(), countedWords.keyValueEnd(),
+ std::back_inserter<QList<pair>>(vec));
+ std::sort(vec.begin(), vec.end(),
+ [](const pair &l, const pair &r) { return l.second > r.second; });
+
+ qDebug() << QCoreApplication::translate("main", "Most occurring words are:");
+ for (qsizetype i = 0; i < qMin(vec.size(), nResults); ++i)
+ qDebug() << vec[i].first << " : " << vec[i].second;
}
diff --git a/examples/qtestlib/CMakeLists.txt b/examples/qtestlib/CMakeLists.txt
index a3ffcd2481..6f139c87dc 100644
--- a/examples/qtestlib/CMakeLists.txt
+++ b/examples/qtestlib/CMakeLists.txt
@@ -1,10 +1,11 @@
-# Generated from qtestlib.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-if(NOT TARGET Qt::Widgets)
+if(NOT TARGET Qt6::Widgets)
return()
endif()
-add_subdirectory(tutorial1)
-add_subdirectory(tutorial2)
-add_subdirectory(tutorial3)
-add_subdirectory(tutorial4)
-add_subdirectory(tutorial5)
+qt_internal_add_example(tutorial1)
+qt_internal_add_example(tutorial2)
+qt_internal_add_example(tutorial3)
+qt_internal_add_example(tutorial4)
+qt_internal_add_example(tutorial5)
diff --git a/examples/qtestlib/tutorial1/CMakeLists.txt b/examples/qtestlib/tutorial1/CMakeLists.txt
index 36664d3b99..b4fc090e94 100644
--- a/examples/qtestlib/tutorial1/CMakeLists.txt
+++ b/examples/qtestlib/tutorial1/CMakeLists.txt
@@ -1,41 +1,38 @@
-# Generated from tutorial1.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(tutorial1 LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Test Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qtestlib/tutorial1")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS Test)
+qt_standard_project_setup()
qt_add_executable(tutorial1
testqstring.cpp
)
+
set_target_properties(tutorial1 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(tutorial1 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Test
- Qt::Widgets
+
+target_link_libraries(tutorial1 PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Test
+ Qt6::Widgets
)
install(TARGETS tutorial1
- 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 tutorial1
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/qtestlib/tutorial1/testqstring.cpp b/examples/qtestlib/tutorial1/testqstring.cpp
index 419d278e2e..a39d1320ee 100644
--- a/examples/qtestlib/tutorial1/testqstring.cpp
+++ b/examples/qtestlib/tutorial1/testqstring.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [0]
#include <QTest>
diff --git a/examples/qtestlib/tutorial2/CMakeLists.txt b/examples/qtestlib/tutorial2/CMakeLists.txt
index 781a910c38..ff4862e3c4 100644
--- a/examples/qtestlib/tutorial2/CMakeLists.txt
+++ b/examples/qtestlib/tutorial2/CMakeLists.txt
@@ -1,41 +1,38 @@
-# Generated from tutorial2.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(tutorial2 LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Test Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qtestlib/tutorial2")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS Test)
+qt_standard_project_setup()
qt_add_executable(tutorial2
testqstring.cpp
)
+
set_target_properties(tutorial2 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(tutorial2 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Test
- Qt::Widgets
+
+target_link_libraries(tutorial2 PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Test
+ Qt6::Widgets
)
install(TARGETS tutorial2
- 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 tutorial2
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/qtestlib/tutorial2/testqstring.cpp b/examples/qtestlib/tutorial2/testqstring.cpp
index 1161cd8a2b..fa6779a16f 100644
--- a/examples/qtestlib/tutorial2/testqstring.cpp
+++ b/examples/qtestlib/tutorial2/testqstring.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QTest>
@@ -67,9 +20,9 @@ void TestQString::toUpper_data()
QTest::addColumn<QString>("string");
QTest::addColumn<QString>("result");
- QTest::newRow("all lower") << "hello" << "HELLO";
+ QTest::newRow("all-lower") << "hello" << "HELLO";
QTest::newRow("mixed") << "Hello" << "HELLO";
- QTest::newRow("all upper") << "HELLO" << "HELLO";
+ QTest::newRow("all-upper") << "HELLO" << "HELLO";
}
//! [1]
diff --git a/examples/qtestlib/tutorial3/CMakeLists.txt b/examples/qtestlib/tutorial3/CMakeLists.txt
index 0ebdb5a81c..be09e1d05b 100644
--- a/examples/qtestlib/tutorial3/CMakeLists.txt
+++ b/examples/qtestlib/tutorial3/CMakeLists.txt
@@ -1,41 +1,38 @@
-# Generated from tutorial3.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(tutorial3 LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Test Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qtestlib/tutorial3")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS Test)
+qt_standard_project_setup()
qt_add_executable(tutorial3
testgui.cpp
)
+
set_target_properties(tutorial3 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(tutorial3 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Test
- Qt::Widgets
+
+target_link_libraries(tutorial3 PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Test
+ Qt6::Widgets
)
install(TARGETS tutorial3
- 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 tutorial3
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/qtestlib/tutorial3/testgui.cpp b/examples/qtestlib/tutorial3/testgui.cpp
index 44ae554862..c65a1f45bc 100644
--- a/examples/qtestlib/tutorial3/testgui.cpp
+++ b/examples/qtestlib/tutorial3/testgui.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [0]
#include <QtWidgets>
diff --git a/examples/qtestlib/tutorial4/CMakeLists.txt b/examples/qtestlib/tutorial4/CMakeLists.txt
index 7238f31fab..6f13c7c2ba 100644
--- a/examples/qtestlib/tutorial4/CMakeLists.txt
+++ b/examples/qtestlib/tutorial4/CMakeLists.txt
@@ -1,41 +1,38 @@
-# Generated from tutorial4.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(tutorial4 LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Test Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qtestlib/tutorial4")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS Test)
+qt_standard_project_setup()
qt_add_executable(tutorial4
testgui.cpp
)
+
set_target_properties(tutorial4 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(tutorial4 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Test
- Qt::Widgets
+
+target_link_libraries(tutorial4 PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Test
+ Qt6::Widgets
)
install(TARGETS tutorial4
- 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 tutorial4
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/qtestlib/tutorial4/testgui.cpp b/examples/qtestlib/tutorial4/testgui.cpp
index dedba45d0a..527532edee 100644
--- a/examples/qtestlib/tutorial4/testgui.cpp
+++ b/examples/qtestlib/tutorial4/testgui.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include <QTest>
@@ -75,7 +28,7 @@ void TestGui::testGui_data()
QTestEventList list2;
list2.addKeyClick('a');
list2.addKeyClick(Qt::Key_Backspace);
- QTest::newRow("there and back again") << list2 << "";
+ QTest::newRow("there+back-again") << list2 << "";
}
//! [1]
diff --git a/examples/qtestlib/tutorial5/CMakeLists.txt b/examples/qtestlib/tutorial5/CMakeLists.txt
index 1cf7085085..55bb4fb251 100644
--- a/examples/qtestlib/tutorial5/CMakeLists.txt
+++ b/examples/qtestlib/tutorial5/CMakeLists.txt
@@ -1,41 +1,38 @@
-# Generated from tutorial5.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(tutorial5 LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Test Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qtestlib/tutorial5")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS Test)
+qt_standard_project_setup()
qt_add_executable(tutorial5
benchmarking.cpp
)
+
set_target_properties(tutorial5 PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(tutorial5 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Test
- Qt::Widgets
+
+target_link_libraries(tutorial5 PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Test
+ Qt6::Widgets
)
install(TARGETS tutorial5
- 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 tutorial5
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/qtestlib/tutorial5/benchmarking.cpp b/examples/qtestlib/tutorial5/benchmarking.cpp
index d52846df63..d88780757a 100644
--- a/examples/qtestlib/tutorial5/benchmarking.cpp
+++ b/examples/qtestlib/tutorial5/benchmarking.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include <qtest.h>
@@ -80,8 +33,8 @@ void TestBenchmark::simple()
void TestBenchmark::multiple_data()
{
QTest::addColumn<bool>("useLocaleCompare");
- QTest::newRow("locale aware compare") << true;
- QTest::newRow("standard compare") << false;
+ QTest::newRow("locale-aware-compare") << true;
+ QTest::newRow("standard-compare") << false;
}
//! [1]
@@ -113,9 +66,8 @@ void TestBenchmark::series_data()
QTest::addColumn<int>("stringSize");
for (int i = 1; i < 10000; i += 2000) {
- QByteArray size = QByteArray::number(i);
- QTest::newRow(("locale aware compare--" + size).constData()) << true << i;
- QTest::newRow(("standard compare--" + size).constData()) << false << i;
+ QTest::addRow("locale-aware-compare:%d", i) << true << i;
+ QTest::addRow("standard-compare:%d", i) << false << i;
}
}
//! [4]
diff --git a/examples/sql/.prev_CMakeLists.txt b/examples/sql/.prev_CMakeLists.txt
deleted file mode 100644
index 18e9112f11..0000000000
--- a/examples/sql/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated from sql.pro.
-
-if(NOT TARGET Qt::Widgets)
- return()
-endif()
-add_subdirectory(books)
-add_subdirectory(drilldown)
-add_subdirectory(cachedtable)
-add_subdirectory(querymodel)
-add_subdirectory(relationaltablemodel)
-add_subdirectory(sqlwidgetmapper)
-add_subdirectory(tablemodel)
-if(TARGET Qt::Xml)
- add_subdirectory(masterdetail)
-endif()
-if(QT_BUILD_PARTS___contains___tools AND NOT CMAKE_CROSSCOMPILING)
- add_subdirectory(sqlbrowser)
-endif()
diff --git a/examples/sql/CMakeLists.txt b/examples/sql/CMakeLists.txt
index e54fc0860f..06d7d532d7 100644
--- a/examples/sql/CMakeLists.txt
+++ b/examples/sql/CMakeLists.txt
@@ -1,19 +1,20 @@
-# Generated from sql.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-if(NOT TARGET Qt::Widgets)
+if(NOT TARGET Qt6::Widgets)
return()
endif()
-add_subdirectory(books)
-add_subdirectory(drilldown)
-add_subdirectory(cachedtable)
-add_subdirectory(querymodel)
-add_subdirectory(relationaltablemodel)
-add_subdirectory(sqlwidgetmapper)
-add_subdirectory(tablemodel)
-if(TARGET Qt::Xml)
- add_subdirectory(masterdetail)
+qt_internal_add_example(books)
+qt_internal_add_example(drilldown)
+qt_internal_add_example(cachedtable)
+qt_internal_add_example(querymodel)
+qt_internal_add_example(relationaltablemodel)
+qt_internal_add_example(sqlwidgetmapper)
+qt_internal_add_example(tablemodel)
+if(TARGET Qt6::Xml)
+ qt_internal_add_example(masterdetail)
endif()
-if(NOT CMAKE_CROSSCOMPILING) # special case
- add_subdirectory(sqlbrowser)
+if(NOT CMAKE_CROSSCOMPILING)
+ qt_internal_add_example(sqlbrowser)
endif()
diff --git a/examples/sql/books/CMakeLists.txt b/examples/sql/books/CMakeLists.txt
index 7595f3fd82..3fff917163 100644
--- a/examples/sql/books/CMakeLists.txt
+++ b/examples/sql/books/CMakeLists.txt
@@ -1,53 +1,39 @@
-# Generated from books.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(books LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Sql Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sql/books")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Sql)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(books
bookdelegate.cpp bookdelegate.h
- bookwindow.cpp bookwindow.h bookwindow.ui
+ bookwindow.cpp bookwindow.h
initdb.h
main.cpp
)
+
set_target_properties(books PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_include_directories(books PUBLIC
- .
-)
-target_link_libraries(books PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Sql
- Qt::Widgets
+target_link_libraries(books PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Sql
+ Qt6::Widgets
)
-
# Resources:
set(books_resource_files
- "images/star.png"
+ "images/star.svg"
+ "images/star-filled.svg"
)
-qt6_add_resources(books "books"
+qt_add_resources(books "books"
PREFIX
"/"
FILES
@@ -55,7 +41,14 @@ qt6_add_resources(books "books"
)
install(TARGETS books
- 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 books
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/sql/books/bookdelegate.cpp b/examples/sql/books/bookdelegate.cpp
index 56d9b1f414..ead9f9e7db 100644
--- a/examples/sql/books/bookdelegate.cpp
+++ b/examples/sql/books/bookdelegate.cpp
@@ -1,64 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "bookdelegate.h"
-#include <QtWidgets>
+#include <QMouseEvent>
+#include <QPainter>
+#include <QSpinBox>
-BookDelegate::BookDelegate(QObject *parent)
- : QSqlRelationalDelegate(parent), star(QPixmap(":images/star.png"))
-{
-}
-
-void BookDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
- const QModelIndex &index) const
+void BookDelegate::paint(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
{
if (index.column() != 5) {
QSqlRelationalDelegate::paint(painter, option, index);
@@ -75,31 +26,33 @@ void BookDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
option.rect,
option.palette.color(cg, QPalette::Highlight));
- int rating = model->data(index, Qt::DisplayRole).toInt();
- int width = star.width();
- int height = star.height();
- int x = option.rect.x();
+ const int rating = model->data(index, Qt::DisplayRole).toInt();
+ const int width = iconDimension;
+ const int height = width;
+ // add cellPadding / 2 to center the stars in the cell
+ int x = option.rect.x() + cellPadding / 2;
int y = option.rect.y() + (option.rect.height() / 2) - (height / 2);
- for (int i = 0; i < rating; ++i) {
- painter->drawPixmap(x, y, star);
+
+ QIcon starIcon(QStringLiteral(":images/star.svg"));
+ QIcon starFilledIcon(QStringLiteral(":images/star-filled.svg"));
+
+ for (int i = 0; i < 5; ++i) {
+ if (i < rating)
+ starFilledIcon.paint(painter, QRect(x, y, width, height));
+ else
+ starIcon.paint(painter, QRect(x, y, width, height));
x += width;
}
}
-
- QPen pen = painter->pen();
- painter->setPen(option.palette.color(QPalette::Mid));
- painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
- painter->drawLine(option.rect.topRight(), option.rect.bottomRight());
- painter->setPen(pen);
}
QSize BookDelegate::sizeHint(const QStyleOptionViewItem &option,
- const QModelIndex &index) const
+ const QModelIndex &index) const
{
if (index.column() == 5)
- return QSize(5 * star.width(), star.height()) + QSize(1, 1);
+ return QSize(5 * iconDimension, iconDimension) + QSize(cellPadding, cellPadding);
// Since we draw the grid ourselves:
- return QSqlRelationalDelegate::sizeHint(option, index) + QSize(1, 1);
+ return QSqlRelationalDelegate::sizeHint(option, index) + QSize(cellPadding, cellPadding);
}
bool BookDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
@@ -111,8 +64,8 @@ bool BookDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
- int stars = qBound(0, int(0.7 + qreal(mouseEvent->position().toPoint().x()
- - option.rect.x()) / star.width()), 5);
+ int stars = qBound(0, int(0.7 + qreal(mouseEvent->position().x()
+ - option.rect.x()) / iconDimension), 5);
model->setData(index, QVariant(stars));
// So that the selection can change:
return false;
diff --git a/examples/sql/books/bookdelegate.h b/examples/sql/books/bookdelegate.h
index f1b4326992..b36cb371ac 100644
--- a/examples/sql/books/bookdelegate.h
+++ b/examples/sql/books/bookdelegate.h
@@ -1,58 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef BOOKDELEGATE_H
#define BOOKDELEGATE_H
#include <QModelIndex>
-#include <QPixmap>
#include <QSize>
#include <QSqlRelationalDelegate>
@@ -61,7 +13,7 @@ QT_FORWARD_DECLARE_CLASS(QPainter)
class BookDelegate : public QSqlRelationalDelegate
{
public:
- BookDelegate(QObject *parent);
+ using QSqlRelationalDelegate::QSqlRelationalDelegate;
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
@@ -77,7 +29,8 @@ public:
const QModelIndex &index) const override;
private:
- QPixmap star;
+ const int cellPadding = 6;
+ const int iconDimension = 24;
};
#endif
diff --git a/examples/sql/books/books.pro b/examples/sql/books/books.pro
index 870e4a6c00..953945912e 100644
--- a/examples/sql/books/books.pro
+++ b/examples/sql/books/books.pro
@@ -4,7 +4,6 @@ INCLUDEPATH += .
HEADERS = bookdelegate.h bookwindow.h initdb.h
RESOURCES = books.qrc
SOURCES = bookdelegate.cpp main.cpp bookwindow.cpp
-FORMS = bookwindow.ui
QT += sql widgets widgets
requires(qtConfig(tableview))
diff --git a/examples/sql/books/books.qrc b/examples/sql/books/books.qrc
index 342638ecb0..1a4dac32cc 100644
--- a/examples/sql/books/books.qrc
+++ b/examples/sql/books/books.qrc
@@ -1,5 +1,6 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
- <file>images/star.png</file>
+ <file>images/star.svg</file>
+ <file>images/star-filled.svg</file>
</qresource>
</RCC>
diff --git a/examples/sql/books/bookwindow.cpp b/examples/sql/books/bookwindow.cpp
index 76f3c9da8f..6de2d5e80a 100644
--- a/examples/sql/books/bookwindow.cpp
+++ b/examples/sql/books/bookwindow.cpp
@@ -1,69 +1,31 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "bookwindow.h"
#include "bookdelegate.h"
#include "initdb.h"
-#include <QtSql>
+#include <QApplication>
+#include <QComboBox>
+#include <QDataWidgetMapper>
+#include <QGridLayout>
+#include <QHeaderView>
+#include <QLabel>
+#include <QLineEdit>
+#include <QMenu>
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QPainter>
+#include <QScrollBar>
+#include <QSpinBox>
+#include <QSqlDatabase>
+#include <QTableView>
BookWindow::BookWindow()
{
- ui.setupUi(this);
-
if (!QSqlDatabase::drivers().contains("QSQLITE"))
- QMessageBox::critical(
- this,
- "Unable to load database",
- "This demo needs the SQLITE driver"
- );
+ QMessageBox::critical(this, tr("Unable to load database"),
+ tr("This demo needs the SQLITE driver"));
// Initialize the database:
QSqlError err = initDb();
@@ -72,20 +34,87 @@ BookWindow::BookWindow()
return;
}
- // Create the data model:
- model = new QSqlRelationalTableModel(ui.bookTable);
+ // create the central widget for the window
+ window = new QWidget(this);
+ setCentralWidget(window);
+
+ createLayout();
+
+ createModel();
+
+ // Populate the model
+ if (!model->select()) {
+ showError(model->lastError());
+ return;
+ }
+
+ configureWidgets();
+
+ // create the mappings between the UI elements and the SQL model
+ createMappings();
+
+ tableView->setCurrentIndex(model->index(0, 0));
+ tableView->selectRow(0);
+
+ createMenuBar();
+}
+
+void BookWindow::showError(const QSqlError &err)
+{
+ QMessageBox::critical(this, tr("Unable to initialize Database"),
+ tr("Error initializing database: %1").arg(err.text()));
+}
+
+void BookWindow::createLayout()
+{
+ tableView = new QTableView(window);
+
+ gridLayout = new QGridLayout(window);
+
+ titleLabel = new QLabel(tr("Title:"), window);
+ titleLineEdit = new QLineEdit(window);
+ authorLabel = new QLabel(tr("Author:"), window);
+ authorComboBox = new QComboBox(window);
+ genreLabel = new QLabel(tr("Genre:"), window);
+ genreComboBox = new QComboBox(window);
+ yearLabel = new QLabel(tr("Year:"), window);
+ yearSpinBox = new QSpinBox(window);
+ ratingLabel = new QLabel(tr("Rating:"), window);
+ ratingComboBox = new QComboBox(window);
+
+ gridLayout->addWidget(titleLabel, 0, 0, Qt::AlignRight);
+ gridLayout->addWidget(titleLineEdit, 0, 1, 1, 3);
+ gridLayout->addWidget(authorLabel, 1, 0, Qt::AlignRight);
+ gridLayout->addWidget(authorComboBox, 1, 1);
+ gridLayout->addWidget(yearLabel, 1, 2, Qt::AlignRight);
+ gridLayout->addWidget(yearSpinBox, 1, 3);
+ gridLayout->addWidget(genreLabel, 2, 0, Qt::AlignRight);
+ gridLayout->addWidget(genreComboBox, 2, 1);
+ gridLayout->addWidget(ratingLabel, 2, 2, Qt::AlignRight);
+ gridLayout->addWidget(ratingComboBox, 2, 3);
+ gridLayout->addWidget(tableView, 3, 0, 1, 4, Qt::AlignCenter);
+ gridLayout->setColumnStretch(1, 1000);
+ gridLayout->setColumnStretch(3, 1000);
+
+ gridLayout->setContentsMargins(18, 18, 18, 18);
+ gridLayout->setSpacing(18);
+ gridLayout->setAlignment(Qt::AlignHCenter);
+}
+
+void BookWindow::createModel()
+{
+ model = new QSqlRelationalTableModel(tableView);
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->setTable("books");
- // Remember the indexes of the columns:
authorIdx = model->fieldIndex("author");
genreIdx = model->fieldIndex("genre");
- // Set the relations to the other database tables:
+ // Set the relations to the other database tables
model->setRelation(authorIdx, QSqlRelation("authors", "id", "name"));
model->setRelation(genreIdx, QSqlRelation("genres", "id", "name"));
- // Set the localized header captions:
+ // Set the localised header captions
model->setHeaderData(authorIdx, Qt::Horizontal, tr("Author Name"));
model->setHeaderData(genreIdx, Qt::Horizontal, tr("Genre"));
model->setHeaderData(model->fieldIndex("title"),
@@ -93,56 +122,81 @@ BookWindow::BookWindow()
model->setHeaderData(model->fieldIndex("year"), Qt::Horizontal, tr("Year"));
model->setHeaderData(model->fieldIndex("rating"),
Qt::Horizontal, tr("Rating"));
+}
- // Populate the model:
- if (!model->select()) {
- showError(model->lastError());
- return;
+void BookWindow::configureWidgets()
+{
+ tableView->setModel(model);
+ tableView->setItemDelegate(new BookDelegate(tableView));
+ tableView->setColumnHidden(model->fieldIndex("id"), true);
+ tableView->verticalHeader()->setVisible(false);
+ tableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
+
+ // Lock and prohibit resizing of the width of the columns
+ tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
+ tableView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
+ tableView->horizontalHeader()->setFixedHeight(tableView->rowHeight(0));
+
+ // increment by two to consider the frame
+ tableView->setFixedWidth(tableView->horizontalHeader()->length() +
+ tableView->verticalScrollBar()->sizeHint().width() + 2);
+ tableView->setMaximumHeight(tableView->verticalHeader()->length() +
+ tableView->horizontalHeader()->height() + 2);
+
+ authorComboBox->setModel(model->relationModel(authorIdx));
+ authorComboBox->setModelColumn(model->relationModel(authorIdx)->fieldIndex("name"));
+
+ genreComboBox->setModel(model->relationModel(genreIdx));
+ genreComboBox->setModelColumn(model->relationModel(genreIdx)->fieldIndex("name"));
+
+ yearSpinBox->setMaximum(9999);
+
+ const int width = 16;
+ const int height = width;
+ const int y = 2;
+ const int padding = 2;
+
+ QSize iconSize = QSize(width * 5 + padding * 2, width + padding * 2);
+ QIcon starIcon(QStringLiteral(":images/star.svg"));
+ QIcon starFilledIcon(QStringLiteral(":images/star-filled.svg"));
+
+ for (int row = 0; row < 6; ++row) {
+ QPixmap icon(iconSize);
+ icon.fill(Qt::transparent);
+ QPainter painter(&icon);
+ int x = 2;
+
+ for (int col = 0; col < 5; ++col) {
+ if (col < row) {
+ starFilledIcon.paint(&painter, QRect(x, y, width, height));
+ } else {
+ starIcon.paint(&painter, QRect(x, y, width, height));
+ }
+ x += width;
+ }
+ ratingComboBox->addItem(icon, "");
+ ratingComboBox->setItemData(row, QString::number(row + 1));
}
- // Set the model and hide the ID column:
- ui.bookTable->setModel(model);
- ui.bookTable->setItemDelegate(new BookDelegate(ui.bookTable));
- ui.bookTable->setColumnHidden(model->fieldIndex("id"), true);
- ui.bookTable->setSelectionMode(QAbstractItemView::SingleSelection);
-
- // Initialize the Author combo box:
- ui.authorEdit->setModel(model->relationModel(authorIdx));
- ui.authorEdit->setModelColumn(
- model->relationModel(authorIdx)->fieldIndex("name"));
-
- ui.genreEdit->setModel(model->relationModel(genreIdx));
- ui.genreEdit->setModelColumn(
- model->relationModel(genreIdx)->fieldIndex("name"));
-
- // Lock and prohibit resizing of the width of the rating column:
- ui.bookTable->horizontalHeader()->setSectionResizeMode(
- model->fieldIndex("rating"),
- QHeaderView::ResizeToContents);
+ ratingComboBox->setIconSize(iconSize);
+}
+void BookWindow::createMappings()
+{
QDataWidgetMapper *mapper = new QDataWidgetMapper(this);
mapper->setModel(model);
mapper->setItemDelegate(new BookDelegate(this));
- mapper->addMapping(ui.titleEdit, model->fieldIndex("title"));
- mapper->addMapping(ui.yearEdit, model->fieldIndex("year"));
- mapper->addMapping(ui.authorEdit, authorIdx);
- mapper->addMapping(ui.genreEdit, genreIdx);
- mapper->addMapping(ui.ratingEdit, model->fieldIndex("rating"));
-
- connect(ui.bookTable->selectionModel(),
+ mapper->addMapping(titleLineEdit, model->fieldIndex("title"));
+ mapper->addMapping(yearSpinBox, model->fieldIndex("year"));
+ mapper->addMapping(authorComboBox, authorIdx);
+ mapper->addMapping(genreComboBox, genreIdx);
+ mapper->addMapping(ratingComboBox, model->fieldIndex("rating"), "currentIndex");
+ connect(tableView->selectionModel(),
&QItemSelectionModel::currentRowChanged,
mapper,
&QDataWidgetMapper::setCurrentModelIndex
);
-
- ui.bookTable->setCurrentIndex(model->index(0, 0));
- createMenuBar();
-}
-
-void BookWindow::showError(const QSqlError &err)
-{
- QMessageBox::critical(this, "Unable to initialize Database",
- "Error initializing database: " + err.text());
}
void BookWindow::createMenuBar()
@@ -158,7 +212,7 @@ void BookWindow::createMenuBar()
helpMenu->addAction(aboutAction);
helpMenu->addAction(aboutQtAction);
- connect(quitAction, &QAction::triggered, this, &BookWindow::close);
+ connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
connect(aboutAction, &QAction::triggered, this, &BookWindow::about);
connect(aboutQtAction, &QAction::triggered, qApp, &QApplication::aboutQt);
}
diff --git a/examples/sql/books/bookwindow.h b/examples/sql/books/bookwindow.h
index ec6b935242..46d3570df1 100644
--- a/examples/sql/books/bookwindow.h
+++ b/examples/sql/books/bookwindow.h
@@ -1,61 +1,18 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef BOOKWINDOW_H
#define BOOKWINDOW_H
-#include <QtWidgets>
-#include <QtSql>
-
-#include "ui_bookwindow.h"
-
+#include <QMainWindow>
+QT_FORWARD_DECLARE_CLASS(QComboBox)
+QT_FORWARD_DECLARE_CLASS(QGridLayout)
+QT_FORWARD_DECLARE_CLASS(QLabel)
+QT_FORWARD_DECLARE_CLASS(QLineEdit)
+QT_FORWARD_DECLARE_CLASS(QSpinBox)
+QT_FORWARD_DECLARE_CLASS(QSqlError)
+QT_FORWARD_DECLARE_CLASS(QSqlRelationalTableModel)
+QT_FORWARD_DECLARE_CLASS(QTableView)
class BookWindow: public QMainWindow
{
@@ -68,11 +25,29 @@ private slots:
private:
void showError(const QSqlError &err);
- Ui::BookWindow ui;
- QSqlRelationalTableModel *model;
- int authorIdx, genreIdx;
+ QSqlRelationalTableModel *model = nullptr;
+ int authorIdx = 0, genreIdx = 0;
+ void createLayout();
+ void createModel();
+ void configureWidgets();
+ void createMappings();
void createMenuBar();
+
+ QWidget *window = nullptr;
+
+ QGridLayout *gridLayout = nullptr;
+ QTableView *tableView = nullptr;
+ QLabel *titleLabel = nullptr;
+ QLineEdit *titleLineEdit = nullptr;
+ QLabel *authorLabel = nullptr;
+ QComboBox *authorComboBox = nullptr;
+ QLabel *genreLabel = nullptr;
+ QComboBox *genreComboBox = nullptr;
+ QLabel *yearLabel = nullptr;
+ QSpinBox *yearSpinBox = nullptr;
+ QLabel *ratingLabel = nullptr;
+ QComboBox *ratingComboBox = nullptr;
};
#endif
diff --git a/examples/sql/books/bookwindow.ui b/examples/sql/books/bookwindow.ui
deleted file mode 100644
index ce8f9f933a..0000000000
--- a/examples/sql/books/bookwindow.ui
+++ /dev/null
@@ -1,164 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>BookWindow</class>
- <widget class="QMainWindow" name="BookWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>601</width>
- <height>420</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Books</string>
- </property>
- <widget class="QWidget" name="centralWidget">
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="leftMargin">
- <number>9</number>
- </property>
- <property name="topMargin">
- <number>9</number>
- </property>
- <property name="rightMargin">
- <number>9</number>
- </property>
- <property name="bottomMargin">
- <number>9</number>
- </property>
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string/>
- </property>
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <property name="leftMargin">
- <number>9</number>
- </property>
- <property name="topMargin">
- <number>9</number>
- </property>
- <property name="rightMargin">
- <number>9</number>
- </property>
- <property name="bottomMargin">
- <number>9</number>
- </property>
- <item>
- <widget class="QTableView" name="bookTable">
- <property name="selectionBehavior">
- <enum>QAbstractItemView::SelectRows</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox_2">
- <property name="title">
- <string>Details</string>
- </property>
- <layout class="QFormLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>&lt;b&gt;Title:&lt;/b&gt;</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="titleEdit">
- <property name="enabled">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>&lt;b&gt;Author: &lt;/b&gt;</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QComboBox" name="authorEdit">
- <property name="enabled">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>&lt;b&gt;Genre:&lt;/b&gt;</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QComboBox" name="genreEdit">
- <property name="enabled">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>&lt;b&gt;Year:&lt;/b&gt;</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QSpinBox" name="yearEdit">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="prefix">
- <string/>
- </property>
- <property name="minimum">
- <number>-1000</number>
- </property>
- <property name="maximum">
- <number>2100</number>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>&lt;b&gt;Rating:&lt;/b&gt;</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QSpinBox" name="ratingEdit">
- <property name="maximum">
- <number>5</number>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- <tabstops>
- <tabstop>bookTable</tabstop>
- <tabstop>titleEdit</tabstop>
- <tabstop>authorEdit</tabstop>
- <tabstop>genreEdit</tabstop>
- <tabstop>yearEdit</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/sql/books/images/star-filled.svg b/examples/sql/books/images/star-filled.svg
new file mode 100644
index 0000000000..8a2aee27fb
--- /dev/null
+++ b/examples/sql/books/images/star-filled.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="#0d0d0d"><path d="M8.41 18.138L12 15.845l3.59 2.323-.94-4.345 3.162-2.897-4.159-.392L12 6.43l-1.652 4.073-4.159.392 3.162 2.927-.94 4.315zm-1.346 3.696a1.04 1.04 0 0 1-1.567-1.104l1.318-6.033-4.476-4.11c-.665-.611-.293-1.726.604-1.808l5.866-.539 2.229-5.587c.348-.872 1.575-.872 1.923 0l2.229 5.587 5.866.539c.897.082 1.269 1.197.604 1.808l-4.476 4.11 1.318 6.033a1.04 1.04 0 0 1-1.567 1.104L12 18.681l-4.935 3.153z"/><path d="M12 5l-1.796 5.528H4.392l4.702 3.416-1.796 5.528L12 16.056l4.702 3.416-1.796-5.528 4.702-3.416h-5.812L12 5z"/></svg>
diff --git a/examples/sql/books/images/star.png b/examples/sql/books/images/star.png
deleted file mode 100644
index 87f4464bd5..0000000000
--- a/examples/sql/books/images/star.png
+++ /dev/null
Binary files differ
diff --git a/examples/sql/books/images/star.svg b/examples/sql/books/images/star.svg
new file mode 100644
index 0000000000..d959abc182
--- /dev/null
+++ b/examples/sql/books/images/star.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"><path d="M8.41 18.138L12 15.845l3.59 2.323-.94-4.345 3.162-2.897-4.159-.392L12 6.43l-1.652 4.073-4.159.392 3.162 2.927-.94 4.315zm-1.346 3.696a1.04 1.04 0 0 1-1.567-1.104l1.318-6.033-4.476-4.11c-.665-.611-.293-1.726.604-1.808l5.866-.539 2.229-5.587c.348-.872 1.575-.872 1.923 0l2.229 5.587 5.866.539c.897.082 1.269 1.197.604 1.808l-4.476 4.11 1.318 6.033a1.04 1.04 0 0 1-1.567 1.104L12 18.681l-4.935 3.153z" fill="#0d0d0d"/></svg>
diff --git a/examples/sql/books/initdb.h b/examples/sql/books/initdb.h
index e1f690a234..9de8845a2f 100644
--- a/examples/sql/books/initdb.h
+++ b/examples/sql/books/initdb.h
@@ -1,57 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef INITDB_H
#define INITDB_H
-#include <QtSql>
+#include <QDate>
+#include <QSqlError>
+#include <QSqlQuery>
void addBook(QSqlQuery &q, const QString &title, int year, const QVariant &authorId,
const QVariant &genreId, int rating)
diff --git a/examples/sql/books/main.cpp b/examples/sql/books/main.cpp
index 7cf6fdd138..76a05f1c39 100644
--- a/examples/sql/books/main.cpp
+++ b/examples/sql/books/main.cpp
@@ -1,61 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "bookwindow.h"
-#include <QtWidgets>
+#include <QApplication>
int main(int argc, char * argv[])
{
- Q_INIT_RESOURCE(books);
-
QApplication app(argc, argv);
BookWindow win;
diff --git a/examples/sql/cachedtable/CMakeLists.txt b/examples/sql/cachedtable/CMakeLists.txt
index 7c5af62005..af6843b734 100644
--- a/examples/sql/cachedtable/CMakeLists.txt
+++ b/examples/sql/cachedtable/CMakeLists.txt
@@ -1,43 +1,40 @@
-# Generated from cachedtable.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(cachedtable LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Sql Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sql/cachedtable")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Sql)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(cachedtable
../connection.h
main.cpp
tableeditor.cpp tableeditor.h
)
+
set_target_properties(cachedtable PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(cachedtable PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Sql
- Qt::Widgets
+
+target_link_libraries(cachedtable PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Sql
+ Qt6::Widgets
)
install(TARGETS cachedtable
- 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 cachedtable
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/sql/cachedtable/main.cpp b/examples/sql/cachedtable/main.cpp
index e995f0d840..cbd5d74f7b 100644
--- a/examples/sql/cachedtable/main.cpp
+++ b/examples/sql/cachedtable/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/sql/cachedtable/tableeditor.cpp b/examples/sql/cachedtable/tableeditor.cpp
index 95c3047c76..b92e256438 100644
--- a/examples/sql/cachedtable/tableeditor.cpp
+++ b/examples/sql/cachedtable/tableeditor.cpp
@@ -1,58 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-#include <QtSql>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "tableeditor.h"
+#include <QDialogButtonBox>
+#include <QHBoxLayout>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QSqlError>
+#include <QSqlTableModel>
+#include <QTableView>
+
//! [0]
TableEditor::TableEditor(const QString &tableName, QWidget *parent)
: QWidget(parent)
diff --git a/examples/sql/cachedtable/tableeditor.h b/examples/sql/cachedtable/tableeditor.h
index 727aa88ab3..8c3c56b397 100644
--- a/examples/sql/cachedtable/tableeditor.h
+++ b/examples/sql/cachedtable/tableeditor.h
@@ -1,63 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TABLEEDITOR_H
#define TABLEEDITOR_H
#include <QDialog>
-QT_BEGIN_NAMESPACE
-class QDialogButtonBox;
-class QPushButton;
-class QSqlTableModel;
-QT_END_NAMESPACE
+QT_FORWARD_DECLARE_CLASS(QDialogButtonBox)
+QT_FORWARD_DECLARE_CLASS(QPushButton)
+QT_FORWARD_DECLARE_CLASS(QSqlTableModel)
//! [0]
class TableEditor : public QWidget
diff --git a/examples/sql/connection.h b/examples/sql/connection.h
index 482feff5b4..22c30780c1 100644
--- a/examples/sql/connection.h
+++ b/examples/sql/connection.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CONNECTION_H
#define CONNECTION_H
diff --git a/examples/sql/doc/images/books-demo.png b/examples/sql/doc/images/books-demo.png
index 77b3b308c9..29f5c84473 100644
--- a/examples/sql/doc/images/books-demo.png
+++ b/examples/sql/doc/images/books-demo.png
Binary files differ
diff --git a/examples/sql/doc/images/drilldown-example.png b/examples/sql/doc/images/drilldown-example.png
index 39a4117637..b6cf443e7c 100644
--- a/examples/sql/doc/images/drilldown-example.png
+++ b/examples/sql/doc/images/drilldown-example.png
Binary files differ
diff --git a/examples/sql/doc/src/books.qdoc b/examples/sql/doc/src/books.qdoc
index f65daed372..b4ca8bdd2e 100644
--- a/examples/sql/doc/src/books.qdoc
+++ b/examples/sql/doc/src/books.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example books
\title Books
\ingroup sql_examples
+ \examplecategory {Data Processing & I/O}
\brief Shows how to use Qt SQL classes with a model/view framework.
The Books example shows how Qt's SQL classes can be used with the model/view
diff --git a/examples/sql/doc/src/cachedtable.qdoc b/examples/sql/doc/src/cachedtable.qdoc
index 0dd7928e21..ff60f7b1b7 100644
--- a/examples/sql/doc/src/cachedtable.qdoc
+++ b/examples/sql/doc/src/cachedtable.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example cachedtable
- \title Cached Table Example
+ \title Cached SQL Table
\ingroup sql_examples
+ \examplecategory {Data Processing & I/O}
\brief The Cached Table example shows how a table view can be used to access a database,
caching any changes to the data until the user explicitly submits them using a
@@ -38,7 +15,7 @@
The example consists of a single class, \c TableEditor, which is a
custom dialog widget that allows the user to modify data stored in
- a database. We will first review the class definiton and how to
+ a database. We will first review the class definition and how to
use the class, then we will take a look at the implementation.
\section1 TableEditor Class Definition
@@ -64,7 +41,7 @@
We are also going to show how a table view can be used to cache
any changes to the data until the user explicitly requests to
submit them. For that reason we need to declare a \c submit() slot
- in additon to the model and the editor's buttons.
+ in addition to the model and the editor's buttons.
\table 100%
\header \li Connecting to a Database
diff --git a/examples/sql/doc/src/drilldown.qdoc b/examples/sql/doc/src/drilldown.qdoc
index f43ba38a23..d334018b4a 100644
--- a/examples/sql/doc/src/drilldown.qdoc
+++ b/examples/sql/doc/src/drilldown.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example drilldown
\title Drill Down Example
\ingroup sql_examples
+ \examplecategory {Data Processing & I/O}
\brief The Drill Down example shows how to read data from a database as
well as submit changes, using the QSqlRelationalTableModel and
@@ -69,8 +46,8 @@
\snippet drilldown/informationwindow.h 0
When we create an information window, we pass the associated
- item ID, a parent, and a pointer to the database, to the
- constructor. We will use the database pointer to populate our
+ item ID, a pointer to the model, and a parent to the
+ constructor. We will use the model pointer to populate our
window with data, while passing the parent parameter on to the
base class. The ID is stored for future reference.
@@ -177,10 +154,6 @@
We need to use lambdas for connecting the \c enableButtons slot
because its signature does not match \c QTextEdit::textChanged
and \c QComboBox::currentIndexChanged.
- Since the latter has another overload with the signature
- \c {const QString &} and the selected signal would be ambiguous,
- we need to use \c QOverload<int>::of to select a specific overload
- for \c currentIndexChanged.
We add all the widgets into a layout, store the item ID and the
name of the displayed image file for future reference, and set
@@ -307,7 +280,7 @@
The \c findWindow() function, on the other hand, is frequently
used. It is called from the \c showInformation() function to
- detemine whether a window is already created for the given
+ determine whether a window is already created for the given
item (whenever we create an \c InformationWindow object, we
store a reference to it in the \c informationWindows list). The
latter function is in turn called from our custom \c
diff --git a/examples/sql/doc/src/masterdetail.qdoc b/examples/sql/doc/src/masterdetail.qdoc
index 033dd41f72..fec579a6a0 100644
--- a/examples/sql/doc/src/masterdetail.qdoc
+++ b/examples/sql/doc/src/masterdetail.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example masterdetail
\title Master Detail Example
\ingroup sql_examples
+ \examplecategory {Data Processing & I/O}
\brief The Master Detail Example shows how to present data from different
data sources in the same application. The album titles, and the
diff --git a/examples/sql/doc/src/querymodel.qdoc b/examples/sql/doc/src/querymodel.qdoc
index 4f14975234..c9fa4cec96 100644
--- a/examples/sql/doc/src/querymodel.qdoc
+++ b/examples/sql/doc/src/querymodel.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example querymodel
\title Query Model Example
\ingroup sql_examples
+ \examplecategory {Data Processing & I/O}
\brief The Query Model example shows how to make customized versions of
data obtained from a SQL query, using a model that encapsulates
diff --git a/examples/sql/doc/src/relationaltablemodel.qdoc b/examples/sql/doc/src/relationaltablemodel.qdoc
index 95648cdc78..371fef8133 100644
--- a/examples/sql/doc/src/relationaltablemodel.qdoc
+++ b/examples/sql/doc/src/relationaltablemodel.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example relationaltablemodel
\title Relational Table Model Example
\ingroup sql_examples
+ \examplecategory {Data Processing & I/O}
\brief The Relational Table Model example shows how to use table views with a relational
model to visualize the relations between items in a database.
diff --git a/examples/sql/doc/src/sqlbrowser.qdoc b/examples/sql/doc/src/sqlbrowser.qdoc
index 6eeb2376f3..ad783f5760 100644
--- a/examples/sql/doc/src/sqlbrowser.qdoc
+++ b/examples/sql/doc/src/sqlbrowser.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example sqlbrowser
\title SQL Browser
\ingroup sql_examples
+ \examplecategory {Data Processing & I/O}
\brief The SQL Browser example shows how a data browser can be used to visualize
the results of SQL statements on a live database.
diff --git a/examples/sql/doc/src/sqlwidgetmapper.qdoc b/examples/sql/doc/src/sqlwidgetmapper.qdoc
index a0fc26a642..0764e601c3 100644
--- a/examples/sql/doc/src/sqlwidgetmapper.qdoc
+++ b/examples/sql/doc/src/sqlwidgetmapper.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example sqlwidgetmapper
\title SQL Widget Mapper Example
\ingroup sql_examples
+ \examplecategory {Data Processing & I/O}
\brief The SQL Widget Mapper example shows how to use a map information from a
database to widgets on a form.
@@ -125,8 +102,7 @@
As a result, the user is able to select an item from the combo box,
and the associated value is written back to the model.
- 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 sqlwidgetmapper/window.cpp Set up connections and layouts
@@ -139,7 +115,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 sqlwidgetmapper/delegate.h Delegate class definition
@@ -150,7 +126,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:
@@ -162,10 +138,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/sql/doc/src/tablemodel.qdoc b/examples/sql/doc/src/tablemodel.qdoc
index 66d1801508..1542d121aa 100644
--- a/examples/sql/doc/src/tablemodel.qdoc
+++ b/examples/sql/doc/src/tablemodel.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example tablemodel
\title Table Model Example
\ingroup sql_examples
+ \examplecategory {Data Processing & I/O}
\brief The Table Model example shows how to use a specialized SQL table model with table
views to edit information in a database.
diff --git a/examples/sql/drilldown/CMakeLists.txt b/examples/sql/drilldown/CMakeLists.txt
index ace085e6ac..fb9b441fa3 100644
--- a/examples/sql/drilldown/CMakeLists.txt
+++ b/examples/sql/drilldown/CMakeLists.txt
@@ -1,24 +1,12 @@
-# Generated from drilldown.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(drilldown LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Sql Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sql/drilldown")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Sql)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(drilldown
../connection.h
@@ -27,17 +15,18 @@ qt_add_executable(drilldown
main.cpp
view.cpp view.h
)
+
set_target_properties(drilldown PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(drilldown PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Sql
- Qt::Widgets
-)
+target_link_libraries(drilldown PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Sql
+ Qt6::Widgets
+)
# Resources:
set(drilldown_resource_files
@@ -47,7 +36,7 @@ set(drilldown_resource_files
"images/qt-quick.png"
)
-qt6_add_resources(drilldown "drilldown"
+qt_add_resources(drilldown "drilldown"
PREFIX
"/"
FILES
@@ -55,7 +44,14 @@ qt6_add_resources(drilldown "drilldown"
)
install(TARGETS drilldown
- 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 drilldown
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/sql/drilldown/imageitem.cpp b/examples/sql/drilldown/imageitem.cpp
index 72de623373..4dfb5ee6e8 100644
--- a/examples/sql/drilldown/imageitem.cpp
+++ b/examples/sql/drilldown/imageitem.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "imageitem.h"
@@ -101,7 +54,7 @@ void ImageItem::setFrame(int frame)
QPointF center = boundingRect().center();
setTransform(QTransform::fromTranslate(center.x(), center.y()), true);
- setTransform(QTransform::fromScale(1 + frame / 330.0, 1 + frame / 330.0), true);
+ setTransform(QTransform::fromScale(1 + frame / 300.0, 1 + frame / 300.0), true);
setTransform(QTransform::fromTranslate(-center.x(), -center.y()), true);
}
//! [3]
@@ -109,8 +62,8 @@ void ImageItem::setFrame(int frame)
//! [4]
void ImageItem::adjust()
{
- setTransform(QTransform::fromScale(120 / boundingRect().width(),
- 120 / boundingRect().height()));
+ setTransform(QTransform::fromScale(120.0 / boundingRect().width(),
+ 120.0 / boundingRect().height()));
}
//! [4]
diff --git a/examples/sql/drilldown/imageitem.h b/examples/sql/drilldown/imageitem.h
index 324c847b12..23a41aa2f2 100644
--- a/examples/sql/drilldown/imageitem.h
+++ b/examples/sql/drilldown/imageitem.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef IMAGEITEM_H
#define IMAGEITEM_H
@@ -58,7 +11,6 @@
class ImageItem : public QObject, public QGraphicsPixmapItem
{
Q_OBJECT
-
public:
enum { Type = UserType + 1 };
@@ -72,7 +24,7 @@ protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
-private slots:
+private Q_SLOTS:
void setFrame(int frame);
void updateItemPosition();
diff --git a/examples/sql/drilldown/images/qt-creator.png b/examples/sql/drilldown/images/qt-creator.png
index 0602bdcad1..576f9f39ff 100644
--- a/examples/sql/drilldown/images/qt-creator.png
+++ b/examples/sql/drilldown/images/qt-creator.png
Binary files differ
diff --git a/examples/sql/drilldown/images/qt-logo.png b/examples/sql/drilldown/images/qt-logo.png
index 7603fa0c90..fb8b1686bd 100644
--- a/examples/sql/drilldown/images/qt-logo.png
+++ b/examples/sql/drilldown/images/qt-logo.png
Binary files differ
diff --git a/examples/sql/drilldown/images/qt-project.png b/examples/sql/drilldown/images/qt-project.png
index e066fbe3f9..8c20e3f0c2 100644
--- a/examples/sql/drilldown/images/qt-project.png
+++ b/examples/sql/drilldown/images/qt-project.png
Binary files differ
diff --git a/examples/sql/drilldown/images/qt-quick.png b/examples/sql/drilldown/images/qt-quick.png
index 90d9fd075d..a905f47c35 100644
--- a/examples/sql/drilldown/images/qt-quick.png
+++ b/examples/sql/drilldown/images/qt-quick.png
Binary files differ
diff --git a/examples/sql/drilldown/informationwindow.cpp b/examples/sql/drilldown/informationwindow.cpp
index 349416b553..d69c91d0cb 100644
--- a/examples/sql/drilldown/informationwindow.cpp
+++ b/examples/sql/drilldown/informationwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "informationwindow.h"
@@ -56,9 +9,9 @@ InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *items,
: QDialog(parent)
{
//! [0] //! [1]
- QLabel *itemLabel = new QLabel(tr("Item: "));
- QLabel *descriptionLabel = new QLabel(tr("Description: "));
- QLabel *imageFileLabel = new QLabel(tr("Image file: "));
+ QLabel *itemLabel = new QLabel(tr("Item:"));
+ QLabel *descriptionLabel = new QLabel(tr("Description:"));
+ QLabel *imageFileLabel = new QLabel(tr("Image file:"));
createButtons();
@@ -84,12 +37,8 @@ InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *items,
//! [3]
//! [4]
- connect(descriptionEditor, &QTextEdit::textChanged, [=]() {
- enableButtons();
- });
- connect(imageFileEditor, &QComboBox::currentIndexChanged, [=]() {
- enableButtons();
- });
+ connect(descriptionEditor, &QTextEdit::textChanged, this, [this]() { enableButtons(true); });
+ connect(imageFileEditor, &QComboBox::currentIndexChanged, this, [this]() { enableButtons(true); });
QFormLayout *formLayout = new QFormLayout;
formLayout->addRow(itemLabel, itemText);
diff --git a/examples/sql/drilldown/informationwindow.h b/examples/sql/drilldown/informationwindow.h
index 653837d722..2380463785 100644
--- a/examples/sql/drilldown/informationwindow.h
+++ b/examples/sql/drilldown/informationwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef INFORMATIONWINDOW_H
#define INFORMATIONWINDOW_H
@@ -58,22 +11,20 @@
class InformationWindow : public QDialog
{
Q_OBJECT
-
public:
InformationWindow(int id, QSqlRelationalTableModel *items,
QWidget *parent = nullptr);
-
int id() const;
-signals:
+Q_SIGNALS:
void imageChanged(int id, const QString &fileName);
//! [0]
//! [1]
-private slots:
+private Q_SLOTS:
void revert();
void submit();
- void enableButtons(bool enable = true);
+ void enableButtons(bool enable);
//! [1]
//! [2]
diff --git a/examples/sql/drilldown/main.cpp b/examples/sql/drilldown/main.cpp
index db3320de48..77b8725281 100644
--- a/examples/sql/drilldown/main.cpp
+++ b/examples/sql/drilldown/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "view.h"
#include "../connection.h"
@@ -58,8 +11,6 @@
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(drilldown);
-
QApplication app(argc, argv);
if (!createConnection())
diff --git a/examples/sql/drilldown/view.cpp b/examples/sql/drilldown/view.cpp
index 9f19668946..c2f7301a21 100644
--- a/examples/sql/drilldown/view.cpp
+++ b/examples/sql/drilldown/view.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "informationwindow.h"
#include "imageitem.h"
@@ -134,8 +87,8 @@ void View::showInformation(ImageItem *image)
if (!window) {
window = new InformationWindow(id, itemTable, this);
- connect(window, QOverload<int,const QString &>::of(&InformationWindow::imageChanged),
- this, QOverload<int,const QString &>::of(&View::updateImage));
+ connect(window, &InformationWindow::imageChanged,
+ this, &View::updateImage);
window->move(pos() + QPoint(20, 40));
window->show();
diff --git a/examples/sql/drilldown/view.h b/examples/sql/drilldown/view.h
index 5afa1a25e9..f44dedce99 100644
--- a/examples/sql/drilldown/view.h
+++ b/examples/sql/drilldown/view.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef VIEW_H
#define VIEW_H
@@ -61,7 +14,6 @@ class InformationWindow;
class View : public QGraphicsView
{
Q_OBJECT
-
public:
View(const QString &items, const QString &images, QWidget *parent = nullptr);
@@ -70,7 +22,7 @@ protected:
//! [0]
//! [1]
-private slots:
+private Q_SLOTS:
void updateImage(int id, const QString &fileName);
//! [1]
diff --git a/examples/sql/masterdetail/CMakeLists.txt b/examples/sql/masterdetail/CMakeLists.txt
index 1a66c81b9c..558bf70ee2 100644
--- a/examples/sql/masterdetail/CMakeLists.txt
+++ b/examples/sql/masterdetail/CMakeLists.txt
@@ -1,25 +1,12 @@
-# Generated from masterdetail.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(masterdetail LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Sql Widgets Xml)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sql/masterdetail")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Sql)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS Xml)
+qt_standard_project_setup()
qt_add_executable(masterdetail
database.h
@@ -27,18 +14,19 @@ qt_add_executable(masterdetail
main.cpp
mainwindow.cpp mainwindow.h
)
+
set_target_properties(masterdetail PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(masterdetail PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Sql
- Qt::Widgets
- Qt::Xml
-)
+target_link_libraries(masterdetail PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Sql
+ Qt6::Widgets
+ Qt6::Xml
+)
# Resources:
set(masterdetail_resource_files
@@ -46,7 +34,7 @@ set(masterdetail_resource_files
"images/image.png"
)
-qt6_add_resources(masterdetail "masterdetail"
+qt_add_resources(masterdetail "masterdetail"
PREFIX
"/"
FILES
@@ -54,7 +42,14 @@ qt6_add_resources(masterdetail "masterdetail"
)
install(TARGETS masterdetail
- 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 masterdetail
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/sql/masterdetail/database.h b/examples/sql/masterdetail/database.h
index 9cbca6f749..ed6d32b558 100644
--- a/examples/sql/masterdetail/database.h
+++ b/examples/sql/masterdetail/database.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DATABASE_H
#define DATABASE_H
diff --git a/examples/sql/masterdetail/dialog.cpp b/examples/sql/masterdetail/dialog.cpp
index 7777929dfd..0b8ed8a75b 100644
--- a/examples/sql/masterdetail/dialog.cpp
+++ b/examples/sql/masterdetail/dialog.cpp
@@ -1,59 +1,25 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "dialog.h"
-int uniqueAlbumId;
-int uniqueArtistId;
-
-Dialog::Dialog(QSqlRelationalTableModel *albums, QDomDocument details,
+#include <QDialogButtonBox>
+#include <QDate>
+#include <QDomDocument>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLineEdit>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QSpinBox>
+#include <QSqlField>
+#include <QSqlRelationalTableModel>
+#include <QSqlRecord>
+#include <QVBoxLayout>
+
+int Dialog::s_artistId = 0;
+int Dialog::s_albumId = 0;
+Dialog::Dialog(QSqlRelationalTableModel *albums, const QDomDocument &details,
QFile *output, QWidget *parent)
: QDialog(parent)
{
@@ -72,6 +38,12 @@ Dialog::Dialog(QSqlRelationalTableModel *albums, QDomDocument details,
setWindowTitle(tr("Add Album"));
}
+void Dialog::setInitialAlbumAndArtistId(int albumId, int artistId)
+{
+ s_albumId = albumId;
+ s_artistId = artistId;
+}
+
void Dialog::submit()
{
QString artist = artistEditor->text();
@@ -192,7 +164,7 @@ void Dialog::addTracks(int albumId, const QStringList &tracks)
*/
}
-void Dialog::increaseAlbumCount(QModelIndex artistIndex)
+void Dialog::increaseAlbumCount(const QModelIndex &artistIndex)
{
QSqlTableModel *artistModel = model->relationModel(2);
@@ -266,7 +238,7 @@ QDialogButtonBox *Dialog::createButtons()
return buttonBox;
}
-QModelIndex Dialog::indexOfArtist(const QString &artist)
+QModelIndex Dialog::indexOfArtist(const QString &artist) const
{
QSqlTableModel *artistModel = model->relationModel(2);
@@ -281,12 +253,12 @@ QModelIndex Dialog::indexOfArtist(const QString &artist)
int Dialog::generateArtistId()
{
- uniqueArtistId += 1;
- return uniqueArtistId;
+ s_artistId += 1;
+ return s_artistId;
}
int Dialog::generateAlbumId()
{
- uniqueAlbumId += 1;
- return uniqueAlbumId;
+ s_albumId += 1;
+ return s_albumId;
}
diff --git a/examples/sql/masterdetail/dialog.h b/examples/sql/masterdetail/dialog.h
index 31c4d8552c..2a4f5a0b8e 100644
--- a/examples/sql/masterdetail/dialog.h
+++ b/examples/sql/masterdetail/dialog.h
@@ -1,67 +1,28 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DIALOG_H
#define DIALOG_H
-#include <QtWidgets>
-#include <QtSql>
-#include <QtXml>
+#include <QDialog>
+#include <QDomDocument>
+
+QT_FORWARD_DECLARE_CLASS(QDialogButtonBox)
+QT_FORWARD_DECLARE_CLASS(QFile)
+QT_FORWARD_DECLARE_CLASS(QGroupBox)
+QT_FORWARD_DECLARE_CLASS(QLineEdit)
+QT_FORWARD_DECLARE_CLASS(QModelIndex)
+QT_FORWARD_DECLARE_CLASS(QSpinBox)
+QT_FORWARD_DECLARE_CLASS(QSqlRelationalTableModel)
class Dialog : public QDialog
{
Q_OBJECT
public:
- Dialog(QSqlRelationalTableModel *albums, QDomDocument details,
+ Dialog(QSqlRelationalTableModel *albums, const QDomDocument &details,
QFile *output, QWidget *parent = nullptr);
+ static void setInitialAlbumAndArtistId(int albumId, int artistId);
private slots:
void revert();
@@ -74,10 +35,8 @@ private:
QDialogButtonBox *createButtons();
QGroupBox *createInputWidgets();
int findArtistId(const QString &artist);
- static int generateAlbumId();
- static int generateArtistId();
- void increaseAlbumCount(QModelIndex artistIndex);
- QModelIndex indexOfArtist(const QString &artist);
+ void increaseAlbumCount(const QModelIndex &artistIndex);
+ QModelIndex indexOfArtist(const QString &artist) const;
QSqlRelationalTableModel *model;
QDomDocument albumDetails;
@@ -87,6 +46,11 @@ private:
QLineEdit *titleEditor;
QSpinBox *yearEditor;
QLineEdit *tracksEditor;
+
+ static int generateAlbumId();
+ static int generateArtistId();
+ static int s_artistId;
+ static int s_albumId;
};
#endif
diff --git a/examples/sql/masterdetail/main.cpp b/examples/sql/masterdetail/main.cpp
index 9a4172e55f..50d99cf24e 100644
--- a/examples/sql/masterdetail/main.cpp
+++ b/examples/sql/masterdetail/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "database.h"
#include "mainwindow.h"
@@ -54,12 +7,8 @@
#include <QApplication>
#include <QFile>
-#include <stdlib.h>
-
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(masterdetail);
-
QApplication app(argc, argv);
if (!createConnection())
diff --git a/examples/sql/masterdetail/mainwindow.cpp b/examples/sql/masterdetail/mainwindow.cpp
index 11f123372c..020a149b22 100644
--- a/examples/sql/masterdetail/mainwindow.cpp
+++ b/examples/sql/masterdetail/mainwindow.cpp
@@ -1,62 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "dialog.h"
-#include <QtWidgets>
-#include <QtSql>
-#include <QtXml>
-
-extern int uniqueAlbumId;
-extern int uniqueArtistId;
+#include <QApplication>
+#include <QComboBox>
+#include <QHeaderView>
+#include <QFile>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QLabel>
+#include <QListWidget>
+#include <QMenu>
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QSqlRecord>
+#include <QSqlRelationalTableModel>
+#include <QTableView>
MainWindow::MainWindow(const QString &artistTable, const QString &albumTable,
QFile *albumDetails, QWidget *parent)
@@ -75,13 +36,12 @@ MainWindow::MainWindow(const QString &artistTable, const QString &albumTable,
QGroupBox *details = createDetailsGroupBox();
artistView->setCurrentIndex(0);
- uniqueAlbumId = model->rowCount();
- uniqueArtistId = artistView->count();
+ Dialog::setInitialAlbumAndArtistId(model->rowCount(), artistView->count());
connect(model, &QSqlRelationalTableModel::rowsInserted,
- this, &MainWindow::updateHeader);
+ this, &MainWindow::adjustHeader);
connect(model, &QSqlRelationalTableModel::rowsRemoved,
- this, &MainWindow::updateHeader);
+ this, &MainWindow::adjustHeader);
QGridLayout *layout = new QGridLayout;
layout->addWidget(artists, 0, 0);
@@ -114,7 +74,7 @@ void MainWindow::changeArtist(int row)
}
}
-void MainWindow::showArtistProfile(QModelIndex index)
+void MainWindow::showArtistProfile(const QModelIndex &index)
{
QSqlRecord record = model->relationModel(2)->record(index.row());
@@ -131,7 +91,7 @@ void MainWindow::showArtistProfile(QModelIndex index)
imageLabel->hide();
}
-void MainWindow::showAlbumDetails(QModelIndex index)
+void MainWindow::showAlbumDetails(const QModelIndex &index)
{
QSqlRecord record = model->record(index.row());
@@ -160,14 +120,11 @@ void MainWindow::getTrackList(QDomNode album)
{
trackList->clear();
- QDomNodeList tracks = album.childNodes();
- QDomNode track;
- QString trackNumber;
-
+ const QDomNodeList tracks = album.childNodes();
for (int i = 0; i < tracks.count(); ++i) {
- track = tracks.item(i);
- trackNumber = track.toElement().attribute("number");
+ const QDomNode track = tracks.item(i);
+ const QString trackNumber = track.toElement().attribute("number");
QListWidgetItem *item = new QListWidgetItem(trackList);
item->setText(trackNumber + ": " + track.toElement().text());
@@ -179,7 +136,7 @@ void MainWindow::addAlbum()
Dialog *dialog = new Dialog(model, albumData, file, this);
int accepted = dialog->exec();
- if (accepted == 1) {
+ if (accepted == QDialog::Accepted) {
int lastRow = model->rowCount() - 1;
albumView->selectRow(lastRow);
albumView->scrollToBottom();
@@ -189,10 +146,10 @@ void MainWindow::addAlbum()
void MainWindow::deleteAlbum()
{
- QModelIndexList selection = albumView->selectionModel()->selectedRows(0);
+ const QModelIndexList selection = albumView->selectionModel()->selectedRows(0);
if (!selection.empty()) {
- QModelIndex idIndex = selection.at(0);
+ const QModelIndex &idIndex = selection.at(0);
int id = idIndex.data().toInt();
QString title = idIndex.sibling(idIndex.row(), 1).data().toString();
QString artist = idIndex.sibling(idIndex.row(), 2).data().toString();
@@ -219,9 +176,7 @@ void MainWindow::deleteAlbum()
void MainWindow::removeAlbumFromFile(int id)
{
-
QDomNodeList albums = albumData.elementsByTagName("album");
-
for (int i = 0; i < albums.count(); ++i) {
QDomNode node = albums.item(i);
if (node.toElement().attribute("id").toInt() == id) {
@@ -244,12 +199,12 @@ void MainWindow::removeAlbumFromFile(int id)
*/
}
-void MainWindow::removeAlbumFromDatabase(QModelIndex index)
+void MainWindow::removeAlbumFromDatabase(const QModelIndex &index)
{
model->removeRow(index.row());
}
-void MainWindow::decreaseAlbumCount(QModelIndex artistIndex)
+void MainWindow::decreaseAlbumCount(const QModelIndex &artistIndex)
{
int row = artistIndex.row();
QModelIndex albumCountIndex = artistIndex.sibling(row, 2);
@@ -388,7 +343,7 @@ void MainWindow::createMenuBar()
connect(deleteAction, &QAction::triggered,
this, &MainWindow::deleteAlbum);
connect(quitAction, &QAction::triggered,
- this, &MainWindow::close);
+ qApp, &QCoreApplication::quit);
connect(aboutAction, &QAction::triggered,
this, &MainWindow::about);
connect(aboutQtAction, &QAction::triggered,
@@ -405,7 +360,7 @@ void MainWindow::showImageLabel()
imageLabel->show();
}
-QModelIndex MainWindow::indexOfArtist(const QString &artist)
+QModelIndex MainWindow::indexOfArtist(const QString &artist) const
{
QSqlTableModel *artistModel = model->relationModel(2);
@@ -417,11 +372,6 @@ QModelIndex MainWindow::indexOfArtist(const QString &artist)
return QModelIndex();
}
-void MainWindow::updateHeader(QModelIndex, int, int)
-{
- adjustHeader();
-}
-
void MainWindow::adjustHeader()
{
albumView->hideColumn(0);
diff --git a/examples/sql/masterdetail/mainwindow.h b/examples/sql/masterdetail/mainwindow.h
index dc6d8d1613..cc2a5c9f59 100644
--- a/examples/sql/masterdetail/mainwindow.h
+++ b/examples/sql/masterdetail/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@@ -55,15 +8,13 @@
#include <QMainWindow>
#include <QModelIndex>
-QT_BEGIN_NAMESPACE
-class QComboBox;
-class QFile;
-class QGroupBox;
-class QLabel;
-class QListWidget;
-class QSqlRelationalTableModel;
-class QTableView;
-QT_END_NAMESPACE
+QT_FORWARD_DECLARE_CLASS(QComboBox)
+QT_FORWARD_DECLARE_CLASS(QFile)
+QT_FORWARD_DECLARE_CLASS(QGroupBox)
+QT_FORWARD_DECLARE_CLASS(QLabel)
+QT_FORWARD_DECLARE_CLASS(QListWidget)
+QT_FORWARD_DECLARE_CLASS(QSqlRelationalTableModel)
+QT_FORWARD_DECLARE_CLASS(QTableView)
class MainWindow : public QMainWindow
{
@@ -78,21 +29,20 @@ private slots:
void addAlbum();
void changeArtist(int row);
void deleteAlbum();
- void showAlbumDetails(QModelIndex index);
- void showArtistProfile(QModelIndex index);
- void updateHeader(QModelIndex, int, int);
+ void showAlbumDetails(const QModelIndex &index);
+ void showArtistProfile(const QModelIndex &index);
+ void adjustHeader();
private:
- void adjustHeader();
QGroupBox *createAlbumGroupBox();
QGroupBox *createArtistGroupBox();
QGroupBox *createDetailsGroupBox();
void createMenuBar();
- void decreaseAlbumCount(QModelIndex artistIndex);
+ void decreaseAlbumCount(const QModelIndex &artistIndex);
void getTrackList(QDomNode album);
- QModelIndex indexOfArtist(const QString &artist);
+ QModelIndex indexOfArtist(const QString &artist) const;
void readAlbumData();
- void removeAlbumFromDatabase(QModelIndex album);
+ void removeAlbumFromDatabase(const QModelIndex &album);
void removeAlbumFromFile(int id);
void showImageLabel();
diff --git a/examples/sql/querymodel/CMakeLists.txt b/examples/sql/querymodel/CMakeLists.txt
index 8320ac917d..b7d863ab05 100644
--- a/examples/sql/querymodel/CMakeLists.txt
+++ b/examples/sql/querymodel/CMakeLists.txt
@@ -1,24 +1,12 @@
-# Generated from querymodel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(querymodel LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Sql Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sql/querymodel")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Sql)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(querymodel
../connection.h
@@ -26,19 +14,28 @@ qt_add_executable(querymodel
editablesqlmodel.cpp editablesqlmodel.h
main.cpp
)
+
set_target_properties(querymodel PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(querymodel PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Sql
- Qt::Widgets
+
+target_link_libraries(querymodel PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Sql
+ Qt6::Widgets
)
install(TARGETS querymodel
- 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 querymodel
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/sql/querymodel/customsqlmodel.cpp b/examples/sql/querymodel/customsqlmodel.cpp
index 7be0a65882..e87be12f09 100644
--- a/examples/sql/querymodel/customsqlmodel.cpp
+++ b/examples/sql/querymodel/customsqlmodel.cpp
@@ -1,57 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "customsqlmodel.h"
+#include <QColor>
+
CustomSqlModel::CustomSqlModel(QObject *parent)
: QSqlQueryModel(parent)
{
diff --git a/examples/sql/querymodel/customsqlmodel.h b/examples/sql/querymodel/customsqlmodel.h
index 462d2ab822..56fcb10210 100644
--- a/examples/sql/querymodel/customsqlmodel.h
+++ b/examples/sql/querymodel/customsqlmodel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CUSTOMSQLMODEL_H
#define CUSTOMSQLMODEL_H
diff --git a/examples/sql/querymodel/editablesqlmodel.cpp b/examples/sql/querymodel/editablesqlmodel.cpp
index c45ef138d5..dc91666c06 100644
--- a/examples/sql/querymodel/editablesqlmodel.cpp
+++ b/examples/sql/querymodel/editablesqlmodel.cpp
@@ -1,65 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtSql>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "editablesqlmodel.h"
+#include <QSqlQuery>
+
EditableSqlModel::EditableSqlModel(QObject *parent)
: QSqlQueryModel(parent)
{
}
//! [0]
-Qt::ItemFlags EditableSqlModel::flags(
- const QModelIndex &index) const
+Qt::ItemFlags EditableSqlModel::flags(const QModelIndex &index) const
{
Qt::ItemFlags flags = QSqlQueryModel::flags(index);
if (index.column() == 1 || index.column() == 2)
@@ -80,11 +32,10 @@ bool EditableSqlModel::setData(const QModelIndex &index, const QVariant &value,
clear();
bool ok;
- if (index.column() == 1) {
+ if (index.column() == 1)
ok = setFirstName(id, value.toString());
- } else {
+ else
ok = setLastName(id, value.toString());
- }
refresh();
return ok;
}
diff --git a/examples/sql/querymodel/editablesqlmodel.h b/examples/sql/querymodel/editablesqlmodel.h
index e8caad2765..ac0a1f6a47 100644
--- a/examples/sql/querymodel/editablesqlmodel.h
+++ b/examples/sql/querymodel/editablesqlmodel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef EDITABLESQLMODEL_H
#define EDITABLESQLMODEL_H
diff --git a/examples/sql/querymodel/main.cpp b/examples/sql/querymodel/main.cpp
index da19939dd8..a4680f7fe8 100644
--- a/examples/sql/querymodel/main.cpp
+++ b/examples/sql/querymodel/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "../connection.h"
#include "customsqlmodel.h"
@@ -55,8 +8,6 @@
#include <QApplication>
#include <QTableView>
-#include <stdlib.h>
-
void initializeModel(QSqlQueryModel *model)
{
model->setQuery("select * from person");
diff --git a/examples/sql/relationaltablemodel/CMakeLists.txt b/examples/sql/relationaltablemodel/CMakeLists.txt
index 63557fba88..fcca1f182b 100644
--- a/examples/sql/relationaltablemodel/CMakeLists.txt
+++ b/examples/sql/relationaltablemodel/CMakeLists.txt
@@ -1,42 +1,39 @@
-# Generated from relationaltablemodel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(relationaltablemodel LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Sql Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sql/relationaltablemodel")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Sql)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(relationaltablemodel
../connection.h
relationaltablemodel.cpp
)
+
set_target_properties(relationaltablemodel PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(relationaltablemodel PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Sql
- Qt::Widgets
+
+target_link_libraries(relationaltablemodel PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Sql
+ Qt6::Widgets
)
install(TARGETS relationaltablemodel
- 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 relationaltablemodel
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/sql/relationaltablemodel/relationaltablemodel.cpp b/examples/sql/relationaltablemodel/relationaltablemodel.cpp
index df4eae6e6e..24a2562ea3 100644
--- a/examples/sql/relationaltablemodel/relationaltablemodel.cpp
+++ b/examples/sql/relationaltablemodel/relationaltablemodel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include <QtSql>
diff --git a/examples/sql/sqlbrowser/CMakeLists.txt b/examples/sql/sqlbrowser/CMakeLists.txt
index 260288b9c0..a124ae203c 100644
--- a/examples/sql/sqlbrowser/CMakeLists.txt
+++ b/examples/sql/sqlbrowser/CMakeLists.txt
@@ -1,24 +1,14 @@
-# Generated from sqlbrowser.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(sqlbrowser LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Sql Widgets)
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sql/sqlbrowser")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Sql)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(sqlbrowser
browser.cpp browser.h
@@ -27,19 +17,28 @@ qt_add_executable(sqlbrowser
main.cpp
qsqlconnectiondialog.cpp qsqlconnectiondialog.h qsqlconnectiondialog.ui
)
+
set_target_properties(sqlbrowser PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(sqlbrowser PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Sql
- Qt::Widgets
+
+target_link_libraries(sqlbrowser PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Sql
+ Qt6::Widgets
)
install(TARGETS sqlbrowser
- 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 sqlbrowser
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/sql/sqlbrowser/browser.cpp b/examples/sql/sqlbrowser/browser.cpp
index 3efd8b77b4..9a99999702 100644
--- a/examples/sql/sqlbrowser/browser.cpp
+++ b/examples/sql/sqlbrowser/browser.cpp
@@ -1,72 +1,51 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "browser.h"
#include "qsqlconnectiondialog.h"
-
-#include <QtWidgets>
-#include <QtSql>
+#include <ui_browserwidget.h>
+
+#include <QAction>
+#include <QMessageBox>
+#include <QStandardItemModel>
+#include <QSqlDriver>
+#include <QSqlError>
+#include <QSqlField>
+#include <QSqlQuery>
+#include <QSqlRecord>
+#include <QTextEdit>
+#include <QTimer>
Browser::Browser(QWidget *parent)
: QWidget(parent)
+ , m_ui(new Ui::Browser)
{
- setupUi(this);
-
- table->addAction(insertRowAction);
- table->addAction(deleteRowAction);
- table->addAction(fieldStrategyAction);
- table->addAction(rowStrategyAction);
- table->addAction(manualStrategyAction);
- table->addAction(submitAction);
- table->addAction(revertAction);
- table->addAction(selectAction);
+ m_ui->setupUi(this);
+
+ m_ui->table->addAction(m_ui->insertRowAction);
+ m_ui->table->addAction(m_ui->deleteRowAction);
+ m_ui->table->addAction(m_ui->fieldStrategyAction);
+ m_ui->table->addAction(m_ui->rowStrategyAction);
+ m_ui->table->addAction(m_ui->manualStrategyAction);
+ m_ui->table->addAction(m_ui->submitAction);
+ m_ui->table->addAction(m_ui->revertAction);
+ m_ui->table->addAction(m_ui->selectAction);
+
+ connect(m_ui->insertRowAction, &QAction::triggered, this, &Browser::insertRow);
+ connect(m_ui->deleteRowAction, &QAction::triggered, this, &Browser::deleteRow);
+ connect(m_ui->fieldStrategyAction, &QAction::triggered, this, &Browser::onFieldStrategyAction);
+ connect(m_ui->rowStrategyAction, &QAction::triggered, this, &Browser::onRowStrategyAction);
+ connect(m_ui->sqlEdit, &QTextEdit::textChanged, this, &Browser::updateActions);
+
+ connect(m_ui->connectionWidget, &ConnectionWidget::tableActivated,
+ this, &Browser::showTable);
+ connect(m_ui->connectionWidget, &ConnectionWidget::metaDataRequested,
+ this, &Browser::showMetaData);
+
+ connect(m_ui->submitButton, &QPushButton::clicked,
+ this, &Browser::onSubmitButton);
+ connect(m_ui->clearButton, &QPushButton::clicked,
+ this, &Browser::onClearButton);
if (QSqlDatabase::drivers().isEmpty())
QMessageBox::information(this, tr("No database drivers found"),
@@ -74,18 +53,22 @@ Browser::Browser(QWidget *parent)
"Please check the documentation how to build the "
"Qt SQL plugins."));
- emit statusMessage(tr("Ready."));
+ QTimer::singleShot(0, this, [this]() {
+ updateActions();
+ emit statusMessage(tr("Ready."));
+ });
}
Browser::~Browser()
{
+ delete m_ui;
}
void Browser::exec()
{
- QSqlQueryModel *model = new QSqlQueryModel(table);
- model->setQuery(QSqlQuery(sqlEdit->toPlainText(), connectionWidget->currentDatabase()));
- table->setModel(model);
+ QSqlQueryModel *model = new QSqlQueryModel(m_ui->table);
+ model->setQuery(QSqlQuery(m_ui->sqlEdit->toPlainText(), m_ui->connectionWidget->currentDatabase()));
+ m_ui->table->setModel(model);
if (model->lastError().type() != QSqlError::NoError)
emit statusMessage(model->lastError().text());
@@ -99,7 +82,7 @@ void Browser::exec()
}
QSqlError Browser::addConnection(const QString &driver, const QString &dbName, const QString &host,
- const QString &user, const QString &passwd, int port)
+ const QString &user, const QString &passwd, int port)
{
static int cCount = 0;
@@ -113,12 +96,12 @@ QSqlError Browser::addConnection(const QString &driver, const QString &dbName, c
db = QSqlDatabase();
QSqlDatabase::removeDatabase(QString("Browser%1").arg(cCount));
}
- connectionWidget->refresh();
+ m_ui->connectionWidget->refresh();
return err;
}
-void Browser::addConnection()
+void Browser::openNewConnectionDialog()
{
QSqlConnectionDialog dialog(this);
if (dialog.exec() != QDialog::Accepted)
@@ -129,10 +112,14 @@ void Browser::addConnection()
QSqlDatabase::removeDatabase("in_mem_db");
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "in_mem_db");
db.setDatabaseName(":memory:");
- if (!db.open())
- QMessageBox::warning(this, tr("Unable to open database"), tr("An error occurred while "
- "opening the connection: ") + db.lastError().text());
- QSqlQuery q("", db);
+ if (!db.open()) {
+ QMessageBox::warning(this, tr("Unable to open database"),
+ tr("An error occurred while "
+ "opening the connection: %1") .arg(db.lastError().text()));
+ return;
+ }
+ db.transaction();
+ QSqlQuery q(db);
q.exec("drop table Movies");
q.exec("drop table Names");
q.exec("create table Movies (id integer primary key, Title varchar, Director varchar, Rating number)");
@@ -141,43 +128,49 @@ void Browser::addConnection()
q.exec("insert into Movies values (2, 'Bis ans Ende der Welt', 'Wim Wenders', '6.5')");
q.exec("insert into Movies values (3, 'Hardware', 'Richard Stanley', '5.2')");
q.exec("insert into Movies values (4, 'Mitchell', 'Andrew V. McLaglen', '2.1')");
- q.exec("create table Names (id integer primary key, Firstname varchar, Lastname varchar, City varchar)");
+ q.exec("create table Names (id integer primary key, FirstName varchar, LastName varchar, City varchar)");
q.exec("insert into Names values (0, 'Sala', 'Palmer', 'Morristown')");
q.exec("insert into Names values (1, 'Christopher', 'Walker', 'Morristown')");
q.exec("insert into Names values (2, 'Donald', 'Duck', 'Andeby')");
q.exec("insert into Names values (3, 'Buck', 'Rogers', 'Paris')");
q.exec("insert into Names values (4, 'Sherlock', 'Holmes', 'London')");
- connectionWidget->refresh();
+ db.commit();
+ m_ui->connectionWidget->refresh();
} else {
QSqlError err = addConnection(dialog.driverName(), dialog.databaseName(), dialog.hostName(),
- dialog.userName(), dialog.password(), dialog.port());
+ dialog.userName(), dialog.password(), dialog.port());
if (err.type() != QSqlError::NoError)
- QMessageBox::warning(this, tr("Unable to open database"), tr("An error occurred while "
- "opening the connection: ") + err.text());
+ QMessageBox::warning(this, tr("Unable to open database"),
+ tr("An error occurred while "
+ "opening the connection: %1").arg(err.text()));
}
}
void Browser::showTable(const QString &t)
{
- QSqlTableModel *model = new CustomModel(table, connectionWidget->currentDatabase());
+ QSqlTableModel *model = new CustomModel(m_ui->table, m_ui->connectionWidget->currentDatabase());
model->setEditStrategy(QSqlTableModel::OnRowChange);
- model->setTable(connectionWidget->currentDatabase().driver()->escapeIdentifier(t, QSqlDriver::TableName));
+ model->setTable(m_ui->connectionWidget->currentDatabase().driver()->escapeIdentifier(t, QSqlDriver::TableName));
model->select();
if (model->lastError().type() != QSqlError::NoError)
emit statusMessage(model->lastError().text());
- table->setModel(model);
- table->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
- connect(table->selectionModel(), &QItemSelectionModel::currentRowChanged,
- this, &Browser::currentChanged);
+ m_ui->table->setModel(model);
+ m_ui->table->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
+ connect(m_ui->table->selectionModel(), &QItemSelectionModel::currentRowChanged,
+ this, &Browser::updateActions);
+
+ connect(m_ui->submitAction, &QAction::triggered, model, &QSqlTableModel::submitAll);
+ connect(m_ui->revertAction, &QAction::triggered, model, &QSqlTableModel::revertAll);
+ connect(m_ui->selectAction, &QAction::triggered, model, &QSqlTableModel::select);
updateActions();
}
void Browser::showMetaData(const QString &t)
{
- QSqlRecord rec = connectionWidget->currentDatabase().record(t);
- QStandardItemModel *model = new QStandardItemModel(table);
+ QSqlRecord rec = m_ui->connectionWidget->currentDatabase().record(t);
+ QStandardItemModel *model = new QStandardItemModel(m_ui->table);
model->insertRows(0, rec.count());
model->insertColumns(0, 7);
@@ -193,9 +186,7 @@ void Browser::showMetaData(const QString &t)
for (int i = 0; i < rec.count(); ++i) {
QSqlField fld = rec.field(i);
model->setData(model->index(i, 0), fld.name());
- model->setData(model->index(i, 1), fld.typeID() == -1
- ? QString(fld.metaType().name())
- : QString("%1 (%2)").arg(fld.metaType().name()).arg(fld.typeID()));
+ model->setData(model->index(i, 1), QString::fromUtf8(fld.metaType().name()));
model->setData(model->index(i, 2), fld.length());
model->setData(model->index(i, 3), fld.precision());
model->setData(model->index(i, 4), fld.requiredStatus() == -1 ? QVariant("?")
@@ -204,37 +195,37 @@ void Browser::showMetaData(const QString &t)
model->setData(model->index(i, 6), fld.defaultValue());
}
- table->setModel(model);
- table->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ m_ui->table->setModel(model);
+ m_ui->table->setEditTriggers(QAbstractItemView::NoEditTriggers);
updateActions();
}
void Browser::insertRow()
{
- QSqlTableModel *model = qobject_cast<QSqlTableModel *>(table->model());
+ QSqlTableModel *model = qobject_cast<QSqlTableModel *>(m_ui->table->model());
if (!model)
return;
- QModelIndex insertIndex = table->currentIndex();
+ QModelIndex insertIndex = m_ui->table->currentIndex();
int row = insertIndex.row() == -1 ? 0 : insertIndex.row();
model->insertRow(row);
insertIndex = model->index(row, 0);
- table->setCurrentIndex(insertIndex);
- table->edit(insertIndex);
+ m_ui->table->setCurrentIndex(insertIndex);
+ m_ui->table->edit(insertIndex);
}
void Browser::deleteRow()
{
- QSqlTableModel *model = qobject_cast<QSqlTableModel *>(table->model());
+ QSqlTableModel *model = qobject_cast<QSqlTableModel *>(m_ui->table->model());
if (!model)
return;
- QModelIndexList currentSelection = table->selectionModel()->selectedIndexes();
- for (int i = 0; i < currentSelection.count(); ++i) {
- if (currentSelection.at(i).column() != 0)
+ const QModelIndexList currentSelection = m_ui->table->selectionModel()->selectedIndexes();
+ for (const auto &idx : currentSelection) {
+ if (idx.column() != 0)
continue;
- model->removeRow(currentSelection.at(i).row());
+ model->removeRow(idx.row());
}
updateActions();
@@ -242,74 +233,70 @@ void Browser::deleteRow()
void Browser::updateActions()
{
- QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
- bool enableIns = tm;
- bool enableDel = enableIns && table->currentIndex().isValid();
+ QSqlTableModel *tm = qobject_cast<QSqlTableModel *>(m_ui->table->model());
+ bool enableIns = tm != nullptr;
+ bool enableDel = enableIns && m_ui->table->currentIndex().isValid();
- insertRowAction->setEnabled(enableIns);
- deleteRowAction->setEnabled(enableDel);
+ m_ui->insertRowAction->setEnabled(enableIns);
+ m_ui->deleteRowAction->setEnabled(enableDel);
- fieldStrategyAction->setEnabled(tm);
- rowStrategyAction->setEnabled(tm);
- manualStrategyAction->setEnabled(tm);
- submitAction->setEnabled(tm);
- revertAction->setEnabled(tm);
- selectAction->setEnabled(tm);
+ m_ui->submitAction->setEnabled(tm);
+ m_ui->revertAction->setEnabled(tm);
+ m_ui->selectAction->setEnabled(tm);
+
+ const bool isEmpty = m_ui->sqlEdit->toPlainText().isEmpty();
+ m_ui->submitButton->setEnabled(m_ui->connectionWidget->currentDatabase().isOpen() && !isEmpty);
+ m_ui->clearButton->setEnabled(!isEmpty);
if (tm) {
QSqlTableModel::EditStrategy es = tm->editStrategy();
- fieldStrategyAction->setChecked(es == QSqlTableModel::OnFieldChange);
- rowStrategyAction->setChecked(es == QSqlTableModel::OnRowChange);
- manualStrategyAction->setChecked(es == QSqlTableModel::OnManualSubmit);
+ m_ui->fieldStrategyAction->setChecked(es == QSqlTableModel::OnFieldChange);
+ m_ui->rowStrategyAction->setChecked(es == QSqlTableModel::OnRowChange);
+ m_ui->manualStrategyAction->setChecked(es == QSqlTableModel::OnManualSubmit);
+ } else {
+ m_ui->fieldStrategyAction->setEnabled(false);
+ m_ui->rowStrategyAction->setEnabled(false);
+ m_ui->manualStrategyAction->setEnabled(false);
}
}
void Browser::about()
{
- QMessageBox::about(this, tr("About"), tr("The SQL Browser demonstration "
- "shows how a data browser can be used to visualize the results of SQL"
- "statements on a live database"));
+ QMessageBox::about(this, tr("About"),
+ tr("The SQL Browser demonstration shows how a data browser "
+ "can be used to visualize the results of SQL "
+ "statements on a live database"));
}
-void Browser::on_fieldStrategyAction_triggered()
+void Browser::onFieldStrategyAction()
{
- QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
+ QSqlTableModel *tm = qobject_cast<QSqlTableModel *>(m_ui->table->model());
if (tm)
tm->setEditStrategy(QSqlTableModel::OnFieldChange);
}
-void Browser::on_rowStrategyAction_triggered()
+void Browser::onRowStrategyAction()
{
- QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
+ QSqlTableModel *tm = qobject_cast<QSqlTableModel *>(m_ui->table->model());
if (tm)
tm->setEditStrategy(QSqlTableModel::OnRowChange);
}
-void Browser::on_manualStrategyAction_triggered()
+void Browser::onManualStrategyAction()
{
- QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
+ QSqlTableModel *tm = qobject_cast<QSqlTableModel *>(m_ui->table->model());
if (tm)
tm->setEditStrategy(QSqlTableModel::OnManualSubmit);
}
-void Browser::on_submitAction_triggered()
-{
- QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
- if (tm)
- tm->submitAll();
-}
-
-void Browser::on_revertAction_triggered()
+void Browser::onSubmitButton()
{
- QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
- if (tm)
- tm->revertAll();
+ exec();
+ m_ui->sqlEdit->setFocus();
}
-void Browser::on_selectAction_triggered()
+void Browser::onClearButton()
{
- QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
- if (tm)
- tm->select();
+ m_ui->sqlEdit->clear();
+ m_ui->sqlEdit->setFocus();
}
-
diff --git a/examples/sql/sqlbrowser/browser.h b/examples/sql/sqlbrowser/browser.h
index 3f98f487c3..c61048c84a 100644
--- a/examples/sql/sqlbrowser/browser.h
+++ b/examples/sql/sqlbrowser/browser.h
@@ -1,124 +1,63 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef BROWSER_H
#define BROWSER_H
#include <QWidget>
#include <QSqlTableModel>
-#include "ui_browserwidget.h"
-class ConnectionWidget;
-QT_FORWARD_DECLARE_CLASS(QTableView)
-QT_FORWARD_DECLARE_CLASS(QPushButton)
-QT_FORWARD_DECLARE_CLASS(QTextEdit)
QT_FORWARD_DECLARE_CLASS(QSqlError)
-class Browser: public QWidget, private Ui::Browser
+QT_BEGIN_NAMESPACE
+namespace Ui
+{
+class Browser;
+}
+QT_END_NAMESPACE
+
+class Browser : public QWidget
{
Q_OBJECT
public:
Browser(QWidget *parent = nullptr);
- virtual ~Browser();
+ ~Browser();
QSqlError addConnection(const QString &driver, const QString &dbName, const QString &host,
- const QString &user, const QString &passwd, int port = -1);
+ const QString &user, const QString &passwd, int port);
+public slots:
+ void openNewConnectionDialog();
+ void about();
+
+protected:
void insertRow();
void deleteRow();
void updateActions();
-public slots:
+protected slots:
void exec();
void showTable(const QString &table);
void showMetaData(const QString &table);
- void addConnection();
- void currentChanged() { updateActions(); }
- void about();
- void on_insertRowAction_triggered()
- { insertRow(); }
- void on_deleteRowAction_triggered()
- { deleteRow(); }
- void on_fieldStrategyAction_triggered();
- void on_rowStrategyAction_triggered();
- void on_manualStrategyAction_triggered();
- void on_submitAction_triggered();
- void on_revertAction_triggered();
- void on_selectAction_triggered();
- void on_connectionWidget_tableActivated(const QString &table)
- { showTable(table); }
- void on_connectionWidget_metaDataRequested(const QString &table)
- { showMetaData(table); }
- void on_submitButton_clicked()
- {
- exec();
- sqlEdit->setFocus();
- }
- void on_clearButton_clicked()
- {
- sqlEdit->clear();
- sqlEdit->setFocus();
- }
+ void onFieldStrategyAction();
+ void onRowStrategyAction();
+ void onManualStrategyAction();
+ void onSubmitButton();
+ void onClearButton();
signals:
void statusMessage(const QString &message);
+
+private:
+ Ui::Browser *m_ui;
};
-class CustomModel: public QSqlTableModel
+class CustomModel : public QSqlTableModel
{
Q_OBJECT
public:
- explicit CustomModel(QObject *parent = nullptr, QSqlDatabase db = QSqlDatabase())
- : QSqlTableModel(parent, db) {}
-
+ using QSqlTableModel::QSqlTableModel;
QVariant data(const QModelIndex &idx, int role) const override
{
if (role == Qt::BackgroundRole && isDirty(idx))
diff --git a/examples/sql/sqlbrowser/connectionwidget.cpp b/examples/sql/sqlbrowser/connectionwidget.cpp
index 658cfb77dc..da6796d7e5 100644
--- a/examples/sql/sqlbrowser/connectionwidget.cpp
+++ b/examples/sql/sqlbrowser/connectionwidget.cpp
@@ -1,66 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "connectionwidget.h"
-#include <QtWidgets>
-#include <QtSql>
+#include <QAction>
+#include <QHeaderView>
+#include <QSqlDatabase>
+#include <QTreeWidget>
+#include <QVBoxLayout>
ConnectionWidget::ConnectionWidget(QWidget *parent)
: QWidget(parent)
+ , tree(new QTreeWidget(this))
{
QVBoxLayout *layout = new QVBoxLayout(this);
- tree = new QTreeWidget(this);
- tree->setObjectName(QLatin1String("tree"));
- tree->setHeaderLabels(QStringList(tr("database")));
- tree->header()->setSectionResizeMode(QHeaderView::Stretch);
+ tree->setHeaderLabels(QStringList(tr("Database")));
+ tree->header()->setStretchLastSection(true);
QAction *refreshAction = new QAction(tr("Refresh"), tree);
metaDataAction = new QAction(tr("Show Schema"), tree);
connect(refreshAction, &QAction::triggered, this, &ConnectionWidget::refresh);
@@ -71,34 +26,37 @@ ConnectionWidget::ConnectionWidget(QWidget *parent)
layout->addWidget(tree);
- QMetaObject::connectSlotsByName(this);
+ connect(tree, &QTreeWidget::itemActivated,
+ this, &ConnectionWidget::onItemActivated);
+ connect(tree, &QTreeWidget::currentItemChanged,
+ this, &ConnectionWidget::onCurrentItemChanged);
}
ConnectionWidget::~ConnectionWidget()
{
}
-static QString qDBCaption(const QSqlDatabase &db)
-{
- QString nm = db.driverName();
- nm.append(QLatin1Char(':'));
- if (!db.userName().isEmpty())
- nm.append(db.userName()).append(QLatin1Char('@'));
- nm.append(db.databaseName());
- return nm;
-}
void ConnectionWidget::refresh()
{
+ const auto qDBCaption = [](const QSqlDatabase &db)
+ {
+ QString nm = db.driverName() + QLatin1Char(':');
+ if (!db.userName().isEmpty())
+ nm += db.userName() + QLatin1Char('@');
+ nm += db.databaseName();
+ return nm;
+ };
+
tree->clear();
- QStringList connectionNames = QSqlDatabase::connectionNames();
+ const QStringList connectionNames = QSqlDatabase::connectionNames();
bool gotActiveDb = false;
- for (int i = 0; i < connectionNames.count(); ++i) {
+ for (const auto &connectionName : connectionNames) {
QTreeWidgetItem *root = new QTreeWidgetItem(tree);
- QSqlDatabase db = QSqlDatabase::database(connectionNames.at(i), false);
+ QSqlDatabase db = QSqlDatabase::database(connectionName, false);
root->setText(0, qDBCaption(db));
- if (connectionNames.at(i) == activeDb) {
+ if (connectionName == activeDb) {
gotActiveDb = true;
setActive(root);
}
@@ -123,15 +81,15 @@ QSqlDatabase ConnectionWidget::currentDatabase() const
return QSqlDatabase::database(activeDb);
}
-static void qSetBold(QTreeWidgetItem *item, bool bold)
-{
- QFont font = item->font(0);
- font.setBold(bold);
- item->setFont(0, font);
-}
-
void ConnectionWidget::setActive(QTreeWidgetItem *item)
{
+ const auto qSetBold = [](QTreeWidgetItem *item, bool bold)
+ {
+ QFont font = item->font(0);
+ font.setBold(bold);
+ item->setFont(0, font);
+ };
+
for (int i = 0; i < tree->topLevelItemCount(); ++i) {
if (tree->topLevelItem(i)->font(0).bold())
qSetBold(tree->topLevelItem(i), false);
@@ -144,7 +102,7 @@ void ConnectionWidget::setActive(QTreeWidgetItem *item)
activeDb = QSqlDatabase::connectionNames().value(tree->indexOfTopLevelItem(item));
}
-void ConnectionWidget::on_tree_itemActivated(QTreeWidgetItem *item, int /* column */)
+void ConnectionWidget::onItemActivated(QTreeWidgetItem *item)
{
if (!item)
return;
@@ -166,7 +124,7 @@ void ConnectionWidget::showMetaData()
emit metaDataRequested(cItem->text(0));
}
-void ConnectionWidget::on_tree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *)
+void ConnectionWidget::onCurrentItemChanged(QTreeWidgetItem *current)
{
metaDataAction->setEnabled(current && current->parent());
}
diff --git a/examples/sql/sqlbrowser/connectionwidget.h b/examples/sql/sqlbrowser/connectionwidget.h
index a805765f69..a00296f3c5 100644
--- a/examples/sql/sqlbrowser/connectionwidget.h
+++ b/examples/sql/sqlbrowser/connectionwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CONNECTIONWIDGET_H
#define CONNECTIONWIDGET_H
@@ -56,14 +9,13 @@
QT_FORWARD_DECLARE_CLASS(QTreeWidget)
QT_FORWARD_DECLARE_CLASS(QTreeWidgetItem)
QT_FORWARD_DECLARE_CLASS(QSqlDatabase)
-QT_FORWARD_DECLARE_CLASS(QMenu)
-class ConnectionWidget: public QWidget
+class ConnectionWidget : public QWidget
{
Q_OBJECT
public:
ConnectionWidget(QWidget *parent = nullptr);
- virtual ~ConnectionWidget();
+ ~ConnectionWidget();
QSqlDatabase currentDatabase() const;
@@ -74,8 +26,8 @@ signals:
public slots:
void refresh();
void showMetaData();
- void on_tree_itemActivated(QTreeWidgetItem *item, int column);
- void on_tree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
+ void onItemActivated(QTreeWidgetItem *item);
+ void onCurrentItemChanged(QTreeWidgetItem *current);
private:
void setActive(QTreeWidgetItem *);
diff --git a/examples/sql/sqlbrowser/main.cpp b/examples/sql/sqlbrowser/main.cpp
index ea4649b68d..b3fa8af142 100644
--- a/examples/sql/sqlbrowser/main.cpp
+++ b/examples/sql/sqlbrowser/main.cpp
@@ -1,65 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "browser.h"
-#include <QtCore>
-#include <QtWidgets>
-#include <QtSql>
+#include <QApplication>
+#include <QMainWindow>
+#include <QMenu>
+#include <QMenuBar>
+#include <QSqlError>
+#include <QStatusBar>
+#include <QUrl>
void addConnectionsFromCommandline(const QStringList &args, Browser *browser)
{
- for (int i = 1; i < args.count(); ++i) {
- QUrl url(args.at(i), QUrl::TolerantMode);
+ for (qsizetype i = 1; i < args.count(); ++i) {
+ const auto &arg = args.at(i);
+ const QUrl url(arg, QUrl::TolerantMode);
if (!url.isValid()) {
- qWarning("Invalid URL: %s", qPrintable(args.at(i)));
+ qWarning("Invalid URL: %s", qPrintable(arg));
continue;
}
QSqlError err = browser->addConnection(url.scheme(), url.path().mid(1), url.host(),
@@ -74,29 +32,32 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
QMainWindow mainWin;
- mainWin.setWindowTitle(QObject::tr("Qt SQL Browser"));
+ mainWin.setWindowTitle(QApplication::translate("MainWindow", "Qt SQL Browser"));
Browser browser(&mainWin);
mainWin.setCentralWidget(&browser);
QMenu *fileMenu = mainWin.menuBar()->addMenu(QObject::tr("&File"));
- fileMenu->addAction(QObject::tr("Add &Connection..."),
- [&]() { browser.addConnection(); });
+ fileMenu->addAction(QApplication::translate("MainWindow", "Add &Connection..."),
+ &browser, &Browser::openNewConnectionDialog);
fileMenu->addSeparator();
- fileMenu->addAction(QObject::tr("&Quit"), []() { qApp->quit(); });
+ fileMenu->addAction(QApplication::translate("MainWindow", "&Quit"),
+ qApp, &QApplication::quit);
QMenu *helpMenu = mainWin.menuBar()->addMenu(QObject::tr("&Help"));
- helpMenu->addAction(QObject::tr("About"), [&]() { browser.about(); });
- helpMenu->addAction(QObject::tr("About Qt"), []() { qApp->aboutQt(); });
+ helpMenu->addAction(QApplication::translate("MainWindow", "About"),
+ &browser, &Browser::about);
+ helpMenu->addAction(QApplication::translate("MainWindow", "About Qt"),
+ qApp, &QApplication::aboutQt);
- QObject::connect(&browser, &Browser::statusMessage, [&mainWin](const QString &text) {
- mainWin.statusBar()->showMessage(text);
- });
+ QObject::connect(&browser, &Browser::statusMessage,
+ &mainWin, [&mainWin](const QString &text) { mainWin.statusBar()->showMessage(text); });
addConnectionsFromCommandline(app.arguments(), &browser);
mainWin.show();
if (QSqlDatabase::connectionNames().isEmpty())
- QMetaObject::invokeMethod(&browser, "addConnection", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(&browser, &Browser::openNewConnectionDialog,
+ Qt::QueuedConnection);
return app.exec();
}
diff --git a/examples/sql/sqlbrowser/qsqlconnectiondialog.cpp b/examples/sql/sqlbrowser/qsqlconnectiondialog.cpp
index 482048ab98..2b85e95805 100644
--- a/examples/sql/sqlbrowser/qsqlconnectiondialog.cpp
+++ b/examples/sql/sqlbrowser/qsqlconnectiondialog.cpp
@@ -1,117 +1,87 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "qsqlconnectiondialog.h"
-#include "ui_qsqlconnectiondialog.h"
+#include <ui_qsqlconnectiondialog.h>
+#include <QCheckBox>
+#include <QMessageBox>
+#include <QPushButton>
#include <QSqlDatabase>
QSqlConnectionDialog::QSqlConnectionDialog(QWidget *parent)
: QDialog(parent)
+ , m_ui(new Ui::QSqlConnectionDialogUi)
{
- ui.setupUi(this);
+ m_ui->setupUi(this);
QStringList drivers = QSqlDatabase::drivers();
if (!drivers.contains("QSQLITE"))
- ui.dbCheckBox->setEnabled(false);
+ m_ui->dbCheckBox->setEnabled(false);
- ui.comboDriver->addItems(drivers);
+ m_ui->comboDriver->addItems(drivers);
+
+ connect(m_ui->okButton, &QPushButton::clicked,
+ this, &QSqlConnectionDialog::onOkButton);
+ connect(m_ui->cancelButton, &QPushButton::clicked,
+ this, &QSqlConnectionDialog::reject);
+ connect(m_ui->dbCheckBox, &QCheckBox::stateChanged,
+ this, &QSqlConnectionDialog::onDbCheckBox);
}
QSqlConnectionDialog::~QSqlConnectionDialog()
{
+ delete m_ui;
}
QString QSqlConnectionDialog::driverName() const
{
- return ui.comboDriver->currentText();
+ return m_ui->comboDriver->currentText();
}
QString QSqlConnectionDialog::databaseName() const
{
- return ui.editDatabase->text();
+ return m_ui->editDatabase->text();
}
QString QSqlConnectionDialog::userName() const
{
- return ui.editUsername->text();
+ return m_ui->editUsername->text();
}
QString QSqlConnectionDialog::password() const
{
- return ui.editPassword->text();
+ return m_ui->editPassword->text();
}
QString QSqlConnectionDialog::hostName() const
{
- return ui.editHostname->text();
+ return m_ui->editHostname->text();
}
int QSqlConnectionDialog::port() const
{
- return ui.portSpinBox->value();
+ return m_ui->portSpinBox->value();
}
bool QSqlConnectionDialog::useInMemoryDatabase() const
{
- return ui.dbCheckBox->isChecked();
+ return m_ui->dbCheckBox->isChecked();
}
-void QSqlConnectionDialog::on_okButton_clicked()
+void QSqlConnectionDialog::onOkButton()
{
- if (ui.comboDriver->currentText().isEmpty()) {
+ if (m_ui->comboDriver->currentText().isEmpty()) {
QMessageBox::information(this, tr("No database driver selected"),
tr("Please select a database driver"));
- ui.comboDriver->setFocus();
+ m_ui->comboDriver->setFocus();
} else {
accept();
}
}
+
+void QSqlConnectionDialog::onDbCheckBox()
+{
+ m_ui->connGroupBox->setEnabled(!m_ui->dbCheckBox->isChecked());
+}
diff --git a/examples/sql/sqlbrowser/qsqlconnectiondialog.h b/examples/sql/sqlbrowser/qsqlconnectiondialog.h
index fc998d7ee9..a6384bb5b7 100644
--- a/examples/sql/sqlbrowser/qsqlconnectiondialog.h
+++ b/examples/sql/sqlbrowser/qsqlconnectiondialog.h
@@ -1,62 +1,19 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef QSQLCONNECTIONDIALOG_H
#define QSQLCONNECTIONDIALOG_H
#include <QDialog>
-#include <QMessageBox>
-#include "ui_qsqlconnectiondialog.h"
+QT_BEGIN_NAMESPACE
+namespace Ui
+{
+class QSqlConnectionDialogUi;
+}
+QT_END_NAMESPACE
-class QSqlConnectionDialog: public QDialog
+class QSqlConnectionDialog : public QDialog
{
Q_OBJECT
public:
@@ -72,12 +29,11 @@ public:
bool useInMemoryDatabase() const;
private slots:
- void on_okButton_clicked();
- void on_cancelButton_clicked() { reject(); }
- void on_dbCheckBox_clicked() { ui.connGroupBox->setEnabled(!ui.dbCheckBox->isChecked()); }
+ void onOkButton();
+ void onDbCheckBox();
private:
- Ui::QSqlConnectionDialogUi ui;
+ Ui::QSqlConnectionDialogUi *m_ui;
};
#endif
diff --git a/examples/sql/sqlwidgetmapper/CMakeLists.txt b/examples/sql/sqlwidgetmapper/CMakeLists.txt
index 24b563a2a3..91ce3cf339 100644
--- a/examples/sql/sqlwidgetmapper/CMakeLists.txt
+++ b/examples/sql/sqlwidgetmapper/CMakeLists.txt
@@ -1,42 +1,39 @@
-# Generated from sqlwidgetmapper.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(sqlwidgetmapper LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Sql Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sql/sqlwidgetmapper")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Sql)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(sqlwidgetmapper
main.cpp
window.cpp window.h
)
+
set_target_properties(sqlwidgetmapper PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(sqlwidgetmapper PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Sql
- Qt::Widgets
+
+target_link_libraries(sqlwidgetmapper PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Sql
+ Qt6::Widgets
)
install(TARGETS sqlwidgetmapper
- 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 sqlwidgetmapper
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/sql/sqlwidgetmapper/main.cpp b/examples/sql/sqlwidgetmapper/main.cpp
index c53f3e2396..9c9f589816 100644
--- a/examples/sql/sqlwidgetmapper/main.cpp
+++ b/examples/sql/sqlwidgetmapper/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/sql/sqlwidgetmapper/window.cpp b/examples/sql/sqlwidgetmapper/window.cpp
index b6946e2386..cd44174f84 100644
--- a/examples/sql/sqlwidgetmapper/window.cpp
+++ b/examples/sql/sqlwidgetmapper/window.cpp
@@ -1,58 +1,20 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-#include <QtSql>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
+#include <QComboBox>
+#include <QDataWidgetMapper>
+#include <QGridLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QSqlQuery>
+#include <QSqlRelationalDelegate>
+#include <QSqlTableModel>
+#include <QTextEdit>
+
//! [Set up widgets]
Window::Window(QWidget *parent)
: QWidget(parent)
diff --git a/examples/sql/sqlwidgetmapper/window.h b/examples/sql/sqlwidgetmapper/window.h
index b336997360..9af9628b90 100644
--- a/examples/sql/sqlwidgetmapper/window.h
+++ b/examples/sql/sqlwidgetmapper/window.h
@@ -1,70 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 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 QComboBox;
-class QDataWidgetMapper;
-class QItemSelectionModel;
-class QLabel;
-class QLineEdit;
-class QPushButton;
-class QSqlRelationalTableModel;
-class QStandardItemModel;
-class QStringListModel;
-class QTextEdit;
-QT_END_NAMESPACE
+QT_FORWARD_DECLARE_CLASS(QComboBox)
+QT_FORWARD_DECLARE_CLASS(QDataWidgetMapper)
+QT_FORWARD_DECLARE_CLASS(QItemSelectionModel)
+QT_FORWARD_DECLARE_CLASS(QLabel)
+QT_FORWARD_DECLARE_CLASS(QLineEdit)
+QT_FORWARD_DECLARE_CLASS(QPushButton)
+QT_FORWARD_DECLARE_CLASS(QSqlRelationalTableModel)
+QT_FORWARD_DECLARE_CLASS(QStandardItemModel)
+QT_FORWARD_DECLARE_CLASS(QStringListModel)
+QT_FORWARD_DECLARE_CLASS(QTextEdit)
//! [Window definition]
class Window : public QWidget
diff --git a/examples/sql/tablemodel/CMakeLists.txt b/examples/sql/tablemodel/CMakeLists.txt
index 7dd042adb7..28919bb69a 100644
--- a/examples/sql/tablemodel/CMakeLists.txt
+++ b/examples/sql/tablemodel/CMakeLists.txt
@@ -1,42 +1,39 @@
-# Generated from tablemodel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(tablemodel LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Sql Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sql/tablemodel")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Sql)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(tablemodel
../connection.h
tablemodel.cpp
)
+
set_target_properties(tablemodel PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(tablemodel PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Sql
- Qt::Widgets
+
+target_link_libraries(tablemodel PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Sql
+ Qt6::Widgets
)
install(TARGETS tablemodel
- 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 tablemodel
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/sql/tablemodel/tablemodel.cpp b/examples/sql/tablemodel/tablemodel.cpp
index a6e0341c23..04c114dc63 100644
--- a/examples/sql/tablemodel/tablemodel.cpp
+++ b/examples/sql/tablemodel/tablemodel.cpp
@@ -1,60 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "../connection.h"
#include <QApplication>
#include <QSqlTableModel>
#include <QTableView>
-#include <stdlib.h>
-
void initializeModel(QSqlTableModel *model)
{
model->setTable("person");
diff --git a/examples/vulkan/CMakeLists.txt b/examples/vulkan/CMakeLists.txt
index b00a40447a..98b0a31b5e 100644
--- a/examples/vulkan/CMakeLists.txt
+++ b/examples/vulkan/CMakeLists.txt
@@ -1,11 +1,10 @@
-# Generated from vulkan.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(hellovulkanwindow)
-add_subdirectory(hellovulkantriangle)
-add_subdirectory(hellovulkantexture)
-if(TARGET Qt::Widgets)
- add_subdirectory(hellovulkanwidget)
+qt_internal_add_example(hellovulkantriangle)
+if(TARGET Qt6::Widgets)
+ qt_internal_add_example(hellovulkanwidget)
endif()
-if(TARGET Qt::Concurrent AND TARGET Qt::Widgets)
- add_subdirectory(hellovulkancubes)
+if(TARGET Qt6::Concurrent AND TARGET Qt6::Widgets)
+ qt_internal_add_example(hellovulkancubes)
endif()
diff --git a/examples/vulkan/doc/images/hellovulkantexture.png b/examples/vulkan/doc/images/hellovulkantexture.png
deleted file mode 100644
index 0cb47a70be..0000000000
--- a/examples/vulkan/doc/images/hellovulkantexture.png
+++ /dev/null
Binary files differ
diff --git a/examples/vulkan/doc/images/hellovulkanwindow.png b/examples/vulkan/doc/images/hellovulkanwindow.png
deleted file mode 100644
index c55029312c..0000000000
--- a/examples/vulkan/doc/images/hellovulkanwindow.png
+++ /dev/null
Binary files differ
diff --git a/examples/vulkan/doc/src/hellovulkancubes.qdoc b/examples/vulkan/doc/src/hellovulkancubes.qdoc
index f6160a5083..91149911df 100644
--- a/examples/vulkan/doc/src/hellovulkancubes.qdoc
+++ b/examples/vulkan/doc/src/hellovulkancubes.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example hellovulkancubes
@@ -31,6 +7,7 @@
\title Hello Vulkan Cubes Example
\ingroup examples-vulkan
\brief Shows the basics of using QVulkanWindow.
+ \examplecategory {Graphics}
The \e{Hello Vulkan Cubes Example} shows more advanced usage of QVulkanWindow.
diff --git a/examples/vulkan/doc/src/hellovulkantexture.qdoc b/examples/vulkan/doc/src/hellovulkantexture.qdoc
deleted file mode 100644
index 968c560236..0000000000
--- a/examples/vulkan/doc/src/hellovulkantexture.qdoc
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example hellovulkantexture
- \meta installpath vulkan
- \ingroup examples-vulkan
- \title Hello Vulkan Texture Vulkan Example
- \brief Shows the basics of rendering with textures in a QVulkanWindow.
-
- The \e{Hello Vulkan Texture Example} builds on \l hellovulkantriangle. Here
- instead of drawing a single triangle, a triangle strip is drawn in order to
- get a quad on the screen. This is then textured using a QImage loaded from
- a .png image file.
-
- \image hellovulkantexture.png
- \include examples-run.qdocinc
-*/
diff --git a/examples/vulkan/doc/src/hellovulkantriangle.qdoc b/examples/vulkan/doc/src/hellovulkantriangle.qdoc
index f030d61578..bafa026ccd 100644
--- a/examples/vulkan/doc/src/hellovulkantriangle.qdoc
+++ b/examples/vulkan/doc/src/hellovulkantriangle.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example hellovulkantriangle
@@ -31,13 +7,56 @@
\ingroup examples-vulkan
\title Hello Vulkan Triangle Example
\brief Shows the basics of rendering with QVulkanWindow and the Vulkan API.
+ \examplecategory {Graphics}
- The \e{Hello Vulkan Triangle Example} builds on \l hellovulkanwindow. This
- time a full graphics pipeline is created, including a vertex and fragment
- shader. This pipeline is then used to render a triangle.
+ The \e{Hello Vulkan Triangle Example} creates a full graphics pipeline,
+ including a vertex and fragment shader, to render a triangle.
\image hellovulkantriangle.png
+ \section1 Startup
+
+ Each Qt application using Vulkan will have to have a \c{Vulkan instance}
+ which encapsulates application-level state and initializes a Vulkan library.
+
+ A QVulkanWindow must always be associated with a QVulkanInstance and hence
+ the example performs instance creation before the window. The
+ QVulkanInstance object must also outlive the window.
+
+ \snippet hellovulkantriangle/main.cpp 0
+
+ The example enables validation layers, when supported. When the requested
+ layers are not present, the request will be ignored. Additional layers and
+ extensions can be enabled in a similar manner.
+
+ \snippet hellovulkantriangle/main.cpp 1
+
+ Once the instance is ready, it is time to create a window. Note that \c w
+ lives on the stack and is declared after \c inst.
+
+ \section1 The QVulkanWindow Subclass
+
+ To add custom functionality to a QVulkanWindow, subclassing is used. This
+ follows the existing patterns from QOpenGLWindow and QOpenGLWidget.
+ However, QVulkanWindow utilizes a separate QVulkanWindowRenderer object.
+
+ The QVulkanWindow subclass reimplements the factory function
+ QVulkanWindow::createRenderer(). This simply returns a new instance of the
+ QVulkanWindowRenderer subclass. In order to be able to access various
+ Vulkan resources via the window object, a pointer to the window is passed
+ and stored via the constructor.
+
+ \snippet hellovulkantriangle/main.cpp 2
+
+ \section1 The Actual Rendering
+
+ QVulkanWindow subclasses queue their draw calls in their reimplementation
+ of QVulkanWindowRenderer::startNextFrame(). Once done, they are required to
+ call back QVulkanWindow::frameReady(). The example has no asynchronous
+ command generation, so the frameReady() call is made directly from
+ startNextFrame(). To get continuous updates, the example simply invokes
+ QWindow::requestUpdate() in order to schedule a repaint.
+
The example also demonstrates multisample antialiasing. Based on the
supported sample counts reported by QVulkanWindow::supportedSampleCounts()
the example chooses between 8x, 4x, or no multisampling. Once configured
diff --git a/examples/vulkan/doc/src/hellovulkanwidget.qdoc b/examples/vulkan/doc/src/hellovulkanwidget.qdoc
index b1fb52ee85..2a71084fc4 100644
--- a/examples/vulkan/doc/src/hellovulkanwidget.qdoc
+++ b/examples/vulkan/doc/src/hellovulkanwidget.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example hellovulkanwidget
@@ -31,6 +7,7 @@
\ingroup examples-vulkan
\title Hello Vulkan Widget Example
\brief Shows the usage of QVulkanWindow in QWidget applications.
+ \examplecategory {Graphics}
The \e{Hello Vulkan Widget Example} is a variant of \l hellovulkantriangle
that embeds the QVulkanWindow into a QWidget-based user interface using
diff --git a/examples/vulkan/doc/src/hellovulkanwindow.qdoc b/examples/vulkan/doc/src/hellovulkanwindow.qdoc
deleted file mode 100644
index e1e95a0952..0000000000
--- a/examples/vulkan/doc/src/hellovulkanwindow.qdoc
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example hellovulkanwindow
- \meta installpath vulkan
- \title Hello Vulkan Window Example
- \ingroup examples-vulkan
- \brief Shows the basics of using QVulkanWindow.
-
- The \e{Hello Vulkan Window Example} shows the basics of using QVulkanWindow
- in order to display rendering with the Vulkan graphics API on systems that
- support this.
-
- \image hellovulkanwindow.png
-
- In this example there will be no actual rendering: it simply begins and
- ends a render pass, which results in clearing the buffers to a fixed value.
- The color buffer clear value changes on every frame.
-
- \section1 Startup
-
- Each Qt application using Vulkan will have to have a \c{Vulkan instance}
- which encapsulates application-level state and initializes a Vulkan library.
-
- A QVulkanWindow must always be associated with a QVulkanInstance and hence
- the example performs instance creation before the window. The
- QVulkanInstance object must also outlive the window.
-
- \snippet hellovulkanwindow/main.cpp 0
-
- The example enables validation layers, when supported. When the requested
- layers are not present, the request will be ignored. Additional layers and
- extensions can be enabled in a similar manner.
-
- \snippet hellovulkanwindow/main.cpp 1
-
- Once the instance is ready, it is time to create a window. Note that \c w
- lives on the stack and is declared after \c inst.
-
- \section1 The QVulkanWindow Subclass
-
- To add custom functionality to a QVulkanWindow, subclassing is used. This
- follows the existing patterns from QOpenGLWindow and QOpenGLWidget.
- However, QVulkanWindow utilizes a separate QVulkanWindowRenderer object.
- This resembles QQuickFramebufferObject, and allows better separation of the
- functions that are supposed to be reimplemented.
-
- \snippet hellovulkanwindow/hellovulkanwindow.h 0
-
- The QVulkanWindow subclass reimplements the factory function
- QVulkanWindow::createRenderer(). This simply returns a new instance of the
- QVulkanWindowRenderer subclass. In order to be able to access various
- Vulkan resources via the window object, a pointer to the window is passed
- and stored via the constructor.
-
- \snippet hellovulkanwindow/hellovulkanwindow.cpp 0
-
- Graphics resource creation and destruction is typically done in one of the
- init - resource functions.
-
- \snippet hellovulkanwindow/hellovulkanwindow.cpp 1
-
- \section1 The Actual Rendering
-
- QVulkanWindow subclasses queue their draw calls in their reimplementation
- of QVulkanWindowRenderer::startNextFrame(). Once done, they are required to
- call back QVulkanWindow::frameReady(). The example has no asynchronous
- command generation, so the frameReady() call is made directly from
- startNextFrame().
-
- \snippet hellovulkanwindow/hellovulkanwindow.cpp 2
-
- To get continuous updates, the example simply invokes
- QWindow::requestUpdate() in order to schedule a repaint.
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/vulkan/hellovulkancubes/CMakeLists.txt b/examples/vulkan/hellovulkancubes/CMakeLists.txt
index 4248375ba0..5debb4efaf 100644
--- a/examples/vulkan/hellovulkancubes/CMakeLists.txt
+++ b/examples/vulkan/hellovulkancubes/CMakeLists.txt
@@ -1,24 +1,12 @@
-# Generated from hellovulkancubes.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(hellovulkancubes LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Concurrent Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/vulkan/hellovulkancubes")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS Concurrent)
+qt_standard_project_setup()
qt_add_executable(hellovulkancubes
camera.cpp camera.h
@@ -29,25 +17,28 @@ qt_add_executable(hellovulkancubes
shader.cpp shader.h
vulkanwindow.cpp vulkanwindow.h
)
+
set_target_properties(hellovulkancubes PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(hellovulkancubes PUBLIC
- Qt::Concurrent
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
+target_link_libraries(hellovulkancubes PRIVATE
+ Qt6::Concurrent
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+)
# Resources:
set_source_files_properties("../shared/block.buf"
PROPERTIES QT_RESOURCE_ALIAS "block.buf"
)
+
set_source_files_properties("../shared/qt_logo.buf"
PROPERTIES QT_RESOURCE_ALIAS "qt_logo.buf"
)
+
set(hellovulkancubes_resource_files
"../shared/block.buf"
"../shared/qt_logo.buf"
@@ -65,7 +56,14 @@ qt6_add_resources(hellovulkancubes "hellovulkancubes"
)
install(TARGETS hellovulkancubes
- 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 hellovulkancubes
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/vulkan/hellovulkancubes/camera.cpp b/examples/vulkan/hellovulkancubes/camera.cpp
index 64dee03154..3862f74391 100644
--- a/examples/vulkan/hellovulkancubes/camera.cpp
+++ b/examples/vulkan/hellovulkancubes/camera.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "camera.h"
diff --git a/examples/vulkan/hellovulkancubes/camera.h b/examples/vulkan/hellovulkancubes/camera.h
index c5c579f066..cffb8ada42 100644
--- a/examples/vulkan/hellovulkancubes/camera.h
+++ b/examples/vulkan/hellovulkancubes/camera.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CAMERA_H
#define CAMERA_H
diff --git a/examples/vulkan/hellovulkancubes/main.cpp b/examples/vulkan/hellovulkancubes/main.cpp
index 4ec4d48645..61ffa1753f 100644
--- a/examples/vulkan/hellovulkancubes/main.cpp
+++ b/examples/vulkan/hellovulkancubes/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QLoggingCategory>
@@ -63,19 +16,7 @@ int main(int argc, char **argv)
if (dbg) {
QLoggingCategory::setFilterRules(QStringLiteral("qt.vulkan=true"));
-
-#ifndef Q_OS_ANDROID
- inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation");
-#else
- inst.setLayers(QByteArrayList()
- << "VK_LAYER_GOOGLE_threading"
- << "VK_LAYER_LUNARG_parameter_validation"
- << "VK_LAYER_LUNARG_object_tracker"
- << "VK_LAYER_LUNARG_core_validation"
- << "VK_LAYER_LUNARG_image"
- << "VK_LAYER_LUNARG_swapchain"
- << "VK_LAYER_GOOGLE_unique_objects");
-#endif
+ inst.setLayers({ "VK_LAYER_KHRONOS_validation" });
}
if (!inst.create())
diff --git a/examples/vulkan/hellovulkancubes/mainwindow.cpp b/examples/vulkan/hellovulkancubes/mainwindow.cpp
index 2be7d237af..198a168bce 100644
--- a/examples/vulkan/hellovulkancubes/mainwindow.cpp
+++ b/examples/vulkan/hellovulkancubes/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "vulkanwindow.h"
@@ -89,7 +42,7 @@ MainWindow::MainWindow(VulkanWindow *vulkanWindow)
pauseButton->setFocusPolicy(Qt::NoFocus);
connect(quitButton, &QPushButton::clicked, qApp, &QCoreApplication::quit);
- connect(newButton, &QPushButton::clicked, vulkanWindow, [=] {
+ connect(newButton, &QPushButton::clicked, vulkanWindow, [this, vulkanWindow] {
vulkanWindow->addNew();
m_count = vulkanWindow->instanceCount();
counterLcd->display(m_count);
diff --git a/examples/vulkan/hellovulkancubes/mainwindow.h b/examples/vulkan/hellovulkancubes/mainwindow.h
index 4109709959..8ecb0002e7 100644
--- a/examples/vulkan/hellovulkancubes/mainwindow.h
+++ b/examples/vulkan/hellovulkancubes/mainwindow.h
@@ -1,64 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
-QT_BEGIN_NAMESPACE
-class QLCDNumber;
-class QLabel;
-class QPushButton;
-class QCheckBox;
-QT_END_NAMESPACE
+QT_FORWARD_DECLARE_CLASS(QLCDNumber)
+QT_FORWARD_DECLARE_CLASS(QLabel)
+QT_FORWARD_DECLARE_CLASS(QPushButton)
+QT_FORWARD_DECLARE_CLASS(QCheckBox)
class VulkanWindow;
diff --git a/examples/vulkan/hellovulkancubes/mesh.cpp b/examples/vulkan/hellovulkancubes/mesh.cpp
index fcc45bfd57..ff7672d405 100644
--- a/examples/vulkan/hellovulkancubes/mesh.cpp
+++ b/examples/vulkan/hellovulkancubes/mesh.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mesh.h"
#include <QtConcurrentRun>
diff --git a/examples/vulkan/hellovulkancubes/mesh.h b/examples/vulkan/hellovulkancubes/mesh.h
index cb6ee9c830..ed99e213b5 100644
--- a/examples/vulkan/hellovulkancubes/mesh.h
+++ b/examples/vulkan/hellovulkancubes/mesh.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MESH_H
#define MESH_H
diff --git a/examples/vulkan/hellovulkancubes/renderer.cpp b/examples/vulkan/hellovulkancubes/renderer.cpp
index faf86bcbfc..037d97014c 100644
--- a/examples/vulkan/hellovulkancubes/renderer.cpp
+++ b/examples/vulkan/hellovulkancubes/renderer.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "renderer.h"
#include "qrandom.h"
@@ -85,7 +38,7 @@ Renderer::Renderer(VulkanWindow *w, int initialCount)
m_blockMesh.load(QStringLiteral(":/block.buf"));
m_logoMesh.load(QStringLiteral(":/qt_logo.buf"));
- QObject::connect(&m_frameWatcher, &QFutureWatcherBase::finished, [this] {
+ QObject::connect(&m_frameWatcher, &QFutureWatcherBase::finished, m_window, [this] {
if (m_framePending) {
m_framePending = false;
m_window->frameReady();
diff --git a/examples/vulkan/hellovulkancubes/renderer.h b/examples/vulkan/hellovulkancubes/renderer.h
index 60bb48377e..c1500f8c8d 100644
--- a/examples/vulkan/hellovulkancubes/renderer.h
+++ b/examples/vulkan/hellovulkancubes/renderer.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef RENDERER_H
#define RENDERER_H
diff --git a/examples/vulkan/hellovulkancubes/shader.cpp b/examples/vulkan/hellovulkancubes/shader.cpp
index e1c01c6842..64b9d521b6 100644
--- a/examples/vulkan/hellovulkancubes/shader.cpp
+++ b/examples/vulkan/hellovulkancubes/shader.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "shader.h"
#include <QtConcurrentRun>
diff --git a/examples/vulkan/hellovulkancubes/shader.h b/examples/vulkan/hellovulkancubes/shader.h
index 265868d2b0..bc12a108b9 100644
--- a/examples/vulkan/hellovulkancubes/shader.h
+++ b/examples/vulkan/hellovulkancubes/shader.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SHADER_H
#define SHADER_H
diff --git a/examples/vulkan/hellovulkancubes/vulkanwindow.cpp b/examples/vulkan/hellovulkancubes/vulkanwindow.cpp
index 3440713737..ec5dbdc6c6 100644
--- a/examples/vulkan/hellovulkancubes/vulkanwindow.cpp
+++ b/examples/vulkan/hellovulkancubes/vulkanwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "vulkanwindow.h"
#include "renderer.h"
diff --git a/examples/vulkan/hellovulkancubes/vulkanwindow.h b/examples/vulkan/hellovulkancubes/vulkanwindow.h
index d085c0bde7..e28b62d117 100644
--- a/examples/vulkan/hellovulkancubes/vulkanwindow.h
+++ b/examples/vulkan/hellovulkancubes/vulkanwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef VULKANWINDOW_H
#define VULKANWINDOW_H
diff --git a/examples/vulkan/hellovulkantexture/CMakeLists.txt b/examples/vulkan/hellovulkantexture/CMakeLists.txt
deleted file mode 100644
index d805f3cb45..0000000000
--- a/examples/vulkan/hellovulkantexture/CMakeLists.txt
+++ /dev/null
@@ -1,53 +0,0 @@
-# Generated from hellovulkantexture.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(hellovulkantexture LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/vulkan/hellovulkantexture")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-
-qt_add_executable(hellovulkantexture
- hellovulkantexture.cpp hellovulkantexture.h
- main.cpp
-)
-set_target_properties(hellovulkantexture PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(hellovulkantexture PUBLIC
- Qt::Core
- Qt::Gui
-)
-
-
-# Resources:
-set(hellovulkantexture_resource_files
- "qt256.png"
- "texture_frag.spv"
- "texture_vert.spv"
-)
-
-qt6_add_resources(hellovulkantexture "hellovulkantexture"
- PREFIX
- "/"
- FILES
- ${hellovulkantexture_resource_files}
-)
-
-install(TARGETS hellovulkantexture
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp b/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp
deleted file mode 100644
index 257191ef4e..0000000000
--- a/examples/vulkan/hellovulkantexture/hellovulkantexture.cpp
+++ /dev/null
@@ -1,839 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "hellovulkantexture.h"
-#include <QVulkanFunctions>
-#include <QCoreApplication>
-#include <QFile>
-
-// Use a triangle strip to get a quad.
-//
-// Note that the vertex data and the projection matrix assume OpenGL. With
-// Vulkan Y is negated in clip space and the near/far plane is at 0/1 instead
-// of -1/1. These will be corrected for by an extra transformation when
-// calculating the modelview-projection matrix.
-static float vertexData[] = { // Y up, front = CW
- // x, y, z, u, v
- -1, -1, 0, 0, 1,
- -1, 1, 0, 0, 0,
- 1, -1, 0, 1, 1,
- 1, 1, 0, 1, 0
-};
-
-static const int UNIFORM_DATA_SIZE = 16 * sizeof(float);
-
-static inline VkDeviceSize aligned(VkDeviceSize v, VkDeviceSize byteAlign)
-{
- return (v + byteAlign - 1) & ~(byteAlign - 1);
-}
-
-QVulkanWindowRenderer *VulkanWindow::createRenderer()
-{
- return new VulkanRenderer(this);
-}
-
-VulkanRenderer::VulkanRenderer(QVulkanWindow *w)
- : m_window(w)
-{
-}
-
-VkShaderModule VulkanRenderer::createShader(const QString &name)
-{
- QFile file(name);
- if (!file.open(QIODevice::ReadOnly)) {
- qWarning("Failed to read shader %s", qPrintable(name));
- return VK_NULL_HANDLE;
- }
- QByteArray blob = file.readAll();
- file.close();
-
- VkShaderModuleCreateInfo shaderInfo;
- memset(&shaderInfo, 0, sizeof(shaderInfo));
- shaderInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
- shaderInfo.codeSize = blob.size();
- shaderInfo.pCode = reinterpret_cast<const uint32_t *>(blob.constData());
- VkShaderModule shaderModule;
- VkResult err = m_devFuncs->vkCreateShaderModule(m_window->device(), &shaderInfo, nullptr, &shaderModule);
- if (err != VK_SUCCESS) {
- qWarning("Failed to create shader module: %d", err);
- return VK_NULL_HANDLE;
- }
-
- return shaderModule;
-}
-
-bool VulkanRenderer::createTexture(const QString &name)
-{
- QImage img(name);
- if (img.isNull()) {
- qWarning("Failed to load image %s", qPrintable(name));
- return false;
- }
-
- // Convert to byte ordered RGBA8. Use premultiplied alpha, see pColorBlendState in the pipeline.
- img = img.convertToFormat(QImage::Format_RGBA8888_Premultiplied);
-
- QVulkanFunctions *f = m_window->vulkanInstance()->functions();
- VkDevice dev = m_window->device();
-
- const bool srgb = QCoreApplication::arguments().contains(QStringLiteral("--srgb"));
- if (srgb)
- qDebug("sRGB swapchain was requested, making texture sRGB too");
-
- m_texFormat = srgb ? VK_FORMAT_R8G8B8A8_SRGB : VK_FORMAT_R8G8B8A8_UNORM;
-
- // Now we can either map and copy the image data directly, or have to go
- // through a staging buffer to copy and convert into the internal optimal
- // tiling format.
- VkFormatProperties props;
- f->vkGetPhysicalDeviceFormatProperties(m_window->physicalDevice(), m_texFormat, &props);
- const bool canSampleLinear = (props.linearTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
- const bool canSampleOptimal = (props.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
- if (!canSampleLinear && !canSampleOptimal) {
- qWarning("Neither linear nor optimal image sampling is supported for RGBA8");
- return false;
- }
-
- static bool alwaysStage = qEnvironmentVariableIntValue("QT_VK_FORCE_STAGE_TEX");
-
- if (canSampleLinear && !alwaysStage) {
- if (!createTextureImage(img.size(), &m_texImage, &m_texMem,
- VK_IMAGE_TILING_LINEAR, VK_IMAGE_USAGE_SAMPLED_BIT,
- m_window->hostVisibleMemoryIndex()))
- return false;
-
- if (!writeLinearImage(img, m_texImage, m_texMem))
- return false;
-
- m_texLayoutPending = true;
- } else {
- if (!createTextureImage(img.size(), &m_texStaging, &m_texStagingMem,
- VK_IMAGE_TILING_LINEAR, VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
- m_window->hostVisibleMemoryIndex()))
- return false;
-
- if (!createTextureImage(img.size(), &m_texImage, &m_texMem,
- VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
- m_window->deviceLocalMemoryIndex()))
- return false;
-
- if (!writeLinearImage(img, m_texStaging, m_texStagingMem))
- return false;
-
- m_texStagingPending = true;
- }
-
- VkImageViewCreateInfo viewInfo;
- memset(&viewInfo, 0, sizeof(viewInfo));
- viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
- viewInfo.image = m_texImage;
- viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
- viewInfo.format = m_texFormat;
- viewInfo.components.r = VK_COMPONENT_SWIZZLE_R;
- viewInfo.components.g = VK_COMPONENT_SWIZZLE_G;
- viewInfo.components.b = VK_COMPONENT_SWIZZLE_B;
- viewInfo.components.a = VK_COMPONENT_SWIZZLE_A;
- viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
- viewInfo.subresourceRange.levelCount = viewInfo.subresourceRange.layerCount = 1;
-
- VkResult err = m_devFuncs->vkCreateImageView(dev, &viewInfo, nullptr, &m_texView);
- if (err != VK_SUCCESS) {
- qWarning("Failed to create image view for texture: %d", err);
- return false;
- }
-
- m_texSize = img.size();
-
- return true;
-}
-
-bool VulkanRenderer::createTextureImage(const QSize &size, VkImage *image, VkDeviceMemory *mem,
- VkImageTiling tiling, VkImageUsageFlags usage, uint32_t memIndex)
-{
- VkDevice dev = m_window->device();
-
- VkImageCreateInfo imageInfo;
- memset(&imageInfo, 0, sizeof(imageInfo));
- imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
- imageInfo.imageType = VK_IMAGE_TYPE_2D;
- imageInfo.format = m_texFormat;
- imageInfo.extent.width = size.width();
- imageInfo.extent.height = size.height();
- imageInfo.extent.depth = 1;
- imageInfo.mipLevels = 1;
- imageInfo.arrayLayers = 1;
- imageInfo.samples = VK_SAMPLE_COUNT_1_BIT;
- imageInfo.tiling = tiling;
- imageInfo.usage = usage;
- imageInfo.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
-
- VkResult err = m_devFuncs->vkCreateImage(dev, &imageInfo, nullptr, image);
- if (err != VK_SUCCESS) {
- qWarning("Failed to create linear image for texture: %d", err);
- return false;
- }
-
- VkMemoryRequirements memReq;
- m_devFuncs->vkGetImageMemoryRequirements(dev, *image, &memReq);
-
- if (!(memReq.memoryTypeBits & (1 << memIndex))) {
- VkPhysicalDeviceMemoryProperties physDevMemProps;
- m_window->vulkanInstance()->functions()->vkGetPhysicalDeviceMemoryProperties(m_window->physicalDevice(), &physDevMemProps);
- for (uint32_t i = 0; i < physDevMemProps.memoryTypeCount; ++i) {
- if (!(memReq.memoryTypeBits & (1 << i)))
- continue;
- memIndex = i;
- }
- }
-
- VkMemoryAllocateInfo allocInfo = {
- VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
- nullptr,
- memReq.size,
- memIndex
- };
- qDebug("allocating %u bytes for texture image", uint32_t(memReq.size));
-
- err = m_devFuncs->vkAllocateMemory(dev, &allocInfo, nullptr, mem);
- if (err != VK_SUCCESS) {
- qWarning("Failed to allocate memory for linear image: %d", err);
- return false;
- }
-
- err = m_devFuncs->vkBindImageMemory(dev, *image, *mem, 0);
- if (err != VK_SUCCESS) {
- qWarning("Failed to bind linear image memory: %d", err);
- return false;
- }
-
- return true;
-}
-
-bool VulkanRenderer::writeLinearImage(const QImage &img, VkImage image, VkDeviceMemory memory)
-{
- VkDevice dev = m_window->device();
-
- VkImageSubresource subres = {
- VK_IMAGE_ASPECT_COLOR_BIT,
- 0, // mip level
- 0
- };
- VkSubresourceLayout layout;
- m_devFuncs->vkGetImageSubresourceLayout(dev, image, &subres, &layout);
-
- uchar *p;
- VkResult err = m_devFuncs->vkMapMemory(dev, memory, layout.offset, layout.size, 0, reinterpret_cast<void **>(&p));
- if (err != VK_SUCCESS) {
- qWarning("Failed to map memory for linear image: %d", err);
- return false;
- }
-
- for (int y = 0; y < img.height(); ++y) {
- const uchar *line = img.constScanLine(y);
- memcpy(p, line, img.width() * 4);
- p += layout.rowPitch;
- }
-
- m_devFuncs->vkUnmapMemory(dev, memory);
- return true;
-}
-
-void VulkanRenderer::ensureTexture()
-{
- if (!m_texLayoutPending && !m_texStagingPending)
- return;
-
- Q_ASSERT(m_texLayoutPending != m_texStagingPending);
- VkCommandBuffer cb = m_window->currentCommandBuffer();
-
- VkImageMemoryBarrier barrier;
- memset(&barrier, 0, sizeof(barrier));
- barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
- barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
- barrier.subresourceRange.levelCount = barrier.subresourceRange.layerCount = 1;
-
- if (m_texLayoutPending) {
- m_texLayoutPending = false;
-
- barrier.oldLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
- barrier.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
- barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
- barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
- barrier.image = m_texImage;
-
- m_devFuncs->vkCmdPipelineBarrier(cb,
- VK_PIPELINE_STAGE_HOST_BIT,
- VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
- 0, 0, nullptr, 0, nullptr,
- 1, &barrier);
- } else {
- m_texStagingPending = false;
-
- barrier.oldLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
- barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
- barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
- barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
- barrier.image = m_texStaging;
- m_devFuncs->vkCmdPipelineBarrier(cb,
- VK_PIPELINE_STAGE_HOST_BIT,
- VK_PIPELINE_STAGE_TRANSFER_BIT,
- 0, 0, nullptr, 0, nullptr,
- 1, &barrier);
-
- barrier.oldLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
- barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
- barrier.srcAccessMask = 0;
- barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
- barrier.image = m_texImage;
- m_devFuncs->vkCmdPipelineBarrier(cb,
- VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
- VK_PIPELINE_STAGE_TRANSFER_BIT,
- 0, 0, nullptr, 0, nullptr,
- 1, &barrier);
-
- VkImageCopy copyInfo;
- memset(&copyInfo, 0, sizeof(copyInfo));
- copyInfo.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
- copyInfo.srcSubresource.layerCount = 1;
- copyInfo.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
- copyInfo.dstSubresource.layerCount = 1;
- copyInfo.extent.width = m_texSize.width();
- copyInfo.extent.height = m_texSize.height();
- copyInfo.extent.depth = 1;
- m_devFuncs->vkCmdCopyImage(cb, m_texStaging, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
- m_texImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &copyInfo);
-
- barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
- barrier.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
- barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
- barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
- barrier.image = m_texImage;
- m_devFuncs->vkCmdPipelineBarrier(cb,
- VK_PIPELINE_STAGE_TRANSFER_BIT,
- VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
- 0, 0, nullptr, 0, nullptr,
- 1, &barrier);
- }
-}
-
-void VulkanRenderer::initResources()
-{
- qDebug("initResources");
-
- VkDevice dev = m_window->device();
- m_devFuncs = m_window->vulkanInstance()->deviceFunctions(dev);
-
- // The setup is similar to hellovulkantriangle. The difference is the
- // presence of a second vertex attribute (texcoord), a sampler, and that we
- // need blending.
-
- const int concurrentFrameCount = m_window->concurrentFrameCount();
- const VkPhysicalDeviceLimits *pdevLimits = &m_window->physicalDeviceProperties()->limits;
- const VkDeviceSize uniAlign = pdevLimits->minUniformBufferOffsetAlignment;
- qDebug("uniform buffer offset alignment is %u", (uint) uniAlign);
- VkBufferCreateInfo bufInfo;
- memset(&bufInfo, 0, sizeof(bufInfo));
- bufInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
- // Our internal layout is vertex, uniform, uniform, ... with each uniform buffer start offset aligned to uniAlign.
- const VkDeviceSize vertexAllocSize = aligned(sizeof(vertexData), uniAlign);
- const VkDeviceSize uniformAllocSize = aligned(UNIFORM_DATA_SIZE, uniAlign);
- bufInfo.size = vertexAllocSize + concurrentFrameCount * uniformAllocSize;
- bufInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
-
- VkResult err = m_devFuncs->vkCreateBuffer(dev, &bufInfo, nullptr, &m_buf);
- if (err != VK_SUCCESS)
- qFatal("Failed to create buffer: %d", err);
-
- VkMemoryRequirements memReq;
- m_devFuncs->vkGetBufferMemoryRequirements(dev, m_buf, &memReq);
-
- VkMemoryAllocateInfo memAllocInfo = {
- VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
- nullptr,
- memReq.size,
- m_window->hostVisibleMemoryIndex()
- };
-
- err = m_devFuncs->vkAllocateMemory(dev, &memAllocInfo, nullptr, &m_bufMem);
- if (err != VK_SUCCESS)
- qFatal("Failed to allocate memory: %d", err);
-
- err = m_devFuncs->vkBindBufferMemory(dev, m_buf, m_bufMem, 0);
- if (err != VK_SUCCESS)
- qFatal("Failed to bind buffer memory: %d", err);
-
- quint8 *p;
- err = m_devFuncs->vkMapMemory(dev, m_bufMem, 0, memReq.size, 0, reinterpret_cast<void **>(&p));
- if (err != VK_SUCCESS)
- qFatal("Failed to map memory: %d", err);
- memcpy(p, vertexData, sizeof(vertexData));
- QMatrix4x4 ident;
- memset(m_uniformBufInfo, 0, sizeof(m_uniformBufInfo));
- for (int i = 0; i < concurrentFrameCount; ++i) {
- const VkDeviceSize offset = vertexAllocSize + i * uniformAllocSize;
- memcpy(p + offset, ident.constData(), 16 * sizeof(float));
- m_uniformBufInfo[i].buffer = m_buf;
- m_uniformBufInfo[i].offset = offset;
- m_uniformBufInfo[i].range = uniformAllocSize;
- }
- m_devFuncs->vkUnmapMemory(dev, m_bufMem);
-
- VkVertexInputBindingDescription vertexBindingDesc = {
- 0, // binding
- 5 * sizeof(float),
- VK_VERTEX_INPUT_RATE_VERTEX
- };
- VkVertexInputAttributeDescription vertexAttrDesc[] = {
- { // position
- 0, // location
- 0, // binding
- VK_FORMAT_R32G32B32_SFLOAT,
- 0
- },
- { // texcoord
- 1,
- 0,
- VK_FORMAT_R32G32_SFLOAT,
- 3 * sizeof(float)
- }
- };
-
- VkPipelineVertexInputStateCreateInfo vertexInputInfo;
- vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
- vertexInputInfo.pNext = nullptr;
- vertexInputInfo.flags = 0;
- vertexInputInfo.vertexBindingDescriptionCount = 1;
- vertexInputInfo.pVertexBindingDescriptions = &vertexBindingDesc;
- vertexInputInfo.vertexAttributeDescriptionCount = 2;
- vertexInputInfo.pVertexAttributeDescriptions = vertexAttrDesc;
-
- // Sampler.
- VkSamplerCreateInfo samplerInfo;
- memset(&samplerInfo, 0, sizeof(samplerInfo));
- samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
- samplerInfo.magFilter = VK_FILTER_NEAREST;
- samplerInfo.minFilter = VK_FILTER_NEAREST;
- samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
- samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
- samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
- samplerInfo.maxAnisotropy = 1.0f;
- err = m_devFuncs->vkCreateSampler(dev, &samplerInfo, nullptr, &m_sampler);
- if (err != VK_SUCCESS)
- qFatal("Failed to create sampler: %d", err);
-
- // Texture.
- if (!createTexture(QStringLiteral(":/qt256.png")))
- qFatal("Failed to create texture");
-
- // Set up descriptor set and its layout.
- VkDescriptorPoolSize descPoolSizes[2] = {
- { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, uint32_t(concurrentFrameCount) },
- { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, uint32_t(concurrentFrameCount) }
- };
- VkDescriptorPoolCreateInfo descPoolInfo;
- memset(&descPoolInfo, 0, sizeof(descPoolInfo));
- descPoolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
- descPoolInfo.maxSets = concurrentFrameCount;
- descPoolInfo.poolSizeCount = 2;
- descPoolInfo.pPoolSizes = descPoolSizes;
- err = m_devFuncs->vkCreateDescriptorPool(dev, &descPoolInfo, nullptr, &m_descPool);
- if (err != VK_SUCCESS)
- qFatal("Failed to create descriptor pool: %d", err);
-
- VkDescriptorSetLayoutBinding layoutBinding[2] =
- {
- {
- 0, // binding
- VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
- 1, // descriptorCount
- VK_SHADER_STAGE_VERTEX_BIT,
- nullptr
- },
- {
- 1, // binding
- VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
- 1, // descriptorCount
- VK_SHADER_STAGE_FRAGMENT_BIT,
- nullptr
- }
- };
- VkDescriptorSetLayoutCreateInfo descLayoutInfo = {
- VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
- nullptr,
- 0,
- 2, // bindingCount
- layoutBinding
- };
- err = m_devFuncs->vkCreateDescriptorSetLayout(dev, &descLayoutInfo, nullptr, &m_descSetLayout);
- if (err != VK_SUCCESS)
- qFatal("Failed to create descriptor set layout: %d", err);
-
- for (int i = 0; i < concurrentFrameCount; ++i) {
- VkDescriptorSetAllocateInfo descSetAllocInfo = {
- VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
- nullptr,
- m_descPool,
- 1,
- &m_descSetLayout
- };
- err = m_devFuncs->vkAllocateDescriptorSets(dev, &descSetAllocInfo, &m_descSet[i]);
- if (err != VK_SUCCESS)
- qFatal("Failed to allocate descriptor set: %d", err);
-
- VkWriteDescriptorSet descWrite[2];
- memset(descWrite, 0, sizeof(descWrite));
- descWrite[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
- descWrite[0].dstSet = m_descSet[i];
- descWrite[0].dstBinding = 0;
- descWrite[0].descriptorCount = 1;
- descWrite[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
- descWrite[0].pBufferInfo = &m_uniformBufInfo[i];
-
- VkDescriptorImageInfo descImageInfo = {
- m_sampler,
- m_texView,
- VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
- };
-
- descWrite[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
- descWrite[1].dstSet = m_descSet[i];
- descWrite[1].dstBinding = 1;
- descWrite[1].descriptorCount = 1;
- descWrite[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
- descWrite[1].pImageInfo = &descImageInfo;
-
- m_devFuncs->vkUpdateDescriptorSets(dev, 2, descWrite, 0, nullptr);
- }
-
- // Pipeline cache
- VkPipelineCacheCreateInfo pipelineCacheInfo;
- memset(&pipelineCacheInfo, 0, sizeof(pipelineCacheInfo));
- pipelineCacheInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;
- err = m_devFuncs->vkCreatePipelineCache(dev, &pipelineCacheInfo, nullptr, &m_pipelineCache);
- if (err != VK_SUCCESS)
- qFatal("Failed to create pipeline cache: %d", err);
-
- // Pipeline layout
- VkPipelineLayoutCreateInfo pipelineLayoutInfo;
- memset(&pipelineLayoutInfo, 0, sizeof(pipelineLayoutInfo));
- pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
- pipelineLayoutInfo.setLayoutCount = 1;
- pipelineLayoutInfo.pSetLayouts = &m_descSetLayout;
- err = m_devFuncs->vkCreatePipelineLayout(dev, &pipelineLayoutInfo, nullptr, &m_pipelineLayout);
- if (err != VK_SUCCESS)
- qFatal("Failed to create pipeline layout: %d", err);
-
- // Shaders
- VkShaderModule vertShaderModule = createShader(QStringLiteral(":/texture_vert.spv"));
- VkShaderModule fragShaderModule = createShader(QStringLiteral(":/texture_frag.spv"));
-
- // Graphics pipeline
- VkGraphicsPipelineCreateInfo pipelineInfo;
- memset(&pipelineInfo, 0, sizeof(pipelineInfo));
- pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
-
- VkPipelineShaderStageCreateInfo shaderStages[2] = {
- {
- VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
- nullptr,
- 0,
- VK_SHADER_STAGE_VERTEX_BIT,
- vertShaderModule,
- "main",
- nullptr
- },
- {
- VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
- nullptr,
- 0,
- VK_SHADER_STAGE_FRAGMENT_BIT,
- fragShaderModule,
- "main",
- nullptr
- }
- };
- pipelineInfo.stageCount = 2;
- pipelineInfo.pStages = shaderStages;
-
- pipelineInfo.pVertexInputState = &vertexInputInfo;
-
- VkPipelineInputAssemblyStateCreateInfo ia;
- memset(&ia, 0, sizeof(ia));
- ia.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
- ia.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
- pipelineInfo.pInputAssemblyState = &ia;
-
- // The viewport and scissor will be set dynamically via vkCmdSetViewport/Scissor.
- // This way the pipeline does not need to be touched when resizing the window.
- VkPipelineViewportStateCreateInfo vp;
- memset(&vp, 0, sizeof(vp));
- vp.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
- vp.viewportCount = 1;
- vp.scissorCount = 1;
- pipelineInfo.pViewportState = &vp;
-
- VkPipelineRasterizationStateCreateInfo rs;
- memset(&rs, 0, sizeof(rs));
- rs.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
- rs.polygonMode = VK_POLYGON_MODE_FILL;
- rs.cullMode = VK_CULL_MODE_BACK_BIT;
- rs.frontFace = VK_FRONT_FACE_CLOCKWISE;
- rs.lineWidth = 1.0f;
- pipelineInfo.pRasterizationState = &rs;
-
- VkPipelineMultisampleStateCreateInfo ms;
- memset(&ms, 0, sizeof(ms));
- ms.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
- ms.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
- pipelineInfo.pMultisampleState = &ms;
-
- VkPipelineDepthStencilStateCreateInfo ds;
- memset(&ds, 0, sizeof(ds));
- ds.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
- ds.depthTestEnable = VK_TRUE;
- ds.depthWriteEnable = VK_TRUE;
- ds.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL;
- pipelineInfo.pDepthStencilState = &ds;
-
- VkPipelineColorBlendStateCreateInfo cb;
- memset(&cb, 0, sizeof(cb));
- cb.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
- // assume pre-multiplied alpha, blend, write out all of rgba
- VkPipelineColorBlendAttachmentState att;
- memset(&att, 0, sizeof(att));
- att.colorWriteMask = 0xF;
- att.blendEnable = VK_TRUE;
- att.srcColorBlendFactor = VK_BLEND_FACTOR_ONE;
- att.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
- att.colorBlendOp = VK_BLEND_OP_ADD;
- att.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
- att.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
- att.alphaBlendOp = VK_BLEND_OP_ADD;
- cb.attachmentCount = 1;
- cb.pAttachments = &att;
- pipelineInfo.pColorBlendState = &cb;
-
- VkDynamicState dynEnable[] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
- VkPipelineDynamicStateCreateInfo dyn;
- memset(&dyn, 0, sizeof(dyn));
- dyn.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
- dyn.dynamicStateCount = sizeof(dynEnable) / sizeof(VkDynamicState);
- dyn.pDynamicStates = dynEnable;
- pipelineInfo.pDynamicState = &dyn;
-
- pipelineInfo.layout = m_pipelineLayout;
- pipelineInfo.renderPass = m_window->defaultRenderPass();
-
- err = m_devFuncs->vkCreateGraphicsPipelines(dev, m_pipelineCache, 1, &pipelineInfo, nullptr, &m_pipeline);
- if (err != VK_SUCCESS)
- qFatal("Failed to create graphics pipeline: %d", err);
-
- if (vertShaderModule)
- m_devFuncs->vkDestroyShaderModule(dev, vertShaderModule, nullptr);
- if (fragShaderModule)
- m_devFuncs->vkDestroyShaderModule(dev, fragShaderModule, nullptr);
-}
-
-void VulkanRenderer::initSwapChainResources()
-{
- qDebug("initSwapChainResources");
-
- // Projection matrix
- m_proj = m_window->clipCorrectionMatrix(); // adjust for Vulkan-OpenGL clip space differences
- const QSize sz = m_window->swapChainImageSize();
- m_proj.perspective(45.0f, sz.width() / (float) sz.height(), 0.01f, 100.0f);
- m_proj.translate(0, 0, -4);
-}
-
-void VulkanRenderer::releaseSwapChainResources()
-{
- qDebug("releaseSwapChainResources");
-}
-
-void VulkanRenderer::releaseResources()
-{
- qDebug("releaseResources");
-
- VkDevice dev = m_window->device();
-
- if (m_sampler) {
- m_devFuncs->vkDestroySampler(dev, m_sampler, nullptr);
- m_sampler = VK_NULL_HANDLE;
- }
-
- if (m_texStaging) {
- m_devFuncs->vkDestroyImage(dev, m_texStaging, nullptr);
- m_texStaging = VK_NULL_HANDLE;
- }
-
- if (m_texStagingMem) {
- m_devFuncs->vkFreeMemory(dev, m_texStagingMem, nullptr);
- m_texStagingMem = VK_NULL_HANDLE;
- }
-
- if (m_texView) {
- m_devFuncs->vkDestroyImageView(dev, m_texView, nullptr);
- m_texView = VK_NULL_HANDLE;
- }
-
- if (m_texImage) {
- m_devFuncs->vkDestroyImage(dev, m_texImage, nullptr);
- m_texImage = VK_NULL_HANDLE;
- }
-
- if (m_texMem) {
- m_devFuncs->vkFreeMemory(dev, m_texMem, nullptr);
- m_texMem = VK_NULL_HANDLE;
- }
-
- if (m_pipeline) {
- m_devFuncs->vkDestroyPipeline(dev, m_pipeline, nullptr);
- m_pipeline = VK_NULL_HANDLE;
- }
-
- if (m_pipelineLayout) {
- m_devFuncs->vkDestroyPipelineLayout(dev, m_pipelineLayout, nullptr);
- m_pipelineLayout = VK_NULL_HANDLE;
- }
-
- if (m_pipelineCache) {
- m_devFuncs->vkDestroyPipelineCache(dev, m_pipelineCache, nullptr);
- m_pipelineCache = VK_NULL_HANDLE;
- }
-
- if (m_descSetLayout) {
- m_devFuncs->vkDestroyDescriptorSetLayout(dev, m_descSetLayout, nullptr);
- m_descSetLayout = VK_NULL_HANDLE;
- }
-
- if (m_descPool) {
- m_devFuncs->vkDestroyDescriptorPool(dev, m_descPool, nullptr);
- m_descPool = VK_NULL_HANDLE;
- }
-
- if (m_buf) {
- m_devFuncs->vkDestroyBuffer(dev, m_buf, nullptr);
- m_buf = VK_NULL_HANDLE;
- }
-
- if (m_bufMem) {
- m_devFuncs->vkFreeMemory(dev, m_bufMem, nullptr);
- m_bufMem = VK_NULL_HANDLE;
- }
-}
-
-void VulkanRenderer::startNextFrame()
-{
- VkDevice dev = m_window->device();
- VkCommandBuffer cb = m_window->currentCommandBuffer();
- const QSize sz = m_window->swapChainImageSize();
-
- // Add the necessary barriers and do the host-linear -> device-optimal copy, if not yet done.
- ensureTexture();
-
- VkClearColorValue clearColor = {{ 0, 0, 0, 1 }};
- VkClearDepthStencilValue clearDS = { 1, 0 };
- VkClearValue clearValues[2];
- memset(clearValues, 0, sizeof(clearValues));
- clearValues[0].color = clearColor;
- clearValues[1].depthStencil = clearDS;
-
- VkRenderPassBeginInfo rpBeginInfo;
- memset(&rpBeginInfo, 0, sizeof(rpBeginInfo));
- rpBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- rpBeginInfo.renderPass = m_window->defaultRenderPass();
- rpBeginInfo.framebuffer = m_window->currentFramebuffer();
- rpBeginInfo.renderArea.extent.width = sz.width();
- rpBeginInfo.renderArea.extent.height = sz.height();
- rpBeginInfo.clearValueCount = 2;
- rpBeginInfo.pClearValues = clearValues;
- VkCommandBuffer cmdBuf = m_window->currentCommandBuffer();
- m_devFuncs->vkCmdBeginRenderPass(cmdBuf, &rpBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
-
- quint8 *p;
- VkResult err = m_devFuncs->vkMapMemory(dev, m_bufMem, m_uniformBufInfo[m_window->currentFrame()].offset,
- UNIFORM_DATA_SIZE, 0, reinterpret_cast<void **>(&p));
- if (err != VK_SUCCESS)
- qFatal("Failed to map memory: %d", err);
- QMatrix4x4 m = m_proj;
- m.rotate(m_rotation, 0, 0, 1);
- memcpy(p, m.constData(), 16 * sizeof(float));
- m_devFuncs->vkUnmapMemory(dev, m_bufMem);
-
- // Not exactly a real animation system, just advance on every frame for now.
- m_rotation += 1.0f;
-
- m_devFuncs->vkCmdBindPipeline(cb, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline);
- m_devFuncs->vkCmdBindDescriptorSets(cb, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineLayout, 0, 1,
- &m_descSet[m_window->currentFrame()], 0, nullptr);
- VkDeviceSize vbOffset = 0;
- m_devFuncs->vkCmdBindVertexBuffers(cb, 0, 1, &m_buf, &vbOffset);
-
- VkViewport viewport;
- viewport.x = viewport.y = 0;
- viewport.width = sz.width();
- viewport.height = sz.height();
- viewport.minDepth = 0;
- viewport.maxDepth = 1;
- m_devFuncs->vkCmdSetViewport(cb, 0, 1, &viewport);
-
- VkRect2D scissor;
- scissor.offset.x = scissor.offset.y = 0;
- scissor.extent.width = viewport.width;
- scissor.extent.height = viewport.height;
- m_devFuncs->vkCmdSetScissor(cb, 0, 1, &scissor);
-
- m_devFuncs->vkCmdDraw(cb, 4, 1, 0, 0);
-
- m_devFuncs->vkCmdEndRenderPass(cmdBuf);
-
- m_window->frameReady();
- m_window->requestUpdate(); // render continuously, throttled by the presentation rate
-}
diff --git a/examples/vulkan/hellovulkantexture/hellovulkantexture.h b/examples/vulkan/hellovulkantexture/hellovulkantexture.h
deleted file mode 100644
index a8c96d1987..0000000000
--- a/examples/vulkan/hellovulkantexture/hellovulkantexture.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QVulkanWindow>
-#include <QImage>
-
-class VulkanRenderer : public QVulkanWindowRenderer
-{
-public:
- VulkanRenderer(QVulkanWindow *w);
-
- void initResources() override;
- void initSwapChainResources() override;
- void releaseSwapChainResources() override;
- void releaseResources() override;
-
- void startNextFrame() override;
-
-private:
- VkShaderModule createShader(const QString &name);
- bool createTexture(const QString &name);
- bool createTextureImage(const QSize &size, VkImage *image, VkDeviceMemory *mem,
- VkImageTiling tiling, VkImageUsageFlags usage, uint32_t memIndex);
- bool writeLinearImage(const QImage &img, VkImage image, VkDeviceMemory memory);
- void ensureTexture();
-
- QVulkanWindow *m_window;
- QVulkanDeviceFunctions *m_devFuncs;
-
- VkDeviceMemory m_bufMem = VK_NULL_HANDLE;
- VkBuffer m_buf = VK_NULL_HANDLE;
- VkDescriptorBufferInfo m_uniformBufInfo[QVulkanWindow::MAX_CONCURRENT_FRAME_COUNT];
-
- VkDescriptorPool m_descPool = VK_NULL_HANDLE;
- VkDescriptorSetLayout m_descSetLayout = VK_NULL_HANDLE;
- VkDescriptorSet m_descSet[QVulkanWindow::MAX_CONCURRENT_FRAME_COUNT];
-
- VkPipelineCache m_pipelineCache = VK_NULL_HANDLE;
- VkPipelineLayout m_pipelineLayout = VK_NULL_HANDLE;
- VkPipeline m_pipeline = VK_NULL_HANDLE;
-
- VkSampler m_sampler = VK_NULL_HANDLE;
- VkImage m_texImage = VK_NULL_HANDLE;
- VkDeviceMemory m_texMem = VK_NULL_HANDLE;
- bool m_texLayoutPending = false;
- VkImageView m_texView = VK_NULL_HANDLE;
- VkImage m_texStaging = VK_NULL_HANDLE;
- VkDeviceMemory m_texStagingMem = VK_NULL_HANDLE;
- bool m_texStagingPending = false;
- QSize m_texSize;
- VkFormat m_texFormat;
-
- QMatrix4x4 m_proj;
- float m_rotation = 0.0f;
-};
-
-class VulkanWindow : public QVulkanWindow
-{
-public:
- QVulkanWindowRenderer *createRenderer() override;
-};
diff --git a/examples/vulkan/hellovulkantexture/hellovulkantexture.pro b/examples/vulkan/hellovulkantexture/hellovulkantexture.pro
deleted file mode 100644
index 59bfcda715..0000000000
--- a/examples/vulkan/hellovulkantexture/hellovulkantexture.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-HEADERS += hellovulkantexture.h
-SOURCES += hellovulkantexture.cpp main.cpp
-RESOURCES += hellovulkantexture.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/vulkan/hellovulkantexture
-INSTALLS += target
diff --git a/examples/vulkan/hellovulkantexture/hellovulkantexture.qrc b/examples/vulkan/hellovulkantexture/hellovulkantexture.qrc
deleted file mode 100644
index 04e7cda859..0000000000
--- a/examples/vulkan/hellovulkantexture/hellovulkantexture.qrc
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>texture_vert.spv</file>
- <file>texture_frag.spv</file>
- <file>qt256.png</file>
-</qresource>
-</RCC>
diff --git a/examples/vulkan/hellovulkantexture/main.cpp b/examples/vulkan/hellovulkantexture/main.cpp
deleted file mode 100644
index bb6103e9cf..0000000000
--- a/examples/vulkan/hellovulkantexture/main.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include <QVulkanInstance>
-#include <QLoggingCategory>
-#include "hellovulkantexture.h"
-
-Q_LOGGING_CATEGORY(lcVk, "qt.vulkan")
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- QLoggingCategory::setFilterRules(QStringLiteral("qt.vulkan=true"));
-
- QVulkanInstance inst;
-
-#ifndef Q_OS_ANDROID
- inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation");
-#else
- inst.setLayers(QByteArrayList()
- << "VK_LAYER_GOOGLE_threading"
- << "VK_LAYER_LUNARG_parameter_validation"
- << "VK_LAYER_LUNARG_object_tracker"
- << "VK_LAYER_LUNARG_core_validation"
- << "VK_LAYER_LUNARG_image"
- << "VK_LAYER_LUNARG_swapchain"
- << "VK_LAYER_GOOGLE_unique_objects");
-#endif
-
- if (!inst.create())
- qFatal("Failed to create Vulkan instance: %d", inst.errorCode());
-
- VulkanWindow w;
- w.setVulkanInstance(&inst);
- if (QCoreApplication::arguments().contains(QStringLiteral("--srgb")))
- w.setPreferredColorFormats(QList<VkFormat>() << VK_FORMAT_B8G8R8A8_SRGB);
-
- w.resize(1024, 768);
- w.show();
-
- return app.exec();
-}
diff --git a/examples/vulkan/hellovulkantexture/qt256.png b/examples/vulkan/hellovulkantexture/qt256.png
deleted file mode 100644
index 30c621c9c6..0000000000
--- a/examples/vulkan/hellovulkantexture/qt256.png
+++ /dev/null
Binary files differ
diff --git a/examples/vulkan/hellovulkantexture/texture.frag b/examples/vulkan/hellovulkantexture/texture.frag
deleted file mode 100644
index e6021fe905..0000000000
--- a/examples/vulkan/hellovulkantexture/texture.frag
+++ /dev/null
@@ -1,12 +0,0 @@
-#version 440
-
-layout(location = 0) in vec2 v_texcoord;
-
-layout(location = 0) out vec4 fragColor;
-
-layout(binding = 1) uniform sampler2D tex;
-
-void main()
-{
- fragColor = texture(tex, v_texcoord);
-}
diff --git a/examples/vulkan/hellovulkantexture/texture.vert b/examples/vulkan/hellovulkantexture/texture.vert
deleted file mode 100644
index de486cb772..0000000000
--- a/examples/vulkan/hellovulkantexture/texture.vert
+++ /dev/null
@@ -1,18 +0,0 @@
-#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;
-} ubuf;
-
-out gl_PerVertex { vec4 gl_Position; };
-
-void main()
-{
- v_texcoord = texcoord;
- gl_Position = ubuf.mvp * position;
-}
diff --git a/examples/vulkan/hellovulkantexture/texture_frag.spv b/examples/vulkan/hellovulkantexture/texture_frag.spv
deleted file mode 100644
index 7521ef6eef..0000000000
--- a/examples/vulkan/hellovulkantexture/texture_frag.spv
+++ /dev/null
Binary files differ
diff --git a/examples/vulkan/hellovulkantexture/texture_vert.spv b/examples/vulkan/hellovulkantexture/texture_vert.spv
deleted file mode 100644
index 6292c0de31..0000000000
--- a/examples/vulkan/hellovulkantexture/texture_vert.spv
+++ /dev/null
Binary files differ
diff --git a/examples/vulkan/hellovulkantriangle/CMakeLists.txt b/examples/vulkan/hellovulkantriangle/CMakeLists.txt
index 3993e931ef..23789d4717 100644
--- a/examples/vulkan/hellovulkantriangle/CMakeLists.txt
+++ b/examples/vulkan/hellovulkantriangle/CMakeLists.txt
@@ -1,50 +1,43 @@
-# Generated from hellovulkantriangle.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(hellovulkantriangle LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/vulkan/hellovulkantriangle")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
+qt_standard_project_setup()
qt_add_executable(hellovulkantriangle
../shared/trianglerenderer.cpp ../shared/trianglerenderer.h
main.cpp
)
+
set_target_properties(hellovulkantriangle PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(hellovulkantriangle PUBLIC
- Qt::Core
- Qt::Gui
-)
+target_link_libraries(hellovulkantriangle PRIVATE
+ Qt6::Core
+ Qt6::Gui
+)
# Resources:
set_source_files_properties("../shared/color_frag.spv"
PROPERTIES QT_RESOURCE_ALIAS "color_frag.spv"
)
+
set_source_files_properties("../shared/color_vert.spv"
PROPERTIES QT_RESOURCE_ALIAS "color_vert.spv"
)
+
set(hellovulkantriangle_resource_files
"../shared/color_frag.spv"
"../shared/color_vert.spv"
)
-qt6_add_resources(hellovulkantriangle "hellovulkantriangle"
+qt_add_resources(hellovulkantriangle "hellovulkantriangle"
PREFIX
"/"
FILES
@@ -52,7 +45,14 @@ qt6_add_resources(hellovulkantriangle "hellovulkantriangle"
)
install(TARGETS hellovulkantriangle
- 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 hellovulkantriangle
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/vulkan/hellovulkantriangle/main.cpp b/examples/vulkan/hellovulkantriangle/main.cpp
index d3eef2e14a..3bf45e6b3a 100644
--- a/examples/vulkan/hellovulkantriangle/main.cpp
+++ b/examples/vulkan/hellovulkantriangle/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QGuiApplication>
#include <QVulkanInstance>
@@ -55,11 +8,13 @@
Q_LOGGING_CATEGORY(lcVk, "qt.vulkan")
+//! [2]
class VulkanWindow : public QVulkanWindow
{
public:
QVulkanWindowRenderer *createRenderer() override;
};
+//! [2]
QVulkanWindowRenderer *VulkanWindow::createRenderer()
{
@@ -72,29 +27,20 @@ int main(int argc, char *argv[])
QLoggingCategory::setFilterRules(QStringLiteral("qt.vulkan=true"));
+//! [0]
QVulkanInstance inst;
-
-#ifndef Q_OS_ANDROID
- inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation");
-#else
- inst.setLayers(QByteArrayList()
- << "VK_LAYER_GOOGLE_threading"
- << "VK_LAYER_LUNARG_parameter_validation"
- << "VK_LAYER_LUNARG_object_tracker"
- << "VK_LAYER_LUNARG_core_validation"
- << "VK_LAYER_LUNARG_image"
- << "VK_LAYER_LUNARG_swapchain"
- << "VK_LAYER_GOOGLE_unique_objects");
-#endif
-
+ inst.setLayers({ "VK_LAYER_KHRONOS_validation" });
if (!inst.create())
qFatal("Failed to create Vulkan instance: %d", inst.errorCode());
+//! [0]
+//! [1]
VulkanWindow w;
w.setVulkanInstance(&inst);
w.resize(1024, 768);
w.show();
+//! [1]
return app.exec();
}
diff --git a/examples/vulkan/hellovulkanwidget/CMakeLists.txt b/examples/vulkan/hellovulkanwidget/CMakeLists.txt
index cecb3a3e52..aed510b6d1 100644
--- a/examples/vulkan/hellovulkanwidget/CMakeLists.txt
+++ b/examples/vulkan/hellovulkanwidget/CMakeLists.txt
@@ -1,53 +1,45 @@
-# Generated from hellovulkanwidget.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(hellovulkanwidget LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/vulkan/hellovulkanwidget")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(hellovulkanwidget
../shared/trianglerenderer.cpp ../shared/trianglerenderer.h
hellovulkanwidget.cpp hellovulkanwidget.h
main.cpp
)
+
set_target_properties(hellovulkanwidget PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(hellovulkanwidget PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
+target_link_libraries(hellovulkanwidget PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+)
# Resources:
set_source_files_properties("../shared/color_frag.spv"
PROPERTIES QT_RESOURCE_ALIAS "color_frag.spv"
)
+
set_source_files_properties("../shared/color_vert.spv"
PROPERTIES QT_RESOURCE_ALIAS "color_vert.spv"
)
+
set(hellovulkanwidget_resource_files
"../shared/color_frag.spv"
"../shared/color_vert.spv"
)
-qt6_add_resources(hellovulkanwidget "hellovulkanwidget"
+qt_add_resources(hellovulkanwidget "hellovulkanwidget"
PREFIX
"/"
FILES
@@ -55,7 +47,14 @@ qt6_add_resources(hellovulkanwidget "hellovulkanwidget"
)
install(TARGETS hellovulkanwidget
- 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 hellovulkanwidget
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/vulkan/hellovulkanwidget/hellovulkanwidget.cpp b/examples/vulkan/hellovulkanwidget/hellovulkanwidget.cpp
index 3e44fabec9..98913eaeb9 100644
--- a/examples/vulkan/hellovulkanwidget/hellovulkanwidget.cpp
+++ b/examples/vulkan/hellovulkanwidget/hellovulkanwidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "hellovulkanwidget.h"
#include <QVulkanFunctions>
diff --git a/examples/vulkan/hellovulkanwidget/hellovulkanwidget.h b/examples/vulkan/hellovulkanwidget/hellovulkanwidget.h
index e70d331ae8..cbebe17f64 100644
--- a/examples/vulkan/hellovulkanwidget/hellovulkanwidget.h
+++ b/examples/vulkan/hellovulkanwidget/hellovulkanwidget.h
@@ -1,63 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef HELLOVULKANWIDGET_H
+#define HELLOVULKANWIDGET_H
#include "../shared/trianglerenderer.h"
#include <QWidget>
-class VulkanWindow;
+QT_FORWARD_DECLARE_CLASS(QTabWidget)
+QT_FORWARD_DECLARE_CLASS(QPlainTextEdit)
+QT_FORWARD_DECLARE_CLASS(QLCDNumber)
-QT_BEGIN_NAMESPACE
-class QTabWidget;
-class QPlainTextEdit;
-class QLCDNumber;
-QT_END_NAMESPACE
+class VulkanWindow;
class MainWindow : public QWidget
{
@@ -98,3 +52,5 @@ signals:
void vulkanInfoReceived(const QString &text);
void frameQueued(int colorValue);
};
+
+#endif // HELLOVULKANWIDGET_H
diff --git a/examples/vulkan/hellovulkanwidget/main.cpp b/examples/vulkan/hellovulkanwidget/main.cpp
index 5ddaf90224..8b8ebe942c 100644
--- a/examples/vulkan/hellovulkanwidget/main.cpp
+++ b/examples/vulkan/hellovulkanwidget/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QPlainTextEdit>
@@ -81,19 +34,7 @@ int main(int argc, char *argv[])
QLoggingCategory::setFilterRules(QStringLiteral("qt.vulkan=true"));
QVulkanInstance inst;
-
-#ifndef Q_OS_ANDROID
- inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation");
-#else
- inst.setLayers(QByteArrayList()
- << "VK_LAYER_GOOGLE_threading"
- << "VK_LAYER_LUNARG_parameter_validation"
- << "VK_LAYER_LUNARG_object_tracker"
- << "VK_LAYER_LUNARG_core_validation"
- << "VK_LAYER_LUNARG_image"
- << "VK_LAYER_LUNARG_swapchain"
- << "VK_LAYER_GOOGLE_unique_objects");
-#endif
+ inst.setLayers({ "VK_LAYER_KHRONOS_validation" });
if (!inst.create())
qFatal("Failed to create Vulkan instance: %d", inst.errorCode());
diff --git a/examples/vulkan/hellovulkanwindow/CMakeLists.txt b/examples/vulkan/hellovulkanwindow/CMakeLists.txt
deleted file mode 100644
index 5e9d789ddf..0000000000
--- a/examples/vulkan/hellovulkanwindow/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Generated from hellovulkanwindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(hellovulkanwindow LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/vulkan/hellovulkanwindow")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-
-qt_add_executable(hellovulkanwindow
- hellovulkanwindow.cpp hellovulkanwindow.h
- main.cpp
-)
-set_target_properties(hellovulkanwindow PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(hellovulkanwindow PUBLIC
- Qt::Core
- Qt::Gui
-)
-
-install(TARGETS hellovulkanwindow
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp b/examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp
deleted file mode 100644
index 31d32307a9..0000000000
--- a/examples/vulkan/hellovulkanwindow/hellovulkanwindow.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "hellovulkanwindow.h"
-#include <QVulkanFunctions>
-
-//! [0]
-QVulkanWindowRenderer *VulkanWindow::createRenderer()
-{
- return new VulkanRenderer(this);
-}
-
-VulkanRenderer::VulkanRenderer(QVulkanWindow *w)
- : m_window(w)
-{
-}
-//! [0]
-
-//! [1]
-void VulkanRenderer::initResources()
-{
- qDebug("initResources");
-
- m_devFuncs = m_window->vulkanInstance()->deviceFunctions(m_window->device());
-}
-//! [1]
-
-void VulkanRenderer::initSwapChainResources()
-{
- qDebug("initSwapChainResources");
-}
-
-void VulkanRenderer::releaseSwapChainResources()
-{
- qDebug("releaseSwapChainResources");
-}
-
-void VulkanRenderer::releaseResources()
-{
- qDebug("releaseResources");
-}
-
-//! [2]
-void VulkanRenderer::startNextFrame()
-{
- m_green += 0.005f;
- if (m_green > 1.0f)
- m_green = 0.0f;
-
- VkClearColorValue clearColor = {{ 0.0f, m_green, 0.0f, 1.0f }};
- VkClearDepthStencilValue clearDS = { 1.0f, 0 };
- VkClearValue clearValues[2];
- memset(clearValues, 0, sizeof(clearValues));
- clearValues[0].color = clearColor;
- clearValues[1].depthStencil = clearDS;
-
- VkRenderPassBeginInfo rpBeginInfo;
- memset(&rpBeginInfo, 0, sizeof(rpBeginInfo));
- rpBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- rpBeginInfo.renderPass = m_window->defaultRenderPass();
- rpBeginInfo.framebuffer = m_window->currentFramebuffer();
- const QSize sz = m_window->swapChainImageSize();
- rpBeginInfo.renderArea.extent.width = sz.width();
- rpBeginInfo.renderArea.extent.height = sz.height();
- rpBeginInfo.clearValueCount = 2;
- rpBeginInfo.pClearValues = clearValues;
- VkCommandBuffer cmdBuf = m_window->currentCommandBuffer();
- m_devFuncs->vkCmdBeginRenderPass(cmdBuf, &rpBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
-
- // Do nothing else. We will just clear to green, changing the component on
- // every invocation. This also helps verifying the rate to which the thread
- // is throttled to. (The elapsed time between startNextFrame calls should
- // typically be around 16 ms. Note that rendering is 2 frames ahead of what
- // is displayed.)
-
- m_devFuncs->vkCmdEndRenderPass(cmdBuf);
-
- m_window->frameReady();
- m_window->requestUpdate(); // render continuously, throttled by the presentation rate
-}
-//! [2]
diff --git a/examples/vulkan/hellovulkanwindow/hellovulkanwindow.h b/examples/vulkan/hellovulkanwindow/hellovulkanwindow.h
deleted file mode 100644
index 5f52e402ca..0000000000
--- a/examples/vulkan/hellovulkanwindow/hellovulkanwindow.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QVulkanWindow>
-
-//! [0]
-class VulkanRenderer : public QVulkanWindowRenderer
-{
-public:
- VulkanRenderer(QVulkanWindow *w);
-
- void initResources() override;
- void initSwapChainResources() override;
- void releaseSwapChainResources() override;
- void releaseResources() override;
-
- void startNextFrame() override;
-
-private:
- QVulkanWindow *m_window;
- QVulkanDeviceFunctions *m_devFuncs;
- float m_green = 0;
-};
-
-class VulkanWindow : public QVulkanWindow
-{
-public:
- QVulkanWindowRenderer *createRenderer() override;
-};
-//! [0]
diff --git a/examples/vulkan/hellovulkanwindow/hellovulkanwindow.pro b/examples/vulkan/hellovulkanwindow/hellovulkanwindow.pro
deleted file mode 100644
index 8f7d9494e2..0000000000
--- a/examples/vulkan/hellovulkanwindow/hellovulkanwindow.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-HEADERS += hellovulkanwindow.h
-SOURCES += hellovulkanwindow.cpp main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/vulkan/hellovulkanwindow
-INSTALLS += target
diff --git a/examples/vulkan/hellovulkanwindow/main.cpp b/examples/vulkan/hellovulkanwindow/main.cpp
deleted file mode 100644
index 313c28f9e0..0000000000
--- a/examples/vulkan/hellovulkanwindow/main.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGuiApplication>
-#include <QVulkanInstance>
-#include <QLoggingCategory>
-#include "hellovulkanwindow.h"
-
-Q_LOGGING_CATEGORY(lcVk, "qt.vulkan")
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
-
- QLoggingCategory::setFilterRules(QStringLiteral("qt.vulkan=true"));
-
-//! [0]
- QVulkanInstance inst;
-
-#ifndef Q_OS_ANDROID
- inst.setLayers(QByteArrayList() << "VK_LAYER_LUNARG_standard_validation");
-#else
- inst.setLayers(QByteArrayList()
- << "VK_LAYER_GOOGLE_threading"
- << "VK_LAYER_LUNARG_parameter_validation"
- << "VK_LAYER_LUNARG_object_tracker"
- << "VK_LAYER_LUNARG_core_validation"
- << "VK_LAYER_LUNARG_image"
- << "VK_LAYER_LUNARG_swapchain"
- << "VK_LAYER_GOOGLE_unique_objects");
-#endif
-
- if (!inst.create())
- qFatal("Failed to create Vulkan instance: %d", inst.errorCode());
-//! [0]
-
-//! [1]
- VulkanWindow w;
- w.setVulkanInstance(&inst);
-
- w.resize(1024, 768);
- w.show();
-//! [1]
-
- return app.exec();
-}
diff --git a/examples/vulkan/shared/objconvert.js b/examples/vulkan/shared/objconvert.js
index 9b49e3cdac..ff3a8e9481 100644
--- a/examples/vulkan/shared/objconvert.js
+++ b/examples/vulkan/shared/objconvert.js
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
var fs = require('fs');
diff --git a/examples/vulkan/shared/trianglerenderer.cpp b/examples/vulkan/shared/trianglerenderer.cpp
index 988d1de75e..56fe323a47 100644
--- a/examples/vulkan/shared/trianglerenderer.cpp
+++ b/examples/vulkan/shared/trianglerenderer.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "trianglerenderer.h"
#include <QVulkanFunctions>
diff --git a/examples/vulkan/shared/trianglerenderer.h b/examples/vulkan/shared/trianglerenderer.h
index 9a33291a95..129c35aed9 100644
--- a/examples/vulkan/shared/trianglerenderer.h
+++ b/examples/vulkan/shared/trianglerenderer.h
@@ -1,52 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef TRIANGLERENDERER_H
+#define TRIANGLERENDERER_H
#include <QVulkanWindow>
@@ -83,3 +39,5 @@ protected:
QMatrix4x4 m_proj;
float m_rotation = 0.0f;
};
+
+#endif // TRIANGLERENDERER_H
diff --git a/examples/vulkan/vulkan.pro b/examples/vulkan/vulkan.pro
index 920762cb9e..4fe4dfda78 100644
--- a/examples/vulkan/vulkan.pro
+++ b/examples/vulkan/vulkan.pro
@@ -1,8 +1,6 @@
TEMPLATE = subdirs
-SUBDIRS = hellovulkanwindow \
- hellovulkantriangle \
- hellovulkantexture
+SUBDIRS = hellovulkantriangle
qtHaveModule(widgets) {
SUBDIRS += hellovulkanwidget
diff --git a/examples/widgets/.prev_CMakeLists.txt b/examples/widgets/.prev_CMakeLists.txt
deleted file mode 100644
index cffc0a6293..0000000000
--- a/examples/widgets/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# Generated from widgets.pro.
-
-if(NOT TARGET Qt::Widgets)
- return()
-endif()
-if(QT_FEATURE_animation)
- add_subdirectory(animation)
-endif()
-add_subdirectory(desktop)
-add_subdirectory(dialogs)
-add_subdirectory(effects)
-add_subdirectory(gallery)
-add_subdirectory(gestures)
-add_subdirectory(graphicsview)
-add_subdirectory(itemviews)
-add_subdirectory(layouts)
-add_subdirectory(painting)
-add_subdirectory(richtext)
-add_subdirectory(scroller)
-add_subdirectory(tools)
-add_subdirectory(touch)
-add_subdirectory(tutorials)
-add_subdirectory(widgets)
-if(QT_FEATURE_draganddrop)
- add_subdirectory(draganddrop)
-endif()
-if(QT_FEATURE_cursor)
- add_subdirectory(mainwindows)
-endif()
-if(QT_FEATURE_opengl AND TARGET Qt::Gui)
- add_subdirectory(windowcontainer)
-endif()
diff --git a/examples/widgets/CMakeLists.txt b/examples/widgets/CMakeLists.txt
index 5026a40a80..42dc87a865 100644
--- a/examples/widgets/CMakeLists.txt
+++ b/examples/widgets/CMakeLists.txt
@@ -1,6 +1,7 @@
-# Generated from widgets.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# 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)
@@ -8,15 +9,14 @@ if(QT_FEATURE_animation)
endif()
add_subdirectory(desktop)
add_subdirectory(dialogs)
-add_subdirectory(effects)
-add_subdirectory(gallery)
+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)
@@ -24,9 +24,6 @@ add_subdirectory(widgets)
if(QT_FEATURE_draganddrop)
add_subdirectory(draganddrop)
endif()
-if(QT_FEATURE_cursor) # special case
+if(QT_FEATURE_cursor)
add_subdirectory(mainwindows)
endif()
-if(QT_FEATURE_opengl AND TARGET Qt::Gui)
- add_subdirectory(windowcontainer)
-endif()
diff --git a/examples/widgets/animation/CMakeLists.txt b/examples/widgets/animation/CMakeLists.txt
index e3382787aa..d9a18bb866 100644
--- a/examples/widgets/animation/CMakeLists.txt
+++ b/examples/widgets/animation/CMakeLists.txt
@@ -1,3 +1 @@
-# Generated from animation.pro.
-
-add_subdirectory(easing)
+qt_internal_add_example(easing)
diff --git a/examples/widgets/animation/easing/CMakeLists.txt b/examples/widgets/animation/easing/CMakeLists.txt
index 7e36ed78c4..8398f7d3e0 100644
--- a/examples/widgets/animation/easing/CMakeLists.txt
+++ b/examples/widgets/animation/easing/CMakeLists.txt
@@ -1,23 +1,12 @@
-# Generated from easing.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(easing LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC 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 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(easing
animation.h
@@ -25,23 +14,24 @@ qt_add_executable(easing
main.cpp
window.cpp window.h
)
+
set_target_properties(easing PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(easing_resource_files
"images/qt-logo.png"
)
-qt6_add_resources(easing "easing"
+qt_add_resources(easing "easing"
PREFIX
"/"
FILES
@@ -49,7 +39,14 @@ qt6_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/animation.h b/examples/widgets/animation/easing/animation.h
index 696257bb4a..111ad44f45 100644
--- a/examples/widgets/animation/easing/animation.h
+++ b/examples/widgets/animation/easing/animation.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef ANIMATION_H
#define ANIMATION_H
@@ -62,8 +15,8 @@ public:
CirclePath,
NPathTypes
};
- Animation(QObject *target, const QByteArray &prop)
- : QPropertyAnimation(target, prop)
+ Animation(QObject *target, const QByteArray &prop, QObject *parent = nullptr)
+ : QPropertyAnimation(target, prop, parent)
{
setPathType(LinearPath);
}
diff --git a/examples/widgets/animation/easing/main.cpp b/examples/widgets/animation/easing/main.cpp
index df2f11f8cf..26009a6bf7 100644
--- a/examples/widgets/animation/easing/main.cpp
+++ b/examples/widgets/animation/easing/main.cpp
@@ -1,59 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include "window.h"
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 7b4fe1d912..d926efc537 100644
--- a/examples/widgets/animation/easing/window.cpp
+++ b/examples/widgets/animation/easing/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
@@ -82,14 +35,14 @@ Window::Window(QWidget *parent)
m_scene.addItem(m_item);
m_ui.graphicsView->setScene(&m_scene);
- m_anim = new Animation(m_item, "pos");
+ m_anim = new Animation(m_item, "pos", this);
m_anim->setEasingCurve(QEasingCurve::OutBounce);
m_ui.easingCurvePicker->setCurrentRow(int(QEasingCurve::OutBounce));
startAnimation();
}
-QEasingCurve createEasingCurve(QEasingCurve::Type curveType)
+static QEasingCurve createEasingCurve(QEasingCurve::Type curveType)
{
QEasingCurve curve(curveType);
@@ -119,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;
@@ -132,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);
@@ -169,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 0c49dd6e8a..ea6bb74667 100644
--- a/examples/widgets/animation/easing/window.h
+++ b/examples/widgets/animation/easing/window.h
@@ -1,52 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef WINDOW_H
+#define WINDOW_H
#include <QtWidgets>
@@ -84,3 +40,5 @@ private:
Animation *m_anim;
QSize m_iconSize;
};
+
+#endif // WINDOW_H
diff --git a/examples/widgets/desktop/CMakeLists.txt b/examples/widgets/desktop/CMakeLists.txt
index a50d3c2f0a..169fa9ffac 100644
--- a/examples/widgets/desktop/CMakeLists.txt
+++ b/examples/widgets/desktop/CMakeLists.txt
@@ -1,4 +1,2 @@
-# Generated from desktop.pro.
-
-add_subdirectory(screenshot)
-add_subdirectory(systray)
+qt_internal_add_example(screenshot)
+qt_internal_add_example(systray)
diff --git a/examples/widgets/desktop/screenshot/CMakeLists.txt b/examples/widgets/desktop/screenshot/CMakeLists.txt
index 2dc1b9909e..4d9b97d114 100644
--- a/examples/widgets/desktop/screenshot/CMakeLists.txt
+++ b/examples/widgets/desktop/screenshot/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from screenshot.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(screenshot LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/desktop/screenshot")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(screenshot
main.cpp
screenshot.cpp screenshot.h
)
+
set_target_properties(screenshot PROPERTIES
WIN32_EXECUTABLE TRUE
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/main.cpp b/examples/widgets/desktop/screenshot/main.cpp
index 96b0d57daa..64bde12e95 100644
--- a/examples/widgets/desktop/screenshot/main.cpp
+++ b/examples/widgets/desktop/screenshot/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QScreen>
diff --git a/examples/widgets/desktop/screenshot/screenshot.cpp b/examples/widgets/desktop/screenshot/screenshot.cpp
index 522b1123b5..5a4ba901b7 100644
--- a/examples/widgets/desktop/screenshot/screenshot.cpp
+++ b/examples/widgets/desktop/screenshot/screenshot.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
@@ -109,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/screenshot/screenshot.h b/examples/widgets/desktop/screenshot/screenshot.h
index 240952120d..c7e10858ee 100644
--- a/examples/widgets/desktop/screenshot/screenshot.h
+++ b/examples/widgets/desktop/screenshot/screenshot.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SCREENSHOT_H
#define SCREENSHOT_H
diff --git a/examples/widgets/desktop/systray/CMakeLists.txt b/examples/widgets/desktop/systray/CMakeLists.txt
index e1d1ca526b..c42469bf59 100644
--- a/examples/widgets/desktop/systray/CMakeLists.txt
+++ b/examples/widgets/desktop/systray/CMakeLists.txt
@@ -1,38 +1,28 @@
-# Generated from systray.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(systray LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/desktop/systray")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(systray
main.cpp
window.cpp window.h
)
+
set_target_properties(systray PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(systray_resource_files
@@ -41,7 +31,7 @@ set(systray_resource_files
"images/trash.png"
)
-qt6_add_resources(systray "systray"
+qt_add_resources(systray "systray"
PREFIX
"/"
FILES
@@ -49,7 +39,14 @@ qt6_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 ae7e925bd8..b0dff58e31 100644
--- a/examples/widgets/desktop/systray/doc/src/systray.qdoc
+++ b/examples/widgets/desktop/systray/doc/src/systray.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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.
@@ -173,11 +150,11 @@
We have reimplemented the QWidget::closeEvent() event handler to
receive widget close events, showing the above message to the
- users when they are closing the editor window. On \macos we need to
+ users when they are closing the editor window. We need to
avoid showing the message and accepting the close event when the
- user really intends to quit the application, that is, when the
- user has triggered "Quit" in the menu bar or pressed the Command+Q
- shortcut.
+ user really intends to quit the application: that is, when the
+ user has triggered "Quit" in the menu bar, or in the tray icon's
+ context menu, or pressed Command+Q shortcut on \macOS.
In addition to the functions and slots discussed above, we have
also implemented several convenience functions to simplify the
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 4e3e628767..d13bde11ce 100644
--- a/examples/widgets/desktop/systray/main.cpp
+++ b/examples/widgets/desktop/systray/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
@@ -57,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/desktop/systray/window.cpp b/examples/widgets/desktop/systray/window.cpp
index e62b5fc0d0..c5632759b0 100644
--- a/examples/widgets/desktop/systray/window.cpp
+++ b/examples/widgets/desktop/systray/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
@@ -111,11 +64,8 @@ void Window::setVisible(bool visible)
//! [2]
void Window::closeEvent(QCloseEvent *event)
{
-#ifdef Q_OS_MACOS
- if (!event->spontaneous() || !isVisible()) {
+ if (!event->spontaneous() || !isVisible())
return;
- }
-#endif
if (trayIcon->isVisible()) {
QMessageBox::information(this, tr("Systray"),
tr("The program will keep running in the "
diff --git a/examples/widgets/desktop/systray/window.h b/examples/widgets/desktop/systray/window.h
index 001338df0c..69978b1ba2 100644
--- a/examples/widgets/desktop/systray/window.h
+++ b/examples/widgets/desktop/systray/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
diff --git a/examples/widgets/dialogs/.prev_CMakeLists.txt b/examples/widgets/dialogs/.prev_CMakeLists.txt
deleted file mode 100644
index 354424bf1f..0000000000
--- a/examples/widgets/dialogs/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-# Generated from dialogs.pro.
-
-if(QT_FEATURE_wizard)
- add_subdirectory(classwizard)
- add_subdirectory(trivialwizard)
-endif()
-add_subdirectory(extension)
-add_subdirectory(findfiles)
-add_subdirectory(standarddialogs)
-add_subdirectory(tabdialog)
-if(QT_FEATURE_wizard AND TARGET Qt::PrintSupport)
- add_subdirectory(licensewizard)
-endif()
diff --git a/examples/widgets/dialogs/CMakeLists.txt b/examples/widgets/dialogs/CMakeLists.txt
index 354424bf1f..3148d3585f 100644
--- a/examples/widgets/dialogs/CMakeLists.txt
+++ b/examples/widgets/dialogs/CMakeLists.txt
@@ -1,13 +1,11 @@
-# Generated from dialogs.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
if(QT_FEATURE_wizard)
- add_subdirectory(classwizard)
- add_subdirectory(trivialwizard)
-endif()
-add_subdirectory(extension)
-add_subdirectory(findfiles)
-add_subdirectory(standarddialogs)
-add_subdirectory(tabdialog)
-if(QT_FEATURE_wizard AND TARGET Qt::PrintSupport)
- add_subdirectory(licensewizard)
+ qt_internal_add_example(trivialwizard)
+ if(Qt6::PrintSupport)
+ qt_internal_add_example(licensewizard)
+ endif()
endif()
+qt_internal_add_example(standarddialogs)
+qt_internal_add_example(tabdialog)
diff --git a/examples/widgets/dialogs/classwizard/CMakeLists.txt b/examples/widgets/dialogs/classwizard/CMakeLists.txt
deleted file mode 100644
index 5134db62be..0000000000
--- a/examples/widgets/dialogs/classwizard/CMakeLists.txt
+++ /dev/null
@@ -1,59 +0,0 @@
-# Generated from classwizard.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(classwizard LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/classwizard")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 8421289eab..0000000000
--- a/examples/widgets/dialogs/classwizard/classwizard.cpp
+++ /dev/null
@@ -1,441 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 0c386f0553..0000000000
--- a/examples/widgets/dialogs/classwizard/classwizard.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 612d194c06..0000000000
--- a/examples/widgets/dialogs/classwizard/main.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <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 37d75d2cc1..0000000000
--- a/examples/widgets/dialogs/extension/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from extension.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(extension LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/extension")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 10a4ae1ac0..0000000000
--- a/examples/widgets/dialogs/extension/finddialog.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 9b4b5b5f3d..0000000000
--- a/examples/widgets/dialogs/extension/finddialog.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 7fa2883fe1..0000000000
--- a/examples/widgets/dialogs/extension/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 1d60d743f2..0000000000
--- a/examples/widgets/dialogs/findfiles/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from findfiles.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(findfiles LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/findfiles")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 99725195e5..0000000000
--- a/examples/widgets/dialogs/findfiles/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 e1f7ccdcc4..0000000000
--- a/examples/widgets/dialogs/findfiles/window.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 b74ba5e70c..0000000000
--- a/examples/widgets/dialogs/findfiles/window.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <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 df0b205cab..0cf2d61c8b 100644
--- a/examples/widgets/dialogs/licensewizard/CMakeLists.txt
+++ b/examples/widgets/dialogs/licensewizard/CMakeLists.txt
@@ -1,40 +1,29 @@
-# Generated from licensewizard.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(licensewizard LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui PrintSupport Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/licensewizard")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS PrintSupport)
+qt_standard_project_setup()
qt_add_executable(licensewizard
licensewizard.cpp licensewizard.h
main.cpp
)
+
set_target_properties(licensewizard PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(licensewizard_resource_files
@@ -42,7 +31,7 @@ set(licensewizard_resource_files
"images/watermark.png"
)
-qt6_add_resources(licensewizard "licensewizard"
+qt_add_resources(licensewizard "licensewizard"
PREFIX
"/"
FILES
@@ -50,7 +39,14 @@ qt6_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 2eaadd1cba..67fa46bf07 100644
--- a/examples/widgets/dialogs/licensewizard/licensewizard.cpp
+++ b/examples/widgets/dialogs/licensewizard/licensewizard.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#if defined(QT_PRINTSUPPORT_LIB)
@@ -335,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/licensewizard.h b/examples/widgets/dialogs/licensewizard/licensewizard.h
index e2890e484f..c163a2af9d 100644
--- a/examples/widgets/dialogs/licensewizard/licensewizard.h
+++ b/examples/widgets/dialogs/licensewizard/licensewizard.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef LICENSEWIZARD_H
#define LICENSEWIZARD_H
diff --git a/examples/widgets/dialogs/licensewizard/main.cpp b/examples/widgets/dialogs/licensewizard/main.cpp
index 47fdb4a09d..d16b5dc6d1 100644
--- a/examples/widgets/dialogs/licensewizard/main.cpp
+++ b/examples/widgets/dialogs/licensewizard/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QTranslator>
@@ -57,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 b42e3a81c7..07e22469ee 100644
--- a/examples/widgets/dialogs/standarddialogs/CMakeLists.txt
+++ b/examples/widgets/dialogs/standarddialogs/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from standarddialogs.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(standarddialogs LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/standarddialogs")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(standarddialogs
dialog.cpp dialog.h
main.cpp
)
+
set_target_properties(standarddialogs PROPERTIES
WIN32_EXECUTABLE TRUE
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 cd7e8085a2..67fb615794 100644
--- a/examples/widgets/dialogs/standarddialogs/dialog.cpp
+++ b/examples/widgets/dialogs/standarddialogs/dialog.cpp
@@ -1,67 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#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:
@@ -99,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;
}
@@ -195,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()"));
@@ -250,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);
@@ -306,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"));
@@ -388,8 +329,14 @@ void Dialog::setColor()
void Dialog::setFont()
{
const QFontDialog::FontDialogOptions options = QFlag(fontDialogOptionsWidget->value());
+
+ const QString &description = fontLabel->text();
+ QFont defaultFont;
+ if (!description.isEmpty())
+ defaultFont.fromString(description);
+
bool ok;
- QFont font = QFontDialog::getFont(&ok, QFont(fontLabel->text()), this, "Select Font", options);
+ QFont font = QFontDialog::getFont(&ok, defaultFont, this, "Select Font", options);
if (ok) {
fontLabel->setText(font.key());
fontLabel->setFont(font);
@@ -454,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)
@@ -468,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"));
@@ -478,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)
@@ -493,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 6d9cbdc07a..88d0f7519f 100644
--- a/examples/widgets/dialogs/standarddialogs/dialog.h
+++ b/examples/widgets/dialogs/standarddialogs/dialog.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DIALOG_H
#define DIALOG_H
@@ -102,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.cpp b/examples/widgets/dialogs/standarddialogs/main.cpp
index 3892c02f9d..c982ef36c5 100644
--- a/examples/widgets/dialogs/standarddialogs/main.cpp
+++ b/examples/widgets/dialogs/standarddialogs/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QScreen>
@@ -57,19 +10,22 @@
#include "dialog.h"
+using namespace Qt::StringLiterals;
+
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- QGuiApplication::setApplicationDisplayName(Dialog::tr("Standard Dialogs"));
-#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);
+#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();
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 8e8ad4213a..b959a5c3e4 100644
--- a/examples/widgets/dialogs/tabdialog/CMakeLists.txt
+++ b/examples/widgets/dialogs/tabdialog/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from tabdialog.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(tabdialog LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/tabdialog")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(tabdialog
main.cpp
tabdialog.cpp tabdialog.h
)
+
set_target_properties(tabdialog PROPERTIES
WIN32_EXECUTABLE TRUE
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/tabdialog/main.cpp b/examples/widgets/dialogs/tabdialog/main.cpp
index d5ed426320..aa05ad0205 100644
--- a/examples/widgets/dialogs/tabdialog/main.cpp
+++ b/examples/widgets/dialogs/tabdialog/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/dialogs/tabdialog/tabdialog.cpp b/examples/widgets/dialogs/tabdialog/tabdialog.cpp
index e64413d6bb..cb4fcea11d 100644
--- a/examples/widgets/dialogs/tabdialog/tabdialog.cpp
+++ b/examples/widgets/dialogs/tabdialog/tabdialog.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
diff --git a/examples/widgets/dialogs/tabdialog/tabdialog.h b/examples/widgets/dialogs/tabdialog/tabdialog.h
index b7c6c5b8da..27f07747d6 100644
--- a/examples/widgets/dialogs/tabdialog/tabdialog.h
+++ b/examples/widgets/dialogs/tabdialog/tabdialog.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TABDIALOG_H
#define TABDIALOG_H
diff --git a/examples/widgets/dialogs/trivialwizard/CMakeLists.txt b/examples/widgets/dialogs/trivialwizard/CMakeLists.txt
index 4c67d8cdb6..966d99a7aa 100644
--- a/examples/widgets/dialogs/trivialwizard/CMakeLists.txt
+++ b/examples/widgets/dialogs/trivialwizard/CMakeLists.txt
@@ -1,39 +1,37 @@
-# Generated from trivialwizard.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(trivialwizard LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/dialogs/trivialwizard")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(trivialwizard
trivialwizard.cpp
)
+
set_target_properties(trivialwizard PROPERTIES
WIN32_EXECUTABLE TRUE
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 e214a4e54a..b9321338a4 100644
--- a/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp
+++ b/examples/widgets/dialogs/trivialwizard/trivialwizard.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include <QTranslator>
@@ -133,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 720d001525..4c38ffc50d 100644
--- a/examples/widgets/doc/dropsite.qdoc
+++ b/examples/widgets/doc/dropsite.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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.
@@ -49,8 +26,8 @@
\snippet draganddrop/dropsite/droparea.h DropArea header part1
- In addition, \c DropArea also contains a private instance of QLabel and
- reimplementations of four \l{QWidget} event handlers:
+ In addition, \c DropArea contains reimplementations of four \l{QWidget}
+ event handlers:
\list 1
\li \l{QWidget::dragEnterEvent()}{dragEnterEvent()}
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/notepad1.png b/examples/widgets/doc/images/notepad1.png
index 40d13269b9..91863de5c3 100644
--- a/examples/widgets/doc/images/notepad1.png
+++ b/examples/widgets/doc/images/notepad1.png
Binary files differ
diff --git a/examples/widgets/doc/images/notepad2.png b/examples/widgets/doc/images/notepad2.png
index 9cec1f9a58..599a5c68f4 100644
--- a/examples/widgets/doc/images/notepad2.png
+++ b/examples/widgets/doc/images/notepad2.png
Binary files differ
diff --git a/examples/widgets/doc/images/notepad3.png b/examples/widgets/doc/images/notepad3.png
index 426861ab06..d4f55ba2a0 100644
--- a/examples/widgets/doc/images/notepad3.png
+++ b/examples/widgets/doc/images/notepad3.png
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/regularexpression-example.png b/examples/widgets/doc/images/regularexpression-example.png
index d426d8514a..ac314a7748 100644
--- a/examples/widgets/doc/images/regularexpression-example.png
+++ b/examples/widgets/doc/images/regularexpression-example.png
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 c64d22eceb..0000000000
--- a/examples/widgets/doc/mousebuttons.qdoc
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Rick Stockton <rickstockton@reno-computerhelp.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 563b6a2be9..0000000000
--- a/examples/widgets/doc/src/addressbook-tutorial.qdoc
+++ /dev/null
@@ -1,972 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 instanciated \c AddressBook on the stack: It
- will now go out of scope. Therefore, \c AddressBook and all its child widgets
- will be deleted, thus preventing memory leaks.
-*/
-
-/*!
- \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{QIODevice::}{WriteOnly} mode.
- If this is unsuccessful, we display a QMessageBox to inform the user.
-
- \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part2
-
- Otherwise, we instantiate a QDataStream object, \c out, to write the open
- file. QDataStream requires that the same version of the stream is used
- for reading and writing. We ensure that this is the case by setting the
- version used to the \l{QDataStream::Qt_4_5}{version introduced with Qt 4.5}
- before serializing the data to \c file.
-
- \snippet tutorials/addressbook/part6/addressbook.cpp saveToFile() function part3
-
- For the loading feature, we also obtain \c fileName using
- QFileDialog::getOpenFileName(). This function, the counterpart to
- QFileDialog::getSaveFileName(), also pops up the modal file dialog and
- allows the user to enter a file name or select any existing \c{.abk} file
- to load it into the address book.
-
- \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part1
-
- On Windows, for example, this function pops up a native file dialog, as
- shown in the following screenshot.
-
- \image addressbook-tutorial-part6-load.png
-
- If \c fileName is not empty, again, we use a QFile object, \c file, and
- attempt to open it in \l{QIODevice::}{ReadOnly} mode. Similar to our
- implementation of \c saveToFile(), if this attempt is unsuccessful, we
- display a QMessageBox to inform the user.
-
- \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part2
-
- Otherwise, we instantiate a QDataStream object, \c in, set its version as
- above and read the serialized data into the \c contacts data structure.
- The \c contacts object is emptied before data is read into it to simplify
- the file reading process. A more advanced method would be to read the
- contacts into a temporary QMap object, and copy over non-duplicate contacts
- into \c contacts.
-
- \snippet tutorials/addressbook/part6/addressbook.cpp loadFromFile() function part3
-
- To display the contacts that have been read from the file, we must first
- validate the data obtained to ensure that the file we read from actually
- contains address book contacts. If it does, we display the first contact;
- otherwise, we display a QMessageBox to inform the user about the problem.
- Lastly, we update the interface to enable and disable the push buttons
- accordingly.
-*/
-
-/*!
- \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{QIODevice::}{WriteOnly} mode. If this
- process fails, we display a QMessageBox to inform the user about the
- problem and return. Otherwise, we pass the file as a parameter to a
- QTextStream object, \c out. Like QDataStream, the QTextStream class
- provides functionality to read and write plain text to files. As a result,
- the \c{.vcf} file generated can be opened for editing in a text editor.
-
- \snippet tutorials/addressbook/part7/addressbook.cpp export function part2
-
- We then write out a vCard file with the \c{BEGIN:VCARD} tag, followed by
- the \c{VERSION:2.1} tag. The contact's name is written with the \c{N:}
- tag. For the \c{FN:} tag, which fills in the "File as" property of a vCard,
- we have to check whether the contact has a last name or not. If the contact
- does, we use the details in \c nameList to fill it. Otherwise, we write
- \c firstName only.
-
- \snippet tutorials/addressbook/part7/addressbook.cpp export function part3
-
- We proceed to write the contact's address. The semicolons in the address
- are escaped with "\\", the newlines are replaced with semicolons, and the
- commas are replaced with spaces. Lastly, we write the \c{ADR;HOME:;}
- tag, followed by \c address and then the \c{END:VCARD} tag.
-
- \snippet tutorials/addressbook/part7/addressbook.cpp export function part4
-
- In the end, a QMessageBox is displayed to inform the user that the vCard
- has been successfully exported.
-
- \e{vCard is a trademark of the \l{http://www.imc.org}
- {Internet Mail Consortium}}.
-*/
diff --git a/examples/widgets/doc/src/addressbook.qdoc b/examples/widgets/doc/src/addressbook.qdoc
index 22769cb270..8f2512298b 100644
--- a/examples/widgets/doc/src/addressbook.qdoc
+++ b/examples/widgets/doc/src/addressbook.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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.
@@ -48,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
@@ -405,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 601a707eb9..2ec3a4fc4d 100644
--- a/examples/widgets/doc/src/affine.qdoc
+++ b/examples/widgets/doc/src/affine.qdoc
@@ -1,35 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 ff65f97730..8f98f4b7b0 100644
--- a/examples/widgets/doc/src/analogclock.qdoc
+++ b/examples/widgets/doc/src/analogclock.qdoc
@@ -1,33 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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.
@@ -41,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:
@@ -50,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
@@ -70,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
@@ -102,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.
@@ -112,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 334c8cb9f0..0000000000
--- a/examples/widgets/doc/src/application.qdoc
+++ /dev/null
@@ -1,395 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 3eda3ffed2..0882c0f32f 100644
--- a/examples/widgets/doc/src/basicdrawing.qdoc
+++ b/examples/widgets/doc/src/basicdrawing.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 23661d0558..1add587464 100644
--- a/examples/widgets/doc/src/basicgraphicslayouts.qdoc
+++ b/examples/widgets/doc/src/basicgraphicslayouts.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 e9d7cea21b..e6f1cab4d9 100644
--- a/examples/widgets/doc/src/basiclayouts.qdoc
+++ b/examples/widgets/doc/src/basiclayouts.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 d598ab1e24..c0b8a5f426 100644
--- a/examples/widgets/doc/src/basicsortfiltermodel.qdoc
+++ b/examples/widgets/doc/src/basicsortfiltermodel.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 d4d84f7248..0000000000
--- a/examples/widgets/doc/src/blurpicker.qdoc
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 6572bfe578..0000000000
--- a/examples/widgets/doc/src/borderlayout.qdoc
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 7d34a86c19..c59d3cd161 100644
--- a/examples/widgets/doc/src/calculator.qdoc
+++ b/examples/widgets/doc/src/calculator.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 4a6a482ff2..0000000000
--- a/examples/widgets/doc/src/calendar.qdoc
+++ /dev/null
@@ -1,226 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 c04fab1fc7..01c6df6926 100644
--- a/examples/widgets/doc/src/calendarwidget.qdoc
+++ b/examples/widgets/doc/src/calendarwidget.qdoc
@@ -1,32 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 3cf4a1210b..0000000000
--- a/examples/widgets/doc/src/charactermap.qdoc
+++ /dev/null
@@ -1,275 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\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 popuplated 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 e721832c5b..0000000000
--- a/examples/widgets/doc/src/chart.qdoc
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 758b692f0e..2c69c10f39 100644
--- a/examples/widgets/doc/src/chip.qdoc
+++ b/examples/widgets/doc/src/chip.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 7f3693b65e..0000000000
--- a/examples/widgets/doc/src/classwizard.qdoc
+++ /dev/null
@@ -1,191 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 7f09f4bba0..0000000000
--- a/examples/widgets/doc/src/codeeditor.qdoc
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 984d3244f9..a1b8e0e141 100644
--- a/examples/widgets/doc/src/collidingmice-example.qdoc
+++ b/examples/widgets/doc/src/collidingmice-example.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example graphicsview/collidingmice
\title Colliding Mice Example
+ \examplecategory {Graphics}
\brief Demonstrates how to animate items on a graphics view.
\ingroup examples-graphicsview
@@ -161,7 +138,7 @@
Because the complexity of arbitrary shape-shape intersection grows
with an order of magnitude when the shapes are complex, this
- operation can be noticably time consuming. An alternative approach
+ operation can be noticeably time consuming. An alternative approach
is to reimplement the \l
{QGraphicsItem::collidesWithItem()}{collidesWithItem()} function
to provide your own custom item and shape collision algorithm.
diff --git a/examples/widgets/doc/src/coloreditorfactory.qdoc b/examples/widgets/doc/src/coloreditorfactory.qdoc
deleted file mode 100644
index 1471f75e78..0000000000
--- a/examples/widgets/doc/src/coloreditorfactory.qdoc
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example itemviews/coloreditorfactory
- \title Color Editor Factory Example
- \ingroup examples-itemviews
- \brief This example shows how to create an editor that can be used by
- a QItemDelegate.
-
- \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
- 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
- item delegates.
-
- An item editor factory contains a collection of
- QItemEditorCreatorBase instances, which are specialized factories
- that produce editors for one particular QVariant data type (all
- models in Qt store their data in \l{QVariant}s). An editor can be any
- Qt or custom widget.
-
- 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
- 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
- have implemented the \c Window class, which displays a
- QTableWidget in which \l{QColor}s can be edited.
-
- \section1 Window Class Implementation
-
- In the Window class, we create the item editor creator
- base for our color editor and add it to the default factory.
- We also create a QTableWidget in which our editor can be
- tested. It is filled with some data and displayed in a window.
-
- We take a closer look at the constructor:
-
- \snippet itemviews/coloreditorfactory/window.cpp 0
-
- The QStandardItemEditorCreator is a convenience class that
- inherits QItemEditorCreatorBase. Its constructor takes a template
- class, of which instances are returned from
- \l{QItemEditorCreatorBase::}{createWidget()}. The creator uses a
- constructor that takes a QWidget as its only parameter; the
- template class must provide this. This way, there is no need to
- subclass QStandardItemEditorCreator.
-
- After the new factory has been set, all standard item delegates
- will use it (i.e, also delegates that were created before the new
- default factory was set).
-
- The \c createGUI() function sets up the table and fills it
- with data.
-
- \section1 ColorListEditor Definition
-
- The ColorListEditor inherits QComboBox and lets the user
- select a QColor from its popup list.
-
- \snippet itemviews/coloreditorfactory/colorlisteditor.h 0
-
- QItemDelegate 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
- delegate uses Qt's \l{Qt's Property System}{property system} to
- access it by name. We declare our user data property with the
- Q_PROPERTY macro. The property is set to be the user type with the
- USER keyword.
-
- \section1 ColorListEditor Implementation
-
- The constructor of \c ColorListEditor simply calls \c
- populateList(), which we will look at later. We move on to the
- \c color() function:
-
- \snippet itemviews/coloreditorfactory/colorlisteditor.cpp 0
-
- We return the data that is selected in the combobox. The data
- is stored in the Qt::DecorationRole as the color is then also
- displayed in the popup list (as shown in the image above).
-
- \snippet itemviews/coloreditorfactory/colorlisteditor.cpp 1
-
- The \c findData() function searches the items in the combobox
- and returns the index of the item that has \c color in the
- Qt::Decoration role.
-
- \snippet itemviews/coloreditorfactory/colorlisteditor.cpp 2
-
- Qt knows some predefined colors by name. We simply loop
- through these to fill our editor with items.
-
- \section1 Further Customization of Item View Editors
-
- You can customize Qt's \l{Model/View Programming}{model view
- framework} in many ways. The procedure shown in this example is
- 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.
-
- Possible suggestions are:
-
- \list
- \li If the editor widget has no user property defined, the delegate
- asks the factory for the property name, which it in turn
- asks the item editor creator for. In this case, you can use
- the QItemEditorCreator class, which takes the property
- name to use for editing as a constructor argument.
- \li If the editor requires other constructors or other
- initialization than provided by QItemEditorCreatorBase, you
- must reimplement
- QItemEditorCreatorBase::createWidget().
- \li You could also subclass QItemEditorFactory if you only want
- to provide editors for certain kinds of data or use another
- method of creating the editors than using creator bases.
- \endlist
-
- 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.
-*/
diff --git a/examples/widgets/doc/src/combowidgetmapper.qdoc b/examples/widgets/doc/src/combowidgetmapper.qdoc
index d1b8948b6d..aae546005c 100644
--- a/examples/widgets/doc/src/combowidgetmapper.qdoc
+++ b/examples/widgets/doc/src/combowidgetmapper.qdoc
@@ -1,47 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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".
@@ -89,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
@@ -119,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
@@ -130,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:
@@ -142,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 8c6b0246ea..f3e4fe8f0e 100644
--- a/examples/widgets/doc/src/completer.qdoc
+++ b/examples/widgets/doc/src/completer.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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
@@ -69,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".
@@ -225,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 89669e7daa..a8adcd2549 100644
--- a/examples/widgets/doc/src/composition.qdoc
+++ b/examples/widgets/doc/src/composition.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example painting/composition
\title Composition Modes
+ \examplecategory {Graphics}
\ingroup examples-painting
\brief Demonstrates how Composition Modes work in QPainter.
@@ -42,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 fdf1f88142..0000000000
--- a/examples/widgets/doc/src/concentriccircles.qdoc
+++ /dev/null
@@ -1,233 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 ebbd29a921..b6ff8e7b48 100644
--- a/examples/widgets/doc/src/customsortfiltermodel.qdoc
+++ b/examples/widgets/doc/src/customsortfiltermodel.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 db7d7a82c9..f33522fa3b 100644
--- a/examples/widgets/doc/src/deform.qdoc
+++ b/examples/widgets/doc/src/deform.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 6a38ebd2c5..6f307ef97c 100644
--- a/examples/widgets/doc/src/diagramscene.qdoc
+++ b/examples/widgets/doc/src/diagramscene.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example graphicsview/diagramscene
\title Diagram Scene Example
+ \examplecategory {Graphics}
\ingroup examples-graphicsview
\brief Demonstrate how to use the Graphics View framework.
@@ -36,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.
@@ -145,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:
@@ -313,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 aff349adb8..0000000000
--- a/examples/widgets/doc/src/digitalclock.qdoc
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 d8c68bf41e..0000000000
--- a/examples/widgets/doc/src/dirview.qdoc
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 34190f6d2e..0000000000
--- a/examples/widgets/doc/src/dockwidgets.qdoc
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 b318cc2fb9..0000000000
--- a/examples/widgets/doc/src/draganddroppuzzle.qdoc
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 ac138072c9..c9ff04574b 100644
--- a/examples/widgets/doc/src/dragdroprobot.qdoc
+++ b/examples/widgets/doc/src/dragdroprobot.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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.
@@ -319,7 +296,7 @@
This snippet has a somewhat random outcome: once in a while, a special
image is assigned to the drag object's mime data. The pixmap is also
- assiged as the drag object's pixmap. This will ensure that you can see the
+ assigned as the drag object's pixmap. This will ensure that you can see the
image that is being dragged as a pixmap under the mouse cursor.
\snippet graphicsview/dragdroprobot/coloritem.cpp 7
diff --git a/examples/widgets/doc/src/draggableicons.qdoc b/examples/widgets/doc/src/draggableicons.qdoc
index 7c5b5dc574..fd4f9e69e3 100644
--- a/examples/widgets/doc/src/draggableicons.qdoc
+++ b/examples/widgets/doc/src/draggableicons.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 e934119e7a..6e15e7f946 100644
--- a/examples/widgets/doc/src/draggabletext.qdoc
+++ b/examples/widgets/doc/src/draggabletext.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 0b9d43c98e..0000000000
--- a/examples/widgets/doc/src/dynamiclayouts.qdoc
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 807dd72e93..79c985392c 100644
--- a/examples/widgets/doc/src/easing.qdoc
+++ b/examples/widgets/doc/src/easing.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 28be789c5c..0000000000
--- a/examples/widgets/doc/src/echoplugin.qdoc
+++ /dev/null
@@ -1,205 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 68e10e3e78..15df678c87 100644
--- a/examples/widgets/doc/src/editabletreemodel.qdoc
+++ b/examples/widgets/doc/src/editabletreemodel.qdoc
@@ -1,36 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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
@@ -108,7 +85,7 @@
\l{TreeItem::data}{data()} function to read entries in the \c itemData
list and a \l{TreeItem::setData}{setData()} function to allow them to
be modified.
- As with other functions in the item, this simplifies the implemention
+ As with other functions in the item, this simplifies the implementation
of the model's \l{QAbstractItemModel::}{data()} and
\l{QAbstractItemModel::}{setData()} functions.
@@ -253,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.
@@ -286,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.
@@ -309,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
@@ -358,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,
@@ -443,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 e78db67be2..c25fd68009 100644
--- a/examples/widgets/doc/src/elasticnodes.qdoc
+++ b/examples/widgets/doc/src/elasticnodes.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example graphicsview/elasticnodes
\title Elastic Nodes Example
+ \examplecategory {Graphics}
\ingroup examples-graphicsview
\brief Demonstrates how to interact with graphical items in a scene.
@@ -259,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
@@ -355,7 +332,7 @@
collection of small items that all move around, it's unnecessary for
Graphics View to waste time finding accurate update regions, so we set the
QGraphicsView::BoundingRectViewportUpdate viewport update mode. The default
- would work fine, but this mode is noticably faster for this example.
+ would work fine, but this mode is noticeably faster for this example.
To improve rendering quality, we set QPainter::Antialiasing.
diff --git a/examples/widgets/doc/src/elidedlabel.qdoc b/examples/widgets/doc/src/elidedlabel.qdoc
deleted file mode 100644
index b731b60e83..0000000000
--- a/examples/widgets/doc/src/elidedlabel.qdoc
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 0b31e01e0c..0000000000
--- a/examples/widgets/doc/src/embeddeddialogs.qdoc
+++ /dev/null
@@ -1,39 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 c895258acf..0000000000
--- a/examples/widgets/doc/src/extension.qdoc
+++ /dev/null
@@ -1,145 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 2035922067..0000000000
--- a/examples/widgets/doc/src/fademessage.qdoc
+++ /dev/null
@@ -1,39 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 a27efaf071..d8dae18f33 100644
--- a/examples/widgets/doc/src/fetchmore.qdoc
+++ b/examples/widgets/doc/src/fetchmore.qdoc
@@ -1,48 +1,19 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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.
\image fetchmore-example.png
-
- This example consists of a dialog where you can enter a directory
- name in the \uicontrol Directory edit field. The application loads and
- visualizes all files it finds as you are typing. It is not required
- to press [Enter] to launch the search.
-
When you have large - or perhaps even infinite - data sets, you
will need to add items to the model in batches, and preferably only
- when the items are needed by the view (i.e., when they are visible
+ when the items are needed by the view (i.e., when they become visible
in the view).
In this example, we implement \c FileListModel - an item view
@@ -50,6 +21,15 @@
Window, which sets up the GUI and feeds the model with
directories.
+ The UI consists of a dialog with a list showing the contents
+ of the root directory. Directories can be navigated by double-clicking.
+
+ At the bottom, there is a log window displaying messages when the view
+ asks the model for more data.
+
+ To exercise it, navigate to a large directory (say \c /bin), and scroll
+ to the bottom. Log messages appear showing the data being retrieved.
+
Let's take a tour of \c {FileListModel}'s code.
\section1 FileListModel Class Definition
diff --git a/examples/widgets/doc/src/findfiles.qdoc b/examples/widgets/doc/src/findfiles.qdoc
deleted file mode 100644
index d7428e7d16..0000000000
--- a/examples/widgets/doc/src/findfiles.qdoc
+++ /dev/null
@@ -1,293 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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
- contructor. 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 c907cb3af7..03dfc164d7 100644
--- a/examples/widgets/doc/src/flowlayout.qdoc
+++ b/examples/widgets/doc/src/flowlayout.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 2e206c7769..0000000000
--- a/examples/widgets/doc/src/fontsampler.qdoc
+++ /dev/null
@@ -1,37 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 101d0fd390..0000000000
--- a/examples/widgets/doc/src/fridgemagnets.qdoc
+++ /dev/null
@@ -1,362 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 actived 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 705d190582..c213ba1779 100644
--- a/examples/widgets/doc/src/frozencolumn.qdoc
+++ b/examples/widgets/doc/src/frozencolumn.qdoc
@@ -1,40 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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.
\image frozencolumn-example.png "Screenshot of the example"
We use Qt's model/view framework to implement a table with its first
- column frozen. This technique can be aplied to several columns or rows,
+ column frozen. This technique can be applied to several columns or rows,
as long as they are on the edge of the table.
The model/view framework allows for one model to be displayed in different
diff --git a/examples/widgets/doc/src/gallery.qdoc b/examples/widgets/doc/src/gallery.qdoc
index 3f2cb4bbcc..36b76d8f63 100644
--- a/examples/widgets/doc/src/gallery.qdoc
+++ b/examples/widgets/doc/src/gallery.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 457e6f837a..e2ad68db1a 100644
--- a/examples/widgets/doc/src/gradients.qdoc
+++ b/examples/widgets/doc/src/gradients.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 7933e3c956..0000000000
--- a/examples/widgets/doc/src/graphicsview-anchorlayout.qdoc
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 13819f5499..0000000000
--- a/examples/widgets/doc/src/graphicsview-flowlayout.qdoc
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 27b3f86156..ce5fe8934a 100644
--- a/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc
+++ b/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example graphicsview/simpleanchorlayout
\title Simple Anchor Layout Example
+ \examplecategory {Graphics}
\ingroup examples-graphicsview-layout
\brief Demonstrates anchor layout on a graphics view scene.
@@ -79,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 71ace60355..0000000000
--- a/examples/widgets/doc/src/graphicsview-weatheranchorlayout.qdoc
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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
deleted file mode 100644
index b9da2f05f4..0000000000
--- a/examples/widgets/doc/src/groupbox.qdoc
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example widgets/groupbox
- \title Group Box Example
- \ingroup examples-widgets
- \brief The Group Box example shows how to use the different kinds of group
- boxes in Qt.
-
- Group boxes are container widgets that organize buttons into groups,
- both logically and on screen. They manage the interactions between
- the user and the application so that you do not have to enforce
- simple constraints.
-
- Group boxes are usually used to organize check boxes and radio
- buttons into exclusive groups.
-
- \borderedimage groupbox-example.png
-
- The Group Boxes example consists of a single \c Window class that
- is used to show four group boxes: an exclusive radio button group,
- a non-exclusive checkbox group, an exclusive radio button group
- with an enabling checkbox, and a group box with normal push buttons.
-
- \section1 Window Class Definition
-
- The \c Window class is a subclass of \c QWidget that is used to
- display a number of group boxes. The class definition contains
- functions to construct each group box and populate it with different
- selections of button widgets:
-
- \snippet widgets/groupbox/window.h 0
-
- In the example, the widget will be used as a top-level window, so
- the constructor is defined so that we do not have to specify a parent
- widget.
-
- \section1 Window Class Implementation
-
- The constructor creates a grid layout and fills it with each of the
- group boxes that are to be displayed:
-
- \snippet widgets/groupbox/window.cpp 0
-
- The functions used to create each group box each return a
- QGroupBox to be inserted into the grid layout.
-
- \snippet widgets/groupbox/window.cpp 1
-
- The first group box contains and manages three radio buttons. Since
- the group box contains only radio buttons, it is exclusive by
- default, so only one radio button can be checked at any given time.
- We check the first radio button to ensure that the button group
- contains one checked button.
-
- \snippet widgets/groupbox/window.cpp 3
-
- We use a vertical layout within the group box to present the
- buttons in the form of a vertical list, and return the group
- box to the constructor.
-
- The second group box is itself checkable, providing a convenient
- way to disable all the buttons inside it. Initially, it is
- unchecked, so the group box itself must be checked before any of
- the radio buttons inside can be checked.
-
- \snippet widgets/groupbox/window.cpp 4
-
- The group box contains three exclusive radio buttons, and an
- independent checkbox. For consistency, one radio button must be
- checked at all times, so we ensure that the first one is initially
- checked.
-
- \snippet widgets/groupbox/window.cpp 5
-
- The buttons are arranged in the same way as those in the first
- group box.
-
- \snippet widgets/groupbox/window.cpp 6
-
- The third group box is constructed with a "flat" style that is
- better suited to certain types of dialog.
-
- \snippet widgets/groupbox/window.cpp 7
-
- This group box contains only checkboxes, so it is non-exclusive by
- default. This means that each checkbox can be checked independently
- of the others.
-
- \snippet widgets/groupbox/window.cpp 8
-
- Again, we use a vertical layout within the group box to present
- the buttons in the form of a vertical list.
-
- \snippet widgets/groupbox/window.cpp 9
-
- The final group box contains only push buttons and, like the
- second group box, it is checkable.
-
- \snippet widgets/groupbox/window.cpp 10
-
- We create a normal button, a toggle button, and a flat push button:
-
- \snippet widgets/groupbox/window.cpp 11
-
- Push buttons can be used to display popup menus. We create one, and
- attach a simple menu to it:
-
- \snippet widgets/groupbox/window.cpp 12
-
- Finally, we lay out the widgets vertically, and return the group box
- that we created:
-
- \snippet widgets/groupbox/window.cpp 13
-*/
diff --git a/examples/widgets/doc/src/i18n.qdoc b/examples/widgets/doc/src/i18n.qdoc
deleted file mode 100644
index e13a315a80..0000000000
--- a/examples/widgets/doc/src/i18n.qdoc
+++ /dev/null
@@ -1,40 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 5dca44a887..0000000000
--- a/examples/widgets/doc/src/icons.qdoc
+++ /dev/null
@@ -1,829 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 97f3a78264..9eec57ca88 100644
--- a/examples/widgets/doc/src/imagecomposition.qdoc
+++ b/examples/widgets/doc/src/imagecomposition.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 8cf8c2489e..0000000000
--- a/examples/widgets/doc/src/imageviewer.qdoc
+++ /dev/null
@@ -1,344 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 072d755e37..0000000000
--- a/examples/widgets/doc/src/interview.qdoc
+++ /dev/null
@@ -1,39 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 4789ce717c..0000000000
--- a/examples/widgets/doc/src/itemviewspuzzle.qdoc
+++ /dev/null
@@ -1,43 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 30f1a876d2..66c822e421 100644
--- a/examples/widgets/doc/src/licensewizard.qdoc
+++ b/examples/widgets/doc/src/licensewizard.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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
@@ -37,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
@@ -215,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 08de3c08dd..7065a5f425 100644
--- a/examples/widgets/doc/src/lineedits.qdoc
+++ b/examples/widgets/doc/src/lineedits.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 b2f397dfc7..0000000000
--- a/examples/widgets/doc/src/mainwindow.qdoc
+++ /dev/null
@@ -1,37 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 f54d8f8f4a..0000000000
--- a/examples/widgets/doc/src/mdi.qdoc
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 0cf74a7dac..b78d394691 100644
--- a/examples/widgets/doc/src/menus.qdoc
+++ b/examples/widgets/doc/src/menus.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example mainwindows/menus
\title Menus Example
+ \examplecategory {User Interface Components}
\ingroup examples-mainwindow
\ingroup examples-layout
@@ -143,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 2363383ffe..0000000000
--- a/examples/widgets/doc/src/movie.qdoc
+++ /dev/null
@@ -1,40 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 5c63081a77..7ae89dfda8 100644
--- a/examples/widgets/doc/src/orderform.qdoc
+++ b/examples/widgets/doc/src/orderform.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 bd821ac1bf..305a7608e5 100644
--- a/examples/widgets/doc/src/painterpaths.qdoc
+++ b/examples/widgets/doc/src/painterpaths.qdoc
@@ -1,39 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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
@@ -127,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
@@ -175,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 83f25113dd..bc4001ebb5 100644
--- a/examples/widgets/doc/src/pathstroke.qdoc
+++ b/examples/widgets/doc/src/pathstroke.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 5ad2158e7e..0000000000
--- a/examples/widgets/doc/src/pixelator.qdoc
+++ /dev/null
@@ -1,255 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 b37176da0e..0000000000
--- a/examples/widgets/doc/src/plugandpaint.qdoc
+++ /dev/null
@@ -1,551 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 f11679cf6c..f6f1e87689 100644
--- a/examples/widgets/doc/src/regularexpression.qdoc
+++ b/examples/widgets/doc/src/regularexpression.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 7274a8f37c..2e2b3123ef 100644
--- a/examples/widgets/doc/src/screenshot.qdoc
+++ b/examples/widgets/doc/src/screenshot.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 ca79431334..3cd7205397 100644
--- a/examples/widgets/doc/src/scribble.qdoc
+++ b/examples/widgets/doc/src/scribble.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 3aa96ff598..0000000000
--- a/examples/widgets/doc/src/sdi.qdoc
+++ /dev/null
@@ -1,37 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 4abf23cf14..0000000000
--- a/examples/widgets/doc/src/settingseditor.qdoc
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 732820cdc8..4bcd04683c 100644
--- a/examples/widgets/doc/src/shapedclock.qdoc
+++ b/examples/widgets/doc/src/shapedclock.qdoc
@@ -1,43 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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.
@@ -49,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
@@ -69,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
@@ -101,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 314e0fe9d4..0000000000
--- a/examples/widgets/doc/src/simpledommodel.qdoc
+++ /dev/null
@@ -1,280 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 f5fe93897c..aa12a9585f 100644
--- a/examples/widgets/doc/src/simpletreemodel.qdoc
+++ b/examples/widgets/doc/src/simpletreemodel.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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
@@ -128,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},
@@ -148,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.
@@ -160,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.
@@ -168,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
@@ -207,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
@@ -341,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 c427dc6542..0000000000
--- a/examples/widgets/doc/src/simplewidgetmapper.qdoc
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 eb9a932c76..9bfb4abdc4 100644
--- a/examples/widgets/doc/src/sliders.qdoc
+++ b/examples/widgets/doc/src/sliders.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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.
@@ -41,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
@@ -54,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
@@ -79,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
@@ -108,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
@@ -154,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
@@ -164,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
@@ -181,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
@@ -193,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
@@ -206,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
@@ -256,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 c234673eb7..0000000000
--- a/examples/widgets/doc/src/spinboxdelegate.qdoc
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 4478ce12d2..eb42696c48 100644
--- a/examples/widgets/doc/src/spinboxes.qdoc
+++ b/examples/widgets/doc/src/spinboxes.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 392fbd0a16..02d5e0a957 100644
--- a/examples/widgets/doc/src/spreadsheet.qdoc
+++ b/examples/widgets/doc/src/spreadsheet.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 0a41f61c00..396f1d1044 100644
--- a/examples/widgets/doc/src/standarddialogs.qdoc
+++ b/examples/widgets/doc/src/standarddialogs.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 f26424abaf..44d75e64f4 100644
--- a/examples/widgets/doc/src/stardelegate.qdoc
+++ b/examples/widgets/doc/src/stardelegate.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 5977633428..0000000000
--- a/examples/widgets/doc/src/styleplugin.qdoc
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 99575a84da..0000000000
--- a/examples/widgets/doc/src/styles.qdoc
+++ /dev/null
@@ -1,472 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 b51f1bed41..0000000000
--- a/examples/widgets/doc/src/stylesheet.qdoc
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 30dc685843..17bcc1fa06 100644
--- a/examples/widgets/doc/src/syntaxhighlighter.qdoc
+++ b/examples/widgets/doc/src/syntaxhighlighter.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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.
@@ -243,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 4a30f51e73..fb45bbae04 100644
--- a/examples/widgets/doc/src/tabdialog.qdoc
+++ b/examples/widgets/doc/src/tabdialog.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 a10846fed4..9d49d8dec8 100644
--- a/examples/widgets/doc/src/tablet.qdoc
+++ b/examples/widgets/doc/src/tablet.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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.
@@ -37,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.
@@ -55,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.
@@ -112,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
@@ -329,7 +304,7 @@
receive tablet proximity events and forward them to \c TabletCanvas.
The \c TabletEnterProximity and \c TabletLeaveProximity events are sent to
the QApplication object, while other tablet events are sent to the QWidget's
- \c event() hander, which sends them on to \l{QWidget::}{tabletEvent()}.
+ \c event() handler, which sends them on to \l{QWidget::}{tabletEvent()}.
\section1 TabletApplication Class Implementation
diff --git a/examples/widgets/doc/src/tetrix.qdoc b/examples/widgets/doc/src/tetrix.qdoc
deleted file mode 100644
index ddcf95013b..0000000000
--- a/examples/widgets/doc/src/tetrix.qdoc
+++ /dev/null
@@ -1,431 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 8f4f8a5ac4..0000000000
--- a/examples/widgets/doc/src/textedit.qdoc
+++ /dev/null
@@ -1,39 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 a278215503..0000000000
--- a/examples/widgets/doc/src/tooltips.qdoc
+++ /dev/null
@@ -1,394 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 we drawed 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 17b540b6cc..d90708340c 100644
--- a/examples/widgets/doc/src/transformations.qdoc
+++ b/examples/widgets/doc/src/transformations.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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.
@@ -72,8 +49,8 @@
coordinate system around the origin (called shearing) using the
QPainter::shear() function.
- All the tranformation operations operate on QPainter's
- tranformation matrix that you can retrieve using the
+ All the transformation operations operate on QPainter's
+ transformation matrix that you can retrieve using the
QPainter::worldTransform() function. A matrix transforms a point in the
plane to another point. For more information about the
transformation matrix, see the \l {Coordinate System} and
@@ -289,11 +266,11 @@
\snippet painting/transformations/window.cpp 1
Then we create the \c RenderArea widgets that will render their
- shapes with coordinate tranformations. By default the applied
+ shapes with coordinate transformations. By default the applied
operation is \uicontrol {No Transformation}, i.e. the shapes are
rendered within the default coordinate system. We create and
initialize the associated \l {QComboBox}es with items
- corresponding to the various transformation operations decribed by
+ corresponding to the various transformation operations described by
the global \c Operation enum.
We also connect the \l {QComboBox}es' \l
@@ -359,10 +336,10 @@
also has good support for coordinate transformations. With the
Transformations application you can scale, rotate and translate
QPainter's coordinate system. The order in which these
- tranformations are applied is essential for the result.
+ transformations are applied is essential for the result.
- All the tranformation operations operate on QPainter's
- tranformation matrix. For more information about the
+ All the transformation operations operate on QPainter's
+ transformation matrix. For more information about the
transformation matrix, see the \l {Coordinate System} and
QTransform documentation.
diff --git a/examples/widgets/doc/src/treemodelcompleter.qdoc b/examples/widgets/doc/src/treemodelcompleter.qdoc
index d3b435976c..ae7c18f442 100644
--- a/examples/widgets/doc/src/treemodelcompleter.qdoc
+++ b/examples/widgets/doc/src/treemodelcompleter.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 783cc07028..75d007f388 100644
--- a/examples/widgets/doc/src/trivialwizard.qdoc
+++ b/examples/widgets/doc/src/trivialwizard.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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
@@ -79,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 321ae159a3..0000000000
--- a/examples/widgets/doc/src/undo.qdoc
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 b4e6f3685d..e8d895b7f0 100644
--- a/examples/widgets/doc/src/undoframework.qdoc
+++ b/examples/widgets/doc/src/undoframework.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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
@@ -93,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:
@@ -100,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
@@ -119,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 9d82f3f575..0000000000
--- a/examples/widgets/doc/src/validators.qdoc
+++ /dev/null
@@ -1,35 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 d70d609e2b..0000000000
--- a/examples/widgets/doc/src/wiggly.qdoc
+++ /dev/null
@@ -1,168 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 3fe00cd266..10b0496728 100644
--- a/examples/widgets/doc/src/windowflags.qdoc
+++ b/examples/widgets/doc/src/windowflags.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 fbad523a73..bdc6480790 100644
--- a/examples/widgets/draganddrop/CMakeLists.txt
+++ b/examples/widgets/draganddrop/CMakeLists.txt
@@ -1,7 +1,6 @@
-# Generated from draganddrop.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(draggableicons)
-add_subdirectory(draggabletext)
-add_subdirectory(dropsite)
-add_subdirectory(fridgemagnets)
-add_subdirectory(puzzle)
+qt_internal_add_example(draggableicons)
+qt_internal_add_example(draggabletext)
+qt_internal_add_example(dropsite)
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 894f8ba520..c1fac8da6b 100644
--- a/examples/widgets/draganddrop/draggableicons/CMakeLists.txt
+++ b/examples/widgets/draganddrop/draggableicons/CMakeLists.txt
@@ -1,38 +1,33 @@
-# Generated from draggableicons.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(draggableicons LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/draganddrop/draggableicons")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(draggableicons
dragwidget.cpp dragwidget.h
main.cpp
)
+
set_target_properties(draggableicons PROPERTIES
WIN32_EXECUTABLE TRUE
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
@@ -41,7 +36,7 @@ set(draggableicons_resource_files
"images/house.png"
)
-qt6_add_resources(draggableicons "draggableicons"
+qt_add_resources(draggableicons "draggableicons"
PREFIX
"/"
FILES
@@ -49,7 +44,14 @@ qt6_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 1b3774db4f..ba06c836d4 100644
--- a/examples/widgets/draganddrop/draggableicons/dragwidget.cpp
+++ b/examples/widgets/draganddrop/draggableicons/dragwidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
@@ -142,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/dragwidget.h b/examples/widgets/draganddrop/draggableicons/dragwidget.h
index 98e623a5e3..d849985981 100644
--- a/examples/widgets/draganddrop/draggableicons/dragwidget.h
+++ b/examples/widgets/draganddrop/draggableicons/dragwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DRAGWIDGET_H
#define DRAGWIDGET_H
diff --git a/examples/widgets/draganddrop/draggableicons/main.cpp b/examples/widgets/draganddrop/draggableicons/main.cpp
index f23dd203b4..fe92708594 100644
--- a/examples/widgets/draganddrop/draggableicons/main.cpp
+++ b/examples/widgets/draganddrop/draggableicons/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QHBoxLayout>
@@ -55,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 d2da6acddb..bc1e72db80 100644
--- a/examples/widgets/draganddrop/draggabletext/CMakeLists.txt
+++ b/examples/widgets/draganddrop/draggabletext/CMakeLists.txt
@@ -1,45 +1,39 @@
-# Generated from draggabletext.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(draggabletext LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/draganddrop/draggabletext")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(draggabletext
dragwidget.cpp dragwidget.h
main.cpp
)
+
set_target_properties(draggabletext PROPERTIES
WIN32_EXECUTABLE TRUE
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"
)
-qt6_add_resources(draggabletext "draggabletext"
+qt_add_resources(draggabletext "draggabletext"
PREFIX
"/dictionary"
FILES
@@ -47,7 +41,14 @@ qt6_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/dragwidget.cpp b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp
index 1f1889c7cf..d56f91e900 100644
--- a/examples/widgets/draganddrop/draggabletext/dragwidget.cpp
+++ b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
diff --git a/examples/widgets/draganddrop/draggabletext/dragwidget.h b/examples/widgets/draganddrop/draggabletext/dragwidget.h
index 38abb0ceb8..dfbe3beb4e 100644
--- a/examples/widgets/draganddrop/draggabletext/dragwidget.h
+++ b/examples/widgets/draganddrop/draggabletext/dragwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DRAGWIDGET_H
#define DRAGWIDGET_H
diff --git a/examples/widgets/draganddrop/draggabletext/main.cpp b/examples/widgets/draganddrop/draggabletext/main.cpp
index e10b537ff5..ebfd481e62 100644
--- a/examples/widgets/draganddrop/draggabletext/main.cpp
+++ b/examples/widgets/draganddrop/draggabletext/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
@@ -54,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 aac6d005b7..ae8d00eb91 100644
--- a/examples/widgets/draganddrop/dropsite/CMakeLists.txt
+++ b/examples/widgets/draganddrop/dropsite/CMakeLists.txt
@@ -1,41 +1,39 @@
-# Generated from dropsite.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(dropsite LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/draganddrop/dropsite")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(dropsite
droparea.cpp droparea.h
dropsitewindow.cpp dropsitewindow.h
main.cpp
)
+
set_target_properties(dropsite PROPERTIES
WIN32_EXECUTABLE TRUE
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/dropsite/droparea.cpp b/examples/widgets/draganddrop/dropsite/droparea.cpp
index 19644ed573..1b2ff1820d 100644
--- a/examples/widgets/draganddrop/dropsite/droparea.cpp
+++ b/examples/widgets/draganddrop/dropsite/droparea.cpp
@@ -1,58 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "droparea.h"
#include <QDragEnterEvent>
#include <QMimeData>
+using namespace Qt::StringLiterals;
+
//! [DropArea constructor]
DropArea::DropArea(QWidget *parent)
: QLabel(parent)
@@ -93,8 +48,8 @@ void DropArea::dropEvent(QDropEvent *event)
//! [dropEvent() function part2]
if (mimeData->hasImage()) {
setPixmap(qvariant_cast<QPixmap>(mimeData->imageData()));
- } else if (mimeData->hasFormat(QLatin1String("text/markdown"))) {
- setText(QString::fromUtf8(mimeData->data(QLatin1String("text/markdown"))));
+ } else if (mimeData->hasFormat(u"text/markdown"_s)) {
+ setText(QString::fromUtf8(mimeData->data(u"text/markdown"_s)));
setTextFormat(Qt::MarkdownText);
} else if (mimeData->hasHtml()) {
setText(mimeData->html());
@@ -105,8 +60,8 @@ void DropArea::dropEvent(QDropEvent *event)
} else if (mimeData->hasUrls()) {
QList<QUrl> urlList = mimeData->urls();
QString text;
- for (int i = 0; i < urlList.size() && i < 32; ++i)
- text += urlList.at(i).path() + QLatin1Char('\n');
+ for (qsizetype i = 0, count = qMin(urlList.size(), qsizetype(32)); i < count; ++i)
+ text += urlList.at(i).path() + u'\n';
setText(text);
} else {
setText(tr("Cannot display data"));
diff --git a/examples/widgets/draganddrop/dropsite/droparea.h b/examples/widgets/draganddrop/dropsite/droparea.h
index ab1de8ea44..3e5947b236 100644
--- a/examples/widgets/draganddrop/dropsite/droparea.h
+++ b/examples/widgets/draganddrop/dropsite/droparea.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DROPAREA_H
#define DROPAREA_H
@@ -78,9 +31,6 @@ protected:
void dragMoveEvent(QDragMoveEvent *event) override;
void dragLeaveEvent(QDragLeaveEvent *event) override;
void dropEvent(QDropEvent *event) override;
-
-private:
- QLabel *label;
};
//! [DropArea header part2]
diff --git a/examples/widgets/draganddrop/dropsite/dropsitewindow.cpp b/examples/widgets/draganddrop/dropsite/dropsitewindow.cpp
index d96ebce2e3..2969fdf7ae 100644
--- a/examples/widgets/draganddrop/dropsite/dropsitewindow.cpp
+++ b/examples/widgets/draganddrop/dropsite/dropsitewindow.cpp
@@ -1,58 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QPushButton>
+#include <QDialogButtonBox>
+#include <QHeaderView>
+#include <QTableWidget>
+#include <QTableWidgetItem>
+#include <QVBoxLayout>
+
+#include <QClipboard>
+#include <QGuiApplication>
+
+#include <QMimeData>
#include "droparea.h"
#include "dropsitewindow.h"
+using namespace Qt::StringLiterals;
+
//! [constructor part1]
DropSiteWindow::DropSiteWindow()
{
@@ -70,13 +35,10 @@ DropSiteWindow::DropSiteWindow()
//! [constructor part2]
//! [constructor part3]
- QStringList labels;
- labels << tr("Format") << tr("Content");
-
formatsTable = new QTableWidget;
formatsTable->setColumnCount(2);
formatsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
- formatsTable->setHorizontalHeaderLabels(labels);
+ formatsTable->setHorizontalHeaderLabels({tr("Format"), tr("Content")});
formatsTable->horizontalHeader()->setStretchLastSection(true);
//! [constructor part3]
@@ -107,7 +69,7 @@ DropSiteWindow::DropSiteWindow()
mainLayout->addWidget(buttonBox);
setWindowTitle(tr("Drop Site"));
- setMinimumSize(350, 500);
+ resize(700, 500);
}
//! [constructor part5]
@@ -130,20 +92,21 @@ void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData)
//! [updateFormatsTable() part3]
QString text;
- if (format == QLatin1String("text/plain")) {
+ if (format == u"text/plain") {
text = mimeData->text().simplified();
- } else if (format == QLatin1String("text/markdown")) {
- text = QString::fromUtf8(mimeData->data(QLatin1String("text/markdown")));
- } else if (format == QLatin1String("text/html")) {
+ } else if (format == u"text/markdown") {
+ text = QString::fromUtf8(mimeData->data(u"text/markdown"_s));
+ } else if (format == u"text/html") {
text = mimeData->html().simplified();
- } else if (format == QLatin1String("text/uri-list")) {
+ } else if (format == u"text/uri-list") {
QList<QUrl> urlList = mimeData->urls();
- for (int i = 0; i < urlList.size() && i < 32; ++i)
- text.append(urlList.at(i).toString() + QLatin1Char(' '));
+ for (qsizetype i = 0, count = qMin(urlList.size(), qsizetype(32)); i < count; ++i)
+ text.append(urlList.at(i).toString() + u' ');
} else {
QByteArray data = mimeData->data(format);
- for (int i = 0; i < data.size() && i < 32; ++i)
- text.append(QStringLiteral("%1 ").arg(uchar(data[i]), 2, 16, QLatin1Char('0')).toUpper());
+ if (data.size() > 32)
+ data.truncate(32);
+ text = QString::fromLatin1(data.toHex(' ')).toUpper();
}
//! [updateFormatsTable() part3]
diff --git a/examples/widgets/draganddrop/dropsite/dropsitewindow.h b/examples/widgets/draganddrop/dropsite/dropsitewindow.h
index a40b481637..942736a3c2 100644
--- a/examples/widgets/draganddrop/dropsite/dropsitewindow.h
+++ b/examples/widgets/draganddrop/dropsite/dropsitewindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DROPSITEWINDOW_H
#define DROPSITEWINDOW_H
diff --git a/examples/widgets/draganddrop/dropsite/main.cpp b/examples/widgets/draganddrop/dropsite/main.cpp
index 70ba55a57c..201bac1ce5 100644
--- a/examples/widgets/draganddrop/dropsite/main.cpp
+++ b/examples/widgets/draganddrop/dropsite/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/draganddrop/fridgemagnets/CMakeLists.txt b/examples/widgets/draganddrop/fridgemagnets/CMakeLists.txt
deleted file mode 100644
index 3f8b9108ae..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/CMakeLists.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-# Generated from fridgemagnets.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(fridgemagnets LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/draganddrop/fridgemagnets")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 8cdf34ad1e..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/draglabel.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 805009cb9c..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/draglabel.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 14e8a1a879..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 ff513a33d8..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/dragwidget.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 4c575f50b3..0000000000
--- a/examples/widgets/draganddrop/fridgemagnets/main.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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/.prev_CMakeLists.txt b/examples/widgets/draganddrop/puzzle/.prev_CMakeLists.txt
deleted file mode 100644
index bcc7708662..0000000000
--- a/examples/widgets/draganddrop/puzzle/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-# Generated from puzzle.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(puzzle LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/draganddrop/puzzle")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(puzzle
- main.cpp
- mainwindow.cpp mainwindow.h
- pieceslist.cpp pieceslist.h
- puzzlewidget.cpp puzzlewidget.h
-)
-set_target_properties(puzzle PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(puzzle PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set(puzzle_resource_files
- "example.jpg"
-)
-
-qt6_add_resources(puzzle "puzzle"
- PREFIX
- "/images"
- FILES
- ${puzzle_resource_files}
-)
-
-install(TARGETS puzzle
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/draganddrop/puzzle/CMakeLists.txt b/examples/widgets/draganddrop/puzzle/CMakeLists.txt
deleted file mode 100644
index b7569fb0d2..0000000000
--- a/examples/widgets/draganddrop/puzzle/CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-# Generated from puzzle.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(puzzle LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/draganddrop_puzzle") # special case
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(draganddrop_puzzle # special case: renamed puzzle
- main.cpp
- mainwindow.cpp mainwindow.h
- pieceslist.cpp pieceslist.h
- puzzlewidget.cpp puzzlewidget.h
-)
-set_target_properties(draganddrop_puzzle PROPERTIES # special case
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(draganddrop_puzzle PUBLIC # special case
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set(puzzle_resource_files
- "example.jpg"
-)
-
-qt6_add_resources(draganddrop_puzzle "puzzle" # special case
- PREFIX
- "/images"
- FILES
- ${puzzle_resource_files}
-)
-
-install(TARGETS draganddrop_puzzle # special case: renamed 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 d013bf078d..0000000000
--- a/examples/widgets/draganddrop/puzzle/main.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 98a7cd4265..0000000000
--- a/examples/widgets/draganddrop/puzzle/mainwindow.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 626612ebe8..0000000000
--- a/examples/widgets/draganddrop/puzzle/mainwindow.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 7846d37ed2..0000000000
--- a/examples/widgets/draganddrop/puzzle/pieceslist.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 a508d17d72..0000000000
--- a/examples/widgets/draganddrop/puzzle/pieceslist.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 06dda9c29f..0000000000
--- a/examples/widgets/draganddrop/puzzle/puzzlewidget.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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
-{
- return QRect(position / pieceSize() * pieceSize(),
- 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 0ac4719d74..0000000000
--- a/examples/widgets/draganddrop/puzzle/puzzlewidget.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 6e8a892de1..0000000000
--- a/examples/widgets/effects/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Generated from effects.pro.
-
-add_subdirectory(blurpicker)
-add_subdirectory(fademessage)
diff --git a/examples/widgets/effects/blurpicker/CMakeLists.txt b/examples/widgets/effects/blurpicker/CMakeLists.txt
deleted file mode 100644
index f24fa685c0..0000000000
--- a/examples/widgets/effects/blurpicker/CMakeLists.txt
+++ /dev/null
@@ -1,62 +0,0 @@
-# Generated from blurpicker.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(blurpicker LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/effects/blurpicker")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 55abf2226e..0000000000
--- a/examples/widgets/effects/blurpicker/blureffect.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 241a0ea535..0000000000
--- a/examples/widgets/effects/blurpicker/blureffect.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 2b5995d870..0000000000
--- a/examples/widgets/effects/blurpicker/blurpicker.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 dc7fc4dabb..0000000000
--- a/examples/widgets/effects/blurpicker/blurpicker.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 41c8169cb3..0000000000
--- a/examples/widgets/effects/blurpicker/main.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 2de3b9b131..0000000000
--- a/examples/widgets/effects/fademessage/CMakeLists.txt
+++ /dev/null
@@ -1,53 +0,0 @@
-# Generated from fademessage.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(fademessage LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/effects/fademessage")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 4c3a70bb4f..0000000000
--- a/examples/widgets/effects/fademessage/fademessage.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 4d84c4ed21..0000000000
--- a/examples/widgets/effects/fademessage/fademessage.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 c78c7de8ce..0000000000
--- a/examples/widgets/effects/fademessage/main.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 f3afe22109..e0c87afb0b 100644
--- a/examples/widgets/gallery/CMakeLists.txt
+++ b/examples/widgets/gallery/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from gallery.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(gallery LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/gallery")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(gallery
main.cpp
widgetgallery.cpp widgetgallery.h
)
+
set_target_properties(gallery PROPERTIES
WIN32_EXECUTABLE TRUE
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/gallery/main.cpp b/examples/widgets/gallery/main.cpp
index ba83c764e3..cfac821209 100644
--- a/examples/widgets/gallery/main.cpp
+++ b/examples/widgets/gallery/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/gallery/widgetgallery.cpp b/examples/widgets/gallery/widgetgallery.cpp
index b2973fad4c..2de46419d9 100644
--- a/examples/widgets/gallery/widgetgallery.cpp
+++ b/examples/widgets/gallery/widgetgallery.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "widgetgallery.h"
diff --git a/examples/widgets/gallery/widgetgallery.h b/examples/widgets/gallery/widgetgallery.h
index 419c925190..c96437a466 100644
--- a/examples/widgets/gallery/widgetgallery.h
+++ b/examples/widgets/gallery/widgetgallery.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WIDGETGALLERY_H
#define WIDGETGALLERY_H
diff --git a/examples/widgets/gestures/CMakeLists.txt b/examples/widgets/gestures/CMakeLists.txt
index eb02ee41a9..0110ca90a6 100644
--- a/examples/widgets/gestures/CMakeLists.txt
+++ b/examples/widgets/gestures/CMakeLists.txt
@@ -1,6 +1,7 @@
-# Generated from gestures.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-if(NOT TARGET Qt::Widgets)
+if(NOT TARGET Qt6::Widgets)
return()
endif()
-add_subdirectory(imagegestures)
+qt_internal_add_example(imagegestures)
diff --git a/examples/widgets/gestures/imagegestures/CMakeLists.txt b/examples/widgets/gestures/imagegestures/CMakeLists.txt
index 994fba8c04..1e173dc63f 100644
--- a/examples/widgets/gestures/imagegestures/CMakeLists.txt
+++ b/examples/widgets/gestures/imagegestures/CMakeLists.txt
@@ -1,41 +1,39 @@
-# Generated from imagegestures.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(imagegestures LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/gestures/imagegestures")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(imagegestures
imagewidget.cpp imagewidget.h
main.cpp
mainwidget.cpp mainwidget.h
)
+
set_target_properties(imagegestures PROPERTIES
WIN32_EXECUTABLE TRUE
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 0ab578f55c..46053566ab 100644
--- a/examples/widgets/gestures/imagegestures/doc/src/imagegestures.qdoc
+++ b/examples/widgets/gestures/imagegestures/doc/src/imagegestures.qdoc
@@ -1,39 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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 072ec2b216..189281cc11 100644
--- a/examples/widgets/gestures/imagegestures/imagewidget.cpp
+++ b/examples/widgets/gestures/imagegestures/imagewidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "imagewidget.h"
@@ -88,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();
@@ -191,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();
@@ -234,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();
}
@@ -251,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();
}
@@ -281,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 f9b5d989e9..1f4010baac 100644
--- a/examples/widgets/gestures/imagegestures/imagewidget.h
+++ b/examples/widgets/gestures/imagegestures/imagewidget.h
@@ -1,56 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef IMAGEWIDGET_H
#define IMAGEWIDGET_H
+#include <QFileInfo>
#include <QImage>
#include <QLoggingCategory>
#include <QWidget>
@@ -71,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:
@@ -87,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/gestures/imagegestures/main.cpp b/examples/widgets/gestures/imagegestures/main.cpp
index ecd7462bd3..434b1efb5a 100644
--- a/examples/widgets/gestures/imagegestures/main.cpp
+++ b/examples/widgets/gestures/imagegestures/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
diff --git a/examples/widgets/gestures/imagegestures/mainwidget.cpp b/examples/widgets/gestures/imagegestures/mainwidget.cpp
index c4e63e9e7d..59bb9570f0 100644
--- a/examples/widgets/gestures/imagegestures/mainwidget.cpp
+++ b/examples/widgets/gestures/imagegestures/mainwidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "imagewidget.h"
#include "mainwidget.h"
diff --git a/examples/widgets/gestures/imagegestures/mainwidget.h b/examples/widgets/gestures/imagegestures/mainwidget.h
index 794f052f3c..d321b84136 100644
--- a/examples/widgets/gestures/imagegestures/mainwidget.h
+++ b/examples/widgets/gestures/imagegestures/mainwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWIDGET_H
#define MAINWIDGET_H
diff --git a/examples/widgets/graphicsview/CMakeLists.txt b/examples/widgets/graphicsview/CMakeLists.txt
index a60ba190ef..7e287f0f42 100644
--- a/examples/widgets/graphicsview/CMakeLists.txt
+++ b/examples/widgets/graphicsview/CMakeLists.txt
@@ -1,15 +1,12 @@
-# Generated from graphicsview.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(chip)
-add_subdirectory(elasticnodes)
-add_subdirectory(embeddeddialogs)
-add_subdirectory(collidingmice)
-add_subdirectory(basicgraphicslayouts)
-add_subdirectory(diagramscene)
-add_subdirectory(flowlayout)
-add_subdirectory(anchorlayout)
-add_subdirectory(simpleanchorlayout)
-add_subdirectory(weatheranchorlayout)
+qt_internal_add_example(chip)
+qt_internal_add_example(elasticnodes)
+qt_internal_add_example(collidingmice)
+qt_internal_add_example(basicgraphicslayouts)
+qt_internal_add_example(diagramscene)
+qt_internal_add_example(simpleanchorlayout)
if(QT_FEATURE_cursor AND QT_FEATURE_draganddrop)
- add_subdirectory(dragdroprobot)
+ 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 9d500bace4..0000000000
--- a/examples/widgets/graphicsview/anchorlayout/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated from anchorlayout.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(anchorlayout LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/anchorlayout")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 98dacfb5fb..0000000000
--- a/examples/widgets/graphicsview/anchorlayout/main.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 a699a75a87..dae3884e8b 100644
--- a/examples/widgets/graphicsview/basicgraphicslayouts/CMakeLists.txt
+++ b/examples/widgets/graphicsview/basicgraphicslayouts/CMakeLists.txt
@@ -1,46 +1,36 @@
-# Generated from basicgraphicslayouts.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(basicgraphicslayouts LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/basicgraphicslayouts")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(basicgraphicslayouts
layoutitem.cpp layoutitem.h
main.cpp
window.cpp window.h
)
+
set_target_properties(basicgraphicslayouts PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(basicgraphicslayouts_resource_files
"images/block.png"
)
-qt6_add_resources(basicgraphicslayouts "basicgraphicslayouts"
+qt_add_resources(basicgraphicslayouts "basicgraphicslayouts"
PREFIX
"/"
FILES
@@ -48,7 +38,14 @@ qt6_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/basicgraphicslayouts/layoutitem.cpp b/examples/widgets/graphicsview/basicgraphicslayouts/layoutitem.cpp
index 2fbc232b20..fd240df4d7 100644
--- a/examples/widgets/graphicsview/basicgraphicslayouts/layoutitem.cpp
+++ b/examples/widgets/graphicsview/basicgraphicslayouts/layoutitem.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "layoutitem.h"
diff --git a/examples/widgets/graphicsview/basicgraphicslayouts/layoutitem.h b/examples/widgets/graphicsview/basicgraphicslayouts/layoutitem.h
index 3dc431d513..3da8a02763 100644
--- a/examples/widgets/graphicsview/basicgraphicslayouts/layoutitem.h
+++ b/examples/widgets/graphicsview/basicgraphicslayouts/layoutitem.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef LAYOUTITEM_H
#define LAYOUTITEM_H
diff --git a/examples/widgets/graphicsview/basicgraphicslayouts/main.cpp b/examples/widgets/graphicsview/basicgraphicslayouts/main.cpp
index 7935b99765..f5601f62a9 100644
--- a/examples/widgets/graphicsview/basicgraphicslayouts/main.cpp
+++ b/examples/widgets/graphicsview/basicgraphicslayouts/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
diff --git a/examples/widgets/graphicsview/basicgraphicslayouts/window.cpp b/examples/widgets/graphicsview/basicgraphicslayouts/window.cpp
index a6edc9d0ed..a06a3d3d0e 100644
--- a/examples/widgets/graphicsview/basicgraphicslayouts/window.cpp
+++ b/examples/widgets/graphicsview/basicgraphicslayouts/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
#include "layoutitem.h"
diff --git a/examples/widgets/graphicsview/basicgraphicslayouts/window.h b/examples/widgets/graphicsview/basicgraphicslayouts/window.h
index c46082e552..d52b236759 100644
--- a/examples/widgets/graphicsview/basicgraphicslayouts/window.h
+++ b/examples/widgets/graphicsview/basicgraphicslayouts/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
diff --git a/examples/widgets/graphicsview/chip/.prev_CMakeLists.txt b/examples/widgets/graphicsview/chip/.prev_CMakeLists.txt
deleted file mode 100644
index 1140aeb969..0000000000
--- a/examples/widgets/graphicsview/chip/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-# Generated from chip.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(chip LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/chip")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(chip
- chip.cpp chip.h
- main.cpp
- mainwindow.cpp mainwindow.h
- view.cpp view.h
-)
-set_target_properties(chip PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(chip PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set(images_resource_files
- "fileprint.png"
- "qt4logo.png"
- "rotateleft.png"
- "rotateright.png"
- "zoomin.png"
- "zoomout.png"
-)
-
-qt6_add_resources(chip "images"
- PREFIX
- "/"
- FILES
- ${images_resource_files}
-)
-
-if(TARGET Qt::PrintSupport)
- target_link_libraries(chip PUBLIC
- Qt::PrintSupport
- )
-endif()
-
-install(TARGETS chip
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/graphicsview/chip/CMakeLists.txt b/examples/widgets/graphicsview/chip/CMakeLists.txt
index cb3e95a43c..81b2e19552 100644
--- a/examples/widgets/graphicsview/chip/CMakeLists.txt
+++ b/examples/widgets/graphicsview/chip/CMakeLists.txt
@@ -1,25 +1,15 @@
-# Generated from chip.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(chip LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC 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
+)
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS OpenGL) # special case
-find_package(Qt6 COMPONENTS PrintSupport) # special case
+qt_standard_project_setup()
qt_add_executable(chip
chip.cpp chip.h
@@ -27,16 +17,17 @@ qt_add_executable(chip
mainwindow.cpp mainwindow.h
view.cpp view.h
)
+
set_target_properties(chip PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(images_resource_files
@@ -48,21 +39,26 @@ set(images_resource_files
"zoomout.png"
)
-qt6_add_resources(chip "images"
+qt_add_resources(chip "images"
PREFIX
"/"
FILES
${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/chip.cpp b/examples/widgets/graphicsview/chip/chip.cpp
index 25f4ccc2e9..c1a539eddb 100644
--- a/examples/widgets/graphicsview/chip/chip.cpp
+++ b/examples/widgets/graphicsview/chip/chip.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "chip.h"
diff --git a/examples/widgets/graphicsview/chip/chip.h b/examples/widgets/graphicsview/chip/chip.h
index 6c36ccb6d3..5eac4be7d9 100644
--- a/examples/widgets/graphicsview/chip/chip.h
+++ b/examples/widgets/graphicsview/chip/chip.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CHIP_H
#define CHIP_H
diff --git a/examples/widgets/graphicsview/chip/main.cpp b/examples/widgets/graphicsview/chip/main.cpp
index 5c64adb7bd..4ccd66bbb9 100644
--- a/examples/widgets/graphicsview/chip/main.cpp
+++ b/examples/widgets/graphicsview/chip/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
@@ -54,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 f2f89c8722..8b4f5b27fd 100644
--- a/examples/widgets/graphicsview/chip/mainwindow.cpp
+++ b/examples/widgets/graphicsview/chip/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "chip.h"
#include "mainwindow.h"
@@ -95,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;
@@ -108,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/chip/mainwindow.h b/examples/widgets/graphicsview/chip/mainwindow.h
index 3f91b2efb4..c8fca23a1c 100644
--- a/examples/widgets/graphicsview/chip/mainwindow.h
+++ b/examples/widgets/graphicsview/chip/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/widgets/graphicsview/chip/view.cpp b/examples/widgets/graphicsview/chip/view.cpp
index 186b24655b..edd5f2d3d4 100644
--- a/examples/widgets/graphicsview/chip/view.cpp
+++ b/examples/widgets/graphicsview/chip/view.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "view.h"
@@ -65,9 +18,9 @@ void GraphicsView::wheelEvent(QWheelEvent *e)
{
if (e->modifiers() & Qt::ControlModifier) {
if (e->angleDelta().y() > 0)
- view->zoomIn(6);
+ view->zoomInBy(6);
else
- view->zoomOut(6);
+ view->zoomOutBy(6);
e->accept();
} else {
QGraphicsView::wheelEvent(e);
@@ -253,12 +206,22 @@ void View::print()
#endif
}
-void View::zoomIn(int level)
+void View::zoomIn()
+{
+ zoomSlider->setValue(zoomSlider->value() + 1);
+}
+
+void View::zoomOut()
+{
+ zoomSlider->setValue(zoomSlider->value() - 1);
+}
+
+void View::zoomInBy(int level)
{
zoomSlider->setValue(zoomSlider->value() + level);
}
-void View::zoomOut(int level)
+void View::zoomOutBy(int level)
{
zoomSlider->setValue(zoomSlider->value() - level);
}
diff --git a/examples/widgets/graphicsview/chip/view.h b/examples/widgets/graphicsview/chip/view.h
index b780702c34..1724178939 100644
--- a/examples/widgets/graphicsview/chip/view.h
+++ b/examples/widgets/graphicsview/chip/view.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef VIEW_H
#define VIEW_H
@@ -86,8 +39,10 @@ public:
QGraphicsView *view() const;
public slots:
- void zoomIn(int level = 1);
- void zoomOut(int level = 1);
+ void zoomIn();
+ void zoomOut();
+ void zoomInBy(int level);
+ void zoomOutBy(int level);
private slots:
void resetView();
diff --git a/examples/widgets/graphicsview/collidingmice/CMakeLists.txt b/examples/widgets/graphicsview/collidingmice/CMakeLists.txt
index 6b13244042..226b72b051 100644
--- a/examples/widgets/graphicsview/collidingmice/CMakeLists.txt
+++ b/examples/widgets/graphicsview/collidingmice/CMakeLists.txt
@@ -1,45 +1,35 @@
-# Generated from collidingmice.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(collidingmice LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/collidingmice")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(collidingmice
main.cpp
mouse.cpp mouse.h
)
+
set_target_properties(collidingmice PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(mice_resource_files
"images/cheese.jpg"
)
-qt6_add_resources(collidingmice "mice"
+qt_add_resources(collidingmice "mice"
PREFIX
"/"
FILES
@@ -47,7 +37,14 @@ qt6_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/collidingmice/main.cpp b/examples/widgets/graphicsview/collidingmice/main.cpp
index ef6d6cca64..5d70303174 100644
--- a/examples/widgets/graphicsview/collidingmice/main.cpp
+++ b/examples/widgets/graphicsview/collidingmice/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtMath>
#include <QtWidgets>
diff --git a/examples/widgets/graphicsview/collidingmice/mouse.cpp b/examples/widgets/graphicsview/collidingmice/mouse.cpp
index 8375092c39..60723fda9a 100644
--- a/examples/widgets/graphicsview/collidingmice/mouse.cpp
+++ b/examples/widgets/graphicsview/collidingmice/mouse.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mouse.h"
diff --git a/examples/widgets/graphicsview/collidingmice/mouse.h b/examples/widgets/graphicsview/collidingmice/mouse.h
index 4b165fced6..8ddb5d5637 100644
--- a/examples/widgets/graphicsview/collidingmice/mouse.h
+++ b/examples/widgets/graphicsview/collidingmice/mouse.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MOUSE_H
#define MOUSE_H
diff --git a/examples/widgets/graphicsview/diagramscene/CMakeLists.txt b/examples/widgets/graphicsview/diagramscene/CMakeLists.txt
index 89bcc6f4cb..9db835478d 100644
--- a/examples/widgets/graphicsview/diagramscene/CMakeLists.txt
+++ b/examples/widgets/graphicsview/diagramscene/CMakeLists.txt
@@ -1,23 +1,12 @@
-# Generated from diagramscene.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(diagramscene LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/diagramscene")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(diagramscene
arrow.cpp arrow.h
@@ -27,16 +16,17 @@ qt_add_executable(diagramscene
main.cpp
mainwindow.cpp mainwindow.h
)
+
set_target_properties(diagramscene PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(diagramscene_resource_files
@@ -57,7 +47,7 @@ set(diagramscene_resource_files
"images/underline.png"
)
-qt6_add_resources(diagramscene "diagramscene"
+qt_add_resources(diagramscene "diagramscene"
PREFIX
"/"
FILES
@@ -65,7 +55,14 @@ qt6_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/arrow.cpp b/examples/widgets/graphicsview/diagramscene/arrow.cpp
index 9b2472bb33..007d9fcb77 100644
--- a/examples/widgets/graphicsview/diagramscene/arrow.cpp
+++ b/examples/widgets/graphicsview/diagramscene/arrow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "arrow.h"
diff --git a/examples/widgets/graphicsview/diagramscene/arrow.h b/examples/widgets/graphicsview/diagramscene/arrow.h
index 13001959bd..f0fc404fad 100644
--- a/examples/widgets/graphicsview/diagramscene/arrow.h
+++ b/examples/widgets/graphicsview/diagramscene/arrow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef ARROW_H
#define ARROW_H
diff --git a/examples/widgets/graphicsview/diagramscene/diagramitem.cpp b/examples/widgets/graphicsview/diagramscene/diagramitem.cpp
index 8ec577170b..82b832837b 100644
--- a/examples/widgets/graphicsview/diagramscene/diagramitem.cpp
+++ b/examples/widgets/graphicsview/diagramscene/diagramitem.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "diagramitem.h"
#include "arrow.h"
@@ -144,7 +97,7 @@ void DiagramItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
scene()->clearSelection();
setSelected(true);
- myContextMenu->exec(event->screenPos());
+ myContextMenu->popup(event->screenPos());
}
//! [5]
@@ -152,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/diagramitem.h b/examples/widgets/graphicsview/diagramscene/diagramitem.h
index 0fc286b2a8..7cd7292d7a 100644
--- a/examples/widgets/graphicsview/diagramscene/diagramitem.h
+++ b/examples/widgets/graphicsview/diagramscene/diagramitem.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DIAGRAMITEM_H
#define DIAGRAMITEM_H
diff --git a/examples/widgets/graphicsview/diagramscene/diagramscene.cpp b/examples/widgets/graphicsview/diagramscene/diagramscene.cpp
index d0688d8552..659f2ec851 100644
--- a/examples/widgets/graphicsview/diagramscene/diagramscene.cpp
+++ b/examples/widgets/graphicsview/diagramscene/diagramscene.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "diagramscene.h"
#include "arrow.h"
diff --git a/examples/widgets/graphicsview/diagramscene/diagramscene.h b/examples/widgets/graphicsview/diagramscene/diagramscene.h
index 5682468ef6..a4cc32d885 100644
--- a/examples/widgets/graphicsview/diagramscene/diagramscene.h
+++ b/examples/widgets/graphicsview/diagramscene/diagramscene.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DIAGRAMSCENE_H
#define DIAGRAMSCENE_H
diff --git a/examples/widgets/graphicsview/diagramscene/diagramtextitem.cpp b/examples/widgets/graphicsview/diagramscene/diagramtextitem.cpp
index 738329d44a..b7eacec13f 100644
--- a/examples/widgets/graphicsview/diagramscene/diagramtextitem.cpp
+++ b/examples/widgets/graphicsview/diagramscene/diagramtextitem.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "diagramtextitem.h"
#include "diagramscene.h"
diff --git a/examples/widgets/graphicsview/diagramscene/diagramtextitem.h b/examples/widgets/graphicsview/diagramscene/diagramtextitem.h
index 7809609e24..cd1d6f954a 100644
--- a/examples/widgets/graphicsview/diagramscene/diagramtextitem.h
+++ b/examples/widgets/graphicsview/diagramscene/diagramtextitem.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DIAGRAMTEXTITEM_H
#define DIAGRAMTEXTITEM_H
diff --git a/examples/widgets/graphicsview/diagramscene/main.cpp b/examples/widgets/graphicsview/diagramscene/main.cpp
index eefaa86554..699c33f079 100644
--- a/examples/widgets/graphicsview/diagramscene/main.cpp
+++ b/examples/widgets/graphicsview/diagramscene/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
@@ -54,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 58b959dd10..7588e43701 100644
--- a/examples/widgets/graphicsview/diagramscene/mainwindow.cpp
+++ b/examples/widgets/graphicsview/diagramscene/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "arrow.h"
#include "diagramitem.h"
@@ -134,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);
@@ -145,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);
@@ -479,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);
@@ -489,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));
@@ -499,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));
@@ -594,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;
@@ -607,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 9fcd1884ca..fe8a91901f 100644
--- a/examples/widgets/graphicsview/diagramscene/mainwindow.h
+++ b/examples/widgets/graphicsview/diagramscene/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@@ -111,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 9cf79ba53e..df2425260e 100644
--- a/examples/widgets/graphicsview/dragdroprobot/CMakeLists.txt
+++ b/examples/widgets/graphicsview/dragdroprobot/CMakeLists.txt
@@ -1,46 +1,36 @@
-# Generated from dragdroprobot.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(dragdroprobot LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/dragdroprobot")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(dragdroprobot
coloritem.cpp coloritem.h
main.cpp
robot.cpp robot.h
)
+
set_target_properties(dragdroprobot PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(robot_resource_files
"images/head.png"
)
-qt6_add_resources(dragdroprobot "robot"
+qt_add_resources(dragdroprobot "robot"
PREFIX
"/"
FILES
@@ -48,7 +38,14 @@ qt6_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/dragdroprobot/coloritem.cpp b/examples/widgets/graphicsview/dragdroprobot/coloritem.cpp
index 23fb5fda50..f2bcda6bb8 100644
--- a/examples/widgets/graphicsview/dragdroprobot/coloritem.cpp
+++ b/examples/widgets/graphicsview/dragdroprobot/coloritem.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "coloritem.h"
diff --git a/examples/widgets/graphicsview/dragdroprobot/coloritem.h b/examples/widgets/graphicsview/dragdroprobot/coloritem.h
index 7701928c27..c0639f4c28 100644
--- a/examples/widgets/graphicsview/dragdroprobot/coloritem.h
+++ b/examples/widgets/graphicsview/dragdroprobot/coloritem.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef COLORITEM_H
#define COLORITEM_H
diff --git a/examples/widgets/graphicsview/dragdroprobot/main.cpp b/examples/widgets/graphicsview/dragdroprobot/main.cpp
index b00e9705d4..b0c5d6b59b 100644
--- a/examples/widgets/graphicsview/dragdroprobot/main.cpp
+++ b/examples/widgets/graphicsview/dragdroprobot/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QGraphicsScene>
diff --git a/examples/widgets/graphicsview/dragdroprobot/robot.cpp b/examples/widgets/graphicsview/dragdroprobot/robot.cpp
index 7457dabf8a..68793e129e 100644
--- a/examples/widgets/graphicsview/dragdroprobot/robot.cpp
+++ b/examples/widgets/graphicsview/dragdroprobot/robot.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "robot.h"
diff --git a/examples/widgets/graphicsview/dragdroprobot/robot.h b/examples/widgets/graphicsview/dragdroprobot/robot.h
index 67f6bb4100..a8a66c0616 100644
--- a/examples/widgets/graphicsview/dragdroprobot/robot.h
+++ b/examples/widgets/graphicsview/dragdroprobot/robot.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef ROBOT_H
#define ROBOT_H
diff --git a/examples/widgets/graphicsview/elasticnodes/CMakeLists.txt b/examples/widgets/graphicsview/elasticnodes/CMakeLists.txt
index c25df365fb..07299cd5a7 100644
--- a/examples/widgets/graphicsview/elasticnodes/CMakeLists.txt
+++ b/examples/widgets/graphicsview/elasticnodes/CMakeLists.txt
@@ -1,23 +1,12 @@
-# Generated from elasticnodes.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(elasticnodes LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/elasticnodes")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(elasticnodes
edge.cpp edge.h
@@ -25,18 +14,27 @@ qt_add_executable(elasticnodes
main.cpp
node.cpp node.h
)
+
set_target_properties(elasticnodes PROPERTIES
WIN32_EXECUTABLE TRUE
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/edge.cpp b/examples/widgets/graphicsview/elasticnodes/edge.cpp
index 9ca8b37f3d..6a7b041b77 100644
--- a/examples/widgets/graphicsview/elasticnodes/edge.cpp
+++ b/examples/widgets/graphicsview/elasticnodes/edge.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "edge.h"
#include "node.h"
diff --git a/examples/widgets/graphicsview/elasticnodes/edge.h b/examples/widgets/graphicsview/elasticnodes/edge.h
index 048d3ffd02..dd288dcba8 100644
--- a/examples/widgets/graphicsview/elasticnodes/edge.h
+++ b/examples/widgets/graphicsview/elasticnodes/edge.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef EDGE_H
#define EDGE_H
diff --git a/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp b/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
index 51e179a464..ede3d23137 100644
--- a/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
+++ b/examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "graphwidget.h"
#include "edge.h"
@@ -170,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/graphwidget.h b/examples/widgets/graphicsview/elasticnodes/graphwidget.h
index 6d241fa9f1..a75f5e2bbe 100644
--- a/examples/widgets/graphicsview/elasticnodes/graphwidget.h
+++ b/examples/widgets/graphicsview/elasticnodes/graphwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef GRAPHWIDGET_H
#define GRAPHWIDGET_H
diff --git a/examples/widgets/graphicsview/elasticnodes/main.cpp b/examples/widgets/graphicsview/elasticnodes/main.cpp
index 1e372a9f6d..a516055b23 100644
--- a/examples/widgets/graphicsview/elasticnodes/main.cpp
+++ b/examples/widgets/graphicsview/elasticnodes/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "graphwidget.h"
diff --git a/examples/widgets/graphicsview/elasticnodes/node.cpp b/examples/widgets/graphicsview/elasticnodes/node.cpp
index 8d44a167fa..eb102f0aa4 100644
--- a/examples/widgets/graphicsview/elasticnodes/node.cpp
+++ b/examples/widgets/graphicsview/elasticnodes/node.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "edge.h"
#include "node.h"
@@ -114,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);
@@ -195,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/elasticnodes/node.h b/examples/widgets/graphicsview/elasticnodes/node.h
index 5ccc52595c..34596cd1aa 100644
--- a/examples/widgets/graphicsview/elasticnodes/node.h
+++ b/examples/widgets/graphicsview/elasticnodes/node.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef NODE_H
#define NODE_H
diff --git a/examples/widgets/graphicsview/embeddeddialogs/CMakeLists.txt b/examples/widgets/graphicsview/embeddeddialogs/CMakeLists.txt
deleted file mode 100644
index 5f69077802..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/CMakeLists.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-# Generated from embeddeddialogs.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(embeddeddialogs LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC 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 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 6eda94e8ba..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/customproxy.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 5aa0250a29..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/customproxy.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 2f1d9a330c..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 c2d87a5660..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/embeddeddialog.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 501405e3ff..0000000000
--- a/examples/widgets/graphicsview/embeddeddialogs/main.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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/.prev_CMakeLists.txt b/examples/widgets/graphicsview/flowlayout/.prev_CMakeLists.txt
deleted file mode 100644
index 4208ba303e..0000000000
--- a/examples/widgets/graphicsview/flowlayout/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from flowlayout.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(flowlayout LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/flowlayout")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(flowlayout
- flowlayout.cpp flowlayout.h
- main.cpp
- window.cpp window.h
-)
-set_target_properties(flowlayout PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(flowlayout PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS flowlayout
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/graphicsview/flowlayout/CMakeLists.txt b/examples/widgets/graphicsview/flowlayout/CMakeLists.txt
deleted file mode 100644
index 4062c1d902..0000000000
--- a/examples/widgets/graphicsview/flowlayout/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from flowlayout.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(flowlayout LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview_flowlayout") # special case
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(graphicsview_flowlayout # special case: renamed flowlayout
- flowlayout.cpp flowlayout.h
- main.cpp
- window.cpp window.h
-)
-set_target_properties(graphicsview_flowlayout PROPERTIES # special case
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(graphicsview_flowlayout PUBLIC # special case
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS graphicsview_flowlayout # special case: renamed 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 03cf320568..0000000000
--- a/examples/widgets/graphicsview/flowlayout/flowlayout.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 14251072ec..0000000000
--- a/examples/widgets/graphicsview/flowlayout/flowlayout.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 dbfed51bb3..0000000000
--- a/examples/widgets/graphicsview/flowlayout/main.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-//! [1]
-#include "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 d0dee2081c..0000000000
--- a/examples/widgets/graphicsview/flowlayout/window.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 24a7cf908b..0000000000
--- a/examples/widgets/graphicsview/flowlayout/window.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 8403fb0a0a..2f31e12bbf 100644
--- a/examples/widgets/graphicsview/simpleanchorlayout/CMakeLists.txt
+++ b/examples/widgets/graphicsview/simpleanchorlayout/CMakeLists.txt
@@ -1,39 +1,37 @@
-# Generated from simpleanchorlayout.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(simpleanchorlayout LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/simpleanchorlayout")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(simpleanchorlayout
main.cpp
)
+
set_target_properties(simpleanchorlayout PROPERTIES
WIN32_EXECUTABLE TRUE
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/simpleanchorlayout/main.cpp b/examples/widgets/graphicsview/simpleanchorlayout/main.cpp
index a5f450c1f9..5be8f3f4fc 100644
--- a/examples/widgets/graphicsview/simpleanchorlayout/main.cpp
+++ b/examples/widgets/graphicsview/simpleanchorlayout/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
diff --git a/examples/widgets/graphicsview/weatheranchorlayout/CMakeLists.txt b/examples/widgets/graphicsview/weatheranchorlayout/CMakeLists.txt
deleted file mode 100644
index 43bd29452e..0000000000
--- a/examples/widgets/graphicsview/weatheranchorlayout/CMakeLists.txt
+++ /dev/null
@@ -1,57 +0,0 @@
-# Generated from weatheranchorlayout.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(weatheranchorlayout LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/graphicsview/weatheranchorlayout")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 5c623b1d00..0000000000
--- a/examples/widgets/graphicsview/weatheranchorlayout/main.cpp
+++ /dev/null
@@ -1,286 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <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/.prev_CMakeLists.txt b/examples/widgets/itemviews/.prev_CMakeLists.txt
deleted file mode 100644
index 96f03a2e61..0000000000
--- a/examples/widgets/itemviews/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-# Generated from itemviews.pro.
-
-add_subdirectory(addressbook)
-add_subdirectory(basicsortfiltermodel)
-add_subdirectory(chart)
-add_subdirectory(coloreditorfactory)
-add_subdirectory(combowidgetmapper)
-add_subdirectory(customsortfiltermodel)
-add_subdirectory(dirview)
-add_subdirectory(editabletreemodel)
-add_subdirectory(fetchmore)
-add_subdirectory(flattreeview)
-add_subdirectory(frozencolumn)
-add_subdirectory(interview)
-add_subdirectory(pixelator)
-add_subdirectory(simpletreemodel)
-add_subdirectory(simplewidgetmapper)
-add_subdirectory(spinboxdelegate)
-add_subdirectory(spreadsheet)
-add_subdirectory(stardelegate)
-add_subdirectory(storageview)
-if(QT_FEATURE_draganddrop)
- add_subdirectory(puzzle)
-endif()
-if(TARGET Qt::Xml)
- add_subdirectory(simpledommodel)
-endif()
diff --git a/examples/widgets/itemviews/CMakeLists.txt b/examples/widgets/itemviews/CMakeLists.txt
index 96f03a2e61..e80d90160b 100644
--- a/examples/widgets/itemviews/CMakeLists.txt
+++ b/examples/widgets/itemviews/CMakeLists.txt
@@ -1,27 +1,12 @@
-# Generated from itemviews.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(addressbook)
-add_subdirectory(basicsortfiltermodel)
-add_subdirectory(chart)
-add_subdirectory(coloreditorfactory)
-add_subdirectory(combowidgetmapper)
-add_subdirectory(customsortfiltermodel)
-add_subdirectory(dirview)
-add_subdirectory(editabletreemodel)
-add_subdirectory(fetchmore)
-add_subdirectory(flattreeview)
-add_subdirectory(frozencolumn)
-add_subdirectory(interview)
-add_subdirectory(pixelator)
-add_subdirectory(simpletreemodel)
-add_subdirectory(simplewidgetmapper)
-add_subdirectory(spinboxdelegate)
-add_subdirectory(spreadsheet)
-add_subdirectory(stardelegate)
-add_subdirectory(storageview)
-if(QT_FEATURE_draganddrop)
- add_subdirectory(puzzle)
-endif()
-if(TARGET Qt::Xml)
- add_subdirectory(simpledommodel)
-endif()
+qt_internal_add_example(addressbook)
+qt_internal_add_example(basicsortfiltermodel)
+qt_internal_add_example(combowidgetmapper)
+qt_internal_add_example(customsortfiltermodel)
+qt_internal_add_example(editabletreemodel)
+qt_internal_add_example(fetchmore)
+qt_internal_add_example(frozencolumn)
+qt_internal_add_example(spreadsheet)
+qt_internal_add_example(stardelegate)
diff --git a/examples/widgets/itemviews/addressbook/CMakeLists.txt b/examples/widgets/itemviews/addressbook/CMakeLists.txt
index 0383a1edf8..91e9cd03c9 100644
--- a/examples/widgets/itemviews/addressbook/CMakeLists.txt
+++ b/examples/widgets/itemviews/addressbook/CMakeLists.txt
@@ -1,23 +1,12 @@
-# Generated from addressbook.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(addressbook LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/addressbook")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(addressbook
adddialog.cpp adddialog.h
@@ -27,18 +16,27 @@ qt_add_executable(addressbook
newaddresstab.cpp newaddresstab.h
tablemodel.cpp tablemodel.h
)
+
set_target_properties(addressbook PROPERTIES
WIN32_EXECUTABLE TRUE
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/adddialog.cpp b/examples/widgets/itemviews/addressbook/adddialog.cpp
index bf87307253..96877661bb 100644
--- a/examples/widgets/itemviews/addressbook/adddialog.cpp
+++ b/examples/widgets/itemviews/addressbook/adddialog.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "adddialog.h"
diff --git a/examples/widgets/itemviews/addressbook/adddialog.h b/examples/widgets/itemviews/addressbook/adddialog.h
index 2867034122..4984e86ddc 100644
--- a/examples/widgets/itemviews/addressbook/adddialog.h
+++ b/examples/widgets/itemviews/addressbook/adddialog.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef ADDDIALOG_H
#define ADDDIALOG_H
diff --git a/examples/widgets/itemviews/addressbook/addresswidget.cpp b/examples/widgets/itemviews/addressbook/addresswidget.cpp
index 25706d1abe..5b226793e4 100644
--- a/examples/widgets/itemviews/addressbook/addresswidget.cpp
+++ b/examples/widgets/itemviews/addressbook/addresswidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "addresswidget.h"
#include "adddialog.h"
@@ -81,7 +34,10 @@ void AddressWidget::showAddEntryDialog()
//! [3]
void AddressWidget::addEntry(const QString &name, const QString &address)
{
- if (!table->getContacts().contains({ name, address })) {
+ if (!name.front().isLetter()) {
+ QMessageBox::information(this, tr("Invalid name"),
+ tr("The name must start with a letter."));
+ } else if (!table->getContacts().contains({ name, address })) {
table->insertRows(0, 1, QModelIndex());
QModelIndex index = table->index(0, 0, QModelIndex());
@@ -157,10 +113,12 @@ void AddressWidget::removeEntry()
//! [1]
void AddressWidget::setupTabs()
{
- const auto groups = { "ABC", "DEF", "GHI", "JKL", "MNO", "PQR", "STU", "VW", "XYZ" };
+ using namespace Qt::StringLiterals;
+ const auto groups = { "ABC"_L1, "DEF"_L1, "GHI"_L1, "JKL"_L1, "MNO"_L1, "PQR"_L1,
+ "STU"_L1, "VW"_L1, "XYZ"_L1 };
- for (const QString &str : groups) {
- const auto regExp = QRegularExpression(QString("^[%1].*").arg(str),
+ for (QLatin1StringView str : groups) {
+ const auto regExp = QRegularExpression(QLatin1StringView("^[%1].*").arg(str),
QRegularExpression::CaseInsensitiveOption);
auto proxyModel = new QSortFilterProxyModel(this);
@@ -191,7 +149,7 @@ void AddressWidget::setupTabs()
//! [1]
//! [7]
-void AddressWidget::readFromFile(const QString &fileName)
+void AddressWidget::readFromFile()
{
QFile file(fileName);
@@ -209,14 +167,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 111ea98328..c5c710286a 100644
--- a/examples/widgets/itemviews/addressbook/addresswidget.h
+++ b/examples/widgets/itemviews/addressbook/addresswidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef ADDRESSWIDGET_H
#define ADDRESSWIDGET_H
@@ -56,6 +9,7 @@
#include <QItemSelection>
#include <QTabWidget>
+#include <QStandardPaths>
QT_BEGIN_NAMESPACE
class QSortFilterProxyModel;
@@ -69,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();
@@ -84,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/main.cpp b/examples/widgets/itemviews/addressbook/main.cpp
index 0731287cdd..8aaf0fe348 100644
--- a/examples/widgets/itemviews/addressbook/main.cpp
+++ b/examples/widgets/itemviews/addressbook/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
diff --git a/examples/widgets/itemviews/addressbook/mainwindow.cpp b/examples/widgets/itemviews/addressbook/mainwindow.cpp
index 42966de375..ce37b523f3 100644
--- a/examples/widgets/itemviews/addressbook/mainwindow.cpp
+++ b/examples/widgets/itemviews/addressbook/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
@@ -75,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);
@@ -113,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/addressbook/mainwindow.h b/examples/widgets/itemviews/addressbook/mainwindow.h
index fca5934e68..8831d78e92 100644
--- a/examples/widgets/itemviews/addressbook/mainwindow.h
+++ b/examples/widgets/itemviews/addressbook/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/widgets/itemviews/addressbook/newaddresstab.cpp b/examples/widgets/itemviews/addressbook/newaddresstab.cpp
index ef725d723f..4ab85aadaf 100644
--- a/examples/widgets/itemviews/addressbook/newaddresstab.cpp
+++ b/examples/widgets/itemviews/addressbook/newaddresstab.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "newaddresstab.h"
#include "adddialog.h"
diff --git a/examples/widgets/itemviews/addressbook/newaddresstab.h b/examples/widgets/itemviews/addressbook/newaddresstab.h
index 6a147e3c7c..3f21a7271b 100644
--- a/examples/widgets/itemviews/addressbook/newaddresstab.h
+++ b/examples/widgets/itemviews/addressbook/newaddresstab.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef NEWADDRESSTAB_H
#define NEWADDRESSTAB_H
diff --git a/examples/widgets/itemviews/addressbook/tablemodel.cpp b/examples/widgets/itemviews/addressbook/tablemodel.cpp
index aac4c92060..2d7ab69eb8 100644
--- a/examples/widgets/itemviews/addressbook/tablemodel.cpp
+++ b/examples/widgets/itemviews/addressbook/tablemodel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "tablemodel.h"
diff --git a/examples/widgets/itemviews/addressbook/tablemodel.h b/examples/widgets/itemviews/addressbook/tablemodel.h
index c5bac4f4a4..4a9778c7b9 100644
--- a/examples/widgets/itemviews/addressbook/tablemodel.h
+++ b/examples/widgets/itemviews/addressbook/tablemodel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TABLEMODEL_H
#define TABLEMODEL_H
diff --git a/examples/widgets/itemviews/basicsortfiltermodel/CMakeLists.txt b/examples/widgets/itemviews/basicsortfiltermodel/CMakeLists.txt
index cd70de6907..da15c4c196 100644
--- a/examples/widgets/itemviews/basicsortfiltermodel/CMakeLists.txt
+++ b/examples/widgets/itemviews/basicsortfiltermodel/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from basicsortfiltermodel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(basicsortfiltermodel LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/basicsortfiltermodel")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(basicsortfiltermodel
main.cpp
window.cpp window.h
)
+
set_target_properties(basicsortfiltermodel PROPERTIES
WIN32_EXECUTABLE TRUE
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/basicsortfiltermodel/main.cpp b/examples/widgets/itemviews/basicsortfiltermodel/main.cpp
index c682b4466b..db132760af 100644
--- a/examples/widgets/itemviews/basicsortfiltermodel/main.cpp
+++ b/examples/widgets/itemviews/basicsortfiltermodel/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
diff --git a/examples/widgets/itemviews/basicsortfiltermodel/window.cpp b/examples/widgets/itemviews/basicsortfiltermodel/window.cpp
index 3f22ab4f3c..3e2e3fbefa 100644
--- a/examples/widgets/itemviews/basicsortfiltermodel/window.cpp
+++ b/examples/widgets/itemviews/basicsortfiltermodel/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
diff --git a/examples/widgets/itemviews/basicsortfiltermodel/window.h b/examples/widgets/itemviews/basicsortfiltermodel/window.h
index 137b0de712..1ff060d9ad 100644
--- a/examples/widgets/itemviews/basicsortfiltermodel/window.h
+++ b/examples/widgets/itemviews/basicsortfiltermodel/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
diff --git a/examples/widgets/itemviews/chart/CMakeLists.txt b/examples/widgets/itemviews/chart/CMakeLists.txt
deleted file mode 100644
index c0a9d66099..0000000000
--- a/examples/widgets/itemviews/chart/CMakeLists.txt
+++ /dev/null
@@ -1,60 +0,0 @@
-# Generated from chart.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(chart LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/chart")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 4c25159fd7..0000000000
--- a/examples/widgets/itemviews/chart/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 671cfb1941..0000000000
--- a/examples/widgets/itemviews/chart/mainwindow.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 51176d261b..0000000000
--- a/examples/widgets/itemviews/chart/mainwindow.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 8ebe6a9d89..0000000000
--- a/examples/widgets/itemviews/chart/pieview.cpp
+++ /dev/null
@@ -1,557 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 f92a443463..0000000000
--- a/examples/widgets/itemviews/chart/pieview.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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
deleted file mode 100644
index 478c61dec7..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from coloreditorfactory.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(coloreditorfactory LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/coloreditorfactory")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(coloreditorfactory
- colorlisteditor.cpp colorlisteditor.h
- main.cpp
- window.cpp window.h
-)
-set_target_properties(coloreditorfactory PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(coloreditorfactory PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS coloreditorfactory
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/itemviews/coloreditorfactory/coloreditorfactory.pro b/examples/widgets/itemviews/coloreditorfactory/coloreditorfactory.pro
deleted file mode 100644
index 2d16ab5e2b..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/coloreditorfactory.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-QT += widgets
-requires(qtConfig(combobox))
-
-HEADERS = colorlisteditor.h \
- window.h
-SOURCES = colorlisteditor.cpp \
- window.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/itemviews/coloreditorfactory
-INSTALLS += target
diff --git a/examples/widgets/itemviews/coloreditorfactory/colorlisteditor.cpp b/examples/widgets/itemviews/coloreditorfactory/colorlisteditor.cpp
deleted file mode 100644
index 0b65c53477..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/colorlisteditor.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "colorlisteditor.h"
-
-#include <QtWidgets>
-
-ColorListEditor::ColorListEditor(QWidget *widget) : QComboBox(widget)
-{
- populateList();
-}
-
-//! [0]
-QColor ColorListEditor::color() const
-{
- return qvariant_cast<QColor>(itemData(currentIndex(), Qt::DecorationRole));
-}
-//! [0]
-
-//! [1]
-void ColorListEditor::setColor(const QColor &color)
-{
- setCurrentIndex(findData(color, Qt::DecorationRole));
-}
-//! [1]
-
-//! [2]
-void ColorListEditor::populateList()
-{
- const QStringList colorNames = QColor::colorNames();
-
- for (int i = 0; i < colorNames.size(); ++i) {
- QColor color(colorNames[i]);
-
- insertItem(i, colorNames[i]);
- setItemData(i, color, Qt::DecorationRole);
- }
-}
-//! [2]
diff --git a/examples/widgets/itemviews/coloreditorfactory/colorlisteditor.h b/examples/widgets/itemviews/coloreditorfactory/colorlisteditor.h
deleted file mode 100644
index f9d736d298..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/colorlisteditor.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef COLORLISTEDITOR_H
-#define COLORLISTEDITOR_H
-
-#include <QComboBox>
-
-QT_BEGIN_NAMESPACE
-class QColor;
-class QWidget;
-QT_END_NAMESPACE
-
-//! [0]
-class ColorListEditor : public QComboBox
-{
- Q_OBJECT
- Q_PROPERTY(QColor color READ color WRITE setColor USER true)
-
-public:
- ColorListEditor(QWidget *widget = nullptr);
-
-public:
- QColor color() const;
- void setColor(const QColor &color);
-
-private:
- void populateList();
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/itemviews/coloreditorfactory/main.cpp b/examples/widgets/itemviews/coloreditorfactory/main.cpp
deleted file mode 100644
index d712abc010..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "window.h"
-
-int main(int argv, char **args)
-{
- QApplication app(argv, args);
-
- Window window;
- window.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/itemviews/coloreditorfactory/window.cpp b/examples/widgets/itemviews/coloreditorfactory/window.cpp
deleted file mode 100644
index fde82accfd..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/window.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "window.h"
-#include "colorlisteditor.h"
-
-#include <QtWidgets>
-
-//! [0]
-Window::Window()
-{
- QItemEditorFactory *factory = new QItemEditorFactory;
-
- QItemEditorCreatorBase *colorListCreator =
- new QStandardItemEditorCreator<ColorListEditor>();
-
- factory->registerEditor(QMetaType::QColor, colorListCreator);
-
- QItemEditorFactory::setDefaultFactory(factory);
-
- createGUI();
-}
-//! [0]
-
-void Window::createGUI()
-{
- const QList<QPair<QString, QColor>> list = { { tr("Alice"), QColor("aliceblue") },
- { tr("Neptun"), QColor("aquamarine") },
- { tr("Ferdinand"), QColor("springgreen") } };
-
- QTableWidget *table = new QTableWidget(3, 2);
- table->setHorizontalHeaderLabels({ tr("Name"), tr("Hair Color") });
- table->verticalHeader()->setVisible(false);
- table->resize(150, 50);
-
- for (int i = 0; i < 3; ++i) {
- const QPair<QString, QColor> &pair = list.at(i);
-
- QTableWidgetItem *nameItem = new QTableWidgetItem(pair.first);
- QTableWidgetItem *colorItem = new QTableWidgetItem;
- colorItem->setData(Qt::DisplayRole, pair.second);
-
- table->setItem(i, 0, nameItem);
- table->setItem(i, 1, colorItem);
- }
- table->resizeColumnToContents(0);
- table->horizontalHeader()->setStretchLastSection(true);
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(table, 0, 0);
-
- setLayout(layout);
-
- setWindowTitle(tr("Color Editor Factory"));
-}
diff --git a/examples/widgets/itemviews/coloreditorfactory/window.h b/examples/widgets/itemviews/coloreditorfactory/window.h
deleted file mode 100644
index 59c97673b7..0000000000
--- a/examples/widgets/itemviews/coloreditorfactory/window.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <QWidget>
-
-class Window : public QWidget
-{
- Q_OBJECT
-
-public:
- Window();
-
-private:
- void createGUI();
-};
-
-#endif
diff --git a/examples/widgets/itemviews/combowidgetmapper/CMakeLists.txt b/examples/widgets/itemviews/combowidgetmapper/CMakeLists.txt
index b239e434e2..f95031b260 100644
--- a/examples/widgets/itemviews/combowidgetmapper/CMakeLists.txt
+++ b/examples/widgets/itemviews/combowidgetmapper/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from combowidgetmapper.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(combowidgetmapper LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/combowidgetmapper")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(combowidgetmapper
main.cpp
window.cpp window.h
)
+
set_target_properties(combowidgetmapper PROPERTIES
WIN32_EXECUTABLE TRUE
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/combowidgetmapper/main.cpp b/examples/widgets/itemviews/combowidgetmapper/main.cpp
index c53f3e2396..9c9f589816 100644
--- a/examples/widgets/itemviews/combowidgetmapper/main.cpp
+++ b/examples/widgets/itemviews/combowidgetmapper/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/itemviews/combowidgetmapper/window.cpp b/examples/widgets/itemviews/combowidgetmapper/window.cpp
index e79036063d..fc45b8b639 100644
--- a/examples/widgets/itemviews/combowidgetmapper/window.cpp
+++ b/examples/widgets/itemviews/combowidgetmapper/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include "window.h"
diff --git a/examples/widgets/itemviews/combowidgetmapper/window.h b/examples/widgets/itemviews/combowidgetmapper/window.h
index 78bd373c13..9f91808021 100644
--- a/examples/widgets/itemviews/combowidgetmapper/window.h
+++ b/examples/widgets/itemviews/combowidgetmapper/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
diff --git a/examples/widgets/itemviews/customsortfiltermodel/CMakeLists.txt b/examples/widgets/itemviews/customsortfiltermodel/CMakeLists.txt
index 9b20b76a9a..a1b2c41cf6 100644
--- a/examples/widgets/itemviews/customsortfiltermodel/CMakeLists.txt
+++ b/examples/widgets/itemviews/customsortfiltermodel/CMakeLists.txt
@@ -1,23 +1,12 @@
-# Generated from customsortfiltermodel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(customsortfiltermodel LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/customsortfiltermodel")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(customsortfiltermodel
filterwidget.cpp filterwidget.h
@@ -25,23 +14,24 @@ qt_add_executable(customsortfiltermodel
mysortfilterproxymodel.cpp mysortfilterproxymodel.h
window.cpp window.h
)
+
set_target_properties(customsortfiltermodel PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(customsortfiltermodel_resource_files
"images/find.png"
)
-qt6_add_resources(customsortfiltermodel "customsortfiltermodel"
+qt_add_resources(customsortfiltermodel "customsortfiltermodel"
PREFIX
"/"
FILES
@@ -49,7 +39,14 @@ qt6_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/customsortfiltermodel/filterwidget.cpp b/examples/widgets/itemviews/customsortfiltermodel/filterwidget.cpp
index bfcc8f84fb..7ccbeb08c3 100644
--- a/examples/widgets/itemviews/customsortfiltermodel/filterwidget.cpp
+++ b/examples/widgets/itemviews/customsortfiltermodel/filterwidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "filterwidget.h"
diff --git a/examples/widgets/itemviews/customsortfiltermodel/filterwidget.h b/examples/widgets/itemviews/customsortfiltermodel/filterwidget.h
index 0404d670b2..b0b8c615d1 100644
--- a/examples/widgets/itemviews/customsortfiltermodel/filterwidget.h
+++ b/examples/widgets/itemviews/customsortfiltermodel/filterwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FILTERWIDGET_H
#define FILTERWIDGET_H
diff --git a/examples/widgets/itemviews/customsortfiltermodel/main.cpp b/examples/widgets/itemviews/customsortfiltermodel/main.cpp
index 0ece5e8920..4eefd404e2 100644
--- a/examples/widgets/itemviews/customsortfiltermodel/main.cpp
+++ b/examples/widgets/itemviews/customsortfiltermodel/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
diff --git a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
index da31f8e361..736d3a4066 100644
--- a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
+++ b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mysortfilterproxymodel.h"
diff --git a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h
index 909949df8e..4a1c38c5ee 100644
--- a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h
+++ b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MYSORTFILTERPROXYMODEL_H
#define MYSORTFILTERPROXYMODEL_H
diff --git a/examples/widgets/itemviews/customsortfiltermodel/window.cpp b/examples/widgets/itemviews/customsortfiltermodel/window.cpp
index 3423ac4ee9..c00db1a972 100644
--- a/examples/widgets/itemviews/customsortfiltermodel/window.cpp
+++ b/examples/widgets/itemviews/customsortfiltermodel/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
#include "mysortfilterproxymodel.h"
diff --git a/examples/widgets/itemviews/customsortfiltermodel/window.h b/examples/widgets/itemviews/customsortfiltermodel/window.h
index 448ff05d7e..793e219251 100644
--- a/examples/widgets/itemviews/customsortfiltermodel/window.h
+++ b/examples/widgets/itemviews/customsortfiltermodel/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
diff --git a/examples/widgets/itemviews/dirview/CMakeLists.txt b/examples/widgets/itemviews/dirview/CMakeLists.txt
deleted file mode 100644
index 27ce1bc144..0000000000
--- a/examples/widgets/itemviews/dirview/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated from dirview.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(dirview LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/dirview")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 20e5d45c95..0000000000
--- a/examples/widgets/itemviews/dirview/main.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <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;
- 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 6ef311d960..e255cdbc63 100644
--- a/examples/widgets/itemviews/editabletreemodel/CMakeLists.txt
+++ b/examples/widgets/itemviews/editabletreemodel/CMakeLists.txt
@@ -1,23 +1,12 @@
-# Generated from editabletreemodel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(editabletreemodel LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Test Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/editabletreemodel")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(editabletreemodel
main.cpp
@@ -25,23 +14,24 @@ qt_add_executable(editabletreemodel
treeitem.cpp treeitem.h
treemodel.cpp treemodel.h
)
+
set_target_properties(editabletreemodel PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(editabletreemodel_resource_files
"default.txt"
)
-qt6_add_resources(editabletreemodel "editabletreemodel"
+qt_add_resources(editabletreemodel "editabletreemodel"
PREFIX
"/"
FILES
@@ -49,7 +39,46 @@ qt6_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 5e9ff214a3..7ed4cf1dc4 100644
--- a/examples/widgets/itemviews/editabletreemodel/main.cpp
+++ b/examples/widgets/itemviews/editabletreemodel/main.cpp
@@ -1,63 +1,17 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#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 7faa325469..cf88932cdb 100644
--- a/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp
+++ b/examples/widgets/itemviews/editabletreemodel/mainwindow.cpp
@@ -1,58 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "treemodel.h"
#include <QFile>
+using namespace Qt::StringLiterals;
+
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
@@ -60,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());
+ 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/mainwindow.h b/examples/widgets/itemviews/editabletreemodel/mainwindow.h
index 314b0cb1fa..541f7252fd 100644
--- a/examples/widgets/itemviews/editabletreemodel/mainwindow.h
+++ b/examples/widgets/itemviews/editabletreemodel/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
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 e82c84a424..42d911823d 100644
--- a/examples/widgets/itemviews/editabletreemodel/treeitem.cpp
+++ b/examples/widgets/itemviews/editabletreemodel/treeitem.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
/*
treeitem.cpp
@@ -57,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())
@@ -135,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)
{
@@ -170,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())
@@ -185,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 b23697efe3..8910312ade 100644
--- a/examples/widgets/itemviews/editabletreemodel/treeitem.h
+++ b/examples/widgets/itemviews/editabletreemodel/treeitem.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TREEITEM_H
#define TREEITEM_H
@@ -58,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;
@@ -70,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 1161a8b5d2..6511b06780 100644
--- a/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
+++ b/examples/widgets/itemviews/editabletreemodel/treemodel.cpp
@@ -1,76 +1,26 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#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]
@@ -84,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);
@@ -108,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]
@@ -172,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]
@@ -212,6 +156,9 @@ bool TreeModel::removeRows(int position, int rows, const QModelIndex &parent)
//! [8]
int TreeModel::rowCount(const QModelIndex &parent) const
{
+ if (parent.isValid() && parent.column() > 0)
+ return 0;
+
const TreeItem *parentItem = getItem(parent);
return parentItem ? parentItem->childCount() : 0;
@@ -246,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;
+ };
+
+ QList<ParentIndentation> state{{rootItem.get(), 0}};
- const QString lineData = lines[number].mid(position).trimmed();
+ 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 8419f9cb9d..4f781c8144 100644
--- a/examples/widgets/itemviews/editabletreemodel/treemodel.h
+++ b/examples/widgets/itemviews/editabletreemodel/treemodel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TREEMODEL_H
#define TREEMODEL_H
@@ -63,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;
@@ -73,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]
@@ -88,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 35ddc52aab..856b0cc3ba 100644
--- a/examples/widgets/itemviews/fetchmore/CMakeLists.txt
+++ b/examples/widgets/itemviews/fetchmore/CMakeLists.txt
@@ -1,41 +1,39 @@
-# Generated from fetchmore.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(fetchmore LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/fetchmore")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(fetchmore
filelistmodel.cpp filelistmodel.h
main.cpp
window.cpp window.h
)
+
set_target_properties(fetchmore PROPERTIES
WIN32_EXECUTABLE TRUE
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/fetchmore/filelistmodel.cpp b/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
index 3ee80617c0..94b00c5d09 100644
--- a/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
+++ b/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "filelistmodel.h"
@@ -54,8 +7,10 @@
#include <QDir>
#include <QPalette>
+static const int batchSize = 100;
+
FileListModel::FileListModel(QObject *parent)
- : QAbstractListModel(parent), fileCount(0)
+ : QAbstractListModel(parent)
{}
//![4]
@@ -67,24 +22,33 @@ int FileListModel::rowCount(const QModelIndex &parent) const
QVariant FileListModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
- return QVariant();
-
- if (index.row() >= fileList.size() || index.row() < 0)
- return QVariant();
-
- if (role == Qt::DisplayRole) {
- return fileList.at(index.row());
- } else if (role == Qt::BackgroundRole) {
- int batch = (index.row() / 100) % 2;
- if (batch == 0)
- return qApp->palette().base();
- else
- return qApp->palette().alternateBase();
+ return {};
+
+ const int row = index.row();
+ if (row >= fileList.size() || row < 0)
+ return {};
+
+ switch (role) {
+ case Qt::DisplayRole:
+ return fileList.at(row).fileName();
+ case Qt::BackgroundRole: {
+ const int batch = row / batchSize;
+ const QPalette &palette = QGuiApplication::palette();
+ return (batch % 2) != 0 ? palette.alternateBase() : palette.base();
+ }
+ case Qt::DecorationRole:
+ return iconProvider.icon(fileList.at(row));
}
- return QVariant();
+ return {};
}
+
//![4]
+QFileInfo FileListModel::fileInfoAt(const QModelIndex &index) const
+{
+ return fileList.at(index.row());
+}
+
//![1]
bool FileListModel::canFetchMore(const QModelIndex &parent) const
{
@@ -99,19 +63,20 @@ void FileListModel::fetchMore(const QModelIndex &parent)
{
if (parent.isValid())
return;
- int remainder = fileList.size() - fileCount;
- int itemsToFetch = qMin(100, remainder);
+ const int start = fileCount;
+ const int remainder = int(fileList.size()) - start;
+ const int itemsToFetch = qMin(batchSize, remainder);
if (itemsToFetch <= 0)
return;
- beginInsertRows(QModelIndex(), fileCount, fileCount + itemsToFetch - 1);
+ beginInsertRows(QModelIndex(), start, start + itemsToFetch - 1);
fileCount += itemsToFetch;
endInsertRows();
- emit numberPopulated(itemsToFetch);
+ emit numberPopulated(path, start, itemsToFetch, int(fileList.size()));
}
//![2]
@@ -121,7 +86,8 @@ void FileListModel::setDirPath(const QString &path)
QDir dir(path);
beginResetModel();
- fileList = dir.entryList();
+ this->path = path;
+ fileList = dir.entryInfoList(QDir::NoDot | QDir::AllEntries, QDir::Name);
fileCount = 0;
endResetModel();
}
diff --git a/examples/widgets/itemviews/fetchmore/filelistmodel.h b/examples/widgets/itemviews/fetchmore/filelistmodel.h
index 35cf6f7b46..b107c56db7 100644
--- a/examples/widgets/itemviews/fetchmore/filelistmodel.h
+++ b/examples/widgets/itemviews/fetchmore/filelistmodel.h
@@ -1,58 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FILELISTMODEL_H
#define FILELISTMODEL_H
#include <QAbstractListModel>
-#include <QStringList>
+#include <QFileInfoList>
+#include <QFileIconProvider>
//![0]
class FileListModel : public QAbstractListModel
@@ -65,8 +19,10 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QFileInfo fileInfoAt(const QModelIndex &) const;
+
signals:
- void numberPopulated(int number);
+ void numberPopulated(const QString &path, int start, int number, int total);
public slots:
void setDirPath(const QString &path);
@@ -76,8 +32,10 @@ protected:
void fetchMore(const QModelIndex &parent) override;
private:
- QStringList fileList;
- int fileCount;
+ QFileInfoList fileList;
+ QString path;
+ QFileIconProvider iconProvider;
+ int fileCount = 0;
};
//![0]
diff --git a/examples/widgets/itemviews/fetchmore/main.cpp b/examples/widgets/itemviews/fetchmore/main.cpp
index d9fa2879c4..1d8fd919b2 100644
--- a/examples/widgets/itemviews/fetchmore/main.cpp
+++ b/examples/widgets/itemviews/fetchmore/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
diff --git a/examples/widgets/itemviews/fetchmore/window.cpp b/examples/widgets/itemviews/fetchmore/window.cpp
index fa23bddc73..ffb89ce7df 100644
--- a/examples/widgets/itemviews/fetchmore/window.cpp
+++ b/examples/widgets/itemviews/fetchmore/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
#include "filelistmodel.h"
@@ -56,37 +9,43 @@
Window::Window(QWidget *parent)
: QWidget(parent)
{
- FileListModel *model = new FileListModel(this);
- model->setDirPath(QLibraryInfo::path(QLibraryInfo::PrefixPath));
+ model = new FileListModel(this);
+ model->setDirPath(QDir::rootPath());
- QLabel *label = new QLabel(tr("&Directory:"));
- QLineEdit *lineEdit = new QLineEdit;
- label->setBuddy(lineEdit);
-
- QListView *view = new QListView;
+ view = new QListView;
view->setModel(model);
- logViewer = new QTextBrowser(this);
- logViewer->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
+ logViewer = new QPlainTextEdit(this);
+ logViewer->setReadOnly(true);
+ logViewer->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
+ QSizePolicy::Preferred));
- connect(lineEdit, &QLineEdit::textChanged,
- model, &FileListModel::setDirPath);
- connect(lineEdit, &QLineEdit::textChanged,
- logViewer, &QTextEdit::clear);
connect(model, &FileListModel::numberPopulated,
this, &Window::updateLog);
+ connect(view, &QAbstractItemView::activated,
+ this, &Window::activated);
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(label, 0, 0);
- layout->addWidget(lineEdit, 0, 1);
- layout->addWidget(view, 1, 0, 1, 2);
- layout->addWidget(logViewer, 2, 0, 1, 2);
+ auto *layout = new QVBoxLayout(this);
+ layout->addWidget(view);
+ layout->addWidget(logViewer);
- setLayout(layout);
setWindowTitle(tr("Fetch More Example"));
}
-void Window::updateLog(int number)
+void Window::updateLog(const QString &path, int start, int number, int total)
+{
+ const int last = start + number - 1;
+ const QString nativePath = QDir::toNativeSeparators(path);
+ const QString message = tr("%1..%2/%3 items from \"%4\" added.")
+ .arg(start).arg(last).arg(total).arg(nativePath);
+ logViewer->appendPlainText(message);
+}
+
+void Window::activated(const QModelIndex &index)
{
- logViewer->append(tr("%1 items added.").arg(number));
+ const QFileInfo fi = model->fileInfoAt(index);
+ if (fi.isDir()) {
+ logViewer->clear();
+ model->setDirPath(fi.absoluteFilePath());
+ }
}
diff --git a/examples/widgets/itemviews/fetchmore/window.h b/examples/widgets/itemviews/fetchmore/window.h
index 61bcb94bde..75240026d5 100644
--- a/examples/widgets/itemviews/fetchmore/window.h
+++ b/examples/widgets/itemviews/fetchmore/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
@@ -54,9 +7,13 @@
#include <QWidget>
QT_BEGIN_NAMESPACE
-class QTextBrowser;
+class QModelIndex;
+class QListView;
+class QPlainTextEdit;
QT_END_NAMESPACE
+class FileListModel;
+
class Window : public QWidget
{
Q_OBJECT
@@ -65,10 +22,13 @@ public:
Window(QWidget *parent = nullptr);
public slots:
- void updateLog(int number);
+ void updateLog(const QString &path, int start, int number, int total);
+ void activated(const QModelIndex &);
private:
- QTextBrowser *logViewer;
+ QPlainTextEdit *logViewer;
+ FileListModel *model;
+ QListView *view;
};
#endif // WINDOW_H
diff --git a/examples/widgets/itemviews/flattreeview/CMakeLists.txt b/examples/widgets/itemviews/flattreeview/CMakeLists.txt
deleted file mode 100644
index 893f19d4ba..0000000000
--- a/examples/widgets/itemviews/flattreeview/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated from flattreeview.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(flattreeview LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/flattreeview")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 e9bbb3fab1..0000000000
--- a/examples/widgets/itemviews/flattreeview/main.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*
- main.cpp
-
- A simple example that shows 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 d27dc6e88b..4801dbffd6 100644
--- a/examples/widgets/itemviews/frozencolumn/CMakeLists.txt
+++ b/examples/widgets/itemviews/frozencolumn/CMakeLists.txt
@@ -1,45 +1,35 @@
-# Generated from frozencolumn.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(frozencolumn LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/frozencolumn")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(frozencolumn
freezetablewidget.cpp freezetablewidget.h
main.cpp
)
+
set_target_properties(frozencolumn PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(grades_resource_files
"grades.txt"
)
-qt6_add_resources(frozencolumn "grades"
+qt_add_resources(frozencolumn "grades"
PREFIX
"/"
FILES
@@ -47,7 +37,14 @@ qt6_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/freezetablewidget.cpp b/examples/widgets/itemviews/frozencolumn/freezetablewidget.cpp
index ce2973bc56..c67ea1eab9 100644
--- a/examples/widgets/itemviews/frozencolumn/freezetablewidget.cpp
+++ b/examples/widgets/itemviews/frozencolumn/freezetablewidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "freezetablewidget.h"
diff --git a/examples/widgets/itemviews/frozencolumn/freezetablewidget.h b/examples/widgets/itemviews/frozencolumn/freezetablewidget.h
index 69a90dab54..74af62c1a0 100644
--- a/examples/widgets/itemviews/frozencolumn/freezetablewidget.h
+++ b/examples/widgets/itemviews/frozencolumn/freezetablewidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FREEZETABLEWIDGET_H
#define FREEZETABLEWIDGET_H
diff --git a/examples/widgets/itemviews/frozencolumn/main.cpp b/examples/widgets/itemviews/frozencolumn/main.cpp
index 2965617ba1..8cc4a1d774 100644
--- a/examples/widgets/itemviews/frozencolumn/main.cpp
+++ b/examples/widgets/itemviews/frozencolumn/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QStandardItemModel>
@@ -57,8 +10,6 @@
int main(int argc, char* argv[])
{
- Q_INIT_RESOURCE(grades);
-
QApplication app( argc, argv );
QStandardItemModel *model=new QStandardItemModel();
@@ -93,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 7c4e6a4fe7..0000000000
--- a/examples/widgets/itemviews/interview/CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-# Generated from interview.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(interview LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/interview")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 10cbc363c8..0000000000
--- a/examples/widgets/itemviews/interview/main.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 5422757d95..0000000000
--- a/examples/widgets/itemviews/interview/model.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 ee64a32f93..0000000000
--- a/examples/widgets/itemviews/interview/model.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MODEL_H
-#define MODEL_H
-
-#include <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..db06874ba5 100644
--- a/examples/widgets/itemviews/itemviews.pro
+++ b/examples/widgets/itemviews/itemviews.pro
@@ -1,24 +1,11 @@
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/.prev_CMakeLists.txt b/examples/widgets/itemviews/pixelator/.prev_CMakeLists.txt
deleted file mode 100644
index 2beeba0939..0000000000
--- a/examples/widgets/itemviews/pixelator/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,61 +0,0 @@
-# Generated from pixelator.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pixelator LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/pixelator")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-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"
-)
-
-qt6_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/CMakeLists.txt b/examples/widgets/itemviews/pixelator/CMakeLists.txt
deleted file mode 100644
index 10a89e4343..0000000000
--- a/examples/widgets/itemviews/pixelator/CMakeLists.txt
+++ /dev/null
@@ -1,62 +0,0 @@
-# Generated from pixelator.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pixelator LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/pixelator")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS PrintSupport) # special case
-
-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"
-)
-
-qt6_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 9abb50fa68..0000000000
--- a/examples/widgets/itemviews/pixelator/imagemodel.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 04ebd705b7..0000000000
--- a/examples/widgets/itemviews/pixelator/imagemodel.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 409abb55b6..0000000000
--- a/examples/widgets/itemviews/pixelator/main.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 591123b187..0000000000
--- a/examples/widgets/itemviews/pixelator/mainwindow.cpp
+++ /dev/null
@@ -1,261 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 acd2eb1b42..0000000000
--- a/examples/widgets/itemviews/pixelator/mainwindow.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 dc8736c836..0000000000
--- a/examples/widgets/itemviews/pixelator/pixeldelegate.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 9f52221a28..0000000000
--- a/examples/widgets/itemviews/pixelator/pixeldelegate.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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/.prev_CMakeLists.txt b/examples/widgets/itemviews/puzzle/.prev_CMakeLists.txt
deleted file mode 100644
index b80cb9c29b..0000000000
--- a/examples/widgets/itemviews/puzzle/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-# Generated from puzzle.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(puzzle LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/puzzle")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(puzzle
- main.cpp
- mainwindow.cpp mainwindow.h
- piecesmodel.cpp piecesmodel.h
- puzzlewidget.cpp puzzlewidget.h
-)
-set_target_properties(puzzle PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(puzzle PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set(puzzle_resource_files
- "example.jpg"
-)
-
-qt6_add_resources(puzzle "puzzle"
- PREFIX
- "/images"
- FILES
- ${puzzle_resource_files}
-)
-
-install(TARGETS puzzle
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/itemviews/puzzle/CMakeLists.txt b/examples/widgets/itemviews/puzzle/CMakeLists.txt
deleted file mode 100644
index bfc597f2da..0000000000
--- a/examples/widgets/itemviews/puzzle/CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-# Generated from puzzle.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(puzzle LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/puzzle")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(itemviews_puzzle # special case: renamed puzzle
- main.cpp
- mainwindow.cpp mainwindow.h
- piecesmodel.cpp piecesmodel.h
- puzzlewidget.cpp puzzlewidget.h
-)
-set_target_properties(itemviews_puzzle PROPERTIES # special case
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(itemviews_puzzle PUBLIC # special case
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set(puzzle_resource_files
- "example.jpg"
-)
-
-qt6_add_resources(itemviews_puzzle "puzzle"
- PREFIX
- "/images"
- FILES
- ${puzzle_resource_files}
-)
-
-install(TARGETS itemviews_puzzle # special case: renamed 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 d013bf078d..0000000000
--- a/examples/widgets/itemviews/puzzle/main.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 d598dc9017..0000000000
--- a/examples/widgets/itemviews/puzzle/mainwindow.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 208d3a5281..0000000000
--- a/examples/widgets/itemviews/puzzle/mainwindow.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 f20fb9f7c3..0000000000
--- a/examples/widgets/itemviews/puzzle/piecesmodel.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 99cd7677b5..0000000000
--- a/examples/widgets/itemviews/puzzle/piecesmodel.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 2c60d28946..0000000000
--- a/examples/widgets/itemviews/puzzle/puzzlewidget.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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
-{
- return QRect(position / pieceSize() * pieceSize(),
- 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 0ac4719d74..0000000000
--- a/examples/widgets/itemviews/puzzle/puzzlewidget.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 4381e6ad1a..0000000000
--- a/examples/widgets/itemviews/simpledommodel/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-# Generated from simpledommodel.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(simpledommodel LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/simpledommodel")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Xml)
-find_package(Qt6 COMPONENTS Widgets)
-
-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 a2dc9530f0..0000000000
--- a/examples/widgets/itemviews/simpledommodel/domitem.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 4a74db5139..0000000000
--- a/examples/widgets/itemviews/simpledommodel/domitem.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 8e15252ebb..0000000000
--- a/examples/widgets/itemviews/simpledommodel/dommodel.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 a91bb33cf9..0000000000
--- a/examples/widgets/itemviews/simpledommodel/dommodel.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 9efd80af8c..0000000000
--- a/examples/widgets/itemviews/simpledommodel/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 86543b07a6..0000000000
--- a/examples/widgets/itemviews/simpledommodel/mainwindow.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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..."), this, &MainWindow::openFile, QKeySequence::Open);
- fileMenu->addAction(tr("E&xit"), this, &QWidget::close, QKeySequence::Quit);
-
- 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 b3f8d77f35..0000000000
--- a/examples/widgets/itemviews/simpledommodel/mainwindow.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 0fd9ebc9df..2fd31fae43 100644
--- a/examples/widgets/itemviews/simpletreemodel/CMakeLists.txt
+++ b/examples/widgets/itemviews/simpletreemodel/CMakeLists.txt
@@ -1,46 +1,36 @@
-# Generated from simpletreemodel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(simpletreemodel LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Test Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/simpletreemodel")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(simpletreemodel
main.cpp
treeitem.cpp treeitem.h
treemodel.cpp treemodel.h
)
+
set_target_properties(simpletreemodel PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(simpletreemodel_resource_files
"default.txt"
)
-qt6_add_resources(simpletreemodel "simpletreemodel"
+qt_add_resources(simpletreemodel "simpletreemodel"
PREFIX
"/"
FILES
@@ -48,7 +38,46 @@ qt6_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 1a358fa25a..5800c595c8 100644
--- a/examples/widgets/itemviews/simpletreemodel/main.cpp
+++ b/examples/widgets/itemviews/simpletreemodel/main.cpp
@@ -1,73 +1,32 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "treemodel.h"
#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 f998432252..67e021d622 100644
--- a/examples/widgets/itemviews/simpletreemodel/treeitem.cpp
+++ b/examples/widgets/itemviews/simpletreemodel/treeitem.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
/*
treeitem.cpp
@@ -57,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 10c5dda35c..b9002f06fd 100644
--- a/examples/widgets/itemviews/simpletreemodel/treeitem.h
+++ b/examples/widgets/itemviews/simpletreemodel/treeitem.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TREEITEM_H
#define TREEITEM_H
@@ -58,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;
@@ -71,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 d94fdb08cd..8538d99629 100644
--- a/examples/widgets/itemviews/simpletreemodel/treemodel.cpp
+++ b/examples/widgets/itemviews/simpletreemodel/treemodel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
/*
treemodel.cpp
@@ -60,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]
@@ -88,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]
@@ -103,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]
@@ -114,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]
@@ -125,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]
@@ -145,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 76fd03f112..1a42fa585f 100644
--- a/examples/widgets/itemviews/simpletreemodel/treemodel.h
+++ b/examples/widgets/itemviews/simpletreemodel/treemodel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TREEMODEL_H
#define TREEMODEL_H
@@ -63,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 aae13df180..0000000000
--- a/examples/widgets/itemviews/simplewidgetmapper/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from simplewidgetmapper.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(simplewidgetmapper LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/simplewidgetmapper")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 ed784f487f..0000000000
--- a/examples/widgets/itemviews/simplewidgetmapper/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 87037ac4df..0000000000
--- a/examples/widgets/itemviews/simplewidgetmapper/window.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 d04b528e16..0000000000
--- a/examples/widgets/itemviews/simplewidgetmapper/window.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <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 88bfd6b9c3..0000000000
--- a/examples/widgets/itemviews/spinboxdelegate/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from spinboxdelegate.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(spinboxdelegate LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/spinboxdelegate")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 f0fe524a60..0000000000
--- a/examples/widgets/itemviews/spinboxdelegate/delegate.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*
- 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/delegate.h b/examples/widgets/itemviews/spinboxdelegate/delegate.h
deleted file mode 100644
index 5dbdda9cd0..0000000000
--- a/examples/widgets/itemviews/spinboxdelegate/delegate.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DELEGATE_H
-#define DELEGATE_H
-
-#include <QStyledItemDelegate>
-
-//! [0]
-class SpinBoxDelegate : public QStyledItemDelegate
-{
- Q_OBJECT
-
-public:
- SpinBoxDelegate(QObject *parent = nullptr);
-
- 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;
-
- void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
- const QModelIndex &index) const override;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/itemviews/spinboxdelegate/main.cpp b/examples/widgets/itemviews/spinboxdelegate/main.cpp
deleted file mode 100644
index 2a37718e18..0000000000
--- a/examples/widgets/itemviews/spinboxdelegate/main.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*
- main.cpp
-
- A simple example that shows how a 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/.prev_CMakeLists.txt b/examples/widgets/itemviews/spreadsheet/.prev_CMakeLists.txt
deleted file mode 100644
index e14931e62f..0000000000
--- a/examples/widgets/itemviews/spreadsheet/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,62 +0,0 @@
-# Generated from spreadsheet.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(spreadsheet LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/spreadsheet")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(spreadsheet
- main.cpp
- printview.cpp printview.h
- spreadsheet.cpp spreadsheet.h
- spreadsheetdelegate.cpp spreadsheetdelegate.h
- spreadsheetitem.cpp spreadsheetitem.h
-)
-set_target_properties(spreadsheet PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(spreadsheet PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set(spreadsheet_resource_files
- "images/interview.png"
-)
-
-qt6_add_resources(spreadsheet "spreadsheet"
- PREFIX
- "/"
- FILES
- ${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}"
-)
diff --git a/examples/widgets/itemviews/spreadsheet/CMakeLists.txt b/examples/widgets/itemviews/spreadsheet/CMakeLists.txt
index a5a9a52574..b6521f0c2f 100644
--- a/examples/widgets/itemviews/spreadsheet/CMakeLists.txt
+++ b/examples/widgets/itemviews/spreadsheet/CMakeLists.txt
@@ -1,24 +1,15 @@
-# Generated from spreadsheet.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(spreadsheet LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC 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
+)
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS PrintSupport) # special case
+qt_standard_project_setup()
qt_add_executable(spreadsheet
main.cpp
@@ -27,42 +18,43 @@ qt_add_executable(spreadsheet
spreadsheetdelegate.cpp spreadsheetdelegate.h
spreadsheetitem.cpp spreadsheetitem.h
)
+
set_target_properties(spreadsheet PROPERTIES
WIN32_EXECUTABLE TRUE
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
)
-# special case begin
-if (TARGET Qt::PrintSupport)
- target_link_libraries(spreadsheet PUBLIC Qt::PrintSupport)
-endif()
-# special case end
+if (TARGET Qt6::PrintSupport)
+ target_link_libraries(spreadsheet PRIVATE Qt6::PrintSupport)
+endif()
# Resources:
set(spreadsheet_resource_files
"images/interview.png"
)
-qt6_add_resources(spreadsheet "spreadsheet"
+qt_add_resources(spreadsheet "spreadsheet"
PREFIX
"/"
FILES
${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 9a6dbf6817..3c2d676e88 100644
--- a/examples/widgets/itemviews/spreadsheet/main.cpp
+++ b/examples/widgets/itemviews/spreadsheet/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "spreadsheet.h"
@@ -55,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"));
@@ -64,5 +15,3 @@ int main(int argc, char **argv)
sheet.layout()->setSizeConstraint(QLayout::SetFixedSize);
return app.exec();
}
-
-
diff --git a/examples/widgets/itemviews/spreadsheet/printview.cpp b/examples/widgets/itemviews/spreadsheet/printview.cpp
index 1d3e794247..335ffaa08e 100644
--- a/examples/widgets/itemviews/spreadsheet/printview.cpp
+++ b/examples/widgets/itemviews/spreadsheet/printview.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "printview.h"
diff --git a/examples/widgets/itemviews/spreadsheet/printview.h b/examples/widgets/itemviews/spreadsheet/printview.h
index 29161103a4..eeb6702c50 100644
--- a/examples/widgets/itemviews/spreadsheet/printview.h
+++ b/examples/widgets/itemviews/spreadsheet/printview.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef PRINTVIEW_H
#define PRINTVIEW_H
@@ -63,7 +16,7 @@ class PrintView : public QTableView
public:
PrintView();
-public Q_SLOTS:
+public slots:
void print(QPrinter *printer);
};
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp b/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp
index eedefba612..37a307b26e 100644
--- a/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheet.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "spreadsheet.h"
#include "spreadsheetdelegate.h"
@@ -153,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/spreadsheet/spreadsheet.h b/examples/widgets/itemviews/spreadsheet/spreadsheet.h
index b36a377156..6c05b6d417 100644
--- a/examples/widgets/itemviews/spreadsheet/spreadsheet.h
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheet.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SPREADSHEET_H
#define SPREADSHEET_H
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp b/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp
index ad80a238aa..00e18d29bb 100644
--- a/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "spreadsheetdelegate.h"
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.h b/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.h
index 36c70d2391..e586e1d425 100644
--- a/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.h
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SPREADSHEETDELEGATE_H
#define SPREADSHEETDELEGATE_H
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheetitem.cpp b/examples/widgets/itemviews/spreadsheet/spreadsheetitem.cpp
index 62d3a6fdcd..306a1e8854 100644
--- a/examples/widgets/itemviews/spreadsheet/spreadsheetitem.cpp
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheetitem.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "spreadsheetitem.h"
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheetitem.h b/examples/widgets/itemviews/spreadsheet/spreadsheetitem.h
index 159f4a7eea..7ac5b77384 100644
--- a/examples/widgets/itemviews/spreadsheet/spreadsheetitem.h
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheetitem.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SPREADSHEETITEM_H
#define SPREADSHEETITEM_H
diff --git a/examples/widgets/itemviews/stardelegate/CMakeLists.txt b/examples/widgets/itemviews/stardelegate/CMakeLists.txt
index 947fdb96a7..500a03f59b 100644
--- a/examples/widgets/itemviews/stardelegate/CMakeLists.txt
+++ b/examples/widgets/itemviews/stardelegate/CMakeLists.txt
@@ -1,23 +1,12 @@
-# Generated from stardelegate.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(stardelegate LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/stardelegate")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(stardelegate
main.cpp
@@ -25,18 +14,27 @@ qt_add_executable(stardelegate
stareditor.cpp stareditor.h
starrating.cpp starrating.h
)
+
set_target_properties(stardelegate PROPERTIES
WIN32_EXECUTABLE TRUE
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/stardelegate/main.cpp b/examples/widgets/itemviews/stardelegate/main.cpp
index 5ca85a6151..9739a226b6 100644
--- a/examples/widgets/itemviews/stardelegate/main.cpp
+++ b/examples/widgets/itemviews/stardelegate/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QTableWidget>
diff --git a/examples/widgets/itemviews/stardelegate/stardelegate.cpp b/examples/widgets/itemviews/stardelegate/stardelegate.cpp
index 41ae5a920f..5981d855a1 100644
--- a/examples/widgets/itemviews/stardelegate/stardelegate.cpp
+++ b/examples/widgets/itemviews/stardelegate/stardelegate.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
diff --git a/examples/widgets/itemviews/stardelegate/stardelegate.h b/examples/widgets/itemviews/stardelegate/stardelegate.h
index 1fc31f8ee8..c5686dd7d5 100644
--- a/examples/widgets/itemviews/stardelegate/stardelegate.h
+++ b/examples/widgets/itemviews/stardelegate/stardelegate.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef STARDELEGATE_H
#define STARDELEGATE_H
diff --git a/examples/widgets/itemviews/stardelegate/stareditor.cpp b/examples/widgets/itemviews/stardelegate/stareditor.cpp
index 72d687c05c..8bd3c850f6 100644
--- a/examples/widgets/itemviews/stardelegate/stareditor.cpp
+++ b/examples/widgets/itemviews/stardelegate/stareditor.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "stareditor.h"
#include "starrating.h"
diff --git a/examples/widgets/itemviews/stardelegate/stareditor.h b/examples/widgets/itemviews/stardelegate/stareditor.h
index 8b1bf2efed..bb5419086f 100644
--- a/examples/widgets/itemviews/stardelegate/stareditor.h
+++ b/examples/widgets/itemviews/stardelegate/stareditor.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef STAREDITOR_H
#define STAREDITOR_H
diff --git a/examples/widgets/itemviews/stardelegate/starrating.cpp b/examples/widgets/itemviews/stardelegate/starrating.cpp
index 75f0bd9cf7..421dc6f218 100644
--- a/examples/widgets/itemviews/stardelegate/starrating.cpp
+++ b/examples/widgets/itemviews/stardelegate/starrating.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "starrating.h"
diff --git a/examples/widgets/itemviews/stardelegate/starrating.h b/examples/widgets/itemviews/stardelegate/starrating.h
index fc3028db58..31054ddfe9 100644
--- a/examples/widgets/itemviews/stardelegate/starrating.h
+++ b/examples/widgets/itemviews/stardelegate/starrating.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef STARRATING_H
#define STARRATING_H
diff --git a/examples/widgets/itemviews/storageview/CMakeLists.txt b/examples/widgets/itemviews/storageview/CMakeLists.txt
deleted file mode 100644
index 173aa7ca89..0000000000
--- a/examples/widgets/itemviews/storageview/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from storageview.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(storageview LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/itemviews/storageview")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 5505d8a984..0000000000
--- a/examples/widgets/itemviews/storageview/main.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Ivan Komissarov
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <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 b98fc8445c..0000000000
--- a/examples/widgets/itemviews/storageview/storagemodel.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Ivan Komissarov
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 597218c220..0000000000
--- a/examples/widgets/itemviews/storageview/storagemodel.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Ivan Komissarov
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 eaca669248..7e679fadd3 100644
--- a/examples/widgets/layouts/CMakeLists.txt
+++ b/examples/widgets/layouts/CMakeLists.txt
@@ -1,6 +1,5 @@
-# Generated from layouts.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(basiclayouts)
-add_subdirectory(borderlayout)
-add_subdirectory(dynamiclayouts)
-add_subdirectory(flowlayout)
+qt_internal_add_example(basiclayouts)
+qt_internal_add_example(flowlayout)
diff --git a/examples/widgets/layouts/basiclayouts/CMakeLists.txt b/examples/widgets/layouts/basiclayouts/CMakeLists.txt
index fdfc452e19..5f126c308a 100644
--- a/examples/widgets/layouts/basiclayouts/CMakeLists.txt
+++ b/examples/widgets/layouts/basiclayouts/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from basiclayouts.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(basiclayouts LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/layouts/basiclayouts")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(basiclayouts
dialog.cpp dialog.h
main.cpp
)
+
set_target_properties(basiclayouts PROPERTIES
WIN32_EXECUTABLE TRUE
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/dialog.cpp b/examples/widgets/layouts/basiclayouts/dialog.cpp
index 8376820545..a0825167d9 100644
--- a/examples/widgets/layouts/basiclayouts/dialog.cpp
+++ b/examples/widgets/layouts/basiclayouts/dialog.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
@@ -83,9 +36,24 @@ Dialog::Dialog()
mainLayout->addWidget(formGroupBox);
mainLayout->addWidget(bigEditor);
mainLayout->addWidget(buttonBox);
-//! [4] //! [5]
- setLayout(mainLayout);
+//! [4]
+ QWidget *scrollAreaContent = new QWidget;
+ scrollAreaContent->setLayout(mainLayout);
+ QScrollArea *scrollArea = new QScrollArea;
+ scrollArea->setFrameShape(QFrame::NoFrame);
+ scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ scrollArea->setWidgetResizable(true);
+ scrollArea->verticalScrollBar()->setStyleSheet("QScrollBar:vertical {width: 20px;}");
+
+ scrollArea->setWidget(scrollAreaContent);
+
+ QVBoxLayout *scrollLayout = new QVBoxLayout;
+ scrollLayout->setContentsMargins(0,0,0,0);
+ scrollLayout->addWidget(scrollArea);
+
+//! [5]
+ setLayout(scrollLayout);
setWindowTitle(tr("Basic Layouts"));
}
//! [5]
diff --git a/examples/widgets/layouts/basiclayouts/dialog.h b/examples/widgets/layouts/basiclayouts/dialog.h
index 0673530b91..ea894bc365 100644
--- a/examples/widgets/layouts/basiclayouts/dialog.h
+++ b/examples/widgets/layouts/basiclayouts/dialog.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DIALOG_H
#define DIALOG_H
diff --git a/examples/widgets/layouts/basiclayouts/main.cpp b/examples/widgets/layouts/basiclayouts/main.cpp
index cf0ff0a535..865e0d1579 100644
--- a/examples/widgets/layouts/basiclayouts/main.cpp
+++ b/examples/widgets/layouts/basiclayouts/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
@@ -56,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 7ea6a0496e..0000000000
--- a/examples/widgets/layouts/borderlayout/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from borderlayout.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(borderlayout LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/layouts/borderlayout")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 b8ddd3af83..0000000000
--- a/examples/widgets/layouts/borderlayout/borderlayout.cpp
+++ /dev/null
@@ -1,218 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 58d1aa394d..0000000000
--- a/examples/widgets/layouts/borderlayout/borderlayout.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 99725195e5..0000000000
--- a/examples/widgets/layouts/borderlayout/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 9e6b5a9511..0000000000
--- a/examples/widgets/layouts/borderlayout/window.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 2577e78b0c..0000000000
--- a/examples/widgets/layouts/borderlayout/window.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <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 3bfa44da47..0000000000
--- a/examples/widgets/layouts/dynamiclayouts/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from dynamiclayouts.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(dynamiclayouts LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/layouts/dynamiclayouts")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 bd9baa9faf..0000000000
--- a/examples/widgets/layouts/dynamiclayouts/dialog.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 b582c1c018..0000000000
--- a/examples/widgets/layouts/dynamiclayouts/dialog.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 cf0ff0a535..0000000000
--- a/examples/widgets/layouts/dynamiclayouts/main.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 deafab4d80..9693d409b7 100644
--- a/examples/widgets/layouts/flowlayout/CMakeLists.txt
+++ b/examples/widgets/layouts/flowlayout/CMakeLists.txt
@@ -1,41 +1,39 @@
-# Generated from flowlayout.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(flowlayout LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/layouts/flowlayout")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(flowlayout
flowlayout.cpp flowlayout.h
main.cpp
window.cpp window.h
)
+
set_target_properties(flowlayout PROPERTIES
WIN32_EXECUTABLE TRUE
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 9a488557cf..0565053096 100644
--- a/examples/widgets/layouts/flowlayout/flowlayout.cpp
+++ b/examples/widgets/layouts/flowlayout/flowlayout.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
@@ -155,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();
@@ -176,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/flowlayout/flowlayout.h b/examples/widgets/layouts/flowlayout/flowlayout.h
index 3155d5d347..3c5291ba91 100644
--- a/examples/widgets/layouts/flowlayout/flowlayout.h
+++ b/examples/widgets/layouts/flowlayout/flowlayout.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FLOWLAYOUT_H
#define FLOWLAYOUT_H
diff --git a/examples/widgets/layouts/flowlayout/main.cpp b/examples/widgets/layouts/flowlayout/main.cpp
index bbc78ccda3..4e1139024d 100644
--- a/examples/widgets/layouts/flowlayout/main.cpp
+++ b/examples/widgets/layouts/flowlayout/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [1]
#include <QApplication>
diff --git a/examples/widgets/layouts/flowlayout/window.cpp b/examples/widgets/layouts/flowlayout/window.cpp
index b616dae17c..e3f0ceb531 100644
--- a/examples/widgets/layouts/flowlayout/window.cpp
+++ b/examples/widgets/layouts/flowlayout/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QPushButton>
diff --git a/examples/widgets/layouts/flowlayout/window.h b/examples/widgets/layouts/flowlayout/window.h
index ee5ef947ff..fd4bf40203 100644
--- a/examples/widgets/layouts/flowlayout/window.h
+++ b/examples/widgets/layouts/flowlayout/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
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 8bb5f52f92..5b7079ed04 100644
--- a/examples/widgets/mainwindows/CMakeLists.txt
+++ b/examples/widgets/mainwindows/CMakeLists.txt
@@ -1,8 +1,4 @@
-# Generated from mainwindows.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(application)
-add_subdirectory(dockwidgets)
-add_subdirectory(mainwindow)
-add_subdirectory(mdi)
-add_subdirectory(menus)
-add_subdirectory(sdi)
+qt_internal_add_example(menus)
diff --git a/examples/widgets/mainwindows/application/CMakeLists.txt b/examples/widgets/mainwindows/application/CMakeLists.txt
deleted file mode 100644
index 53354d0460..0000000000
--- a/examples/widgets/mainwindows/application/CMakeLists.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-# Generated from application.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(application LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/mainwindows/application")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 78db7134a3..0000000000
--- a/examples/widgets/mainwindows/application/main.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//! [0]
-#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 9c0910ae63..0000000000
--- a/examples/widgets/mainwindows/application/mainwindow.cpp
+++ /dev/null
@@ -1,417 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//! [0]
-#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 1300247ce7..0000000000
--- a/examples/widgets/mainwindows/application/mainwindow.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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/.prev_CMakeLists.txt b/examples/widgets/mainwindows/dockwidgets/.prev_CMakeLists.txt
deleted file mode 100644
index 2affbef3b9..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,62 +0,0 @@
-# Generated from dockwidgets.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(dockwidgets LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/mainwindows/dockwidgets")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-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
-)
-
-
-# Resources:
-set(dockwidgets_resource_files
- "images/new.png"
- "images/print.png"
- "images/save.png"
- "images/undo.png"
-)
-
-qt6_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/CMakeLists.txt b/examples/widgets/mainwindows/dockwidgets/CMakeLists.txt
deleted file mode 100644
index 308960e547..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/CMakeLists.txt
+++ /dev/null
@@ -1,68 +0,0 @@
-# Generated from dockwidgets.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(dockwidgets LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/mainwindows/dockwidgets")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS PrintSupport) # special case
-
-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
-)
-# special case begin
-if (TARGET Qt::PrintSupport)
- target_link_libraries(dockwidgets PUBLIC Qt::PrintSupport)
-endif()
-# special case end
-
-
-# Resources:
-set(dockwidgets_resource_files
- "images/new.png"
- "images/print.png"
- "images/save.png"
- "images/undo.png"
-)
-
-qt6_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 ff3ba506a8..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 dba4a081df..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp
+++ /dev/null
@@ -1,345 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//! [0]
-#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 479f0973f0..0000000000
--- a/examples/widgets/mainwindows/dockwidgets/mainwindow.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 88d1c7ddf7..0000000000
--- a/examples/widgets/mainwindows/mainwindow/CMakeLists.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-# Generated from mainwindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(mainwindow LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/mainwindows/mainwindow")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 cb568a7a5a..0000000000
--- a/examples/widgets/mainwindows/mainwindow/colorswatch.cpp
+++ /dev/null
@@ -1,732 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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->exec(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 2bd9fd2891..0000000000
--- a/examples/widgets/mainwindows/mainwindow/colorswatch.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 b68be3cdf6..0000000000
--- a/examples/widgets/mainwindows/mainwindow/main.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 d5a7d6ae07..0000000000
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
+++ /dev/null
@@ -1,491 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 3ce9732763..0000000000
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-
-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 2c663a1618..0000000000
--- a/examples/widgets/mainwindows/mainwindow/toolbar.cpp
+++ /dev/null
@@ -1,363 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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(int(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 27b93d2d6f..0000000000
--- a/examples/widgets/mainwindows/mainwindow/toolbar.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 1c9aac9a33..0000000000
--- a/examples/widgets/mainwindows/mdi/CMakeLists.txt
+++ /dev/null
@@ -1,59 +0,0 @@
-# Generated from mdi.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(mdi LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/mainwindows/mdi")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 950244ad53..0000000000
--- a/examples/widgets/mainwindows/mdi/main.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <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 a6690a1ac4..0000000000
--- a/examples/widgets/mainwindows/mdi/mainwindow.cpp
+++ /dev/null
@@ -1,508 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 f163145c2c..0000000000
--- a/examples/widgets/mainwindows/mdi/mainwindow.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 727d4f6cfd..0000000000
--- a/examples/widgets/mainwindows/mdi/mdichild.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 2ac8194f73..0000000000
--- a/examples/widgets/mainwindows/mdi/mdichild.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 ba32b3086a..9b3735eff8 100644
--- a/examples/widgets/mainwindows/menus/CMakeLists.txt
+++ b/examples/widgets/mainwindows/menus/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from menus.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(menus LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/mainwindows/menus")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(menus
main.cpp
mainwindow.cpp mainwindow.h
)
+
set_target_properties(menus PROPERTIES
WIN32_EXECUTABLE TRUE
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/main.cpp b/examples/widgets/mainwindows/menus/main.cpp
index 1bf46b226f..7d7cf3e573 100644
--- a/examples/widgets/mainwindows/menus/main.cpp
+++ b/examples/widgets/mainwindows/menus/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/mainwindows/menus/mainwindow.cpp b/examples/widgets/mainwindows/menus/mainwindow.cpp
index c6aba8be83..c003d9f568 100644
--- a/examples/widgets/mainwindows/menus/mainwindow.cpp
+++ b/examples/widgets/mainwindows/menus/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
@@ -207,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"));
@@ -272,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"));
@@ -292,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);
@@ -301,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/menus/mainwindow.h b/examples/widgets/mainwindows/menus/mainwindow.h
index 1f1a065aaf..bd81e455ae 100644
--- a/examples/widgets/mainwindows/menus/mainwindow.h
+++ b/examples/widgets/mainwindows/menus/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/widgets/mainwindows/sdi/CMakeLists.txt b/examples/widgets/mainwindows/sdi/CMakeLists.txt
deleted file mode 100644
index 111b127e38..0000000000
--- a/examples/widgets/mainwindows/sdi/CMakeLists.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-# Generated from sdi.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(sdi LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/mainwindows/sdi")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 7a18c0c39c..0000000000
--- a/examples/widgets/mainwindows/sdi/main.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <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 25c9df7102..0000000000
--- a/examples/widgets/mainwindows/sdi/mainwindow.cpp
+++ /dev/null
@@ -1,492 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 059710eacb..0000000000
--- a/examples/widgets/mainwindows/sdi/mainwindow.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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/.prev_CMakeLists.txt b/examples/widgets/painting/.prev_CMakeLists.txt
deleted file mode 100644
index 2ef5da303a..0000000000
--- a/examples/widgets/painting/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-# Generated from painting.pro.
-
-add_subdirectory(basicdrawing)
-add_subdirectory(concentriccircles)
-add_subdirectory(affine)
-add_subdirectory(composition)
-add_subdirectory(deform)
-add_subdirectory(gradients)
-add_subdirectory(pathstroke)
-add_subdirectory(imagecomposition)
-add_subdirectory(painterpaths)
-add_subdirectory(transformations)
-add_subdirectory(fontsampler)
diff --git a/examples/widgets/painting/CMakeLists.txt b/examples/widgets/painting/CMakeLists.txt
index 8a106982cf..8a0b625e4d 100644
--- a/examples/widgets/painting/CMakeLists.txt
+++ b/examples/widgets/painting/CMakeLists.txt
@@ -1,14 +1,12 @@
-# Generated from painting.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(shared) # special case
-add_subdirectory(basicdrawing)
-add_subdirectory(concentriccircles)
-add_subdirectory(affine)
-# add_subdirectory(composition) # special case FIXME: Seems buggy wrt. usesOpenGL function
-add_subdirectory(deform)
-add_subdirectory(gradients)
-add_subdirectory(pathstroke)
-add_subdirectory(imagecomposition)
-add_subdirectory(painterpaths)
-add_subdirectory(transformations)
-add_subdirectory(fontsampler)
+qt_internal_add_example(basicdrawing)
+qt_internal_add_example(affine)
+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)
diff --git a/examples/widgets/painting/affine/.prev_CMakeLists.txt b/examples/widgets/painting/affine/.prev_CMakeLists.txt
deleted file mode 100644
index d367ef75bd..0000000000
--- a/examples/widgets/painting/affine/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,223 +0,0 @@
-# Generated from affine.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(affine LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/affine")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(affine
- ../shared/arthurstyle.cpp ../shared/arthurstyle.h
- ../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- ../shared/hoverpoints.cpp ../shared/hoverpoints.h
- main.cpp
- xform.cpp xform.h
-)
-set_target_properties(affine PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_include_directories(affine PUBLIC
- ../shared
-)
-
-target_link_libraries(affine PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
-set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
-)
-
-qt6_add_resources(affine "shared"
- PREFIX
- "/res"
- BASE
- "../shared"
- FILES
- ${shared_resource_files}
-)
-set(affine_resource_files
- "bg1.jpg"
- "xform.cpp"
- "xform.html"
-)
-
-qt6_add_resources(affine "affine"
- PREFIX
- "/res/affine"
- FILES
- ${affine_resource_files}
-)
-
-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}"
-)
diff --git a/examples/widgets/painting/affine/CMakeLists.txt b/examples/widgets/painting/affine/CMakeLists.txt
index c3323693b8..dd39086620 100644
--- a/examples/widgets/painting/affine/CMakeLists.txt
+++ b/examples/widgets/painting/affine/CMakeLists.txt
@@ -1,201 +1,74 @@
-# Generated from affine.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(affine LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/affine")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(affine
- # special case begin
- # remove files from ../shared
- #../shared/arthurstyle.cpp ../shared/arthurstyle.h
- #../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- #../shared/hoverpoints.cpp ../shared/hoverpoints.h
- # special case end
main.cpp
xform.cpp xform.h
)
+
set_target_properties(affine PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_include_directories(affine PUBLIC
- ../shared
-)
-# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
-# special case end
-target_link_libraries(affine PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
- painting_shared::painting_shared # special case
+target_link_libraries(affine PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+ painting_shared::painting_shared
)
-
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
-)
-
-qt6_add_resources(affine "shared"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
+)
+
+qt_add_resources(affine "shared"
PREFIX
"/res"
BASE
@@ -203,34 +76,29 @@ qt6_add_resources(affine "shared"
FILES
${shared_resource_files}
)
+
set(affine_resource_files
"bg1.jpg"
"xform.cpp"
"xform.html"
)
-qt6_add_resources(affine "affine"
+qt_add_resources(affine "affine"
PREFIX
"/res/affine"
FILES
${affine_resource_files}
)
-# special case begin
-# 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()
-# special case end
-
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 641fc5c204..1f9c2399c9 100644
--- a/examples/widgets/painting/affine/main.cpp
+++ b/examples/widgets/painting/affine/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "xform.h"
@@ -54,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 d7ed2125d2..5754490eed 100644
--- a/examples/widgets/painting/affine/xform.cpp
+++ b/examples/widgets/painting/affine/xform.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "xform.h"
#include "hoverpoints.h"
@@ -58,27 +11,22 @@
const int alpha = 155;
XFormView::XFormView(QWidget *parent)
- : ArthurFrame(parent)
+ : ArthurFrame(parent),
+ m_pixmap(QPixmap(":res/affine/bg1.jpg"))
{
setAttribute(Qt::WA_MouseTracking);
- m_type = VectorType;
- m_rotation = 0.0;
- m_scale = 1.0;
- m_shear = 0.0;
-
- m_pixmap = QPixmap(":res/affine/bg1.jpg");
- pts = new HoverPoints(this, HoverPoints::CircleShape);
- pts->setConnectionType(HoverPoints::LineConnection);
- pts->setEditable(false);
- pts->setPointSize(QSize(15, 15));
- pts->setShapeBrush(QBrush(QColor(151, 0, 0, alpha)));
- pts->setShapePen(QPen(QColor(255, 100, 50, alpha)));
- pts->setConnectionPen(QPen(QColor(151, 0, 0, 50)));
- pts->setBoundingRect(QRectF(0, 0, 500, 500));
- ctrlPoints << QPointF(250, 250) << QPointF(350, 250);
- pts->setPoints(ctrlPoints);
- connect(pts, &HoverPoints::pointsChanged,
- this,&XFormView::updateCtrlPoints);
+
+ m_hoverPoints = new HoverPoints(this, HoverPoints::CircleShape);
+ m_hoverPoints->setConnectionType(HoverPoints::LineConnection);
+ m_hoverPoints->setEditable(false);
+ m_hoverPoints->setPointSize(QSize(15, 15));
+ m_hoverPoints->setShapeBrush(QBrush(QColor(151, 0, 0, alpha)));
+ m_hoverPoints->setShapePen(QPen(QColor(255, 100, 50, alpha)));
+ m_hoverPoints->setConnectionPen(QPen(QColor(151, 0, 0, 50)));
+ m_hoverPoints->setBoundingRect(QRectF(0, 0, 500, 500));
+ m_hoverPoints->setPoints(m_controlPoints);
+ connect(m_hoverPoints, &HoverPoints::pointsChanged,
+ this, &XFormView::updateControlPoints);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
@@ -122,7 +70,7 @@ void XFormView::mousePressEvent(QMouseEvent *)
void XFormView::resizeEvent(QResizeEvent *e)
{
- pts->setBoundingRect(rect());
+ m_hoverPoints->setBoundingRect(rect());
ArthurFrame::resizeEvent(e);
}
@@ -145,24 +93,24 @@ void XFormView::paint(QPainter *p)
p->restore();
}
-void XFormView::updateCtrlPoints(const QPolygonF &points)
+void XFormView::updateControlPoints(const QPolygonF &points)
{
- QPointF trans = points.at(0) - ctrlPoints.at(0);
+ QPointF trans = points.at(0) - m_controlPoints.at(0);
if (qAbs(points.at(0).x() - points.at(1).x()) < 10
&& qAbs(points.at(0).y() - points.at(1).y()) < 10)
- pts->setPoints(ctrlPoints);
+ m_hoverPoints->setPoints(m_controlPoints);
if (!trans.isNull()) {
- ctrlPoints[0] = points.at(0);
- ctrlPoints[1] += trans;
- pts->setPoints(ctrlPoints);
+ m_controlPoints[0] = points.at(0);
+ m_controlPoints[1] += trans;
+ m_hoverPoints->setPoints(m_controlPoints);
}
- ctrlPoints = points;
+ m_controlPoints = points;
- QLineF line(ctrlPoints.at(0), ctrlPoints.at(1));
+ QLineF line(m_controlPoints.at(0), m_controlPoints.at(1));
m_rotation = 360 - QLineF(0, 0, 1, 0).angleTo(line);
if (trans.isNull())
- emit rotationChanged(int(m_rotation*10));
+ emit rotationChanged(int(m_rotation * 10));
}
void XFormView::setVectorType()
@@ -222,12 +170,12 @@ void XFormView::setRotation(qreal r)
qreal old_rot = m_rotation;
m_rotation = r;
- QPointF center(pts->points().at(0));
+ QPointF center(m_hoverPoints->points().at(0));
QTransform m;
m.translate(center.x(), center.y());
m.rotate(m_rotation - old_rot);
m.translate(-center.x(), -center.y());
- pts->setPoints(pts->points() * m);
+ m_hoverPoints->setPoints(m_hoverPoints->points() * m);
update();
}
@@ -235,12 +183,12 @@ void XFormView::setRotation(qreal r)
void XFormView::timerEvent(QTimerEvent *e)
{
if (e->timerId() == timer.timerId()) {
- QPointF center(pts->points().at(0));
+ QPointF center(m_hoverPoints->points().at(0));
QTransform m;
m.translate(center.x(), center.y());
m.rotate(0.2);
m.translate(-center.x(), -center.y());
- pts->setPoints(pts->points() * m);
+ m_hoverPoints->setPoints(m_hoverPoints->points() * m);
setUpdatesEnabled(false);
static qreal scale_inc = 0.003;
@@ -253,7 +201,7 @@ void XFormView::timerEvent(QTimerEvent *e)
shear_inc = -shear_inc;
setUpdatesEnabled(true);
- pts->firePointChange();
+ m_hoverPoints->firePointChange();
}
}
@@ -271,16 +219,15 @@ void XFormView::reset()
emit rotationChanged(0);
emit scaleChanged(1000);
emit shearChanged(0);
- ctrlPoints = QPolygonF();
- ctrlPoints << QPointF(250, 250) << QPointF(350, 250);
- pts->setPoints(ctrlPoints);
- pts->firePointChange();
+ m_controlPoints = {{250, 250}, {350, 250}};
+ m_hoverPoints->setPoints(m_controlPoints);
+ m_hoverPoints->firePointChange();
}
void XFormView::drawPixmapType(QPainter *painter)
{
QPointF center(m_pixmap.width() / qreal(2), m_pixmap.height() / qreal(2));
- painter->translate(ctrlPoints.at(0) - center);
+ painter->translate(m_controlPoints.at(0) - center);
painter->translate(center);
painter->rotate(m_rotation);
@@ -289,9 +236,11 @@ void XFormView::drawPixmapType(QPainter *painter)
painter->translate(-center);
painter->drawPixmap(QPointF(0, 0), m_pixmap);
- painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
+ painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25,
+ Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
painter->setBrush(Qt::NoBrush);
- painter->drawRect(QRectF(0, 0, m_pixmap.width(), m_pixmap.height()).adjusted(-2, -2, 2, 2));
+ painter->drawRect(QRectF(0, 0, m_pixmap.width(),
+ m_pixmap.height()).adjusted(-2, -2, 2, 2));
}
void XFormView::drawTextType(QPainter *painter)
@@ -306,7 +255,7 @@ void XFormView::drawTextType(QPainter *painter)
QFontMetrics fm(f);
QRectF br(fm.boundingRect(m_text));
QPointF center(br.center());
- painter->translate(ctrlPoints.at(0) - center);
+ painter->translate(m_controlPoints.at(0) - center);
painter->translate(center);
painter->rotate(m_rotation);
@@ -316,7 +265,8 @@ void XFormView::drawTextType(QPainter *painter)
painter->fillPath(path, Qt::black);
- painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
+ painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25,
+ Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
painter->setBrush(Qt::NoBrush);
painter->drawRect(br.adjusted(-1, -1, 1, 1));
}
@@ -324,7 +274,7 @@ void XFormView::drawTextType(QPainter *painter)
void XFormView::drawVectorType(QPainter *painter)
{
QPainterPath path;
- painter->translate(ctrlPoints.at(0) - QPointF(250,250));
+ painter->translate(m_controlPoints.at(0) - QPointF(250,250));
painter->scale(0.77, 0.77);
painter->translate(98.9154 + 30 , -217.691 - 20);
@@ -339,10 +289,10 @@ void XFormView::drawVectorType(QPainter *painter)
painter->setPen(Qt::NoPen);
path.moveTo(120, 470);
- path.lineTo(60+245, 470);
- path.lineTo(60+245, 470+350);
- path.lineTo(60, 470+350);
- path.lineTo(60, 470+80);
+ path.lineTo(60 + 245, 470);
+ path.lineTo(60 + 245, 470 + 350);
+ path.lineTo(60, 470 + 350);
+ path.lineTo(60, 470 + 80);
painter->setBrush(Qt::white);
painter->drawPath(path);
@@ -827,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);
@@ -862,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);
@@ -902,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/affine/xform.h b/examples/widgets/painting/affine/xform.h
index 1dce3b26da..20bf8102ce 100644
--- a/examples/widgets/painting/affine/xform.h
+++ b/examples/widgets/painting/affine/xform.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef XFORM_H
#define XFORM_H
@@ -88,7 +41,7 @@ public:
void mousePressEvent(QMouseEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
- HoverPoints *hoverPoints() { return pts; }
+ HoverPoints *hoverPoints() { return m_hoverPoints; }
bool animation() const { return timer.isActive(); }
qreal shear() const { return m_shear; }
@@ -104,7 +57,7 @@ public:
public slots:
void setAnimation(bool animate);
- void updateCtrlPoints(const QPolygonF &);
+ void updateControlPoints(const QPolygonF &);
void changeRotation(int rotation);
void changeScale(int scale);
void changeShear(int shear);
@@ -130,12 +83,12 @@ protected:
#endif
private:
- QPolygonF ctrlPoints;
- HoverPoints *pts;
- qreal m_rotation;
- qreal m_scale;
- qreal m_shear;
- XFormType m_type;
+ QPolygonF m_controlPoints{{250, 250}, {350, 250}};
+ HoverPoints *m_hoverPoints;
+ qreal m_rotation = 0;
+ qreal m_scale = 1;
+ qreal m_shear = 0;
+ XFormType m_type = VectorType;
QPixmap m_pixmap;
QString m_text;
QBasicTimer timer;
diff --git a/examples/widgets/painting/basicdrawing/CMakeLists.txt b/examples/widgets/painting/basicdrawing/CMakeLists.txt
index b36f44f8ba..c3fb855709 100644
--- a/examples/widgets/painting/basicdrawing/CMakeLists.txt
+++ b/examples/widgets/painting/basicdrawing/CMakeLists.txt
@@ -1,39 +1,29 @@
-# Generated from basicdrawing.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(basicdrawing LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/basicdrawing")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(basicdrawing
main.cpp
renderarea.cpp renderarea.h
window.cpp window.h
)
+
set_target_properties(basicdrawing PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(basicdrawing_resource_files
@@ -41,7 +31,7 @@ set(basicdrawing_resource_files
"images/qt-logo.png"
)
-qt6_add_resources(basicdrawing "basicdrawing"
+qt_add_resources(basicdrawing "basicdrawing"
PREFIX
"/"
FILES
@@ -49,7 +39,14 @@ qt6_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 7b927f35c9..1d8fd919b2 100644
--- a/examples/widgets/painting/basicdrawing/main.cpp
+++ b/examples/widgets/painting/basicdrawing/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
@@ -54,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/basicdrawing/renderarea.cpp b/examples/widgets/painting/basicdrawing/renderarea.cpp
index 09d610ee95..d32abb5206 100644
--- a/examples/widgets/painting/basicdrawing/renderarea.cpp
+++ b/examples/widgets/painting/basicdrawing/renderarea.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "renderarea.h"
diff --git a/examples/widgets/painting/basicdrawing/renderarea.h b/examples/widgets/painting/basicdrawing/renderarea.h
index 5f85aa7f96..dfc7d0752b 100644
--- a/examples/widgets/painting/basicdrawing/renderarea.h
+++ b/examples/widgets/painting/basicdrawing/renderarea.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef RENDERAREA_H
#define RENDERAREA_H
diff --git a/examples/widgets/painting/basicdrawing/window.cpp b/examples/widgets/painting/basicdrawing/window.cpp
index 0a035cc299..9699e71605 100644
--- a/examples/widgets/painting/basicdrawing/window.cpp
+++ b/examples/widgets/painting/basicdrawing/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "renderarea.h"
#include "window.h"
diff --git a/examples/widgets/painting/basicdrawing/window.h b/examples/widgets/painting/basicdrawing/window.h
index 7551783a8b..d2035c5b0b 100644
--- a/examples/widgets/painting/basicdrawing/window.h
+++ b/examples/widgets/painting/basicdrawing/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
diff --git a/examples/widgets/painting/composition/.prev_CMakeLists.txt b/examples/widgets/painting/composition/.prev_CMakeLists.txt
deleted file mode 100644
index 5e3cb8c10c..0000000000
--- a/examples/widgets/painting/composition/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,224 +0,0 @@
-# Generated from composition.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(composition LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/composition")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(composition
- ../shared/arthurstyle.cpp ../shared/arthurstyle.h
- ../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- ../shared/hoverpoints.cpp ../shared/hoverpoints.h
- composition.cpp composition.h
- main.cpp
-)
-set_target_properties(composition PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_include_directories(composition PUBLIC
- ../shared
-)
-
-target_link_libraries(composition PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
-set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
-)
-
-qt6_add_resources(composition "shared"
- PREFIX
- "/res"
- BASE
- "../shared"
- FILES
- ${shared_resource_files}
-)
-set(composition_resource_files
- "composition.cpp"
- "composition.html"
- "flower.jpg"
- "flower_alpha.jpg"
-)
-
-qt6_add_resources(composition "composition"
- PREFIX
- "/res/composition"
- FILES
- ${composition_resource_files}
-)
-
-if(QT_FEATURE_opengl)
- target_sources(composition PUBLIC
- ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h
- )
-
- target_link_libraries(composition PUBLIC
- Qt::OpenGL
- )
-endif()
-
-install(TARGETS composition
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/painting/composition/CMakeLists.txt b/examples/widgets/painting/composition/CMakeLists.txt
index 8192439737..b88ee42e41 100644
--- a/examples/widgets/painting/composition/CMakeLists.txt
+++ b/examples/widgets/painting/composition/CMakeLists.txt
@@ -1,201 +1,74 @@
-# Generated from composition.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(composition LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/composition")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(composition
- # special case begin
- # remove files from ../shared
- #../shared/arthurstyle.cpp ../shared/arthurstyle.h
- #../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- #../shared/hoverpoints.cpp ../shared/hoverpoints.h
- # special case end
composition.cpp composition.h
main.cpp
)
+
set_target_properties(composition PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_include_directories(composition PUBLIC
- ../shared
-)
-# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
-# special case end
-target_link_libraries(composition PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
- painting_shared::painting_shared # special case
+target_link_libraries(composition PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+ painting_shared::painting_shared
)
-
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
-)
-
-qt6_add_resources(composition "shared"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
+)
+
+qt_add_resources(composition "shared"
PREFIX
"/res"
BASE
@@ -203,6 +76,7 @@ qt6_add_resources(composition "shared"
FILES
${shared_resource_files}
)
+
set(composition_resource_files
"composition.cpp"
"composition.html"
@@ -210,28 +84,22 @@ set(composition_resource_files
"flower_alpha.jpg"
)
-qt6_add_resources(composition "composition"
+qt_add_resources(composition "composition"
PREFIX
"/res/composition"
FILES
${composition_resource_files}
)
-# special case begin
-# 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()
-# special case end
-
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 a220fb42fa..b4fb4fa3f7 100644
--- a/examples/widgets/painting/composition/composition.cpp
+++ b/examples/widgets/painting/composition/composition.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "composition.h"
#include <QBoxLayout>
@@ -57,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)
@@ -141,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);
@@ -168,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);
@@ -212,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);
@@ -264,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()
@@ -359,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)
@@ -486,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 52ca7919b0..6a5206da08 100644
--- a/examples/widgets/painting/composition/composition.h
+++ b/examples/widgets/painting/composition/composition.h
@@ -1,63 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef COMPOSITION_H
#define COMPOSITION_H
#include "arthurwidgets.h"
-#if QT_CONFIG(opengl)
-#include "fbopaintdevice.h"
-#include <QOpenGLTextureBlitter>
-#endif
-
#include <QPainter>
#include <QEvent>
@@ -190,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/composition/main.cpp b/examples/widgets/painting/composition/main.cpp
index 1ffa29dddc..bc468d0424 100644
--- a/examples/widgets/painting/composition/main.cpp
+++ b/examples/widgets/painting/composition/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "composition.h"
diff --git a/examples/widgets/painting/concentriccircles/CMakeLists.txt b/examples/widgets/painting/concentriccircles/CMakeLists.txt
deleted file mode 100644
index e75da10aff..0000000000
--- a/examples/widgets/painting/concentriccircles/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from concentriccircles.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(concentriccircles LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/concentriccircles")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 639f9e5e4e..0000000000
--- a/examples/widgets/painting/concentriccircles/circlewidget.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 a83ea0637e..0000000000
--- a/examples/widgets/painting/concentriccircles/circlewidget.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 d9fa2879c4..0000000000
--- a/examples/widgets/painting/concentriccircles/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 45258e0bc4..0000000000
--- a/examples/widgets/painting/concentriccircles/window.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 461e03b6f2..0000000000
--- a/examples/widgets/painting/concentriccircles/window.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <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/.prev_CMakeLists.txt b/examples/widgets/painting/deform/.prev_CMakeLists.txt
deleted file mode 100644
index 4462680de7..0000000000
--- a/examples/widgets/painting/deform/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,222 +0,0 @@
-# Generated from deform.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(deform LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/deform")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(deform
- ../shared/arthurstyle.cpp ../shared/arthurstyle.h
- ../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- ../shared/hoverpoints.cpp ../shared/hoverpoints.h
- main.cpp
- pathdeform.cpp pathdeform.h
-)
-set_target_properties(deform PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_include_directories(deform PUBLIC
- ../shared
-)
-
-target_link_libraries(deform PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
-set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
-)
-
-qt6_add_resources(deform "shared"
- PREFIX
- "/res"
- BASE
- "../shared"
- FILES
- ${shared_resource_files}
-)
-set(deform_resource_files
- "pathdeform.cpp"
- "pathdeform.html"
-)
-
-qt6_add_resources(deform "deform"
- PREFIX
- "/res/deform"
- FILES
- ${deform_resource_files}
-)
-
-if(QT_FEATURE_opengl)
- target_sources(deform PUBLIC
- ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h
- )
-
- target_link_libraries(deform PUBLIC
- Qt::OpenGL
- )
-endif()
-
-install(TARGETS deform
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/painting/deform/CMakeLists.txt b/examples/widgets/painting/deform/CMakeLists.txt
index c2517ac66f..1038df03ad 100644
--- a/examples/widgets/painting/deform/CMakeLists.txt
+++ b/examples/widgets/painting/deform/CMakeLists.txt
@@ -1,201 +1,74 @@
-# Generated from deform.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(deform LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/deform")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(deform
- # special case begin
- # remove files from ../shared
- #../shared/arthurstyle.cpp ../shared/arthurstyle.h
- #../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- #../shared/hoverpoints.cpp ../shared/hoverpoints.h
- # special case end
main.cpp
pathdeform.cpp pathdeform.h
)
+
set_target_properties(deform PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_include_directories(deform PUBLIC
- ../shared
-)
-# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
-# special case end
-target_link_libraries(deform PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
- painting_shared::painting_shared # special case
+target_link_libraries(deform PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+ painting_shared::painting_shared
)
-
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
-)
-
-qt6_add_resources(deform "shared"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
+)
+
+qt_add_resources(deform "shared"
PREFIX
"/res"
BASE
@@ -203,33 +76,28 @@ qt6_add_resources(deform "shared"
FILES
${shared_resource_files}
)
+
set(deform_resource_files
"pathdeform.cpp"
"pathdeform.html"
)
-qt6_add_resources(deform "deform"
+qt_add_resources(deform "deform"
PREFIX
"/res/deform"
FILES
${deform_resource_files}
)
-# special case begin
-# 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()
-# special case end
-
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 28e3d6823d..5ac5b4cc3f 100644
--- a/examples/widgets/painting/deform/main.cpp
+++ b/examples/widgets/painting/deform/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "pathdeform.h"
@@ -54,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 acf0191260..f2c67c1587 100644
--- a/examples/widgets/painting/deform/pathdeform.cpp
+++ b/examples/widgets/painting/deform/pathdeform.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "pathdeform.h"
@@ -108,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);
@@ -129,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);
@@ -155,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,
@@ -198,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);
@@ -218,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);
@@ -234,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);
@@ -427,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)
@@ -461,27 +386,14 @@ 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)
{
- if (m_show_doc) {
+ if (m_showDoc) {
setDescriptionEnabled(false);
return;
}
@@ -525,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);
}
}
@@ -617,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/deform/pathdeform.h b/examples/widgets/painting/deform/pathdeform.h
index 0314755b34..5fa279e6de 100644
--- a/examples/widgets/painting/deform/pathdeform.h
+++ b/examples/widgets/painting/deform/pathdeform.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef PATHDEFORM_H
#define PATHDEFORM_H
diff --git a/examples/widgets/painting/fontsampler/CMakeLists.txt b/examples/widgets/painting/fontsampler/CMakeLists.txt
deleted file mode 100644
index d3a7680bdc..0000000000
--- a/examples/widgets/painting/fontsampler/CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-# Generated from fontsampler.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(fontsampler LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC 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 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-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 1bf46b226f..0000000000
--- a/examples/widgets/painting/fontsampler/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 33f6f9a927..0000000000
--- a/examples/widgets/painting/fontsampler/mainwindow.cpp
+++ /dev/null
@@ -1,361 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 34e54440d4..0000000000
--- a/examples/widgets/painting/fontsampler/mainwindow.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include "ui_mainwindowbase.h"
-
-#if defined(QT_PRINTSUPPORT_LIB)
-#include <QtPrintSupport/qtprintsupportglobal.h>
-#endif
-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/.prev_CMakeLists.txt b/examples/widgets/painting/gradients/.prev_CMakeLists.txt
deleted file mode 100644
index 7e798d032e..0000000000
--- a/examples/widgets/painting/gradients/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,222 +0,0 @@
-# Generated from gradients.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(gradients LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/gradients")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(gradients
- ../shared/arthurstyle.cpp ../shared/arthurstyle.h
- ../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- ../shared/hoverpoints.cpp ../shared/hoverpoints.h
- gradients.cpp gradients.h
- main.cpp
-)
-set_target_properties(gradients PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_include_directories(gradients PUBLIC
- ../shared
-)
-
-target_link_libraries(gradients PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
-set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
-)
-
-qt6_add_resources(gradients "shared"
- PREFIX
- "/res"
- BASE
- "../shared"
- FILES
- ${shared_resource_files}
-)
-set(gradients_resource_files
- "gradients.cpp"
- "gradients.html"
-)
-
-qt6_add_resources(gradients "gradients"
- PREFIX
- "/res/gradients"
- FILES
- ${gradients_resource_files}
-)
-
-if(QT_FEATURE_opengl)
- target_sources(gradients PUBLIC
- ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h
- )
-
- target_link_libraries(gradients PUBLIC
- Qt::OpenGL
- )
-endif()
-
-install(TARGETS gradients
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/painting/gradients/CMakeLists.txt b/examples/widgets/painting/gradients/CMakeLists.txt
index 6ad4dfa771..39cc44ed8f 100644
--- a/examples/widgets/painting/gradients/CMakeLists.txt
+++ b/examples/widgets/painting/gradients/CMakeLists.txt
@@ -1,201 +1,74 @@
-# Generated from gradients.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(gradients LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/gradients")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(gradients
- # special case begin
- # remove files from ../shared
- #../shared/arthurstyle.cpp ../shared/arthurstyle.h
- #../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- #../shared/hoverpoints.cpp ../shared/hoverpoints.h
- # special case end
gradients.cpp gradients.h
main.cpp
)
+
set_target_properties(gradients PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_include_directories(gradients PUBLIC
- ../shared
-)
-# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
-# special case end
-target_link_libraries(gradients PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
- painting_shared::painting_shared # special case
+target_link_libraries(gradients PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+ painting_shared::painting_shared
)
-
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
-)
-
-qt6_add_resources(gradients "shared"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
+)
+
+qt_add_resources(gradients "shared"
PREFIX
"/res"
BASE
@@ -203,33 +76,28 @@ qt6_add_resources(gradients "shared"
FILES
${shared_resource_files}
)
+
set(gradients_resource_files
"gradients.cpp"
"gradients.html"
)
-qt6_add_resources(gradients "gradients"
+qt_add_resources(gradients "gradients"
PREFIX
"/res/gradients"
FILES
${gradients_resource_files}
)
-# special case begin
-# 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()
-# special case end
-
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 76d5818d32..5ed3d764d1 100644
--- a/examples/widgets/painting/gradients/gradients.cpp
+++ b/examples/widgets/painting/gradients/gradients.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "gradients.h"
#include "hoverpoints.h"
@@ -105,6 +58,8 @@ uint ShadeWidget::colorAt(int x)
for (int i = 1; i < pts.size(); ++i) {
if (pts.at(i - 1).x() <= x && pts.at(i).x() >= x) {
QLineF l(pts.at(i - 1), pts.at(i));
+ if (qIsNull(l.dx()))
+ continue;
l.setLength(l.length() * ((x - l.x1()) / l.dx()));
return m_shade.pixel(qRound(qMin(l.x2(), (qreal(m_shade.width() - 1)))),
qRound(qMin(l.y2(), qreal(m_shade.height() - 1))));
@@ -318,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);
@@ -337,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);
@@ -415,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),
@@ -579,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/gradients.h b/examples/widgets/painting/gradients/gradients.h
index 45ef5d0f93..227424b7b4 100644
--- a/examples/widgets/painting/gradients/gradients.h
+++ b/examples/widgets/painting/gradients/gradients.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef GRADIENTS_H
#define GRADIENTS_H
diff --git a/examples/widgets/painting/gradients/main.cpp b/examples/widgets/painting/gradients/main.cpp
index 7ffb0326e9..c1e2297512 100644
--- a/examples/widgets/painting/gradients/main.cpp
+++ b/examples/widgets/painting/gradients/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "gradients.h"
@@ -54,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 d90958d77b..eea0c24173 100644
--- a/examples/widgets/painting/imagecomposition/CMakeLists.txt
+++ b/examples/widgets/painting/imagecomposition/CMakeLists.txt
@@ -1,38 +1,28 @@
-# Generated from imagecomposition.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(imagecomposition LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/imagecomposition")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(imagecomposition
imagecomposer.cpp imagecomposer.h
main.cpp
)
+
set_target_properties(imagecomposition PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(imagecomposition_resource_files
@@ -40,7 +30,7 @@ set(imagecomposition_resource_files
"images/checker.png"
)
-qt6_add_resources(imagecomposition "imagecomposition"
+qt_add_resources(imagecomposition "imagecomposition"
PREFIX
"/"
FILES
@@ -48,7 +38,14 @@ qt6_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/imagecomposer.cpp b/examples/widgets/painting/imagecomposition/imagecomposer.cpp
index f0935147cf..611a44b6b5 100644
--- a/examples/widgets/painting/imagecomposition/imagecomposer.cpp
+++ b/examples/widgets/painting/imagecomposition/imagecomposer.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "imagecomposer.h"
diff --git a/examples/widgets/painting/imagecomposition/imagecomposer.h b/examples/widgets/painting/imagecomposition/imagecomposer.h
index 7aa75bbc52..1d6a3072fe 100644
--- a/examples/widgets/painting/imagecomposition/imagecomposer.h
+++ b/examples/widgets/painting/imagecomposition/imagecomposer.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef IMAGECOMPOSER_H
#define IMAGECOMPOSER_H
diff --git a/examples/widgets/painting/imagecomposition/main.cpp b/examples/widgets/painting/imagecomposition/main.cpp
index 89502df708..a3cf65a344 100644
--- a/examples/widgets/painting/imagecomposition/main.cpp
+++ b/examples/widgets/painting/imagecomposition/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "imagecomposer.h"
@@ -55,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 4b4b36fa08..46f7948277 100644
--- a/examples/widgets/painting/painterpaths/CMakeLists.txt
+++ b/examples/widgets/painting/painterpaths/CMakeLists.txt
@@ -1,47 +1,45 @@
-# Generated from painterpaths.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(painterpaths LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/painterpaths")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(painterpaths
main.cpp
renderarea.cpp renderarea.h
window.cpp window.h
)
+
set_target_properties(painterpaths PROPERTIES
WIN32_EXECUTABLE TRUE
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/main.cpp b/examples/widgets/painting/painterpaths/main.cpp
index d9fa2879c4..1d8fd919b2 100644
--- a/examples/widgets/painting/painterpaths/main.cpp
+++ b/examples/widgets/painting/painterpaths/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
diff --git a/examples/widgets/painting/painterpaths/renderarea.cpp b/examples/widgets/painting/painterpaths/renderarea.cpp
index 9a5cd3ee87..2d10e0e186 100644
--- a/examples/widgets/painting/painterpaths/renderarea.cpp
+++ b/examples/widgets/painting/painterpaths/renderarea.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "renderarea.h"
diff --git a/examples/widgets/painting/painterpaths/renderarea.h b/examples/widgets/painting/painterpaths/renderarea.h
index 4b3ea5a397..befbdda54a 100644
--- a/examples/widgets/painting/painterpaths/renderarea.h
+++ b/examples/widgets/painting/painterpaths/renderarea.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef RENDERAREA_H
#define RENDERAREA_H
diff --git a/examples/widgets/painting/painterpaths/window.cpp b/examples/widgets/painting/painterpaths/window.cpp
index 07d3c5aaa8..01b62d6988 100644
--- a/examples/widgets/painting/painterpaths/window.cpp
+++ b/examples/widgets/painting/painterpaths/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "renderarea.h"
#include "window.h"
@@ -203,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,
@@ -214,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;
}
@@ -251,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]
@@ -262,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]
@@ -272,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/painterpaths/window.h b/examples/widgets/painting/painterpaths/window.h
index 6a5a5953df..55ac38653c 100644
--- a/examples/widgets/painting/painterpaths/window.h
+++ b/examples/widgets/painting/painterpaths/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
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/.prev_CMakeLists.txt b/examples/widgets/painting/pathstroke/.prev_CMakeLists.txt
deleted file mode 100644
index 22a6635164..0000000000
--- a/examples/widgets/painting/pathstroke/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,222 +0,0 @@
-# Generated from pathstroke.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pathstroke LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/pathstroke")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(pathstroke
- ../shared/arthurstyle.cpp ../shared/arthurstyle.h
- ../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- ../shared/hoverpoints.cpp ../shared/hoverpoints.h
- main.cpp
- pathstroke.cpp pathstroke.h
-)
-set_target_properties(pathstroke PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_include_directories(pathstroke PUBLIC
- ../shared
-)
-
-target_link_libraries(pathstroke PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
-set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
-)
-
-qt6_add_resources(pathstroke "shared"
- PREFIX
- "/res"
- BASE
- "../shared"
- FILES
- ${shared_resource_files}
-)
-set(pathstroke_resource_files
- "pathstroke.cpp"
- "pathstroke.html"
-)
-
-qt6_add_resources(pathstroke "pathstroke"
- PREFIX
- "/res/pathstroke"
- FILES
- ${pathstroke_resource_files}
-)
-
-if(QT_FEATURE_opengl)
- target_sources(pathstroke PUBLIC
- ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h
- )
-
- target_link_libraries(pathstroke PUBLIC
- Qt::OpenGL
- )
-endif()
-
-install(TARGETS pathstroke
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/painting/pathstroke/CMakeLists.txt b/examples/widgets/painting/pathstroke/CMakeLists.txt
index 17de61fede..5c995617eb 100644
--- a/examples/widgets/painting/pathstroke/CMakeLists.txt
+++ b/examples/widgets/painting/pathstroke/CMakeLists.txt
@@ -1,201 +1,74 @@
-# Generated from pathstroke.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(pathstroke LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/pathstroke")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(pathstroke
- # special case begin
- # remove files from ../shared
- #../shared/arthurstyle.cpp ../shared/arthurstyle.h
- #../shared/arthurwidgets.cpp ../shared/arthurwidgets.h
- #../shared/hoverpoints.cpp ../shared/hoverpoints.h
- # special case end
main.cpp
pathstroke.cpp pathstroke.h
)
+
set_target_properties(pathstroke PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_include_directories(pathstroke PUBLIC
- ../shared
-)
-# special case begin
if(NOT TARGET painting_shared::painting_shared)
- add_subdirectory(../shared painting_shared)
+ include(../shared/use_lib.cmake)
endif()
-# special case end
-target_link_libraries(pathstroke PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
- painting_shared::painting_shared # special case
+target_link_libraries(pathstroke PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+ painting_shared::painting_shared
)
-
# Resources:
-set_source_files_properties("../shared/images/button_normal_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_normal_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_normal_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png"
-)
-set_source_files_properties("../shared/images/button_pressed_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png"
-)
-set_source_files_properties("../shared/images/button_pressed_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png"
-)
-set_source_files_properties("../shared/images/frame_bottom.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png"
-)
-set_source_files_properties("../shared/images/frame_bottomleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png"
-)
-set_source_files_properties("../shared/images/frame_bottomright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png"
-)
-set_source_files_properties("../shared/images/frame_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png"
-)
-set_source_files_properties("../shared/images/frame_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png"
-)
-set_source_files_properties("../shared/images/frame_top.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png"
-)
-set_source_files_properties("../shared/images/frame_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png"
-)
-set_source_files_properties("../shared/images/frame_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png"
-)
-set_source_files_properties("../shared/images/groupframe_bottom_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_left_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_right_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_top_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png"
-)
-set_source_files_properties("../shared/images/groupframe_topleft.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png"
-)
-set_source_files_properties("../shared/images/groupframe_topright.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png"
-)
-set_source_files_properties("../shared/images/line_dash_dot_dot.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png"
-)
-set_source_files_properties("../shared/images/line_dashed.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png"
-)
-set_source_files_properties("../shared/images/line_dotted.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png"
-)
-set_source_files_properties("../shared/images/line_solid.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png"
-)
-set_source_files_properties("../shared/images/radiobutton-on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png"
-)
-set_source_files_properties("../shared/images/radiobutton_off.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png"
-)
-set_source_files_properties("../shared/images/radiobutton_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png"
-)
-set_source_files_properties("../shared/images/slider_bar.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png"
-)
-set_source_files_properties("../shared/images/slider_thumb_on.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png"
-)
-set_source_files_properties("../shared/images/title_cap_left.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png"
-)
-set_source_files_properties("../shared/images/title_cap_right.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png"
-)
-set_source_files_properties("../shared/images/title_stretch.png"
- PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png"
-)
set(shared_resource_files
- "images/button_normal_cap_left.png"
- "images/button_normal_cap_right.png"
- "images/button_normal_stretch.png"
- "images/button_pressed_cap_left.png"
- "images/button_pressed_cap_right.png"
- "images/button_pressed_stretch.png"
- "images/frame_bottom.png"
- "images/frame_bottomleft.png"
- "images/frame_bottomright.png"
- "images/frame_left.png"
- "images/frame_right.png"
- "images/frame_top.png"
- "images/frame_topleft.png"
- "images/frame_topright.png"
- "images/groupframe_bottom_left.png"
- "images/groupframe_bottom_right.png"
- "images/groupframe_bottom_stretch.png"
- "images/groupframe_left_stretch.png"
- "images/groupframe_right_stretch.png"
- "images/groupframe_top_stretch.png"
- "images/groupframe_topleft.png"
- "images/groupframe_topright.png"
- "images/line_dash_dot.png"
- "images/line_dash_dot_dot.png"
- "images/line_dashed.png"
- "images/line_dotted.png"
- "images/line_solid.png"
- "images/radiobutton-on.png"
- "images/radiobutton_off.png"
- "images/radiobutton_on.png"
- "images/slider_bar.png"
- "images/slider_thumb_on.png"
- "images/title_cap_left.png"
- "images/title_cap_right.png"
- "images/title_stretch.png"
-)
-
-qt6_add_resources(pathstroke "shared"
+ "../shared/images/button_normal_cap_left.png"
+ "../shared/images/button_normal_cap_right.png"
+ "../shared/images/button_normal_stretch.png"
+ "../shared/images/button_pressed_cap_left.png"
+ "../shared/images/button_pressed_cap_right.png"
+ "../shared/images/button_pressed_stretch.png"
+ "../shared/images/frame_bottom.png"
+ "../shared/images/frame_bottomleft.png"
+ "../shared/images/frame_bottomright.png"
+ "../shared/images/frame_left.png"
+ "../shared/images/frame_right.png"
+ "../shared/images/frame_top.png"
+ "../shared/images/frame_topleft.png"
+ "../shared/images/frame_topright.png"
+ "../shared/images/groupframe_bottom_left.png"
+ "../shared/images/groupframe_bottom_right.png"
+ "../shared/images/groupframe_bottom_stretch.png"
+ "../shared/images/groupframe_left_stretch.png"
+ "../shared/images/groupframe_right_stretch.png"
+ "../shared/images/groupframe_top_stretch.png"
+ "../shared/images/groupframe_topleft.png"
+ "../shared/images/groupframe_topright.png"
+ "../shared/images/line_dash_dot.png"
+ "../shared/images/line_dash_dot_dot.png"
+ "../shared/images/line_dashed.png"
+ "../shared/images/line_dotted.png"
+ "../shared/images/line_solid.png"
+ "../shared/images/radiobutton-on.png"
+ "../shared/images/radiobutton_off.png"
+ "../shared/images/radiobutton_on.png"
+ "../shared/images/slider_bar.png"
+ "../shared/images/slider_thumb_on.png"
+ "../shared/images/title_cap_left.png"
+ "../shared/images/title_cap_right.png"
+ "../shared/images/title_stretch.png"
+)
+
+qt_add_resources(pathstroke "shared"
PREFIX
"/res"
BASE
@@ -203,33 +76,28 @@ qt6_add_resources(pathstroke "shared"
FILES
${shared_resource_files}
)
+
set(pathstroke_resource_files
"pathstroke.cpp"
"pathstroke.html"
)
-qt6_add_resources(pathstroke "pathstroke"
+qt_add_resources(pathstroke "pathstroke"
PREFIX
"/res/pathstroke"
FILES
${pathstroke_resource_files}
)
-# special case begin
-# 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()
-# special case end
-
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 35317480a3..4f991e8a0a 100644
--- a/examples/widgets/painting/pathstroke/main.cpp
+++ b/examples/widgets/painting/pathstroke/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "pathstroke.h"
@@ -54,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 412c2da6a4..cd54a7a8aa 100644
--- a/examples/widgets/painting/pathstroke/pathstroke.cpp
+++ b/examples/widgets/painting/pathstroke/pathstroke.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "pathstroke.h"
#include "arthurstyle.h"
@@ -224,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);
@@ -253,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);
@@ -268,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,
@@ -306,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);
@@ -321,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;
@@ -344,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);
@@ -388,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()
@@ -622,11 +548,11 @@ bool PathStrokeRenderer::event(QEvent *e)
case QEvent::TouchUpdate:
{
const QTouchEvent *const event = static_cast<const QTouchEvent*>(e);
- const QList<QTouchEvent::TouchPoint> points = event->touchPoints();
- for (const QTouchEvent::TouchPoint &touchPoint : points) {
- const int id = touchPoint.id();
- switch (touchPoint.state()) {
- case Qt::TouchPointPressed:
+ const auto points = event->points();
+ for (const auto &point : points) {
+ const int id = point.id();
+ switch (point.state()) {
+ case QEventPoint::Pressed:
{
// find the point, move it
const auto mappedPoints = m_fingerPointMapping.values();
@@ -638,32 +564,32 @@ bool PathStrokeRenderer::event(QEvent *e)
if (activePoints.contains(i))
continue;
- qreal d = QLineF(touchPoint.position(), m_points.at(i)).length();
+ qreal d = QLineF(point.position(), m_points.at(i)).length();
if ((distance < 0 && d < 12 * m_pointSize) || d < distance) {
distance = d;
activePoint = i;
}
}
if (activePoint != -1) {
- m_fingerPointMapping.insert(touchPoint.id(), activePoint);
- m_points[activePoint] = touchPoint.position();
+ m_fingerPointMapping.insert(point.id(), activePoint);
+ m_points[activePoint] = point.position();
}
break;
}
- case Qt::TouchPointReleased:
+ case QEventPoint::Released:
{
// move the point and release
QHash<int,int>::iterator it = m_fingerPointMapping.find(id);
- m_points[it.value()] = touchPoint.position();
+ m_points[it.value()] = point.position();
m_fingerPointMapping.erase(it);
break;
}
- case Qt::TouchPointMoved:
+ case QEventPoint::Updated:
{
// move the point
const int pointIdx = m_fingerPointMapping.value(id, -1);
if (pointIdx >= 0)
- m_points[pointIdx] = touchPoint.position();
+ m_points[pointIdx] = point.position();
break;
}
default:
diff --git a/examples/widgets/painting/pathstroke/pathstroke.h b/examples/widgets/painting/pathstroke/pathstroke.h
index e7e78b641b..05f678dcc6 100644
--- a/examples/widgets/painting/pathstroke/pathstroke.h
+++ b/examples/widgets/painting/pathstroke/pathstroke.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef PATHSTROKE_H
#define PATHSTROKE_H
diff --git a/examples/widgets/painting/shared/CMakeLists.txt b/examples/widgets/painting/shared/CMakeLists.txt
index 9d43e4a980..5eaa3b42e1 100644
--- a/examples/widgets/painting/shared/CMakeLists.txt
+++ b/examples/widgets/painting/shared/CMakeLists.txt
@@ -1,13 +1,5 @@
-# special case skip regeneration
-# Port of shared.pri to be included by painting examples
-
-if(NOT TARGET Qt::Widgets)
- find_package(Qt6 REQUIRED COMPONENTS Widgets)
-endif()
-
-if(NOT TARGET Qt::OpenGL)
- find_package(Qt6 OPTIONAL_COMPONENTS OpenGL)
-endif()
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
add_library(painting_shared OBJECT)
add_library(painting_shared::painting_shared ALIAS painting_shared)
@@ -18,17 +10,8 @@ target_sources(painting_shared PRIVATE
hoverpoints.cpp hoverpoints.h
${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/arthurstyle.cpp b/examples/widgets/painting/shared/arthurstyle.cpp
index 31be899357..15087b8e1a 100644
--- a/examples/widgets/painting/shared/arthurstyle.cpp
+++ b/examples/widgets/painting/shared/arthurstyle.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "arthurstyle.h"
#include "arthurwidgets.h"
@@ -441,7 +394,7 @@ int ArthurStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWid
void ArthurStyle::polish(QWidget *widget)
{
if (widget->layout() && qobject_cast<QGroupBox *>(widget)) {
- if (widget->findChildren<QGroupBox *>().size() == 0) {
+ if (!widget->findChild<QGroupBox *>()) {
widget->layout()->setSpacing(0);
widget->layout()->setContentsMargins(12, 12, 12, 12);
} else {
diff --git a/examples/widgets/painting/shared/arthurstyle.h b/examples/widgets/painting/shared/arthurstyle.h
index 64c888b636..e665a87192 100644
--- a/examples/widgets/painting/shared/arthurstyle.h
+++ b/examples/widgets/painting/shared/arthurstyle.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef ARTHURSTYLE_H
#define ARTHURSTYLE_H
diff --git a/examples/widgets/painting/shared/arthurwidgets.cpp b/examples/widgets/painting/shared/arthurwidgets.cpp
index 667246b79a..4ff435783b 100644
--- a/examples/widgets/painting/shared/arthurwidgets.cpp
+++ b/examples/widgets/painting/shared/arthurwidgets.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "arthurwidgets.h"
#include <QApplication>
@@ -61,94 +14,28 @@
#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);
ArthurFrame::ArthurFrame(QWidget *parent)
- : QWidget(parent)
- , m_prefer_image(false)
+ : QWidget(parent),
+ m_tile(QPixmap(128, 128))
{
-#if QT_CONFIG(opengl)
- m_glWindow = nullptr;
- m_glWidget = nullptr;
- m_use_opengl = false;
-#endif
- m_document = nullptr;
- m_show_doc = false;
-
- m_tile = QPixmap(128, 128);
m_tile.fill(Qt::white);
QPainter pt(&m_tile);
QColor color(230, 230, 230);
pt.fillRect(0, 0, 64, 64, color);
pt.fillRect(64, 64, 64, 64, color);
pt.end();
-
-// QPalette pal = palette();
-// pal.setBrush(backgroundRole(), m_tile);
-// setPalette(pal);
}
-
-#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);
@@ -163,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());
@@ -209,7 +85,7 @@ void ArthurFrame::paintEvent(QPaintEvent *e)
painter.restore();
painter.save();
- if (m_show_doc)
+ if (m_showDoc)
paintDescription(&painter);
painter.restore();
@@ -218,35 +94,23 @@ 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);
}
void ArthurFrame::setDescriptionEnabled(bool enabled)
{
- if (m_show_doc != enabled) {
- m_show_doc = enabled;
- emit descriptionEnabledChanged(m_show_doc);
+ if (m_showDoc != enabled) {
+ m_showDoc = enabled;
+ emit descriptionEnabledChanged(m_showDoc);
update();
}
}
@@ -276,9 +140,8 @@ void ArthurFrame::paintDescription(QPainter *painter)
int pageWidth = qMax(width() - 100, 100);
int pageHeight = qMax(height() - 100, 100);
- if (pageWidth != m_document->pageSize().width()) {
+ if (pageWidth != m_document->pageSize().width())
m_document->setPageSize(QSize(pageWidth, pageHeight));
- }
QRect textRect(width() / 2 - pageWidth / 2,
height() / 2 - pageHeight / 2,
@@ -340,7 +203,7 @@ void ArthurFrame::showSource()
if (!f.open(QFile::ReadOnly))
contents = tr("Could not open file: '%1'").arg(m_sourceFileName);
else
- contents = f.readAll();
+ contents = QString::fromUtf8(f.readAll());
}
contents.replace(QLatin1Char('&'), QStringLiteral("&amp;"));
diff --git a/examples/widgets/painting/shared/arthurwidgets.h b/examples/widgets/painting/shared/arthurwidgets.h
index 73e1310c0e..e508e811cb 100644
--- a/examples/widgets/painting/shared/arthurwidgets.h
+++ b/examples/widgets/painting/shared/arthurwidgets.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef ARTHURWIDGETS_H
#define ARTHURWIDGETS_H
@@ -56,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)
@@ -69,7 +21,6 @@ public:
ArthurFrame(QWidget *parent);
virtual void paint(QPainter *) {}
-
void paintDescription(QPainter *p);
void loadDescription(const QString &filename);
@@ -77,21 +28,13 @@ public:
void loadSourceFile(const QString &fileName);
- bool preferImage() const { return m_prefer_image; }
-#if QT_CONFIG(opengl)
- QOpenGLWindow *glWindow() const { return m_glWindow; }
-#endif
+ bool preferImage() const { return m_preferImage; }
public slots:
- void setPreferImage(bool pi) { m_prefer_image = pi; }
+ 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);
@@ -99,20 +42,13 @@ protected:
void paintEvent(QPaintEvent *) override;
void resizeEvent(QResizeEvent *) override;
-#if QT_CONFIG(opengl)
- virtual void createGlWindow();
- QOpenGLWindow *m_glWindow;
- QWidget *m_glWidget;
- bool m_use_opengl;
-#endif
QPixmap m_tile;
- bool m_show_doc;
- bool m_prefer_image;
- QTextDocument *m_document;
+ bool m_showDoc = false;
+ bool m_preferImage = false;
+ QTextDocument *m_document = nullptr;
QString m_sourceFileName;
-
};
#endif
diff --git a/examples/widgets/painting/shared/fbopaintdevice.cpp b/examples/widgets/painting/shared/fbopaintdevice.cpp
deleted file mode 100644
index 9368293218..0000000000
--- a/examples/widgets/painting/shared/fbopaintdevice.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 a42bcc756d..0000000000
--- a/examples/widgets/painting/shared/fbopaintdevice.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 9fe947cedc..a917139613 100644
--- a/examples/widgets/painting/shared/hoverpoints.cpp
+++ b/examples/widgets/painting/shared/hoverpoints.cpp
@@ -1,87 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "arthurwidgets.h"
#include "hoverpoints.h"
#include <algorithm>
-#if QT_CONFIG(opengl)
-#include <QtOpenGL/QOpenGLWindow>
-#endif
-
-#define printf
-
HoverPoints::HoverPoints(QWidget *widget, PointShape shape)
- : QObject(widget)
+ : QObject(widget),
+ m_widget(widget),
+ m_shape(shape)
{
- m_widget = widget;
widget->installEventFilter(this);
widget->setAttribute(Qt::WA_AcceptTouchEvents);
- m_connectionType = CurveConnection;
- m_sortType = NoSort;
- m_shape = shape;
- m_pointPen = QPen(QColor(255, 255, 255, 191), 1);
- m_connectionPen = QPen(QColor(255, 255, 255, 127), 2);
- m_pointBrush = QBrush(QColor(191, 191, 191, 127));
- m_pointSize = QSize(11, 11);
- m_currentIndex = -1;
- m_editable = true;
- m_enabled = true;
-
connect(this, &HoverPoints::pointsChanged,
m_widget, QOverload<>::of(&QWidget::update));
}
-
void HoverPoints::setEnabled(bool enabled)
{
if (m_enabled != enabled) {
@@ -90,191 +26,200 @@ void HoverPoints::setEnabled(bool enabled)
}
}
-
bool HoverPoints::eventFilter(QObject *object, QEvent *event)
{
- if (object == m_widget && m_enabled) {
- switch (event->type()) {
+ if (object != m_widget || !m_enabled)
+ return false;
- case QEvent::MouseButtonPress:
- {
- if (!m_fingerPointMapping.isEmpty())
- return true;
- QMouseEvent *me = (QMouseEvent *) event;
-
- QPointF clickPos = me->position().toPoint();
- int index = -1;
- for (int i=0; i<m_points.size(); ++i) {
- QPainterPath path;
- if (m_shape == CircleShape)
- path.addEllipse(pointBoundingRect(i));
- else
- path.addRect(pointBoundingRect(i));
-
- if (path.contains(clickPos)) {
- index = i;
- break;
- }
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ {
+ if (!m_fingerPointMapping.isEmpty())
+ return true;
+ auto *me = static_cast<const QMouseEvent *>(event);
+ QPointF clickPos = me->position().toPoint();
+ qsizetype index = -1;
+ for (qsizetype i = 0; i < m_points.size(); ++i) {
+ QPainterPath path;
+ const QRectF rect = pointBoundingRect(m_points.at(i));
+ if (m_shape == CircleShape)
+ path.addEllipse(rect);
+ else
+ path.addRect(rect);
+
+ if (path.contains(clickPos)) {
+ index = i;
+ break;
}
+ }
- if (me->button() == Qt::LeftButton) {
- if (index == -1) {
- if (!m_editable)
- return false;
- int pos = 0;
- // Insert sort for x or y
- if (m_sortType == XSort) {
- for (int i=0; i<m_points.size(); ++i)
- if (m_points.at(i).x() > clickPos.x()) {
- pos = i;
- break;
- }
- } else if (m_sortType == YSort) {
- for (int i=0; i<m_points.size(); ++i)
- if (m_points.at(i).y() > clickPos.y()) {
- pos = i;
- break;
- }
+ if (me->button() == Qt::LeftButton) {
+ if (index == -1) {
+ if (!m_editable)
+ return false;
+ qsizetype pos = 0;
+ // Insert sort for x or y
+ switch (m_sortType) {
+ case XSort:
+ for (qsizetype i = 0; i < m_points.size(); ++i) {
+ if (m_points.at(i).x() > clickPos.x()) {
+ pos = i;
+ break;
+ }
}
-
- m_points.insert(pos, clickPos);
- m_locks.insert(pos, 0);
- m_currentIndex = pos;
- firePointChange();
- } else {
- m_currentIndex = index;
- }
- return true;
-
- } else if (me->button() == Qt::RightButton) {
- if (index >= 0 && m_editable) {
- if (m_locks[index] == 0) {
- m_locks.remove(index);
- m_points.remove(index);
+ break;
+ case YSort:
+ for (qsizetype i = 0; i < m_points.size(); ++i) {
+ if (m_points.at(i).y() > clickPos.y()) {
+ pos = i;
+ break;
+ }
}
- firePointChange();
- return true;
+ break;
+ default:
+ break;
}
+
+ m_points.insert(pos, clickPos);
+ m_locks.insert(pos, 0);
+ m_currentIndex = pos;
+ firePointChange();
+ } else {
+ m_currentIndex = index;
}
+ return true;
+ } else if (me->button() == Qt::RightButton) {
+ if (index >= 0 && m_editable) {
+ if (m_locks[index] == 0) {
+ m_locks.remove(index);
+ m_points.remove(index);
+ }
+ firePointChange();
+ return true;
+ }
}
+ }
+ break;
+
+ case QEvent::MouseButtonRelease:
+ if (!m_fingerPointMapping.isEmpty())
+ return true;
+ m_currentIndex = -1;
break;
- case QEvent::MouseButtonRelease:
- if (!m_fingerPointMapping.isEmpty())
- return true;
- m_currentIndex = -1;
- break;
+ case QEvent::MouseMove:
+ if (!m_fingerPointMapping.isEmpty())
+ return true;
+ if (m_currentIndex >= 0) {
+ auto *me = static_cast<const QMouseEvent *>(event);
+ movePoint(m_currentIndex, me->position().toPoint());
+ }
+ break;
- case QEvent::MouseMove:
- if (!m_fingerPointMapping.isEmpty())
- return true;
- if (m_currentIndex >= 0)
- movePoint(m_currentIndex, ((QMouseEvent *)event)->position().toPoint());
- break;
- case QEvent::TouchBegin:
- case QEvent::TouchUpdate:
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ {
+ auto *touchEvent = static_cast<const QTouchEvent*>(event);
+ const auto points = touchEvent->points();
+ const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height());
+ for (const auto &point : points) {
+ const int id = point.id();
+ switch (point.state()) {
+ case QEventPoint::Pressed:
+ case QEventPoint::Stationary:
{
- const QTouchEvent *const touchEvent = static_cast<const QTouchEvent*>(event);
- const QList<QTouchEvent::TouchPoint> points = touchEvent->touchPoints();
- const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height());
- for (const QTouchEvent::TouchPoint &touchPoint : points) {
- const int id = touchPoint.id();
- switch (touchPoint.state()) {
- case Qt::TouchPointPressed:
- {
- // find the point, move it
- const auto mappedPoints = m_fingerPointMapping.values();
- QSet<int> activePoints = QSet<int>(mappedPoints.begin(), mappedPoints.end());
- int activePoint = -1;
- qreal distance = -1;
- const int pointsCount = m_points.size();
- const int activePointCount = activePoints.size();
- if (pointsCount == 2 && activePointCount == 1) { // only two points
- activePoint = activePoints.contains(0) ? 1 : 0;
- } else {
- for (int i=0; i<pointsCount; ++i) {
- if (activePoints.contains(i))
- continue;
-
- qreal d = QLineF(touchPoint.position(), m_points.at(i)).length();
- if ((distance < 0 && d < 12 * pointSize) || d < distance) {
- distance = d;
- activePoint = i;
- }
-
- }
- }
- if (activePoint != -1) {
- m_fingerPointMapping.insert(touchPoint.id(), activePoint);
- movePoint(activePoint, touchPoint.position());
- }
- }
- break;
- case Qt::TouchPointReleased:
- {
- // move the point and release
- QHash<int,int>::iterator it = m_fingerPointMapping.find(id);
- movePoint(it.value(), touchPoint.position());
- m_fingerPointMapping.erase(it);
- }
- break;
- case Qt::TouchPointMoved:
- {
- // move the point
- const int pointIdx = m_fingerPointMapping.value(id, -1);
- if (pointIdx >= 0) // do we track this point?
- movePoint(pointIdx, touchPoint.position());
+ // find the point, move it
+ const auto mappedPoints = m_fingerPointMapping.values();
+ QSet<qsizetype> activePoints(mappedPoints.begin(), mappedPoints.end());
+ qsizetype activePoint = -1;
+ qreal distance = -1;
+ const qsizetype pointsCount = m_points.size();
+ const qsizetype activePointCount = activePoints.size();
+ if (pointsCount == 2 && activePointCount == 1) { // only two points
+ activePoint = activePoints.contains(0) ? 1 : 0;
+ } else {
+ for (qsizetype i = 0; i < pointsCount; ++i) {
+ if (activePoints.contains(i))
+ continue;
+
+ qreal d = QLineF(point.position(), m_points.at(i)).length();
+ if ((distance < 0 && d < 12 * pointSize) || d < distance) {
+ distance = d;
+ activePoint = i;
}
- break;
- default:
- break;
+
}
}
- if (m_fingerPointMapping.isEmpty()) {
- event->ignore();
- return false;
- } else {
- return true;
+ if (activePoint != -1) {
+ m_fingerPointMapping.insert(id, activePoint);
+ movePoint(activePoint, point.position());
}
}
break;
- case QEvent::TouchEnd:
- if (m_fingerPointMapping.isEmpty()) {
- event->ignore();
- return false;
+ case QEventPoint::Released:
+ {
+ // move the point and release
+ const auto it = m_fingerPointMapping.constFind(id);
+ if (it != m_fingerPointMapping.constEnd()) {
+ movePoint(it.value(), point.position());
+ m_fingerPointMapping.erase(it);
+ }
}
- return true;
break;
-
- case QEvent::Resize:
- {
- QResizeEvent *e = (QResizeEvent *) event;
- if (e->oldSize().width() == 0 || e->oldSize().height() == 0)
- break;
- qreal stretch_x = e->size().width() / qreal(e->oldSize().width());
- qreal stretch_y = e->size().height() / qreal(e->oldSize().height());
- for (int i=0; i<m_points.size(); ++i) {
- QPointF p = m_points[i];
- movePoint(i, QPointF(p.x() * stretch_x, p.y() * stretch_y), false);
+ case QEventPoint::Updated:
+ {
+ // move the point
+ const qsizetype pointIdx = m_fingerPointMapping.value(id, -1);
+ if (pointIdx >= 0) // do we track this point?
+ movePoint(pointIdx, point.position());
}
-
- firePointChange();
break;
+ default:
+ break;
+ }
}
-
- case QEvent::Paint:
- {
- QWidget *that_widget = m_widget;
- m_widget = nullptr;
- QCoreApplication::sendEvent(object, event);
- m_widget = that_widget;
- paintPoints();
- return true;
+ if (m_fingerPointMapping.isEmpty()) {
+ event->ignore();
+ return false;
+ }
+ return true;
+ }
+ case QEvent::TouchEnd:
+ if (m_fingerPointMapping.isEmpty()) {
+ event->ignore();
+ return false;
}
- default:
+ return true;
+
+ case QEvent::Resize:
+ {
+ auto *e = static_cast<const QResizeEvent *>(event);
+ if (e->oldSize().width() <= 0 || e->oldSize().height() <= 0)
break;
+ qreal stretch_x = e->size().width() / qreal(e->oldSize().width());
+ qreal stretch_y = e->size().height() / qreal(e->oldSize().height());
+ for (qsizetype i = 0; i < m_points.size(); ++i) {
+ QPointF p = m_points.at(i);
+ movePoint(i, QPointF(p.x() * stretch_x, p.y() * stretch_y), false);
}
+
+ firePointChange();
+ break;
+ }
+
+ case QEvent::Paint:
+ {
+ QWidget *that_widget = m_widget;
+ m_widget = nullptr;
+ QCoreApplication::sendEvent(object, event);
+ m_widget = that_widget;
+ paintPoints();
+ return true;
+ }
+
+ default:
+ break;
}
return false;
@@ -284,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);
@@ -304,8 +239,8 @@ void HoverPoints::paintPoints()
if (m_connectionType == CurveConnection) {
QPainterPath path;
path.moveTo(m_points.at(0));
- for (int i=1; i<m_points.size(); ++i) {
- QPointF p1 = m_points.at(i-1);
+ for (qsizetype i = 1; i < m_points.size(); ++i) {
+ QPointF p1 = m_points.at(i - 1);
QPointF p2 = m_points.at(i);
qreal distance = p2.x() - p1.x();
@@ -322,8 +257,8 @@ void HoverPoints::paintPoints()
p.setPen(m_pointPen);
p.setBrush(m_pointBrush);
- for (int i=0; i<m_points.size(); ++i) {
- QRectF bounds = pointBoundingRect(i);
+ for (const auto &point : std::as_const(m_points)) {
+ QRectF bounds = pointBoundingRect(point);
if (m_shape == CircleShape)
p.drawEllipse(bounds);
else
@@ -354,32 +289,28 @@ void HoverPoints::setPoints(const QPolygonF &points)
if (points.size() != m_points.size())
m_fingerPointMapping.clear();
m_points.clear();
- for (int i=0; i<points.size(); ++i)
+ for (qsizetype i = 0; i < points.size(); ++i)
m_points << bound_point(points.at(i), boundingRect(), 0);
m_locks.clear();
if (m_points.size() > 0) {
m_locks.resize(m_points.size());
-
m_locks.fill(0);
}
}
-
-void HoverPoints::movePoint(int index, const QPointF &point, bool emitUpdate)
+void HoverPoints::movePoint(qsizetype index, const QPointF &point, bool emitUpdate)
{
m_points[index] = bound_point(point, boundingRect(), m_locks.at(index));
if (emitUpdate)
firePointChange();
}
-
inline static bool x_less_than(const QPointF &p1, const QPointF &p2)
{
return p1.x() < p2.x();
}
-
inline static bool y_less_than(const QPointF &p1, const QPointF &p2)
{
return p1.y() < p2.y();
@@ -387,14 +318,11 @@ inline static bool y_less_than(const QPointF &p1, const QPointF &p2)
void HoverPoints::firePointChange()
{
-// printf("HoverPoints::firePointChange(), current=%d\n", m_currentIndex);
-
if (m_sortType != NoSort) {
QPointF oldCurrent;
- if (m_currentIndex != -1) {
+ if (m_currentIndex != -1)
oldCurrent = m_points[m_currentIndex];
- }
if (m_sortType == XSort)
std::sort(m_points.begin(), m_points.end(), x_less_than);
@@ -403,22 +331,14 @@ void HoverPoints::firePointChange()
// Compensate for changed order...
if (m_currentIndex != -1) {
- for (int i=0; i<m_points.size(); ++i) {
+ for (qsizetype i = 0; i < m_points.size(); ++i) {
if (m_points[i] == oldCurrent) {
m_currentIndex = i;
break;
}
}
}
-
-// printf(" - firePointChange(), current=%d\n", m_currentIndex);
-
}
-// for (int i=0; i<m_points.size(); ++i) {
-// printf(" - point(%2d)=[%.2f, %.2f], lock=%d\n",
-// i, m_points.at(i).x(), m_points.at(i).y(), m_locks.at(i));
-// }
-
emit pointsChanged(m_points);
}
diff --git a/examples/widgets/painting/shared/hoverpoints.h b/examples/widgets/painting/shared/hoverpoints.h
index 3c6f356e1b..cac0dd5892 100644
--- a/examples/widgets/painting/shared/hoverpoints.h
+++ b/examples/widgets/painting/shared/hoverpoints.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef HOVERPOINTS_H
#define HOVERPOINTS_H
@@ -124,35 +77,33 @@ public:
void firePointChange();
private:
- inline QRectF pointBoundingRect(int i) const;
- void movePoint(int i, const QPointF &newPos, bool emitChange = true);
+ inline QRectF pointBoundingRect(const QPointF &p) const;
+ void movePoint(qsizetype i, const QPointF &newPos, bool emitChange = true);
QWidget *m_widget;
QPolygonF m_points;
QRectF m_bounds;
PointShape m_shape;
- SortType m_sortType;
- ConnectionType m_connectionType;
+ SortType m_sortType = NoSort;
+ ConnectionType m_connectionType = CurveConnection;
QList<uint> m_locks;
- QSizeF m_pointSize;
- int m_currentIndex;
- bool m_editable;
- bool m_enabled;
+ QSizeF m_pointSize{11, 11};
+ qsizetype m_currentIndex= -1;
+ bool m_editable = true;
+ bool m_enabled = true;
- QHash<int, int> m_fingerPointMapping;
+ QHash<int, qsizetype> m_fingerPointMapping;
- QPen m_pointPen;
- QBrush m_pointBrush;
- QPen m_connectionPen;
+ QPen m_pointPen{QColor(255, 255, 255, 191), 1};
+ QBrush m_pointBrush{QColor(191, 191, 191, 127)};
+ QPen m_connectionPen{QColor(255, 255, 255, 127), 2};
};
-
-inline QRectF HoverPoints::pointBoundingRect(int i) const
+inline QRectF HoverPoints::pointBoundingRect(const QPointF &p) const
{
- QPointF p = m_points.at(i);
qreal w = m_pointSize.width();
qreal h = m_pointSize.height();
qreal x = p.x() - w / 2;
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
new file mode 100644
index 0000000000..84684a3444
--- /dev/null
+++ b/examples/widgets/painting/shared/use_lib.cmake
@@ -0,0 +1,12 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# 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
+# consuming target.
+
+if(NOT TARGET Qt::Widgets)
+ find_package(Qt6 REQUIRED COMPONENTS Widgets)
+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 c0ca191c8a..dfc35b2551 100644
--- a/examples/widgets/painting/transformations/CMakeLists.txt
+++ b/examples/widgets/painting/transformations/CMakeLists.txt
@@ -1,41 +1,39 @@
-# Generated from transformations.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(transformations LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/transformations")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(transformations
main.cpp
renderarea.cpp renderarea.h
window.cpp window.h
)
+
set_target_properties(transformations PROPERTIES
WIN32_EXECUTABLE TRUE
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/painting/transformations/main.cpp b/examples/widgets/painting/transformations/main.cpp
index 99725195e5..27409403a5 100644
--- a/examples/widgets/painting/transformations/main.cpp
+++ b/examples/widgets/painting/transformations/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/painting/transformations/renderarea.cpp b/examples/widgets/painting/transformations/renderarea.cpp
index 1ebdfd5423..f967db6ee6 100644
--- a/examples/widgets/painting/transformations/renderarea.cpp
+++ b/examples/widgets/painting/transformations/renderarea.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "renderarea.h"
diff --git a/examples/widgets/painting/transformations/renderarea.h b/examples/widgets/painting/transformations/renderarea.h
index d4be7cefa4..37286a889a 100644
--- a/examples/widgets/painting/transformations/renderarea.h
+++ b/examples/widgets/painting/transformations/renderarea.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef RENDERAREA_H
#define RENDERAREA_H
diff --git a/examples/widgets/painting/transformations/window.cpp b/examples/widgets/painting/transformations/window.cpp
index a07e4dd5d1..fb1512c256 100644
--- a/examples/widgets/painting/transformations/window.cpp
+++ b/examples/widgets/painting/transformations/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
diff --git a/examples/widgets/painting/transformations/window.h b/examples/widgets/painting/transformations/window.h
index a1129a3609..550817acce 100644
--- a/examples/widgets/painting/transformations/window.h
+++ b/examples/widgets/painting/transformations/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
diff --git a/examples/widgets/qnx/foreignwindows/collector.cpp b/examples/widgets/qnx/foreignwindows/collector.cpp
index 4b9e774945..8831aab3aa 100644
--- a/examples/widgets/qnx/foreignwindows/collector.cpp
+++ b/examples/widgets/qnx/foreignwindows/collector.cpp
@@ -1,41 +1,5 @@
-/***************************************************************************
-**
-** Copyright (C) 2018 QNX Software Systems. All rights reserved.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 QNX Software Systems. All rights reserved.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QDebug>
@@ -63,7 +27,7 @@ Collector::~Collector()
QApplication::instance()->removeNativeEventFilter(this);
}
-bool Collector::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
+bool Collector::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result)
{
Q_UNUSED(result);
diff --git a/examples/widgets/qnx/foreignwindows/collector.h b/examples/widgets/qnx/foreignwindows/collector.h
index 7c0b2e5cb6..4ee93cbc51 100644
--- a/examples/widgets/qnx/foreignwindows/collector.h
+++ b/examples/widgets/qnx/foreignwindows/collector.h
@@ -1,41 +1,5 @@
-/***************************************************************************
-**
-** Copyright (C) 2018 QNX Software Systems. All rights reserved.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 QNX Software Systems. All rights reserved.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef COLLECTOR_H_
#define COLLECTOR_H_
@@ -52,7 +16,7 @@ public:
explicit Collector(QWidget *parent = nullptr);
~Collector() override;
- bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
+ bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override;
private:
struct Collectible
diff --git a/examples/widgets/qnx/foreignwindows/main.cpp b/examples/widgets/qnx/foreignwindows/main.cpp
index 128e93cf88..55dfc98f01 100644
--- a/examples/widgets/qnx/foreignwindows/main.cpp
+++ b/examples/widgets/qnx/foreignwindows/main.cpp
@@ -1,41 +1,5 @@
-/***************************************************************************
-**
-** Copyright (C) 2018 QNX Software Systems. All rights reserved.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 QNX Software Systems. All rights reserved.
+// 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 adb98e38f9..d62e88b3e8 100644
--- a/examples/widgets/richtext/CMakeLists.txt
+++ b/examples/widgets/richtext/CMakeLists.txt
@@ -1,6 +1,5 @@
-# Generated from richtext.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(calendar)
-add_subdirectory(orderform)
-add_subdirectory(syntaxhighlighter)
-add_subdirectory(textedit)
+qt_internal_add_example(orderform)
+qt_internal_add_example(syntaxhighlighter)
diff --git a/examples/widgets/richtext/calendar/CMakeLists.txt b/examples/widgets/richtext/calendar/CMakeLists.txt
deleted file mode 100644
index d8ef569f5f..0000000000
--- a/examples/widgets/richtext/calendar/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from calendar.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(calendar LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/richtext/calendar")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 647677fb9c..0000000000
--- a/examples/widgets/richtext/calendar/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 2b8fd518af..0000000000
--- a/examples/widgets/richtext/calendar/mainwindow.cpp
+++ /dev/null
@@ -1,226 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 7080f50fc2..0000000000
--- a/examples/widgets/richtext/calendar/mainwindow.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 d1538778cc..eacf41fd1f 100644
--- a/examples/widgets/richtext/orderform/CMakeLists.txt
+++ b/examples/widgets/richtext/orderform/CMakeLists.txt
@@ -1,47 +1,43 @@
-# Generated from orderform.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(orderform LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/richtext/orderform")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(orderform
detailsdialog.cpp detailsdialog.h
main.cpp
mainwindow.cpp mainwindow.h
)
+
set_target_properties(orderform PROPERTIES
WIN32_EXECUTABLE TRUE
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/orderform/detailsdialog.cpp b/examples/widgets/richtext/orderform/detailsdialog.cpp
index 9ef9eff73d..e141f3c4bf 100644
--- a/examples/widgets/richtext/orderform/detailsdialog.cpp
+++ b/examples/widgets/richtext/orderform/detailsdialog.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
diff --git a/examples/widgets/richtext/orderform/detailsdialog.h b/examples/widgets/richtext/orderform/detailsdialog.h
index f2f8070bb2..32dead952a 100644
--- a/examples/widgets/richtext/orderform/detailsdialog.h
+++ b/examples/widgets/richtext/orderform/detailsdialog.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DETAILSDIALOG_H
#define DETAILSDIALOG_H
diff --git a/examples/widgets/richtext/orderform/main.cpp b/examples/widgets/richtext/orderform/main.cpp
index ce586969f8..e22ef44357 100644
--- a/examples/widgets/richtext/orderform/main.cpp
+++ b/examples/widgets/richtext/orderform/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/richtext/orderform/mainwindow.cpp b/examples/widgets/richtext/orderform/mainwindow.cpp
index 3916c28b1b..0a4bcb3143 100644
--- a/examples/widgets/richtext/orderform/mainwindow.cpp
+++ b/examples/widgets/richtext/orderform/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#if defined(QT_PRINTSUPPORT_LIB)
diff --git a/examples/widgets/richtext/orderform/mainwindow.h b/examples/widgets/richtext/orderform/mainwindow.h
index e477631640..829257cdaf 100644
--- a/examples/widgets/richtext/orderform/mainwindow.h
+++ b/examples/widgets/richtext/orderform/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
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 5bdc9f7981..13fd37ba1b 100644
--- a/examples/widgets/richtext/syntaxhighlighter/CMakeLists.txt
+++ b/examples/widgets/richtext/syntaxhighlighter/CMakeLists.txt
@@ -1,41 +1,39 @@
-# Generated from syntaxhighlighter.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(syntaxhighlighter LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/richtext/syntaxhighlighter")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(syntaxhighlighter
highlighter.cpp highlighter.h
main.cpp
mainwindow.cpp mainwindow.h
)
+
set_target_properties(syntaxhighlighter PROPERTIES
WIN32_EXECUTABLE TRUE
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 0c10eed6cf..d78de20a7d 100644
--- a/examples/widgets/richtext/syntaxhighlighter/highlighter.cpp
+++ b/examples/widgets/richtext/syntaxhighlighter/highlighter.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "highlighter.h"
@@ -119,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/syntaxhighlighter/highlighter.h b/examples/widgets/richtext/syntaxhighlighter/highlighter.h
index a60da038b3..482b4352ff 100644
--- a/examples/widgets/richtext/syntaxhighlighter/highlighter.h
+++ b/examples/widgets/richtext/syntaxhighlighter/highlighter.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef HIGHLIGHTER_H
#define HIGHLIGHTER_H
diff --git a/examples/widgets/richtext/syntaxhighlighter/main.cpp b/examples/widgets/richtext/syntaxhighlighter/main.cpp
index 426cacea27..39cc6b7aba 100644
--- a/examples/widgets/richtext/syntaxhighlighter/main.cpp
+++ b/examples/widgets/richtext/syntaxhighlighter/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
diff --git a/examples/widgets/richtext/syntaxhighlighter/mainwindow.cpp b/examples/widgets/richtext/syntaxhighlighter/mainwindow.cpp
index 2dba0ba73e..dce2a40a0f 100644
--- a/examples/widgets/richtext/syntaxhighlighter/mainwindow.cpp
+++ b/examples/widgets/richtext/syntaxhighlighter/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
@@ -117,12 +70,12 @@ void MainWindow::setupFileMenu()
QMenu *fileMenu = new QMenu(tr("&File"), this);
menuBar()->addMenu(fileMenu);
- fileMenu->addAction(tr("&New"), this,
- &MainWindow::newFile, QKeySequence::New);
- fileMenu->addAction(tr("&Open..."),
- this, [this](){ openFile(); }, QKeySequence::Open);
- fileMenu->addAction(tr("E&xit"), qApp,
- &QApplication::quit, QKeySequence::Quit);
+ fileMenu->addAction(tr("&New"), QKeySequence::New,
+ this, &MainWindow::newFile);
+ fileMenu->addAction(tr("&Open..."), QKeySequence::Open,
+ this, [this](){ openFile(); });
+ fileMenu->addAction(tr("E&xit"), QKeySequence::Quit,
+ qApp, &QApplication::quit);
}
void MainWindow::setupHelpMenu()
diff --git a/examples/widgets/richtext/syntaxhighlighter/mainwindow.h b/examples/widgets/richtext/syntaxhighlighter/mainwindow.h
index a54b810e16..8925beff78 100644
--- a/examples/widgets/richtext/syntaxhighlighter/mainwindow.h
+++ b/examples/widgets/richtext/syntaxhighlighter/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/widgets/richtext/textedit/.prev_CMakeLists.txt b/examples/widgets/richtext/textedit/.prev_CMakeLists.txt
deleted file mode 100644
index 97fde062dd..0000000000
--- a/examples/widgets/richtext/textedit/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,106 +0,0 @@
-# Generated from textedit.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(textedit LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/richtext/textedit")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-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
-)
-
-
-# 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/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/zoomin.png"
- "images/win/zoomout.png"
-)
-
-qt6_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/CMakeLists.txt b/examples/widgets/richtext/textedit/CMakeLists.txt
deleted file mode 100644
index a376f9f747..0000000000
--- a/examples/widgets/richtext/textedit/CMakeLists.txt
+++ /dev/null
@@ -1,112 +0,0 @@
-# Generated from textedit.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(textedit LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/richtext/textedit")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS PrintSupport) # special case
-
-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
-)
-# special case begin
-if (TARGET Qt::PrintSupport)
- target_link_libraries(textedit PUBLIC Qt::PrintSupport)
-endif()
-# special case end
-
-
-# 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/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/zoomin.png"
- "images/win/zoomout.png"
-)
-
-qt6_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 99090a697f..0000000000
--- a/examples/widgets/richtext/textedit/example.html
+++ /dev/null
@@ -1,79 +0,0 @@
-<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>QTextEdit Example</title><style type="text/css">
-p, li { white-space: pre-wrap; }
-</style></head><body style=" font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
-<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; 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 programatically.</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 158728a784..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
-programatically.
-
-## 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/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/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 256d183811..0000000000
--- a/examples/widgets/richtext/textedit/main.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "textedit.h"
-
-#include <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 194e1e3d92..0000000000
--- a/examples/widgets/richtext/textedit/textedit.cpp
+++ /dev/null
@@ -1,893 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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>
-#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
-
-#include "textedit.h"
-
-#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());
-
- connect(textEdit->document(), &QTextDocument::modificationChanged,
- actionSave, &QAction::setEnabled);
- connect(textEdit->document(), &QTextDocument::modificationChanged,
- this, &QWidget::setWindowModified);
- connect(textEdit->document(), &QTextDocument::undoAvailable,
- actionUndo, &QAction::setEnabled);
- connect(textEdit->document(), &QTextDocument::redoAvailable,
- actionRedo, &QAction::setEnabled);
-
- setWindowModified(textEdit->document()->isModified());
- actionSave->setEnabled(textEdit->document()->isModified());
- actionUndo->setEnabled(textEdit->document()->isUndoAvailable());
- actionRedo->setEnabled(textEdit->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(QApplication::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 = QApplication::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 (QApplication::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);
-
- 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->addItem("Standard");
- comboStyle->addItem("Bullet List (Disc)");
- comboStyle->addItem("Bullet List (Circle)");
- comboStyle->addItem("Bullet List (Square)");
- comboStyle->addItem("Task List (Unchecked)");
- comboStyle->addItem("Task List (Checked)");
- comboStyle->addItem("Ordered List (Decimal)");
- comboStyle->addItem("Ordered List (Alpha lower)");
- comboStyle->addItem("Ordered List (Alpha upper)");
- comboStyle->addItem("Ordered List (Roman lower)");
- comboStyle->addItem("Ordered List (Roman upper)");
- comboStyle->addItem("Heading 1");
- comboStyle->addItem("Heading 2");
- comboStyle->addItem("Heading 3");
- comboStyle->addItem("Heading 4");
- comboStyle->addItem("Heading 5");
- comboStyle->addItem("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;
- if (db.mimeTypeForFileNameAndData(f, data).name() == QLatin1String("text/html")) {
- auto encoding = QStringDecoder::encodingForHtml(data);
- QString str = QStringDecoder(encoding ? *encoding : QStringDecoder::Utf8)(data);
- QUrl baseUrl = (f.front() == QLatin1Char(':') ? QUrl(f) : QUrl::fromLocalFile(f)).adjusted(QUrl::RemoveFilename);
- textEdit->document()->setBaseUrl(baseUrl);
- textEdit->setHtml(str);
-#if QT_CONFIG(textmarkdownreader)
- } else if (db.mimeTypeForFileNameAndData(f, data).name() == QLatin1String("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();
- else 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(QString());
- }
-}
-
-void TextEdit::fileOpen()
-{
- QFileDialog fileDialog(this, tr("Open File..."));
- fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
- fileDialog.setFileMode(QFileDialog::ExistingFile);
- fileDialog.setMimeTypeFilters(QStringList()
-#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().first();
- 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())
- return fileSaveAs();
- if (fileName.startsWith(QStringLiteral(":/")))
- 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;
- 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().first();
- setCurrentFileName(fn);
- return fileSave();
-}
-
-void TextEdit::filePrint()
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
- QPrinter printer(QPrinter::HighResolution);
- QPrintDialog *dlg = new QPrintDialog(&printer, this);
- if (textEdit->textCursor().hasSelection())
- dlg->setOption(QAbstractPrintDialog::PrintSelection);
- dlg->setWindowTitle(tr("Print Document"));
- if (dlg->exec() == QDialog::Accepted)
- textEdit->print(&printer);
- delete dlg;
-#endif
-}
-
-void TextEdit::filePrintPreview()
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printpreviewdialog)
- QPrinter printer(QPrinter::HighResolution);
- QPrintPreviewDialog preview(&printer, this);
- connect(&preview, &QPrintPreviewDialog::paintRequested, this, &TextEdit::printPreview);
- preview.exec();
-#endif
-}
-
-void TextEdit::printPreview(QPrinter *printer)
-{
-#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
- textEdit->print(printer);
-#else
- Q_UNUSED(printer);
-#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 fileName = fileDialog.selectedFiles().first();
- QPrinter printer(QPrinter::HighResolution);
- printer.setOutputFormat(QPrinter::PdfFormat);
- printer.setOutputFileName(fileName);
- textEdit->document()->print(&printer);
- statusBar()->showMessage(tr("Exported \"%1\"")
- .arg(QDir::toNativeSeparators(fileName)));
-//! [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.setFontFamily(f);
- mergeFormatOnWordOrSelection(fmt);
-}
-
-void TextEdit::textSize(const QString &p)
-{
- qreal pointSize = p.toFloat();
- if (p.toFloat() > 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::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 = QApplication::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 & Qt::AlignLeft)
- actionAlignLeft->setChecked(true);
- else if (a & Qt::AlignHCenter)
- actionAlignCenter->setChecked(true);
- else if (a & Qt::AlignRight)
- actionAlignRight->setChecked(true);
- else if (a & 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 07a307f83d..0000000000
--- a/examples/widgets/richtext/textedit/textedit.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef TEXTEDIT_H
-#define TEXTEDIT_H
-
-#include <QMainWindow>
-#include <QMap>
-#include <QPointer>
-
-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 textAlign(QAction *a);
- void setChecked(bool checked);
- void indent();
- void unindent();
-
- void currentCharFormatChanged(const QTextCharFormat &format);
- void cursorPositionChanged();
-
- void clipboardDataChanged();
- void about();
- void printPreview(QPrinter *);
-
-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 *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;
-
- QToolBar *tb;
- 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 ff65043db6..0000000000
--- a/examples/widgets/richtext/textedit/textedit.qdoc
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*! \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 1641acc207..0000000000
--- a/examples/widgets/richtext/textedit/textedit.qrc
+++ /dev/null
@@ -1,52 +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/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/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 f663cd9890..0000000000
--- a/examples/widgets/scroller/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-# Generated from scroller.pro.
-
-add_subdirectory(graphicsview)
diff --git a/examples/widgets/scroller/graphicsview/CMakeLists.txt b/examples/widgets/scroller/graphicsview/CMakeLists.txt
deleted file mode 100644
index cf1349f110..0000000000
--- a/examples/widgets/scroller/graphicsview/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated from graphicsview.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(graphicsview LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/scroller/graphicsview")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 178c431e6c..0000000000
--- a/examples/widgets/scroller/graphicsview/main.cpp
+++ /dev/null
@@ -1,302 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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/.prev_CMakeLists.txt b/examples/widgets/tools/.prev_CMakeLists.txt
deleted file mode 100644
index 29e7f8f9e8..0000000000
--- a/examples/widgets/tools/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-# Generated from tools.pro.
-
-add_subdirectory(completer)
-add_subdirectory(customcompleter)
-add_subdirectory(regularexpression)
-add_subdirectory(settingseditor)
-add_subdirectory(styleplugin)
-add_subdirectory(treemodelcompleter)
-add_subdirectory(undo)
-add_subdirectory(undoframework)
-if(QT_FEATURE_library)
- add_subdirectory(echoplugin)
- add_subdirectory(plugandpaint)
-endif()
-if(QT_FEATURE_translation)
- add_subdirectory(i18n)
-endif()
diff --git a/examples/widgets/tools/CMakeLists.txt b/examples/widgets/tools/CMakeLists.txt
index 022f4a2b8f..a5ec5c4a3e 100644
--- a/examples/widgets/tools/CMakeLists.txt
+++ b/examples/widgets/tools/CMakeLists.txt
@@ -1,18 +1,8 @@
-# Generated from tools.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(completer)
-add_subdirectory(customcompleter)
-if(QT_FEATURE_translation) # special case
- add_subdirectory(i18n)
-endif()
-add_subdirectory(regularexpression)
-add_subdirectory(settingseditor)
-add_subdirectory(styleplugin)
-add_subdirectory(treemodelcompleter)
-add_subdirectory(undo)
-add_subdirectory(undoframework)
-
-if(QT_FEATURE_library) # special case
- add_subdirectory(echoplugin)
- add_subdirectory(plugandpaint) # special case
-endif()
+qt_internal_add_example(completer)
+qt_internal_add_example(customcompleter)
+qt_internal_add_example(regularexpression)
+qt_internal_add_example(treemodelcompleter)
+qt_internal_add_example(undoframework)
diff --git a/examples/widgets/tools/completer/CMakeLists.txt b/examples/widgets/tools/completer/CMakeLists.txt
index a04d25f045..a4ad8055b9 100644
--- a/examples/widgets/tools/completer/CMakeLists.txt
+++ b/examples/widgets/tools/completer/CMakeLists.txt
@@ -1,39 +1,29 @@
-# Generated from completer.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(completer LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/completer")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(completer
fsmodel.cpp fsmodel.h
main.cpp
mainwindow.cpp mainwindow.h
)
+
set_target_properties(completer PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(completer_resource_files
@@ -41,7 +31,7 @@ set(completer_resource_files
"resources/wordlist.txt"
)
-qt6_add_resources(completer "completer"
+qt_add_resources(completer "completer"
PREFIX
"/"
FILES
@@ -49,7 +39,14 @@ qt6_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/fsmodel.cpp b/examples/widgets/tools/completer/fsmodel.cpp
index caa0e824b8..13357a9889 100644
--- a/examples/widgets/tools/completer/fsmodel.cpp
+++ b/examples/widgets/tools/completer/fsmodel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "fsmodel.h"
diff --git a/examples/widgets/tools/completer/fsmodel.h b/examples/widgets/tools/completer/fsmodel.h
index 587e08b192..4157cd33c0 100644
--- a/examples/widgets/tools/completer/fsmodel.h
+++ b/examples/widgets/tools/completer/fsmodel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FILESYSTEMMODEL_H
#define FILESYSTEMMODEL_H
diff --git a/examples/widgets/tools/completer/main.cpp b/examples/widgets/tools/completer/main.cpp
index 165be38f0e..060dfe5bd8 100644
--- a/examples/widgets/tools/completer/main.cpp
+++ b/examples/widgets/tools/completer/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include "mainwindow.h"
@@ -54,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/completer/mainwindow.cpp b/examples/widgets/tools/completer/mainwindow.cpp
index 8e9c0e0615..3b70d76ef0 100644
--- a/examples/widgets/tools/completer/mainwindow.cpp
+++ b/examples/widgets/tools/completer/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "fsmodel.h"
diff --git a/examples/widgets/tools/completer/mainwindow.h b/examples/widgets/tools/completer/mainwindow.h
index 6e6238bf32..5cfa490b9f 100644
--- a/examples/widgets/tools/completer/mainwindow.h
+++ b/examples/widgets/tools/completer/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/widgets/tools/customcompleter/CMakeLists.txt b/examples/widgets/tools/customcompleter/CMakeLists.txt
index 13dd1123eb..8340f2cfdf 100644
--- a/examples/widgets/tools/customcompleter/CMakeLists.txt
+++ b/examples/widgets/tools/customcompleter/CMakeLists.txt
@@ -1,46 +1,36 @@
-# Generated from customcompleter.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(customcompleter LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/customcompleter")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(customcompleter
main.cpp
mainwindow.cpp mainwindow.h
textedit.cpp textedit.h
)
+
set_target_properties(customcompleter PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(customcompleter_resource_files
"resources/wordlist.txt"
)
-qt6_add_resources(customcompleter "customcompleter"
+qt_add_resources(customcompleter "customcompleter"
PREFIX
"/"
FILES
@@ -48,7 +38,14 @@ qt6_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/doc/src/customcompleter.qdoc b/examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc
index 9ca86c966c..0b36549dec 100644
--- a/examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc
+++ b/examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example tools/customcompleter
diff --git a/examples/widgets/tools/customcompleter/main.cpp b/examples/widgets/tools/customcompleter/main.cpp
index 939c6788ba..060dfe5bd8 100644
--- a/examples/widgets/tools/customcompleter/main.cpp
+++ b/examples/widgets/tools/customcompleter/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include "mainwindow.h"
@@ -54,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/customcompleter/mainwindow.cpp b/examples/widgets/tools/customcompleter/mainwindow.cpp
index b8072b505c..a466250836 100644
--- a/examples/widgets/tools/customcompleter/mainwindow.cpp
+++ b/examples/widgets/tools/customcompleter/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "textedit.h"
diff --git a/examples/widgets/tools/customcompleter/mainwindow.h b/examples/widgets/tools/customcompleter/mainwindow.h
index cde553e291..1e2e75bd8b 100644
--- a/examples/widgets/tools/customcompleter/mainwindow.h
+++ b/examples/widgets/tools/customcompleter/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/widgets/tools/customcompleter/textedit.cpp b/examples/widgets/tools/customcompleter/textedit.cpp
index 0d536fea3c..86f11ca56e 100644
--- a/examples/widgets/tools/customcompleter/textedit.cpp
+++ b/examples/widgets/tools/customcompleter/textedit.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "textedit.h"
#include <QCompleter>
diff --git a/examples/widgets/tools/customcompleter/textedit.h b/examples/widgets/tools/customcompleter/textedit.h
index 788cb74ae1..55df217813 100644
--- a/examples/widgets/tools/customcompleter/textedit.h
+++ b/examples/widgets/tools/customcompleter/textedit.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TEXTEDIT_H
#define TEXTEDIT_H
diff --git a/examples/widgets/tools/echoplugin/CMakeLists.txt b/examples/widgets/tools/echoplugin/CMakeLists.txt
deleted file mode 100644
index b848e08e72..0000000000
--- a/examples/widgets/tools/echoplugin/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Generated from echoplugin.pro.
-
-add_subdirectory(echowindow)
-add_subdirectory(plugin)
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/.prev_CMakeLists.txt b/examples/widgets/tools/echoplugin/echowindow/.prev_CMakeLists.txt
deleted file mode 100644
index 1262ce5452..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from echowindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(echoplugin LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/echoplugin")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(echoplugin
- echointerface.h
- echowindow.cpp echowindow.h
- main.cpp
-)
-set_target_properties(echoplugin PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(echoplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS echoplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/echoplugin/echowindow/CMakeLists.txt b/examples/widgets/tools/echoplugin/echowindow/CMakeLists.txt
deleted file mode 100644
index 3814fb235d..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from echowindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(echoplugin LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/echoplugin")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(echopluginwindow # special case: renamed target
- echointerface.h
- echowindow.cpp echowindow.h
- main.cpp
-)
-set_target_properties(echopluginwindow PROPERTIES # special case
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(echopluginwindow PUBLIC # special case
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS echopluginwindow # special case: renamed target
- 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 fb07f7fb79..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/echointerface.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 dce6bdedc3..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 4005937c05..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/echowindow.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 d3cf45fcde..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/main.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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/.prev_CMakeLists.txt b/examples/widgets/tools/echoplugin/plugin/.prev_CMakeLists.txt
deleted file mode 100644
index 9f3a93b3bd..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# Generated from plugin.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(echoplugin LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-set(INSTALL_EXAMPLEDIR "examples/widgets/tools/echoplugin/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_library(echoplugin MODULE
- echoplugin.cpp echoplugin.h
-)
-target_include_directories(echoplugin PUBLIC
- ../echowindow
-)
-
-target_link_libraries(echoplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS echoplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/echoplugin/plugin/CMakeLists.txt b/examples/widgets/tools/echoplugin/plugin/CMakeLists.txt
deleted file mode 100644
index 3e605cd2c9..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-# Generated from plugin.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(echoplugin LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/echoplugin/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_plugin(echoplugin)
-target_sources(echoplugin PRIVATE
- echoplugin.cpp echoplugin.h
-)
-set_target_properties(echoplugin PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_include_directories(echoplugin PUBLIC
- ../echowindow
-)
-
-target_link_libraries(echoplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS echoplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE 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 c9dd93aab8..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/echoplugin.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 f0f237099c..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/echoplugin.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 7579853312..0000000000
--- a/examples/widgets/tools/i18n/CMakeLists.txt
+++ /dev/null
@@ -1,67 +0,0 @@
-# Generated from i18n.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(i18n LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/i18n")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 18f6c7bbcf..0000000000
--- a/examples/widgets/tools/i18n/languagechooser.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 6193ab8756..0000000000
--- a/examples/widgets/tools/i18n/languagechooser.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 33db0dbfc2..0000000000
--- a/examples/widgets/tools/i18n/main.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <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 a107a819ca..0000000000
--- a/examples/widgets/tools/i18n/mainwindow.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 105472d60c..0000000000
--- a/examples/widgets/tools/i18n/mainwindow.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 4e35d0d0c3..0000000000
--- a/examples/widgets/tools/plugandpaint/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-# Generated from plugandpaint.pro.
-
-if(NOT QT_FEATURE_inputdialog)
- return()
-endif()
-add_subdirectory(plugins)
-add_subdirectory(app)
diff --git a/examples/widgets/tools/plugandpaint/app/.prev_CMakeLists.txt b/examples/widgets/tools/plugandpaint/app/.prev_CMakeLists.txt
deleted file mode 100644
index feaac7ad8f..0000000000
--- a/examples/widgets/tools/plugandpaint/app/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,74 +0,0 @@
-# Generated from app.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(plugandpaint LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/plugandpaint")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-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 PUBLIC
- # Remove: L../plugins
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-if(macx-xcode)
- target_link_libraries(plugandpaint PUBLIC
- (
- )
- pnp_basictools$
- )
-endif()
-
-if(NOT macx-xcode)
- target_link_libraries(plugandpaint PUBLIC
- pnp_basictools
- )
-endif()
-
-if(((NOT (macx-xcode)) AND (( NOT debug_and_release OR build_pass ) AND CONFIG(debug,debug OR release))) AND (APPLE))
- target_link_libraries(plugandpaint PUBLIC
- (LIBS, 0)
- (LIBS, 1)
- _debug
- )
-endif()
-
-if(((NOT (macx-xcode)) AND (( NOT debug_and_release OR build_pass ) AND CONFIG(debug,debug OR release))) AND (WIN32))
- target_link_libraries(plugandpaint PUBLIC
- (LIBS, 0)
- (LIBS, 1)
- d
- )
-endif()
-
-install(TARGETS plugandpaint
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/plugandpaint/app/CMakeLists.txt b/examples/widgets/tools/plugandpaint/app/CMakeLists.txt
deleted file mode 100644
index bdf934fa2c..0000000000
--- a/examples/widgets/tools/plugandpaint/app/CMakeLists.txt
+++ /dev/null
@@ -1,76 +0,0 @@
-# Generated from app.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(plugandpaint LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/plugandpaint")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-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 PUBLIC
- # Remove: L../plugins
- Qt::Core
- Qt::Gui
- Qt::Widgets
- pnp_basictools # special case
-)
-target_link_libraries(plugandpaint PUBLIC pnp_basictools) # special case
-
-if(macx-xcode)
- target_link_libraries(plugandpaint PUBLIC
- (
- )
- pnp_basictools$
- )
-endif()
-
-if(NOT macx-xcode)
- target_link_libraries(plugandpaint PUBLIC
- pnp_basictools
- )
-endif()
-
-if(((NOT (macx-xcode)) AND (( NOT debug_and_release OR build_pass ) AND CONFIG(debug,debug OR release))) AND (APPLE))
- target_link_libraries(plugandpaint PUBLIC
- (LIBS, 0)
- (LIBS, 1)
- _debug
- )
-endif()
-
-if(((NOT (macx-xcode)) AND (( NOT debug_and_release OR build_pass ) AND CONFIG(debug,debug OR release))) AND (WIN32))
- target_link_libraries(plugandpaint PUBLIC
- (LIBS, 0)
- (LIBS, 1)
- d
- )
-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 558d359e7d..0000000000
--- a/examples/widgets/tools/plugandpaint/app/app.pro
+++ /dev/null
@@ -1,33 +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 {
- 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 5e92b01dc3..0000000000
--- a/examples/widgets/tools/plugandpaint/app/interfaces.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 f50fd86b97..0000000000
--- a/examples/widgets/tools/plugandpaint/app/main.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//! [0]
-#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 ff3b3614af..0000000000
--- a/examples/widgets/tools/plugandpaint/app/mainwindow.cpp
+++ /dev/null
@@ -1,329 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include "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 2b54264893..0000000000
--- a/examples/widgets/tools/plugandpaint/app/mainwindow.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 e3292e3b91..0000000000
--- a/examples/widgets/tools/plugandpaint/app/paintarea.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include "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 1d1e6006c8..0000000000
--- a/examples/widgets/tools/plugandpaint/app/paintarea.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 204d6ffec4..0000000000
--- a/examples/widgets/tools/plugandpaint/app/plugindialog.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include "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 d480fe4283..0000000000
--- a/examples/widgets/tools/plugandpaint/app/plugindialog.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 1e63da97ca..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Generated from plugins.pro.
-
-add_subdirectory(basictools)
-add_subdirectory(extrafilters)
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/.prev_CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/basictools/.prev_CMakeLists.txt
deleted file mode 100644
index 76474c282b..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated from basictools.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pnp_basictools LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-set(INSTALL_EXAMPLEDIR "examples/widgets/tools/plugandpaint/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt6_add_plugin(pnp_basictools STATIC)
-target_sources(pnp_basictools PRIVATE
- basictoolsplugin.cpp basictoolsplugin.h
-)
-target_include_directories(pnp_basictools PUBLIC
- ../../app
-)
-
-target_link_libraries(pnp_basictools PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS pnp_basictools
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
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 97e4021d61..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-# Generated from basictools.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pnp_basictools LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/plugandpaint/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_plugin(pnp_basictools STATIC)
-target_sources(pnp_basictools PRIVATE
- basictoolsplugin.cpp basictoolsplugin.h
-)
-set_target_properties(pnp_basictools PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_include_directories(pnp_basictools PUBLIC
- ../../app
-)
-
-target_link_libraries(pnp_basictools PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS pnp_basictools
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
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 64f9f7a0d9..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 1d9d170daa..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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/.prev_CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/extrafilters/.prev_CMakeLists.txt
deleted file mode 100644
index 57f37843b8..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated from extrafilters.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pnp_extrafilters LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-set(INSTALL_EXAMPLEDIR "examples/widgets/tools/plugandpaint/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_plugin(pnp_extrafilters)
-target_sources(pnp_extrafilters PRIVATE
- extrafiltersplugin.cpp extrafiltersplugin.h
-)
-target_include_directories(pnp_extrafilters PUBLIC
- ../../app
-)
-
-target_link_libraries(pnp_extrafilters PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS pnp_extrafilters
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
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 bb6948e610..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-# Generated from extrafilters.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pnp_extrafilters LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/plugandpaint/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_plugin(pnp_extrafilters)
-target_sources(pnp_extrafilters PRIVATE
- extrafiltersplugin.cpp extrafiltersplugin.h
-)
-set_target_properties(pnp_extrafilters PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_include_directories(pnp_extrafilters PUBLIC
- ../../app
-)
-
-target_link_libraries(pnp_extrafilters PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS pnp_extrafilters
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
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 30c616a830..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 dddde78caa..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 c0dbf8e24e..af7701f1cf 100644
--- a/examples/widgets/tools/regularexpression/CMakeLists.txt
+++ b/examples/widgets/tools/regularexpression/CMakeLists.txt
@@ -1,45 +1,35 @@
-# Generated from regularexpression.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(regularexpression LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/regularexpression")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(regularexpression
main.cpp
regularexpressiondialog.cpp regularexpressiondialog.h
)
+
set_target_properties(regularexpression PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(regularexpression_resource_files
"images/copy.png"
)
-qt6_add_resources(regularexpression "regularexpression"
+qt_add_resources(regularexpression "regularexpression"
PREFIX
"/"
FILES
@@ -47,7 +37,14 @@ qt6_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/regularexpression/main.cpp b/examples/widgets/tools/regularexpression/main.cpp
index 4b6b210226..460aa892c0 100644
--- a/examples/widgets/tools/regularexpression/main.cpp
+++ b/examples/widgets/tools/regularexpression/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "regularexpressiondialog.h"
diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
index 51025b7100..6ba781731f 100644
--- a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
+++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
@@ -1,54 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
-** Copyright (C) 2016 Samuel Gaist <samuel.gaist@edeltech.ch>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
+// Copyright (C) 2016 Samuel Gaist <samuel.gaist@edeltech.ch>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "regularexpressiondialog.h"
@@ -66,12 +19,13 @@
#include <QAction>
#include <QClipboard>
#include <QContextMenuEvent>
+#include <QFont>
+#include <QFontDatabase>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QFormLayout>
-#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QRegularExpressionMatchIterator>
@@ -106,6 +60,20 @@ static QString codeToPattern(QString code)
return code;
}
+static QFrame *createHorizontalSeparator()
+{
+ auto *result = new QFrame;
+ result->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ return result;
+}
+
+static QFrame *createVerticalSeparator()
+{
+ auto *result = new QFrame;
+ result->setFrameStyle(QFrame::VLine | QFrame::Sunken);
+ return result;
+}
+
class PatternLineEdit : public QLineEdit
{
Q_OBJECT
@@ -239,6 +207,7 @@ void RegularExpressionDialog::setResultUiEnabled(bool enabled)
{
matchDetailsTreeWidget->setEnabled(enabled);
namedGroupsTreeWidget->setEnabled(enabled);
+ replacementTextEdit->setEnabled(enabled);
}
static void setTextColor(QWidget *widget, const QColor &color)
@@ -264,6 +233,7 @@ void RegularExpressionDialog::refresh()
matchDetailsTreeWidget->clear();
namedGroupsTreeWidget->clear();
regexpStatusLabel->setText(QString());
+ replacementTextEdit->clear();
if (pattern.isEmpty()) {
setResultUiEnabled(false);
@@ -271,12 +241,12 @@ void RegularExpressionDialog::refresh()
return;
}
- QRegularExpression rx(pattern);
- if (!rx.isValid()) {
+ regularExpression.setPattern(pattern);
+ if (!regularExpression.isValid()) {
setTextColor(patternLineEdit, Qt::red);
regexpStatusLabel->setText(tr("Invalid: syntax error at position %1 (%2)")
- .arg(rx.patternErrorOffset())
- .arg(rx.errorString()));
+ .arg(regularExpression.patternErrorOffset())
+ .arg(regularExpression.errorString()));
setResultUiEnabled(false);
setUpdatesEnabled(true);
return;
@@ -308,11 +278,13 @@ void RegularExpressionDialog::refresh()
if (useUnicodePropertiesOptionCheckBox->isChecked())
patternOptions |= QRegularExpression::UseUnicodePropertiesOption;
- rx.setPatternOptions(patternOptions);
+ regularExpression.setPatternOptions(patternOptions);
- const int capturingGroupsCount = rx.captureCount() + 1;
+ const int capturingGroupsCount = regularExpression.captureCount() + 1;
- QRegularExpressionMatchIterator iterator = rx.globalMatch(text, offsetSpinBox->value(), matchType, matchOptions);
+ const int offset = offsetSpinBox->value();
+ QRegularExpressionMatchIterator iterator =
+ regularExpression.globalMatch(text, offset, matchType, matchOptions);
int i = 0;
while (iterator.hasNext()) {
@@ -334,7 +306,7 @@ void RegularExpressionDialog::refresh()
regexpStatusLabel->setText(tr("Valid"));
- const QStringList namedCaptureGroups = rx.namedCaptureGroups();
+ const QStringList namedCaptureGroups = regularExpression.namedCaptureGroups();
for (int i = 0; i < namedCaptureGroups.size(); ++i) {
const QString currentNamedCaptureGroup = namedCaptureGroups.at(i);
@@ -343,28 +315,44 @@ void RegularExpressionDialog::refresh()
namedGroupItem->setText(1, currentNamedCaptureGroup.isNull() ? tr("<no name>") : currentNamedCaptureGroup);
}
+ updateReplacement();
setUpdatesEnabled(true);
}
-void RegularExpressionDialog::setupUi()
+void RegularExpressionDialog::updateReplacement()
{
- QWidget *leftHalfContainer = setupLeftUi();
-
- QFrame *verticalSeparator = new QFrame;
- verticalSeparator->setFrameStyle(QFrame::VLine | QFrame::Sunken);
-
- QWidget *rightHalfContainer = setupRightUi();
+ replacementTextEdit->clear();
+ const QString &replacement = replacementLineEdit->text();
+ if (!regularExpression.isValid() || replacement.isEmpty())
+ return;
- QHBoxLayout *mainLayout = new QHBoxLayout;
- mainLayout->addWidget(leftHalfContainer);
- mainLayout->addWidget(verticalSeparator);
- mainLayout->addWidget(rightHalfContainer);
+ QString replaced = subjectTextEdit->toPlainText();
+ replaced.replace(regularExpression, replacement);
+ replacementTextEdit->setPlainText(replaced);
+}
- setLayout(mainLayout);
+void RegularExpressionDialog::setupUi()
+{
+ auto *mainLayout = new QVBoxLayout(this);
+ mainLayout->addWidget(setupTextUi());
+ mainLayout->addWidget(createHorizontalSeparator());
+ auto *horizontalLayout = new QHBoxLayout();
+ mainLayout->addLayout(horizontalLayout);
+ horizontalLayout->addWidget(setupOptionsUi());
+ horizontalLayout->addWidget(createVerticalSeparator());
+ horizontalLayout->addWidget(setupInfoUi());
+
+ auto font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
+ patternLineEdit->setFont(font);
+ rawStringLiteralLineEdit->setFont(font);
+ escapedPatternLineEdit->setFont(font);
+ replacementLineEdit->setFont(font);
+ subjectTextEdit->setFont(font);
+ replacementTextEdit->setFont(font);
}
-QWidget *RegularExpressionDialog::setupLeftUi()
+QWidget *RegularExpressionDialog::setupTextUi()
{
QWidget *container = new QWidget;
@@ -387,6 +375,35 @@ QWidget *RegularExpressionDialog::setupLeftUi()
subjectTextEdit = new QPlainTextEdit;
layout->addRow(tr("&Subject text:"), subjectTextEdit);
+ layout->addRow(createHorizontalSeparator());
+
+ QLabel *replaceLabel = new QLabel(tr("<h3>Replacement"));
+ layout->addRow(replaceLabel);
+
+ replacementLineEdit = new QLineEdit;
+ replacementLineEdit->setClearButtonEnabled(true);
+ connect(replacementLineEdit, &QLineEdit::textChanged, this,
+ &RegularExpressionDialog::updateReplacement);
+ layout->addRow(tr("&Replace by:"), replacementLineEdit);
+ replacementLineEdit->setToolTip(tr("Use \\1, \\2... as placeholders for the captured groups."));
+
+ replacementTextEdit = new QPlainTextEdit;
+ replacementTextEdit->setReadOnly(true);
+ layout->addRow(tr("Result:"), replacementTextEdit);
+
+ return container;
+}
+
+QWidget *RegularExpressionDialog::setupOptionsUi()
+{
+ QWidget *container = new QWidget;
+
+ QFormLayout *layout = new QFormLayout(container);
+ layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
+ layout->setContentsMargins(QMargins());
+
+ layout->addRow(new QLabel(tr("<h3>Options</h3>")));
+
caseInsensitiveOptionCheckBox = new QCheckBox(tr("Case insensitive (/i)"));
dotMatchesEverythingOptionCheckBox = new QCheckBox(tr("Dot matches everything (/s)"));
multilineOptionCheckBox = new QCheckBox(tr("Multiline (/m)"));
@@ -431,7 +448,7 @@ QWidget *RegularExpressionDialog::setupLeftUi()
return container;
}
-QWidget *RegularExpressionDialog::setupRightUi()
+QWidget *RegularExpressionDialog::setupInfoUi()
{
QWidget *container = new QWidget;
@@ -447,9 +464,7 @@ QWidget *RegularExpressionDialog::setupRightUi()
matchDetailsTreeWidget->setSizeAdjustPolicy(QTreeWidget::AdjustToContents);
layout->addRow(tr("Match details:"), matchDetailsTreeWidget);
- QFrame *horizontalSeparator = new QFrame;
- horizontalSeparator->setFrameStyle(QFrame::HLine | QFrame::Sunken);
- layout->addRow(horizontalSeparator);
+ layout->addRow(createHorizontalSeparator());
QLabel *regexpInfoLabel = new QLabel(tr("<h3>Regular expression information</h3>"));
layout->addRow(regexpInfoLabel);
diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.h b/examples/widgets/tools/regularexpression/regularexpressiondialog.h
index b0db4d884c..6924cc0c7b 100644
--- a/examples/widgets/tools/regularexpression/regularexpressiondialog.h
+++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.h
@@ -1,59 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
-** Copyright (C) 2016 Samuel Gaist <samuel.gaist@edeltech.ch>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
+// Copyright (C) 2016 Samuel Gaist <samuel.gaist@edeltech.ch>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef REGULAREXPRESSIONDIALOG_H
#define REGULAREXPRESSIONDIALOG_H
#include <QDialog>
+#include <QRegularExpression>
QT_BEGIN_NAMESPACE
class QCheckBox;
@@ -72,18 +26,25 @@ class RegularExpressionDialog : public QDialog
public:
RegularExpressionDialog(QWidget *parent = nullptr);
+private slots:
+ void updateReplacement();
+
private:
void refresh();
void setupUi();
QWidget *setupLeftUi();
- QWidget *setupRightUi();
+ QWidget *setupTextUi();
+ QWidget *setupOptionsUi();
+ QWidget *setupInfoUi();
void setResultUiEnabled(bool enabled);
QLineEdit *patternLineEdit;
QLineEdit *rawStringLiteralLineEdit;
QLineEdit *escapedPatternLineEdit;
+ QLineEdit *replacementLineEdit;
QPlainTextEdit *subjectTextEdit;
+ QPlainTextEdit *replacementTextEdit;
QCheckBox *caseInsensitiveOptionCheckBox;
QCheckBox *dotMatchesEverythingOptionCheckBox;
@@ -104,6 +65,8 @@ private:
QLabel *regexpStatusLabel;
QTreeWidget *namedGroupsTreeWidget;
+
+ QRegularExpression regularExpression;
};
#endif
diff --git a/examples/widgets/tools/settingseditor/CMakeLists.txt b/examples/widgets/tools/settingseditor/CMakeLists.txt
deleted file mode 100644
index b875192bbb..0000000000
--- a/examples/widgets/tools/settingseditor/CMakeLists.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-# Generated from settingseditor.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(settingseditor LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/settingseditor")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 86119a1afd..0000000000
--- a/examples/widgets/tools/settingseditor/locationdialog.cpp
+++ /dev/null
@@ -1,240 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 cd2efecb0b..0000000000
--- a/examples/widgets/tools/settingseditor/locationdialog.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 3186e9dea5..0000000000
--- a/examples/widgets/tools/settingseditor/main.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 225a396f91..0000000000
--- a/examples/widgets/tools/settingseditor/mainwindow.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 b1115005a9..0000000000
--- a/examples/widgets/tools/settingseditor/mainwindow.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 04af8ce3b9..0000000000
--- a/examples/widgets/tools/settingseditor/settingstree.cpp
+++ /dev/null
@@ -1,278 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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.type() == QVariant::String) {
- 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 54b1ce6157..0000000000
--- a/examples/widgets/tools/settingseditor/settingstree.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 24a236aeee..0000000000
--- a/examples/widgets/tools/settingseditor/variantdelegate.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 9d46aa77a5..0000000000
--- a/examples/widgets/tools/settingseditor/variantdelegate.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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/.prev_CMakeLists.txt b/examples/widgets/tools/styleplugin/.prev_CMakeLists.txt
deleted file mode 100644
index 630c3703f8..0000000000
--- a/examples/widgets/tools/styleplugin/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Generated from styleplugin.pro.
-
-add_subdirectory(stylewindow)
-add_subdirectory(plugin)
diff --git a/examples/widgets/tools/styleplugin/CMakeLists.txt b/examples/widgets/tools/styleplugin/CMakeLists.txt
deleted file mode 100644
index af10d38700..0000000000
--- a/examples/widgets/tools/styleplugin/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-# Generated from styleplugin.pro.
-
-# special case begin
-cmake_minimum_required(VERSION 3.14)
-project(styleplugin LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-set(INSTALL_EXAMPLEDIR "examples")
-
-find_package(Qt6 COMPONENTS Widgets)
-# special case end
-
-add_subdirectory(stylewindow)
-add_subdirectory(plugin)
diff --git a/examples/widgets/tools/styleplugin/plugin/.prev_CMakeLists.txt b/examples/widgets/tools/styleplugin/plugin/.prev_CMakeLists.txt
deleted file mode 100644
index c1be706fde..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# Generated from plugin.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(simplestyleplugin LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-set(INSTALL_EXAMPLEDIR "examples/widgets/tools/styleplugin/styles")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_library(simplestyleplugin MODULE
- simplestyle.cpp simplestyle.h
- simplestyleplugin.cpp simplestyleplugin.h
-)
-target_link_libraries(simplestyleplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS simplestyleplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt b/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt
deleted file mode 100644
index d3899bc0f4..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from plugin.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(simplestyleplugin LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/styleplugin/styles")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_plugin(simplestyleplugin)
-target_sources(simplestyleplugin PRIVATE
- simplestyle.cpp simplestyle.h
- simplestyleplugin.cpp simplestyleplugin.h
-)
-set_target_properties(simplestyleplugin PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(simplestyleplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS simplestyleplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE 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 765c9c2745..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyle.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 4f49de8cbc..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyle.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 cbe7c15cc0..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 3ce37410eb..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 5d692b0564..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from stylewindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(styleplugin LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/styleplugin")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-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 PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-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 ff29eb119e..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/main.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <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 90413ed12e..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 7538f8d1bb..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 34d1d996ed..4f512db3ee 100644
--- a/examples/widgets/tools/treemodelcompleter/CMakeLists.txt
+++ b/examples/widgets/tools/treemodelcompleter/CMakeLists.txt
@@ -1,46 +1,36 @@
-# Generated from treemodelcompleter.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(treemodelcompleter LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/treemodelcompleter")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(treemodelcompleter
main.cpp
mainwindow.cpp mainwindow.h
treemodelcompleter.cpp treemodelcompleter.h
)
+
set_target_properties(treemodelcompleter PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(treemodelcompleter_resource_files
"resources/treemodel.txt"
)
-qt6_add_resources(treemodelcompleter "treemodelcompleter"
+qt_add_resources(treemodelcompleter "treemodelcompleter"
PREFIX
"/"
FILES
@@ -48,7 +38,14 @@ qt6_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 6d150fe80f..060dfe5bd8 100644
--- a/examples/widgets/tools/treemodelcompleter/main.cpp
+++ b/examples/widgets/tools/treemodelcompleter/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include "mainwindow.h"
@@ -54,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/treemodelcompleter/mainwindow.cpp b/examples/widgets/tools/treemodelcompleter/mainwindow.cpp
index 44c5b1312a..cf7c73911d 100644
--- a/examples/widgets/tools/treemodelcompleter/mainwindow.cpp
+++ b/examples/widgets/tools/treemodelcompleter/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "treemodelcompleter.h"
@@ -206,7 +159,7 @@ QAbstractItemModel *MainWindow::modelFromFile(const QString &fileName)
QRegularExpression re("^\\s+");
while (!file.atEnd()) {
- const QString line = QString::fromUtf8(file.readLine()).trimmed();
+ const QString line = QString::fromUtf8(file.readLine());
const QString trimmedLine = line.trimmed();
if (trimmedLine.isEmpty())
continue;
@@ -218,7 +171,7 @@ QAbstractItemModel *MainWindow::modelFromFile(const QString &fileName)
level = 0;
} else {
const int capLen = match.capturedLength();
- level = line.startsWith(QLatin1Char('\t')) ? capLen / 4 : capLen;
+ level = capLen / 4;
}
if (level + 1 >= parents.size())
@@ -267,4 +220,3 @@ void MainWindow::updateContentsLabel(const QString &sep)
{
contentsLabel->setText(tr("Type path from model above with items at each level separated by a '%1'").arg(sep));
}
-
diff --git a/examples/widgets/tools/treemodelcompleter/mainwindow.h b/examples/widgets/tools/treemodelcompleter/mainwindow.h
index 87f492c4ac..5641196241 100644
--- a/examples/widgets/tools/treemodelcompleter/mainwindow.h
+++ b/examples/widgets/tools/treemodelcompleter/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp b/examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp
index 8930c815d5..28a15404f1 100644
--- a/examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp
+++ b/examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "treemodelcompleter.h"
#include <QStringList>
diff --git a/examples/widgets/tools/treemodelcompleter/treemodelcompleter.h b/examples/widgets/tools/treemodelcompleter/treemodelcompleter.h
index d7d1852cc7..7fb413781b 100644
--- a/examples/widgets/tools/treemodelcompleter/treemodelcompleter.h
+++ b/examples/widgets/tools/treemodelcompleter/treemodelcompleter.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TREEMODELCOMPLETER_H
#define TREEMODELCOMPLETER_H
diff --git a/examples/widgets/tools/undo/CMakeLists.txt b/examples/widgets/tools/undo/CMakeLists.txt
deleted file mode 100644
index 8156e12bcd..0000000000
--- a/examples/widgets/tools/undo/CMakeLists.txt
+++ /dev/null
@@ -1,70 +0,0 @@
-# Generated from undo.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(undo LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC 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 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 97204f9d2f..0000000000
--- a/examples/widgets/tools/undo/commands.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 ccb550fdd4..0000000000
--- a/examples/widgets/tools/undo/commands.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 339a63abae..0000000000
--- a/examples/widgets/tools/undo/document.cpp
+++ /dev/null
@@ -1,448 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 6e728ca7a9..0000000000
--- a/examples/widgets/tools/undo/document.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 a5ec1b1b83..0000000000
--- a/examples/widgets/tools/undo/main.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include "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 5623a09ad2..0000000000
--- a/examples/widgets/tools/undo/mainwindow.cpp
+++ /dev/null
@@ -1,457 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 87ee3084fb..0000000000
--- a/examples/widgets/tools/undo/mainwindow.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 9286f83ddb..27912f04c7 100644
--- a/examples/widgets/tools/undoframework/CMakeLists.txt
+++ b/examples/widgets/tools/undoframework/CMakeLists.txt
@@ -1,23 +1,12 @@
-# Generated from undoframework.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(undoframework LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tools/undoframework")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(undoframework
commands.cpp commands.h
@@ -26,23 +15,29 @@ qt_add_executable(undoframework
main.cpp
mainwindow.cpp mainwindow.h
)
+
set_target_properties(undoframework PROPERTIES
WIN32_EXECUTABLE TRUE
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"
)
-qt6_add_resources(undoframework "undoframework"
+qt_add_resources(undoframework "undoframework"
PREFIX
"/"
FILES
@@ -50,7 +45,14 @@ qt6_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/commands.cpp b/examples/widgets/tools/undoframework/commands.cpp
index 077d7eccaa..67fb739dc4 100644
--- a/examples/widgets/tools/undoframework/commands.cpp
+++ b/examples/widgets/tools/undoframework/commands.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "commands.h"
#include "diagramitem.h"
diff --git a/examples/widgets/tools/undoframework/commands.h b/examples/widgets/tools/undoframework/commands.h
index 185d36d668..f4048ce198 100644
--- a/examples/widgets/tools/undoframework/commands.h
+++ b/examples/widgets/tools/undoframework/commands.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef COMMANDS_H
#define COMMANDS_H
diff --git a/examples/widgets/tools/undoframework/diagramitem.cpp b/examples/widgets/tools/undoframework/diagramitem.cpp
index 91da6538cf..918de742a5 100644
--- a/examples/widgets/tools/undoframework/diagramitem.cpp
+++ b/examples/widgets/tools/undoframework/diagramitem.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "diagramitem.h"
diff --git a/examples/widgets/tools/undoframework/diagramitem.h b/examples/widgets/tools/undoframework/diagramitem.h
index 13ff614427..95adac928e 100644
--- a/examples/widgets/tools/undoframework/diagramitem.h
+++ b/examples/widgets/tools/undoframework/diagramitem.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DIAGRAMITEM_H
#define DIAGRAMITEM_H
diff --git a/examples/widgets/tools/undoframework/diagramscene.cpp b/examples/widgets/tools/undoframework/diagramscene.cpp
index 65909ab6cb..8fab7b86bc 100644
--- a/examples/widgets/tools/undoframework/diagramscene.cpp
+++ b/examples/widgets/tools/undoframework/diagramscene.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "diagramscene.h"
#include "diagramitem.h"
diff --git a/examples/widgets/tools/undoframework/diagramscene.h b/examples/widgets/tools/undoframework/diagramscene.h
index 205d4162bb..fe4c06b11a 100644
--- a/examples/widgets/tools/undoframework/diagramscene.h
+++ b/examples/widgets/tools/undoframework/diagramscene.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DIAGRAMSCENE_H
#define DIAGRAMSCENE_H
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 cf090f56eb..8dfa3ffb4b 100644
--- a/examples/widgets/tools/undoframework/main.cpp
+++ b/examples/widgets/tools/undoframework/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
@@ -55,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 583af11a2b..c2a6c1cff6 100644
--- a/examples/widgets/tools/undoframework/mainwindow.cpp
+++ b/examples/widgets/tools/undoframework/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "diagramscene.h"
@@ -54,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]
@@ -130,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())
@@ -178,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 c1a56e0770..5ef1dddf75 100644
--- a/examples/widgets/tools/undoframework/mainwindow.h
+++ b/examples/widgets/tools/undoframework/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@@ -79,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 d2c3152ad8..6b5aebb98a 100644
--- a/examples/widgets/touch/CMakeLists.txt
+++ b/examples/widgets/touch/CMakeLists.txt
@@ -1,9 +1,7 @@
-# Generated from touch.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-if(NOT TARGET Qt::Widgets)
+if(NOT TARGET Qt6::Widgets)
return()
endif()
-add_subdirectory(pinchzoom)
-add_subdirectory(fingerpaint)
-add_subdirectory(knobs)
-add_subdirectory(dials)
+qt_internal_add_example(knobs)
diff --git a/examples/widgets/touch/dials/CMakeLists.txt b/examples/widgets/touch/dials/CMakeLists.txt
deleted file mode 100644
index 81a4878c80..0000000000
--- a/examples/widgets/touch/dials/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from dials.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(dials LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC 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 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 dec8248efb..0000000000
--- a/examples/widgets/touch/dials/doc/src/touch-dials.qdoc
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 059dfdc716..0000000000
--- a/examples/widgets/touch/dials/main.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <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/.prev_CMakeLists.txt b/examples/widgets/touch/fingerpaint/.prev_CMakeLists.txt
deleted file mode 100644
index 3077bf5bc6..0000000000
--- a/examples/widgets/touch/fingerpaint/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-# Generated from fingerpaint.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(fingerpaint LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/touch/fingerpaint")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-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()
-
-install(TARGETS fingerpaint
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/touch/fingerpaint/CMakeLists.txt b/examples/widgets/touch/fingerpaint/CMakeLists.txt
deleted file mode 100644
index 9f677d7467..0000000000
--- a/examples/widgets/touch/fingerpaint/CMakeLists.txt
+++ /dev/null
@@ -1,53 +0,0 @@
-# Generated from fingerpaint.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(fingerpaint LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/touch/fingerpaint")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS PrintSupport) # special case
-
-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
-)
-# special case begin
-if (TARGET Qt::PrintSupport)
- target_link_libraries(fingerpaint PUBLIC Qt::PrintSupport)
-endif()
-# special case end
-
-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 6f8f636f86..0000000000
--- a/examples/widgets/touch/fingerpaint/doc/src/fingerpaint.qdoc
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 e7ab8856b7..0000000000
--- a/examples/widgets/touch/fingerpaint/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 2f7ec38d1a..0000000000
--- a/examples/widgets/touch/fingerpaint/mainwindow.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 47c339050e..0000000000
--- a/examples/widgets/touch/fingerpaint/mainwindow.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 7af565ff30..0000000000
--- a/examples/widgets/touch/fingerpaint/scribblearea.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints();
- for (const QTouchEvent::TouchPoint &touchPoint : touchPoints) {
- switch (touchPoint.state()) {
- case Qt::TouchPointStationary:
- case Qt::TouchPointReleased:
- // 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 fcdde53cc4..0000000000
--- a/examples/widgets/touch/fingerpaint/scribblearea.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 08dfb0a78a..eae0e58b36 100644
--- a/examples/widgets/touch/knobs/CMakeLists.txt
+++ b/examples/widgets/touch/knobs/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from knobs.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(knobs LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/touch/knobs")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(knobs
knob.cpp knob.h
main.cpp
)
+
set_target_properties(knobs PROPERTIES
WIN32_EXECUTABLE TRUE
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 6da5992195..fc6daa3732 100644
--- a/examples/widgets/touch/knobs/doc/src/touch-knobs.qdoc
+++ b/examples/widgets/touch/knobs/doc/src/touch-knobs.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\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/knob.cpp b/examples/widgets/touch/knobs/knob.cpp
index 659ba82f45..d0ad55ed5c 100644
--- a/examples/widgets/touch/knobs/knob.cpp
+++ b/examples/widgets/touch/knobs/knob.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "knob.h"
@@ -77,11 +30,11 @@ bool Knob::sceneEvent(QEvent *event)
{
QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
- if (touchEvent->touchPoints().count() == 2) {
- const QTouchEvent::TouchPoint &touchPoint1 = touchEvent->touchPoints().first();
- const QTouchEvent::TouchPoint &touchPoint2 = touchEvent->touchPoints().last();
+ if (touchEvent->points().count() == 2) {
+ const QEventPoint &touchPoint1 = touchEvent->points().first();
+ const QEventPoint &touchPoint2 = touchEvent->points().last();
- QLineF line1(touchPoint1.lastScenePos(), touchPoint2.lastScenePos());
+ QLineF line1(touchPoint1.sceneLastPosition(), touchPoint2.sceneLastPosition());
QLineF line2(touchPoint1.scenePosition(), touchPoint2.scenePosition());
setTransform(QTransform().rotate(line2.angleTo(line1)), true);
diff --git a/examples/widgets/touch/knobs/knob.h b/examples/widgets/touch/knobs/knob.h
index c16b61d6f1..62ce241415 100644
--- a/examples/widgets/touch/knobs/knob.h
+++ b/examples/widgets/touch/knobs/knob.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef KNOB_H
#define KNOB_H
diff --git a/examples/widgets/touch/knobs/main.cpp b/examples/widgets/touch/knobs/main.cpp
index ea0e857e7b..74b64a99eb 100644
--- a/examples/widgets/touch/knobs/main.cpp
+++ b/examples/widgets/touch/knobs/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QGraphicsView>
@@ -59,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 6288301683..0000000000
--- a/examples/widgets/touch/pinchzoom/CMakeLists.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-# Generated from pinchzoom.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pinchzoom LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/touch/pinchzoom")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 61db2f96c5..0000000000
--- a/examples/widgets/touch/pinchzoom/doc/src/pinchzoom.qdoc
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \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 e1ce42f93f..0000000000
--- a/examples/widgets/touch/pinchzoom/graphicsview.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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);
- QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
- if (touchPoints.count() == 2) {
- // determine scale factor
- const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
- const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();
- qreal currentScaleFactor =
- QLineF(touchPoint0.position(), touchPoint1.position()).length()
- / QLineF(touchPoint0.pressPosition(), touchPoint1.pressPosition()).length();
- if (touchEvent->touchPointStates() & Qt::TouchPointReleased) {
- // 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 c0faeba444..0000000000
--- a/examples/widgets/touch/pinchzoom/graphicsview.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#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 2c2ba39a26..0000000000
--- a/examples/widgets/touch/pinchzoom/main.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 8456a0214d..0000000000
--- a/examples/widgets/touch/pinchzoom/mouse.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 8ac110821e..0000000000
--- a/examples/widgets/touch/pinchzoom/mouse.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 c2fa4a81d7..e1192d9c6f 100644
--- a/examples/widgets/tutorials/CMakeLists.txt
+++ b/examples/widgets/tutorials/CMakeLists.txt
@@ -1,7 +1,6 @@
-# Generated from tutorials.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(addressbook)
add_subdirectory(widgets)
add_subdirectory(modelview)
-add_subdirectory(gettingStarted)
-add_subdirectory(notepad)
+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 a8823d059a..0000000000
--- a/examples/widgets/tutorials/addressbook/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-# Generated from addressbook.pro.
-
-add_subdirectory(part1)
-add_subdirectory(part2)
-add_subdirectory(part3)
-add_subdirectory(part4)
-add_subdirectory(part5)
-add_subdirectory(part6)
-add_subdirectory(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 264b22e259..0000000000
--- a/examples/widgets/tutorials/addressbook/part1/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from part1.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(part1 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part1")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 c272ca1e7d..0000000000
--- a/examples/widgets/tutorials/addressbook/part1/addressbook.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 4c2b456a41..0000000000
--- a/examples/widgets/tutorials/addressbook/part1/addressbook.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 ba163456cc..0000000000
--- a/examples/widgets/tutorials/addressbook/part1/main.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 8e5e446802..0000000000
--- a/examples/widgets/tutorials/addressbook/part2/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from part2.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(part2 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part2")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 d5ee394abd..0000000000
--- a/examples/widgets/tutorials/addressbook/part2/addressbook.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 e690d14244..0000000000
--- a/examples/widgets/tutorials/addressbook/part2/addressbook.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 ba163456cc..0000000000
--- a/examples/widgets/tutorials/addressbook/part2/main.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 3cf1f5c49f..0000000000
--- a/examples/widgets/tutorials/addressbook/part3/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from part3.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(part3 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part3")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 b6d48f7a0d..0000000000
--- a/examples/widgets/tutorials/addressbook/part3/addressbook.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 f4a8aaa976..0000000000
--- a/examples/widgets/tutorials/addressbook/part3/addressbook.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 e7e7f31f62..0000000000
--- a/examples/widgets/tutorials/addressbook/part3/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 0497353753..0000000000
--- a/examples/widgets/tutorials/addressbook/part4/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from part4.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(part4 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part4")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 77ce216c07..0000000000
--- a/examples/widgets/tutorials/addressbook/part4/addressbook.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 307df1eb15..0000000000
--- a/examples/widgets/tutorials/addressbook/part4/addressbook.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 e7e7f31f62..0000000000
--- a/examples/widgets/tutorials/addressbook/part4/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 d3ac961064..0000000000
--- a/examples/widgets/tutorials/addressbook/part5/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from part5.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(part5 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part5")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 5505a0e35c..0000000000
--- a/examples/widgets/tutorials/addressbook/part5/addressbook.cpp
+++ /dev/null
@@ -1,330 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 9dd7ed1d89..0000000000
--- a/examples/widgets/tutorials/addressbook/part5/addressbook.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 615b39d42f..0000000000
--- a/examples/widgets/tutorials/addressbook/part5/finddialog.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 8e63eeee79..0000000000
--- a/examples/widgets/tutorials/addressbook/part5/finddialog.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 e7e7f31f62..0000000000
--- a/examples/widgets/tutorials/addressbook/part5/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 a3dd87619a..0000000000
--- a/examples/widgets/tutorials/addressbook/part6/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from part6.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(part6 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part6")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 8e740cfffc..0000000000
--- a/examples/widgets/tutorials/addressbook/part6/addressbook.cpp
+++ /dev/null
@@ -1,413 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 fca62c52b7..0000000000
--- a/examples/widgets/tutorials/addressbook/part6/addressbook.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 c25cccd552..0000000000
--- a/examples/widgets/tutorials/addressbook/part6/finddialog.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 46f8047a56..0000000000
--- a/examples/widgets/tutorials/addressbook/part6/finddialog.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 e7e7f31f62..0000000000
--- a/examples/widgets/tutorials/addressbook/part6/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 88b5ca3a1e..0000000000
--- a/examples/widgets/tutorials/addressbook/part7/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from part7.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(part7 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/addressbook/part7")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 1ba23756c4..0000000000
--- a/examples/widgets/tutorials/addressbook/part7/addressbook.cpp
+++ /dev/null
@@ -1,466 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 47a0f3c062..0000000000
--- a/examples/widgets/tutorials/addressbook/part7/addressbook.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 c25cccd552..0000000000
--- a/examples/widgets/tutorials/addressbook/part7/finddialog.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 46f8047a56..0000000000
--- a/examples/widgets/tutorials/addressbook/part7/finddialog.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 e7e7f31f62..0000000000
--- a/examples/widgets/tutorials/addressbook/part7/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 2aa8163029..0000000000
--- a/examples/widgets/tutorials/gettingStarted/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generated from gettingStarted.pro.
-
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 7a9ade8511..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-# Generated from gsqt.pro.
-
-add_subdirectory(part1)
-add_subdirectory(part2)
-add_subdirectory(part3)
-add_subdirectory(part4)
-add_subdirectory(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 e2877a26ba..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part1/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated from part1.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(part1 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part1")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(part1
- 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/gettingStarted/gsQt/part1/main.cpp b/examples/widgets/tutorials/gettingStarted/gsQt/part1/main.cpp
deleted file mode 100644
index 5752856773..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part1/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 65a3ff3539..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part2/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated from part2.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(part2 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part2")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(part2
- 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/gettingStarted/gsQt/part2/main.cpp b/examples/widgets/tutorials/gettingStarted/gsQt/part2/main.cpp
deleted file mode 100644
index 8bf83859a0..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part2/main.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 4a9b79b00b..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part3/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated from part3.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(part3 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part3")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(part3
- 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/gettingStarted/gsQt/part3/main.cpp b/examples/widgets/tutorials/gettingStarted/gsQt/part3/main.cpp
deleted file mode 100644
index d4b43eb034..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part3/main.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 b1b224c70d..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part4/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated from part4.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(part4 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part4")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(part4
- 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/gettingStarted/gsQt/part4/main.cpp b/examples/widgets/tutorials/gettingStarted/gsQt/part4/main.cpp
deleted file mode 100644
index 8c5fbc70ca..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part4/main.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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 182c2e9a48..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part5/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated from part5.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(part5 LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/gettingStarted/gsQt/part5")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(part5
- 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/gettingStarted/gsQt/part5/main.cpp b/examples/widgets/tutorials/gettingStarted/gsQt/part5/main.cpp
deleted file mode 100644
index cc3e1a261c..0000000000
--- a/examples/widgets/tutorials/gettingStarted/gsQt/part5/main.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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/gettingstartedqt.qdoc b/examples/widgets/tutorials/gettingstartedqt.qdoc
deleted file mode 100644
index 32e8845c05..0000000000
--- a/examples/widgets/tutorials/gettingstartedqt.qdoc
+++ /dev/null
@@ -1,559 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example tutorials/notepad
- \title Getting Started Programming with Qt Widgets
- \brief A tutorial for Qt Widgets based on a notepad application.
-
- In this topic, we teach basic Qt knowledge by implementing a simple
- Notepad application using C++ and the \l{Qt Widgets} module. The
- application is a small text editor which allows you to create a text
- file, save it, print it,
- or reopen and edit it again. You can also set the font to be used.
-
- \image notepad1.png "Notepad application"
-
- You can find the final Notepad source files in the qtdoc repository
- in the tutorials/notepad directory. You can either fetch
- the Qt 5 sources from Qt Project or install them as part of Qt 5.
- The application is also available in the example list of Qt Creator's
- Welcome mode.
-
- \section1 Creating the Notepad Project
-
- Setting up a new project in Qt Creator is aided by a wizard that
- guides you step-by-step through the project creation process. The
- wizard prompts you to enter the settings needed for that particular
- type of project and creates the project for you.
-
- \image notepad2.png "Qt Creator New File or Project dialog"
-
- To create the Notepad project, select \b File > \b{New File or
- Project} > \b Applications > \b {Qt Widgets Application} > \b Choose,
- and follow the instructions of the wizard. In the
- \b{Class Information}
- dialog, type \b Notepad as the class name and select \b QMainWindow
- as the base class.
-
- \image notepad3.png "Class Information Dialog"
-
- The \b {Qt Widgets Application} wizard creates a project that contains
- a main source file and a set of files that specify a user interface
- (Notepad widget):
-
- \list
- \li notepad.pro - the project file.
- \li main.cpp - the main source file for the application.
- \li notepad.cpp - the source file of the notepad class of the
- Notepad widget.
- \li notepad.h - the header file of the notepad class for the
- Notepad widget.
- \li notepad.ui - the UI form for the Notepad widget.
- \endlist
-
- The .cpp, .h, and .ui files come with the necessary boiler plate code
- for you to be able to build and run the project. The .pro file is
- complete.
- We will take a closer look at the file contents in the following
- sections.
-
- \b{Learn More}
-
- \table
- \header
- \li About
- \li Here
- \row
- \li Using Qt Creator
- \li \l{Qt Creator Manual}{Qt Creator}
- \row
- \li Creating other kind of applications with Qt Creator
- \li \l{Qt Creator: Tutorials}{Qt Creator Tutorials}
- \endtable
-
-
- \section1 Main Source File
-
- The wizard generates the following code in the main.cpp file:
-
- \quotefromfile tutorials/notepad/main.cpp
- \skipto "notepad.h"
- \printuntil EditorApp.exec()
- \printuntil }
-
- We will go through the code line by line. The following lines include
- the header files for the Notepad widget and QApplication. All Qt classes
- have a header file named after them.
-
- \quotefromfile tutorials/notepad/main.cpp
- \skipto notepad.h
- \printuntil QApplication
-
- The following line defines the main function that is the entry point
- for all C and C++ based applications:
-
- \printline main
-
- The following line creates a QApplication object. This object manages
- application-wide resources and is necessary to run any Qt program
- that uses Qt Widgets. It constructs an application object with \c argc
- command line arguments run in \c argv. (For GUI applications that
- do not use Qt Widgets, you can use QGuiApplication instead.)
-
- \skipuntil {
- \printuntil QApplication
-
- The following line creates the Notepad object. This is the object for
- which the wizard created the class and the UI file. The user interface
- contains visual elements that are called \c widgets in Qt. Examples
- of widgets are text edits, scroll bars, labels, and radio buttons. A
- widget can also be a container for other widgets; a dialog or a main
- application window, for example.
-
- \printline Notepad
-
- The following line shows the Notepad widget on the screen in its own
- window. Widgets can also function as containers. An example of this
- is QMainWindow which often contains several types of widgets. Widgets
- are not visible by default; the function \l{QWidget::}{show()} makes
- the widget visible.
-
- \printline Editor.show
-
- The following line makes the QApplication enter its event loop. When
- a Qt application is running, events are generated and sent to the
- widgets of the application. Examples of events are mouse presses
- and key strokes.
-
- \printline EditorApp.exec
-
- \b{Learn More}
-
- \table
- \header
- \li About
- \li Here
- \row
- \li Widgets and Window Geometry
- \li \l{Window and Dialog Widgets}
- \row
- \li Events and event handling
- \li \l{The Event System}
- \endtable
-
- \section1 Designing a UI
-
- 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.
-
- 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
-
- 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:
-
- \list 1
- \li In the Qt Creator \b Editor mode, double-click the notepad.ui
- file in the \b Projects view to launch the file in the integrated
- Qt Designer.
- \li Drag and drop widgets Text Edit (QTextEdit) to the form.
- \li Press \b {Ctrl+A} (or \b {Cmd+A}) to select the widgets and click
- \b {Lay out Vertically} (or press \b {Ctrl+L}) to apply a vertical
- layout (QVBoxLayout).
- \li Press \b {Ctrl+S} (or \b {Cmd+S}) to save your changes.
- \endlist
-
- The UI now looks as follows in Qt Designer:
-
- \image notepad4.png
-
- You can view the generated XML file in the code editor:
-
- \quotefromfile tutorials/notepad/notepad.ui
-
- \printuntil QMenuBar
- \dots
-
- The following line contains the XML declaration, which specifies the
- XML version and character encoding used in the document:
-
- \code
- <?xml version="1.0" encoding="UTF-8"?>
- \endcode
-
- The rest of the file specifies an \c ui element that defines a
- Notepad widget:
-
- \code
- <ui version="4.0">
- \endcode
-
- The UI file is used together with the header and source file of the
- Notepad class. We will look at the rest of the UI file in the later
- sections.
-
- \section2 Notepad Header File
-
- The wizard generated a header file for the Notepad class that has the
- necessary #includes, a constructor, a destructor, and the Ui object.
- The file looks as follows:
-
- \snippet tutorials/notepad/notepad.h all
-
- The following line includes QMainWindow that provides a main application
- window:
-
- \snippet tutorials/notepad/notepad.h 1
-
- The following lines declare the Notepad class in the Ui namespace,
- which is the standard namespace for the UI classes generated from
- .ui files by the \c uic tool:
-
- \snippet tutorials/notepad/notepad.h 2
-
- The class declaration contains the \c Q_OBJECT macro. It must come
- first in the class definition, and declares our class as a QObject.
- Naturally, it must also inherit from QObject. A QObject adds several
- abilities to a normal C++ class. Notably, the class name and slot
- names can be queried at runtime. It is also possible to query a slot's
- parameter types and invoke it.
-
- \snippet tutorials/notepad/notepad.h 3
-
- The following lines declare a constructor that has a default argument
- called \c parent.
- The value 0 indicates that the widget has no parent (it is a top-level
- widget).
-
- \snippet tutorials/notepad/notepad.h 4
-
- The following line declares a virtual destructor to free the resources
- that were acquired by the object during its life-cycle. According to
- the C++ naming convention, destructors have the same name as the class
- they are associated with, prefixed with a tilde (~). In QObject,
- destructors are virtual to ensure that the destructors of derived
- classes are invoked properly when an object is deleted through a
- pointer-to-base-class.
-
- \snippet tutorials/notepad/notepad.h 5
-
- The following lines declare a member variable which is a pointer to
- the Notepad UI class. A member variable is associated with a specific
- class, and accessible for all its methods.
-
- \snippet tutorials/notepad/notepad.h 6
-
- \section2 Notepad Source File
-
- The source file that the wizard generated for the Notepad class looks
- as follows:
-
- \quotefromfile tutorials/notepad/notepad.cpp
- \skipto notepad.h
- \printuntil ui->textEdit->setFont(font)
- \printuntil }
-
- The following lines include the Notepad class header file that was
- generated by the wizard and the UI header file that was generated
- by the \c uic tool:
-
- \quotefromfile tutorials/notepad/notepad.cpp
- \skipto notepad.h
- \printuntil ui_notepad
-
- The following line defines the \c {Notepad} constructor:
-
- \skipto Notepad::Notepad
- \printline Notepad::Notepad
-
- The following line calls the QMainWindow constructor, which is
- the base class for the Notepad class:
-
- \printline QMainWindow
-
- The following line creates the UI class instance and assigns it to
- the \c ui member:
-
- \printline ui(new
-
- The following line sets up the UI:
-
- \quotefromfile tutorials/notepad/notepad.cpp
- \skipto ui->setupUi
- \printline ui->setupUi(this)
-
- In the destructor, we delete the \c ui:
-
- \skipto Notepad::~Notepad
- \printuntil }
-
- In order to have the text edit field occupy the whole screen, we add
- \c setCentralWidget to the main window.
-
- \quotefromfile tutorials/notepad/notepad.cpp
- \skipto Notepad::Notepad(QWidget *parent)
- \printuntil }
-
- \section2 Project File
-
- The wizard generates the following project file, \c {notepad.pro}, for
- us:
-
- \quotefile tutorials/notepad/notepad.pro
-
- The project file specifies the application name and the \c qmake
- template to use for generating the project, as well as the source,
- header, and UI files included in the project.
-
- You could also use \c qmake's \c -project option to generate the \.pro
- file. Although, in that case, you have to remember to add the line
- \c{QT += widgets} to the generated file in order to link against the
- Qt Widgets Module.
-
- \b{Learn More}
-
- \table
- \header
- \li About
- \li Here
- \row
- \li Using Qt Designer
- \li \l{Qt Designer Manual}
- \row
- \li Layouts
- \li \l{Layout Management},
- \l{Widgets and Layouts},
- \l{Layout Examples}
- \row
- \li The widgets that come with Qt
- \li \l{Qt Widget Gallery}
- \row
- \li Main windows and main window classes
- \li \l{Application Main Window},
- \l{Main Window Examples}
- \row
- \li QObjects and the Qt Object model (This is essential to
- understand Qt)
- \li \l{Object Model}
- \row
- \li qmake and the Qt build system
- \li \l{qmake Manual}
- \endtable
-
- \section1 Adding User Interaction
-
-
- To add functionality to the editor, we start by adding menu items
- and buttons on a toolbar.
-
- Click on "Type Here", and add the options New, Open, Save, Save as,
- Print and Exit. This creates 5 lines in the Action Editor below.
- To connect the actions to slots, right-click an action and select
- Go to slot > triggered(), and complete the code for that given slot.
-
- If we also want to add the actions to a toolbar, we can assign an
- icon to each QAction, and then drag the QAction to the toolbar. You
- assign an icon by entering an icon name in the Icon property of the
- action concerned. When the QAction has been dragged to the toolbar,
- clicking the icon will launch the associated slot.
-
- Complete the method \c newDocument():
-
- \quotefromfile tutorials/notepad/notepad.cpp
- \skipto newDocument()
- \printuntil }
-
- \c current_file is a global variable containing the file presently
- being edited.
- It is defined in the private part of notepad.h:
-
- \quotefromfile tutorials/notepad/notepad.h
- \skipto private:
- \printuntil currentFile;
-
- \c clear() clears the text buffer.
-
- \section2 Opening a file
-
- In \c notepad.ui, right click on \c actionOpen and select \c {Go to
- slot}
-
- Complete method \c open().
-
- \quotefromfile tutorials/notepad/notepad.cpp
- \skipto open()
- \printuntil file.close
- \printuntil }
-
-
- \c QFileDialog::getOpenFileName opens a dialog enabling you to select
- a file. QFile object \c myfile has the selected \c file_name as
- parameter. We store the selected file also into the global variable
- \c current_file for later purposes. We open the file with \c file.open
- as a readonly text file. If it cannot be opened, a warning is issued,
- and the program stops.
-
- We define a QTextStream \c instream for parameter \c myfile.
- The contents of file \c myfile is copied into QString \a text.
- \c setText(text) fille the buffer of our editor with \c text.
-
- \c section2 Saving a file
-
- We create the method for saving a file in the same way as for
- \l {Opening a file}, by right clicking on \c actionSave, and
- selecting \c {Go to Slot}.
-
- \skipto Notepad::save
- \printuntil file.close
- \printuntil }
-
- QFile object \c myfile is linked to global variable \c current_file,
- the variable that contains the file we were working with.
- If we cannot open \c myfile, an error message is issued and the
- method stops. We create a QTextStream \c outstream. The contents
- of the editor buffer is converted to plain text, and then written
- to \c outstream.
-
- \section2 Saving a file with \c {Save as}
-
- \skipto Notepad::saveAs
- \printuntil file.close
- \printuntil }
-
- This is the same procedure as for \c {Saving a file}, the only
- difference being that here you need to enter a new file name for
- the file to be created.
-
-
- \section2 Print a File
-
- If you want to use print functionalities, you need to add
- \c printsupport to the project file:
-
- \badcode
- QT += printsupport
- \endcode
-
- We declare a QPrinter object called \c printer.
- We launch a printer dialog box and store the selected printer in
- object \c printer. If we clicked on \c Cancel and did not select
- a printer, the methods returns. The actual printer command is given
- with \a ui->textEdit->print with our QPrinter object as parameter.
-
- \section2 Select a Font
-
- \skipto Notepad::selectFont
- \printuntil ui->textEdit->setFont
- \printline }
-
- We declare a boolean indicating if we did select a font with
- QFontDialog. If so, we set the font with \c ui->textEdit->setFont(myfont).
-
- \section2 Copy, Cut, Paste, Undo, and Redo
-
- If you select some text, and want to copy it to the clipboard,
- you call the appropriate method of ui->textEdit. The same counts
- for cut, paste, undo, and redo.
-
- This table shows the method name to use.
-
- \table
- \header
- \li Task
- \li Method called
- \row
- \li Copy
- \li ui->textEdit->copy()
- \row
- \li Cut
- \li ui->textEdit->cut()
- \row
- \li Paste
- \li ui->textEdit->paste()
- \row
- \li Undo
- \li ui->textEdit->undo()
- \row
- \li Redo
- \li ui->textEdit->redo()
- \endtable
-
- \b{Learn More}
-
- \table
- \header
- \li About
- \li Here
- \row
- \li MDI applications
- \li QMdiArea,
- \l{MDI Example}
- \row
- \li Files and I/O devices
- \li QFile, QIODevice
- \row
- \li tr() and internationalization
- \li \l{Qt Linguist Manual},
- \l{Writing Source Code for Translation},
- \l{Internationalization with Qt}
- \endtable
-
- \section1 Building and Running Notepad
-
- Now that you have all the necessary files, select \b Build >
- \b {Build Project Notepad} to build and run the application. Qt
- Creator uses \c qmake and \c make to create an executable in the
- directory specified in the build settings of the project and runs
- it.
-
- \section2 Building and Running from the Command Line
-
- To build the application from the command line, switch to the
- directory in which you have the \c .cpp file of the application
- and add the project file (suffixed .pro) described earlier. The
- following shell commands then build the application:
-
- \badcode
- qmake
- make (or nmake on Windows)
- \endcode
-
- The commands create an executable in the project directory. The
- \c qmake tool reads the project file and produces a \c Makefile
- with instructions on how to build the application.
- The \c make tool (or the \c nmake tool) then reads the \c Makefile
- and produces the executable binary.
-*/
diff --git a/examples/widgets/tutorials/modelview/1_readonly/CMakeLists.txt b/examples/widgets/tutorials/modelview/1_readonly/CMakeLists.txt
index a9aa027352..3ff7f06721 100644
--- a/examples/widgets/tutorials/modelview/1_readonly/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/1_readonly/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from 1_readonly.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(mv_readonly LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/1_readonly")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(mv_readonly
main.cpp
mymodel.cpp mymodel.h
)
+
set_target_properties(mv_readonly PROPERTIES
WIN32_EXECUTABLE TRUE
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/1_readonly/main.cpp b/examples/widgets/tutorials/modelview/1_readonly/main.cpp
index ea571d3699..6630fe4e85 100644
--- a/examples/widgets/tutorials/modelview/1_readonly/main.cpp
+++ b/examples/widgets/tutorials/modelview/1_readonly/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [Quoting ModelView Tutorial]
// main.cpp
diff --git a/examples/widgets/tutorials/modelview/1_readonly/mymodel.cpp b/examples/widgets/tutorials/modelview/1_readonly/mymodel.cpp
index 2b36565bc6..c007ad4283 100644
--- a/examples/widgets/tutorials/modelview/1_readonly/mymodel.cpp
+++ b/examples/widgets/tutorials/modelview/1_readonly/mymodel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [Quoting ModelView Tutorial]
// mymodel.cpp
diff --git a/examples/widgets/tutorials/modelview/1_readonly/mymodel.h b/examples/widgets/tutorials/modelview/1_readonly/mymodel.h
index 8761322896..ab26790a03 100644
--- a/examples/widgets/tutorials/modelview/1_readonly/mymodel.h
+++ b/examples/widgets/tutorials/modelview/1_readonly/mymodel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MYMODEL_H
#define MYMODEL_H
@@ -59,7 +12,8 @@ class MyModel : public QAbstractTableModel
{
Q_OBJECT
public:
- MyModel(QObject *parent = nullptr);
+ explicit MyModel(QObject *parent = nullptr);
+
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;
diff --git a/examples/widgets/tutorials/modelview/2_formatting/CMakeLists.txt b/examples/widgets/tutorials/modelview/2_formatting/CMakeLists.txt
index d17ac4f413..a758b6eaa5 100644
--- a/examples/widgets/tutorials/modelview/2_formatting/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/2_formatting/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from 2_formatting.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(mv_formatting LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/2_formatting")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(mv_formatting
main.cpp
mymodel.cpp mymodel.h
)
+
set_target_properties(mv_formatting PROPERTIES
WIN32_EXECUTABLE TRUE
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/2_formatting/main.cpp b/examples/widgets/tutorials/modelview/2_formatting/main.cpp
index ea571d3699..6630fe4e85 100644
--- a/examples/widgets/tutorials/modelview/2_formatting/main.cpp
+++ b/examples/widgets/tutorials/modelview/2_formatting/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [Quoting ModelView Tutorial]
// main.cpp
diff --git a/examples/widgets/tutorials/modelview/2_formatting/mymodel.cpp b/examples/widgets/tutorials/modelview/2_formatting/mymodel.cpp
index 5ddde156ae..229aa48ad7 100644
--- a/examples/widgets/tutorials/modelview/2_formatting/mymodel.cpp
+++ b/examples/widgets/tutorials/modelview/2_formatting/mymodel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mymodel.h"
@@ -88,22 +41,22 @@ QVariant MyModel::data(const QModelIndex &index, int role) const
.arg(row + 1)
.arg(col +1);
case Qt::FontRole:
- if (row == 0 && col == 0) { //change font only for cell(0,0)
+ if (row == 0 && col == 0) { // change font only for cell(0,0)
QFont boldFont;
boldFont.setBold(true);
return boldFont;
}
break;
case Qt::BackgroundRole:
- if (row == 1 && col == 2) //change background only for cell(1,2)
+ if (row == 1 && col == 2) // change background only for cell(1,2)
return QBrush(Qt::red);
break;
case Qt::TextAlignmentRole:
- if (row == 1 && col == 1) //change text alignment only for cell(1,1)
+ if (row == 1 && col == 1) // change text alignment only for cell(1,1)
return int(Qt::AlignRight | Qt::AlignVCenter);
break;
case Qt::CheckStateRole:
- if (row == 1 && col == 0) //add a checkbox to cell(1,0)
+ if (row == 1 && col == 0) // add a checkbox to cell(1,0)
return Qt::Checked;
break;
}
diff --git a/examples/widgets/tutorials/modelview/2_formatting/mymodel.h b/examples/widgets/tutorials/modelview/2_formatting/mymodel.h
index e8ae673f62..bd3d0afe17 100644
--- a/examples/widgets/tutorials/modelview/2_formatting/mymodel.h
+++ b/examples/widgets/tutorials/modelview/2_formatting/mymodel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MYMODEL_H
#define MYMODEL_H
@@ -57,7 +10,8 @@ class MyModel : public QAbstractTableModel
{
Q_OBJECT
public:
- MyModel(QObject *parent = nullptr);
+ explicit MyModel(QObject *parent = nullptr);
+
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;
diff --git a/examples/widgets/tutorials/modelview/3_changingmodel/CMakeLists.txt b/examples/widgets/tutorials/modelview/3_changingmodel/CMakeLists.txt
index 02305a8140..1b8dd84c92 100644
--- a/examples/widgets/tutorials/modelview/3_changingmodel/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/3_changingmodel/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from 3_changingmodel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(mv_changingmodel LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/3_changingmodel")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(mv_changingmodel
main.cpp
mymodel.cpp mymodel.h
)
+
set_target_properties(mv_changingmodel PROPERTIES
WIN32_EXECUTABLE TRUE
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/3_changingmodel/main.cpp b/examples/widgets/tutorials/modelview/3_changingmodel/main.cpp
index 90a8c6e894..88c9241232 100644
--- a/examples/widgets/tutorials/modelview/3_changingmodel/main.cpp
+++ b/examples/widgets/tutorials/modelview/3_changingmodel/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QTableView>
diff --git a/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.cpp b/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.cpp
index f289d9abda..5ce56632ff 100644
--- a/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.cpp
+++ b/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mymodel.h"
@@ -91,9 +44,9 @@ QVariant MyModel::data(const QModelIndex &index, int role) const
//! [quoting mymodel_b ]
void MyModel::timerHit()
{
- //we identify the top left cell
+ // we identify the top left cell
QModelIndex topLeft = createIndex(0,0);
- //emit a signal to make the view reread identified data
+ // emit a signal to make the view reread identified data
emit dataChanged(topLeft, topLeft, {Qt::DisplayRole});
}
//! [quoting mymodel_b ]
diff --git a/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.h b/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.h
index 2ef0e480c2..5fab806c42 100644
--- a/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.h
+++ b/examples/widgets/tutorials/modelview/3_changingmodel/mymodel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MYMODEL_H
#define MYMODEL_H
@@ -58,14 +11,17 @@ class MyModel : public QAbstractTableModel
{
Q_OBJECT
public:
- MyModel(QObject *parent = nullptr);
+ explicit MyModel(QObject *parent = nullptr);
+
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;
-private:
- QTimer *timer;
+
private slots:
void timerHit();
+
+private:
+ QTimer *timer;
};
#endif // MYMODEL_H
diff --git a/examples/widgets/tutorials/modelview/4_headers/CMakeLists.txt b/examples/widgets/tutorials/modelview/4_headers/CMakeLists.txt
index 1ff44691a1..b0c05e4212 100644
--- a/examples/widgets/tutorials/modelview/4_headers/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/4_headers/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from 4_headers.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(mv_headers LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/4_headers")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(mv_headers
main.cpp
mymodel.cpp mymodel.h
)
+
set_target_properties(mv_headers PROPERTIES
WIN32_EXECUTABLE TRUE
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/4_headers/main.cpp b/examples/widgets/tutorials/modelview/4_headers/main.cpp
index 90a8c6e894..88c9241232 100644
--- a/examples/widgets/tutorials/modelview/4_headers/main.cpp
+++ b/examples/widgets/tutorials/modelview/4_headers/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QTableView>
diff --git a/examples/widgets/tutorials/modelview/4_headers/mymodel.cpp b/examples/widgets/tutorials/modelview/4_headers/mymodel.cpp
index 0084475374..4f4023dd10 100644
--- a/examples/widgets/tutorials/modelview/4_headers/mymodel.cpp
+++ b/examples/widgets/tutorials/modelview/4_headers/mymodel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mymodel.h"
diff --git a/examples/widgets/tutorials/modelview/4_headers/mymodel.h b/examples/widgets/tutorials/modelview/4_headers/mymodel.h
index 6d8477dae2..43e708c297 100644
--- a/examples/widgets/tutorials/modelview/4_headers/mymodel.h
+++ b/examples/widgets/tutorials/modelview/4_headers/mymodel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MYMODEL_H
#define MYMODEL_H
@@ -57,7 +10,8 @@ class MyModel : public QAbstractTableModel
{
Q_OBJECT
public:
- MyModel(QObject *parent = nullptr);
+ explicit MyModel(QObject *parent = nullptr);
+
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;
diff --git a/examples/widgets/tutorials/modelview/5_edit/CMakeLists.txt b/examples/widgets/tutorials/modelview/5_edit/CMakeLists.txt
index bcb0f06714..f0269ac2bc 100644
--- a/examples/widgets/tutorials/modelview/5_edit/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/5_edit/CMakeLists.txt
@@ -1,41 +1,39 @@
-# Generated from 5_edit.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(mv_edit LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/5_edit")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(mv_edit
main.cpp
mainwindow.cpp mainwindow.h
mymodel.cpp mymodel.h
)
+
set_target_properties(mv_edit PROPERTIES
WIN32_EXECUTABLE TRUE
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/5_edit/main.cpp b/examples/widgets/tutorials/modelview/5_edit/main.cpp
index 315875a627..515990da03 100644
--- a/examples/widgets/tutorials/modelview/5_edit/main.cpp
+++ b/examples/widgets/tutorials/modelview/5_edit/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include "mainwindow.h"
diff --git a/examples/widgets/tutorials/modelview/5_edit/mainwindow.cpp b/examples/widgets/tutorials/modelview/5_edit/mainwindow.cpp
index d8dfc33212..4fe164e888 100644
--- a/examples/widgets/tutorials/modelview/5_edit/mainwindow.cpp
+++ b/examples/widgets/tutorials/modelview/5_edit/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "mymodel.h"
@@ -58,15 +11,10 @@ MainWindow::MainWindow(QWidget *parent)
, tableView(new QTableView(this))
{
setCentralWidget(tableView);
- MyModel *myModel = new MyModel(this);
+ auto *myModel = new MyModel(this);
tableView->setModel(myModel);
- //transfer changes to the model to the window title
+ // transfer changes to the model to the window title
connect(myModel, &MyModel::editCompleted,
- this, &MainWindow::showWindowTitle);
-}
-
-void MainWindow::showWindowTitle(const QString &title)
-{
- setWindowTitle(title);
+ this, &QWidget::setWindowTitle);
}
diff --git a/examples/widgets/tutorials/modelview/5_edit/mainwindow.h b/examples/widgets/tutorials/modelview/5_edit/mainwindow.h
index 104f06f82e..2ec6fce57d 100644
--- a/examples/widgets/tutorials/modelview/5_edit/mainwindow.h
+++ b/examples/widgets/tutorials/modelview/5_edit/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@@ -54,19 +7,18 @@
#include <QMainWindow>
QT_BEGIN_NAMESPACE
-class QTableView; //forward declaration
+class QTableView; // forward declaration
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
+public:
+ explicit MainWindow(QWidget *parent = nullptr);
+
private:
QTableView *tableView;
-public:
- MainWindow(QWidget *parent = nullptr);
-public slots:
- void showWindowTitle(const QString &title);
};
#endif // MAINWINDOW_H
diff --git a/examples/widgets/tutorials/modelview/5_edit/mymodel.cpp b/examples/widgets/tutorials/modelview/5_edit/mymodel.cpp
index eeca2ce0a0..f481f2ce6f 100644
--- a/examples/widgets/tutorials/modelview/5_edit/mymodel.cpp
+++ b/examples/widgets/tutorials/modelview/5_edit/mymodel.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mymodel.h"
diff --git a/examples/widgets/tutorials/modelview/5_edit/mymodel.h b/examples/widgets/tutorials/modelview/5_edit/mymodel.h
index ce462351af..0407a408ae 100644
--- a/examples/widgets/tutorials/modelview/5_edit/mymodel.h
+++ b/examples/widgets/tutorials/modelview/5_edit/mymodel.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MYMODEL_H
#define MYMODEL_H
diff --git a/examples/widgets/tutorials/modelview/6_treeview/CMakeLists.txt b/examples/widgets/tutorials/modelview/6_treeview/CMakeLists.txt
index d020349fa5..2a47ebc24a 100644
--- a/examples/widgets/tutorials/modelview/6_treeview/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/6_treeview/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from 6_treeview.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(mv_tree LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/6_treeview")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(mv_tree
main.cpp
mainwindow.cpp mainwindow.h
)
+
set_target_properties(mv_tree PROPERTIES
WIN32_EXECUTABLE TRUE
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/6_treeview/main.cpp b/examples/widgets/tutorials/modelview/6_treeview/main.cpp
index 315875a627..515990da03 100644
--- a/examples/widgets/tutorials/modelview/6_treeview/main.cpp
+++ b/examples/widgets/tutorials/modelview/6_treeview/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include "mainwindow.h"
diff --git a/examples/widgets/tutorials/modelview/6_treeview/mainwindow.cpp b/examples/widgets/tutorials/modelview/6_treeview/mainwindow.cpp
index ae4a343680..cc79125aad 100644
--- a/examples/widgets/tutorials/modelview/6_treeview/mainwindow.cpp
+++ b/examples/widgets/tutorials/modelview/6_treeview/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [Quoting ModelView Tutorial]
// modelview.cpp
diff --git a/examples/widgets/tutorials/modelview/6_treeview/mainwindow.h b/examples/widgets/tutorials/modelview/6_treeview/mainwindow.h
index 65d9c18658..38446c7a73 100644
--- a/examples/widgets/tutorials/modelview/6_treeview/mainwindow.h
+++ b/examples/widgets/tutorials/modelview/6_treeview/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@@ -54,7 +7,7 @@
#include <QMainWindow>
QT_BEGIN_NAMESPACE
-class QTreeView; //forward declarations
+class QTreeView; // forward declarations
class QStandardItemModel;
class QStandardItem;
QT_END_NAMESPACE
@@ -63,14 +16,16 @@ QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
+public:
+ explicit MainWindow(QWidget *parent = nullptr);
+
private:
- QTreeView *treeView;
- QStandardItemModel *standardModel;
QList<QStandardItem *> prepareRow(const QString &first,
const QString &second,
const QString &third) const;
-public:
- MainWindow(QWidget *parent = nullptr);
+
+ QTreeView *treeView;
+ QStandardItemModel *standardModel;
};
#endif // MAINWINDOW_H
diff --git a/examples/widgets/tutorials/modelview/7_selections/CMakeLists.txt b/examples/widgets/tutorials/modelview/7_selections/CMakeLists.txt
index 776b8d7688..0eda358808 100644
--- a/examples/widgets/tutorials/modelview/7_selections/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/7_selections/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from 7_selections.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(mv_selections LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/modelview/7_selections")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(mv_selections
main.cpp
mainwindow.cpp mainwindow.h
)
+
set_target_properties(mv_selections PROPERTIES
WIN32_EXECUTABLE TRUE
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/7_selections/main.cpp b/examples/widgets/tutorials/modelview/7_selections/main.cpp
index 315875a627..515990da03 100644
--- a/examples/widgets/tutorials/modelview/7_selections/main.cpp
+++ b/examples/widgets/tutorials/modelview/7_selections/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include "mainwindow.h"
diff --git a/examples/widgets/tutorials/modelview/7_selections/mainwindow.cpp b/examples/widgets/tutorials/modelview/7_selections/mainwindow.cpp
index 2b10071a68..3bedb2f82c 100644
--- a/examples/widgets/tutorials/modelview/7_selections/mainwindow.cpp
+++ b/examples/widgets/tutorials/modelview/7_selections/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [quoting modelview_a]
#include "mainwindow.h"
@@ -61,20 +14,20 @@ MainWindow::MainWindow(QWidget *parent)
, standardModel(new QStandardItemModel(this))
{
setCentralWidget(treeView);
- QStandardItem *rootNode = standardModel->invisibleRootItem();
+ auto *rootNode = standardModel->invisibleRootItem();
- //defining a couple of items
- QStandardItem *americaItem = new QStandardItem("America");
- QStandardItem *mexicoItem = new QStandardItem("Canada");
- QStandardItem *usaItem = new QStandardItem("USA");
- QStandardItem *bostonItem = new QStandardItem("Boston");
- QStandardItem *europeItem = new QStandardItem("Europe");
- QStandardItem *italyItem = new QStandardItem("Italy");
- QStandardItem *romeItem = new QStandardItem("Rome");
- QStandardItem *veronaItem = new QStandardItem("Verona");
+ // defining a couple of items
+ auto *americaItem = new QStandardItem("America");
+ auto *mexicoItem = new QStandardItem("Canada");
+ auto *usaItem = new QStandardItem("USA");
+ auto *bostonItem = new QStandardItem("Boston");
+ auto *europeItem = new QStandardItem("Europe");
+ auto *italyItem = new QStandardItem("Italy");
+ auto *romeItem = new QStandardItem("Rome");
+ auto *veronaItem = new QStandardItem("Verona");
- //building up the hierarchy
+ // building up the hierarchy
rootNode-> appendRow(americaItem);
rootNode-> appendRow(europeItem);
americaItem-> appendRow(mexicoItem);
@@ -84,11 +37,11 @@ MainWindow::MainWindow(QWidget *parent)
italyItem-> appendRow(romeItem);
italyItem-> appendRow(veronaItem);
- //register the model
+ // register the model
treeView->setModel(standardModel);
treeView->expandAll();
- //selection changes shall trigger a slot
+ // selection changes shall trigger a slot
QItemSelectionModel *selectionModel = treeView->selectionModel();
connect(selectionModel, &QItemSelectionModel::selectionChanged,
this, &MainWindow::selectionChangedSlot);
@@ -100,13 +53,13 @@ MainWindow::MainWindow(QWidget *parent)
//! [quoting modelview_b]
void MainWindow::selectionChangedSlot(const QItemSelection & /*newSelection*/, const QItemSelection & /*oldSelection*/)
{
- //get the text of the selected item
+ // get the text of the selected item
const QModelIndex index = treeView->selectionModel()->currentIndex();
QString selectedText = index.data(Qt::DisplayRole).toString();
- //find out the hierarchy level of the selected item
+ // find out the hierarchy level of the selected item
int hierarchyLevel = 1;
QModelIndex seekRoot = index;
- while (seekRoot.parent() != QModelIndex()) {
+ while (seekRoot.parent().isValid()) {
seekRoot = seekRoot.parent();
hierarchyLevel++;
}
diff --git a/examples/widgets/tutorials/modelview/7_selections/mainwindow.h b/examples/widgets/tutorials/modelview/7_selections/mainwindow.h
index 74906c831d..cca1ae837f 100644
--- a/examples/widgets/tutorials/modelview/7_selections/mainwindow.h
+++ b/examples/widgets/tutorials/modelview/7_selections/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@@ -54,7 +7,7 @@
#include <QMainWindow>
QT_BEGIN_NAMESPACE
-class QTreeView; //forward declarations
+class QTreeView; // forward declarations
class QStandardItemModel;
class QItemSelection;
QT_END_NAMESPACE
@@ -63,13 +16,15 @@ QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
+public:
+ explicit MainWindow(QWidget *parent = nullptr);
+
+private slots:
+ void selectionChangedSlot(const QItemSelection &newSelection, const QItemSelection &oldSelection);
+
private:
QTreeView *treeView;
QStandardItemModel *standardModel;
-private slots:
- void selectionChangedSlot(const QItemSelection &newSelection, const QItemSelection &oldSelection);
-public:
- MainWindow(QWidget *parent = nullptr);
};
#endif // MAINWINDOW_H
diff --git a/examples/widgets/tutorials/modelview/CMakeLists.txt b/examples/widgets/tutorials/modelview/CMakeLists.txt
index 10f2cf6ecf..cbf36834cb 100644
--- a/examples/widgets/tutorials/modelview/CMakeLists.txt
+++ b/examples/widgets/tutorials/modelview/CMakeLists.txt
@@ -1,9 +1,10 @@
-# Generated from modelview.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(1_readonly)
-add_subdirectory(2_formatting)
-add_subdirectory(3_changingmodel)
-add_subdirectory(4_headers)
-add_subdirectory(5_edit)
-add_subdirectory(6_treeview)
-add_subdirectory(7_selections)
+qt_internal_add_example(1_readonly)
+qt_internal_add_example(2_formatting)
+qt_internal_add_example(3_changingmodel)
+qt_internal_add_example(4_headers)
+qt_internal_add_example(5_edit)
+qt_internal_add_example(6_treeview)
+qt_internal_add_example(7_selections)
diff --git a/examples/widgets/tutorials/notepad/.prev_CMakeLists.txt b/examples/widgets/tutorials/notepad/.prev_CMakeLists.txt
deleted file mode 100644
index 119ca9d6cf..0000000000
--- a/examples/widgets/tutorials/notepad/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,76 +0,0 @@
-# Generated from notepad.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(notepad LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC 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 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(notepad
- main.cpp
- notepad.cpp notepad.h notepad.ui
-)
-set_target_properties(notepad PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(notepad PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set(notepad_resource_files
- "images/bold.png"
- "images/copy.png"
- "images/create.png"
- "images/cut.png"
- "images/edit_redo.png"
- "images/edit_undo.png"
- "images/exit.png"
- "images/font.png"
- "images/info.png"
- "images/italic.png"
- "images/new.png"
- "images/open.png"
- "images/paste.png"
- "images/pencil.png"
- "images/print.png"
- "images/save.png"
- "images/save_as.png"
- "images/underline.png"
-)
-
-qt6_add_resources(notepad "notepad"
- PREFIX
- "/"
- FILES
- ${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}"
-)
diff --git a/examples/widgets/tutorials/notepad/CMakeLists.txt b/examples/widgets/tutorials/notepad/CMakeLists.txt
index 267c3583b7..43048830c2 100644
--- a/examples/widgets/tutorials/notepad/CMakeLists.txt
+++ b/examples/widgets/tutorials/notepad/CMakeLists.txt
@@ -1,39 +1,35 @@
-# Generated from notepad.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(notepad LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC 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
+)
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS PrintSupport) # special case: add
+qt_standard_project_setup()
qt_add_executable(notepad
main.cpp
notepad.cpp notepad.h notepad.ui
)
+
set_target_properties(notepad PROPERTIES
WIN32_EXECUTABLE TRUE
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
@@ -57,21 +53,22 @@ set(notepad_resource_files
"images/underline.png"
)
-qt6_add_resources(notepad "notepad"
+qt_add_resources(notepad "notepad"
PREFIX
"/"
FILES
${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/notepad/gettingstartedqt.qdoc b/examples/widgets/tutorials/notepad/gettingstartedqt.qdoc
new file mode 100644
index 0000000000..0979cecb18
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/gettingstartedqt.qdoc
@@ -0,0 +1,501 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \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
+ Notepad application using C++ and the \l{Qt Widgets} module. The
+ application is a small text editor which allows you to create a text
+ file, save it, print it,
+ or reopen and edit it again. You can also set the font to be used.
+
+ \image notepad1.png "Notepad application"
+
+ \include examples-run.qdocinc
+
+ \section1 Creating the Notepad Project
+
+ Setting up a new project in Qt Creator is aided by a wizard that
+ guides you step-by-step through the project creation process. The
+ wizard prompts you to enter the settings needed for that particular
+ type of project and creates the project for you.
+
+ \note The UI text in Qt Creator and the contents of the generated files
+ depend on the Qt Creator version that you use.
+
+ \image notepad2.png "Qt Creator New Project dialog"
+
+ To create the Notepad project, select \uicontrol File >
+ \uicontrol {New Project} > \uicontrol {Application (Qt)} >
+ \uicontrol {Qt Widgets Application} > \uicontrol Choose, and follow the
+ instructions of the wizard. In the \uicontrol{Class Information} dialog,
+ type \e Notepad as the class name and select \uicontrol QMainWindow
+ as the base class.
+
+ \image notepad3.png "Class Information Dialog"
+
+ The \uicontrol {Qt Widgets Application} wizard creates a project that contains
+ a main source file and a set of files that specify a user interface
+ (Notepad widget):
+
+ \list
+ \li CMakeLists.txt - the project file.
+ \li main.cpp - the main source file for the application.
+ \li notepad.cpp - the source file of the notepad class of the
+ Notepad widget.
+ \li notepad.h - the header file of the notepad class for the
+ Notepad widget.
+ \li notepad.ui - the UI form for the Notepad widget.
+ \endlist
+
+ The files come with the necessary boiler plate code for you to be able to
+ build and run the project. We will take a closer look at the file contents
+ in the following sections.
+
+ \b{Learn More}
+
+ \table
+ \header
+ \li About
+ \li Here
+ \row
+ \li Using Qt Creator
+ \li \l{Qt Creator Manual}{Qt Creator}
+ \row
+ \li Creating other kind of applications with Qt Creator
+ \li \l{Qt Creator: Tutorials}{Qt Creator Tutorials}
+ \endtable
+
+
+ \section1 Main Source File
+
+ The wizard generates the following code in the main.cpp file:
+
+ \quotefromfile tutorials/notepad/main.cpp
+ \skipto "notepad.h"
+ \printuntil }
+
+ We will go through the code line by line. The following lines include
+ the header files for the Notepad widget and QApplication. All Qt classes
+ have a header file named after them.
+
+ \quotefromfile tutorials/notepad/main.cpp
+ \skipto notepad.h
+ \printuntil QApplication
+
+ The following line defines the main function that is the entry point
+ for all C and C++ based applications:
+
+ \printline main
+
+ The following line creates a QApplication object. This object manages
+ application-wide resources and is necessary to run any Qt program
+ that uses Qt Widgets. It constructs an application object with \c argc
+ command line arguments run in \c argv. (For GUI applications that
+ do not use Qt Widgets, you can use QGuiApplication instead.)
+
+ \skipuntil {
+ \printuntil QApplication
+
+ The following line creates the Notepad object. This is the object for
+ which the wizard created the class and the UI file. The user interface
+ contains visual elements that are called \c widgets in Qt. Examples
+ of widgets are text edits, scroll bars, labels, and radio buttons. A
+ widget can also be a container for other widgets; a dialog or a main
+ application window, for example.
+
+ \printline Notepad
+
+ The following line shows the Notepad widget on the screen in its own
+ window. Widgets can also function as containers. An example of this
+ is QMainWindow which often contains several types of widgets. Widgets
+ are not visible by default; the function \l{QWidget::}{show()} makes
+ the widget visible.
+
+ \printline w.show
+
+ The following line makes the QApplication enter its event loop. When
+ a Qt application is running, events are generated and sent to the
+ widgets of the application. Examples of events are mouse presses
+ and key strokes.
+
+ \printline a.exec
+
+ \b{Learn More}
+
+ \table
+ \header
+ \li About
+ \li Here
+ \row
+ \li Widgets and Window Geometry
+ \li \l{Window and Dialog Widgets}
+ \row
+ \li Events and event handling
+ \li \l{The Event System}
+ \endtable
+
+ \section1 Designing a UI
+
+ 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 \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 \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 \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
+ \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
+ layout (QVBoxLayout).
+ \li Press \key {Ctrl+S} (or \key {Cmd+S}) to save your changes.
+ \endlist
+
+ The UI now looks as follows in \QD:
+
+ \image notepad4.png
+
+ You can view the generated XML file in the code editor:
+
+ \quotefromfile tutorials/notepad/notepad.ui
+
+ \printuntil QMenuBar
+ \dots
+
+ The following line contains the XML declaration, which specifies the
+ XML version and character encoding used in the document:
+
+ \code
+ <?xml version="1.0" encoding="UTF-8"?>
+ \endcode
+
+ The rest of the file specifies an \c ui element that defines a
+ Notepad widget:
+
+ \code
+ <ui version="4.0">
+ \endcode
+
+ The UI file is used together with the header and source file of the
+ Notepad class. We will look at the rest of the UI file in the later
+ sections.
+
+ \section2 Notepad Header File
+
+ The wizard generated a header file for the Notepad class that has the
+ necessary #includes, a constructor, a destructor, and the Ui object.
+ The file looks as follows:
+
+ \quotefromfile tutorials/notepad/notepad.h
+ \skipto #include
+ \printuntil ~Notepad();
+ \skipto private:
+ \printuntil };
+
+ The following line includes QMainWindow that provides a main application
+ window:
+
+ \quotefromfile tutorials/notepad/notepad.h
+ \skipto #include
+ \printuntil >
+
+ The following lines declare the Notepad class in the Ui namespace,
+ which is the standard namespace for the UI classes generated from
+ .ui files by the \c uic tool:
+
+ \skipto Ui {
+ \printuntil }
+
+ The class declaration contains the \c Q_OBJECT macro. It must come
+ first in the class definition, and declares our class as a QObject.
+ Naturally, it must also inherit from QObject. A QObject adds several
+ abilities to a normal C++ class. Notably, the class name and slot
+ names can be queried at runtime. It is also possible to query a slot's
+ parameter types and invoke it.
+
+ \skipto class Notepad
+ \printuntil Q_OBJECT
+
+ The following lines declare a constructor that has a default argument
+ called \c parent.
+ The value 0 indicates that the widget has no parent (it is a top-level
+ widget).
+
+ \printuntil explicit
+
+ The following line declares a virtual destructor to free the resources
+ that were acquired by the object during its life-cycle. According to
+ the C++ naming convention, destructors have the same name as the class
+ they are associated with, prefixed with a tilde (~). In QObject,
+ destructors are virtual to ensure that the destructors of derived
+ classes are invoked properly when an object is deleted through a
+ pointer-to-base-class.
+
+ \printuntil ~Notepad();
+
+ The following lines declare a member variable which is a pointer to
+ the Notepad UI class. A member variable is associated with a specific
+ class, and accessible for all its methods.
+
+ \skipto private:
+ \printuntil };
+
+ \section2 Notepad Source File
+
+ The source file that the wizard generated for the Notepad class looks
+ as follows:
+
+ \quotefromfile tutorials/notepad/notepad.cpp
+ \skipto #include "notepad.h"
+ \printuntil ui->setupUi(this);
+ \skipto }
+ \printuntil }
+
+ The following lines include the Notepad class header file that was
+ generated by the wizard and the UI header file that was generated
+ by the \c uic tool:
+
+ \quotefromfile tutorials/notepad/notepad.cpp
+ \skipto #include "notepad.h"
+ \printuntil #include "ui_notepad.h"
+
+ The following line defines the \c {Notepad} constructor:
+
+ \printuntil Notepad::Notepad
+
+ The following line calls the QMainWindow constructor, which is
+ the base class for the Notepad class:
+
+ \printuntil QMainWindow
+
+ The following line creates the UI class instance and assigns it to
+ the \c ui member:
+
+ \printline ui(new
+
+ The following line sets up the UI:
+
+ \printuntil ui->setupUi(this)
+
+ In the destructor, we delete the \c ui:
+
+ \skipto Notepad::~Notepad
+ \printuntil }
+
+ \section2 Project File
+
+ The wizard generates the following project file, \c CMakeLists.txt, for
+ us:
+
+ \quotefile tutorials/notepad/CMakeLists.txt
+
+ The project file specifies the source, header, and UI files included in
+ the project.
+
+ \b{Learn More}
+
+ \table
+ \header
+ \li About
+ \li Here
+ \row
+ \li Using \QD
+ \li \l{Qt Widgets Designer Manual}
+ \row
+ \li Layouts
+ \li \l{Layout Management},
+ \l{Widgets and Layouts},
+ \l{Layout Examples}
+ \row
+ \li The widgets that come with Qt
+ \li \l{Qt Widget Gallery}
+ \row
+ \li Main windows and main window classes
+ \li \l{Application Main Window},
+ \l{Main Window Examples}
+ \row
+ \li QObjects and the Qt Object model (This is essential to
+ understand Qt)
+ \li \l{Object Model}
+ \row
+ \li qmake and the Qt build system
+ \li \l{qmake Manual}
+ \endtable
+
+ \section1 Adding User Interaction
+
+
+ To add functionality to the editor, we start by adding menu items
+ and buttons on a toolbar.
+
+ Click on "Type Here", and add the options New, Open, Save, Save as,
+ Print and Exit. This creates 5 lines in the Action Editor below.
+ To connect the actions to slots, right-click an action and select
+ \uicontrol {Go to slot} > \uicontrol triggered(), and complete the
+ code for that given slot.
+
+ If we also want to add the actions to a toolbar, we can assign an
+ icon to each QAction, and then drag the QAction to the toolbar. You
+ assign an icon by entering an icon name in the Icon property of the
+ action concerned. When the QAction has been dragged to the toolbar,
+ clicking the icon will launch the associated slot.
+
+ Complete the method \c newDocument():
+
+ \quotefromfile tutorials/notepad/notepad.cpp
+ \skipto newDocument()
+ \printuntil }
+
+ The \c currentFile variable is a global variable containing the file
+ presently being edited, and \c clear() clears the text buffer.
+ The \c currentFile variable is defined in the private part of notepad.h:
+
+ \quotefromfile tutorials/notepad/notepad.h
+ \skipto private:
+ \printuntil currentFile;
+
+ \section2 Opening a file
+
+ In \c notepad.ui, right click on \c actionOpen and select
+ \uicontrol {Go to Slot}.
+
+ Complete method \c open().
+
+ \quotefromfile tutorials/notepad/notepad.cpp
+ \skipto open()
+ \printuntil file.close
+ \printuntil }
+
+
+ \c QFileDialog::getOpenFileName opens a dialog enabling you to select
+ a file. QFile object \c myfile has the selected \c file_name as
+ parameter. We store the selected file also into the global variable
+ \c currentFile for later purposes. We open the file with \c file.open
+ as a readonly text file. If it cannot be opened, a warning is issued,
+ and the program stops.
+
+ We define a QTextStream \c instream for parameter \c myfile.
+ The contents of file \c myfile is copied into QString \c text.
+ \c setText(text) fills the buffer of our editor with \c text.
+
+ \section2 Saving a file
+
+ We create the method for saving a file in the same way as for
+ \l {Opening a file}, by right clicking on \c actionSave, and
+ selecting \uicontrol {Go to Slot}.
+
+ \skipto Notepad::save
+ \printuntil file.close
+ \printuntil }
+
+ QFile object \c myfile is linked to global variable \c current_file,
+ the variable that contains the file we were working with.
+ If we cannot open \c myfile, an error message is issued and the
+ method stops. We create a QTextStream \c outstream. The contents
+ of the editor buffer is converted to plain text, and then written
+ to \c outstream.
+
+ \section2 Saving a file under another name
+
+ \skipto Notepad::saveAs
+ \printuntil file.close
+ \printuntil }
+
+ This is the same procedure as for \l {Saving a file}, the only
+ difference being that here you need to enter a new file name for
+ the file to be created.
+
+
+ \section2 Printing a File
+
+ If you want to use print functionalities, you need to add
+ \c PrintSupport to the project file:
+
+ \quotefromfile tutorials/notepad/CMakeLists.txt
+ \skipto find_package(Qt6
+ \printuntil )
+
+ In \c notepad.cpp, we declare a QPrinter object called \c printDev:
+
+ \quotefromfile tutorials/notepad/notepad.cpp
+ \skipto void Notepad::print()
+ \printuntil }
+
+ We launch a printer dialog box and store the selected printer in
+ object \c printDev. If we clicked on \c Cancel and did not select
+ a printer, the methods returns. The actual printer command is given
+ with \c ui->textEdit->print with our QPrinter object as parameter.
+
+ \section2 Select a Font
+
+ \skipto Notepad::selectFont
+ \printuntil }
+
+ We declare a boolean indicating if we did select a font with
+ QFontDialog. If so, we set the font with \c ui->textEdit->setFont(myfont).
+
+ \section2 Copy, Cut, Paste, Undo, and Redo
+
+ If you select some text, and want to copy it to the clipboard,
+ you call the appropriate method of \c ui->textEdit. The same counts
+ for cut, paste, undo, and redo.
+
+ This table shows the method name to use.
+
+ \table
+ \header
+ \li Task
+ \li Method called
+ \row
+ \li Copy
+ \li ui->textEdit->copy()
+ \row
+ \li Cut
+ \li ui->textEdit->cut()
+ \row
+ \li Paste
+ \li ui->textEdit->paste()
+ \row
+ \li Undo
+ \li ui->textEdit->undo()
+ \row
+ \li Redo
+ \li ui->textEdit->redo()
+ \endtable
+
+ \b{Learn More}
+
+ \table
+ \header
+ \li About
+ \li Here
+ \row
+ \li Files and I/O devices
+ \li QFile, QIODevice
+ \row
+ \li tr() and internationalization
+ \li \l{Qt Linguist Manual},
+ \l{Writing Source Code for Translation},
+ \l{Internationalization with Qt}
+ \endtable
+
+ \include cli-build-cmake.qdocinc cli-build-cmake
+*/
diff --git a/examples/widgets/tutorials/notepad/main.cpp b/examples/widgets/tutorials/notepad/main.cpp
index 20bcdaa7df..729e315952 100644
--- a/examples/widgets/tutorials/notepad/main.cpp
+++ b/examples/widgets/tutorials/notepad/main.cpp
@@ -1,61 +1,14 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "notepad.h"
+
#include <QApplication>
int main(int argc, char *argv[])
{
- QApplication EditorApp(argc, argv);
- Notepad Editor;
- Editor.show();
-
- return EditorApp.exec();
+ QApplication a(argc, argv);
+ Notepad w;
+ w.show();
+ return a.exec();
}
diff --git a/examples/widgets/tutorials/notepad/notepad.cpp b/examples/widgets/tutorials/notepad/notepad.cpp
index 5fd0d69cea..0f9e3459ea 100644
--- a/examples/widgets/tutorials/notepad/notepad.cpp
+++ b/examples/widgets/tutorials/notepad/notepad.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QFile>
#include <QFileDialog>
@@ -72,19 +25,24 @@ Notepad::Notepad(QWidget *parent) :
ui(new Ui::Notepad)
{
ui->setupUi(this);
- this->setCentralWidget(ui->textEdit);
connect(ui->actionNew, &QAction::triggered, this, &Notepad::newDocument);
connect(ui->actionOpen, &QAction::triggered, this, &Notepad::open);
connect(ui->actionSave, &QAction::triggered, this, &Notepad::save);
connect(ui->actionSave_as, &QAction::triggered, this, &Notepad::saveAs);
connect(ui->actionPrint, &QAction::triggered, this, &Notepad::print);
- connect(ui->actionExit, &QAction::triggered, this, &Notepad::exit);
- connect(ui->actionCopy, &QAction::triggered, this, &Notepad::copy);
- connect(ui->actionCut, &QAction::triggered, this, &Notepad::cut);
- connect(ui->actionPaste, &QAction::triggered, this, &Notepad::paste);
- connect(ui->actionUndo, &QAction::triggered, this, &Notepad::undo);
- connect(ui->actionRedo, &QAction::triggered, this, &Notepad::redo);
+ connect(ui->actionExit, &QAction::triggered, this, &QWidget::close);
+#if QT_CONFIG(clipboard)
+ connect(ui->textEdit, &QTextEdit::copyAvailable, ui->actionCopy, &QAction::setEnabled);
+ connect(ui->actionCopy, &QAction::triggered, ui->textEdit, &QTextEdit::copy);
+ connect(ui->actionCut, &QAction::triggered, ui->textEdit, &QTextEdit::cut);
+ connect(ui->actionPaste, &QAction::triggered, ui->textEdit, &QTextEdit::paste);
+#endif
+ connect(ui->textEdit, &QTextEdit::undoAvailable, ui->actionUndo, &QAction::setEnabled);
+ connect(ui->actionUndo, &QAction::triggered, ui->textEdit, &QTextEdit::undo);
+ connect(ui->textEdit, &QTextEdit::redoAvailable, ui->actionRedo, &QAction::setEnabled);
+ connect(ui->actionRedo, &QAction::triggered, ui->textEdit, &QTextEdit::redo);
+
connect(ui->actionFont, &QAction::triggered, this, &Notepad::selectFont);
connect(ui->actionBold, &QAction::triggered, this, &Notepad::setFontBold);
connect(ui->actionUnderline, &QAction::triggered, this, &Notepad::setFontUnderline);
@@ -117,6 +75,8 @@ void Notepad::newDocument()
void Notepad::open()
{
QString fileName = QFileDialog::getOpenFileName(this, "Open the file");
+ if (fileName.isEmpty())
+ return;
QFile file(fileName);
currentFile = fileName;
if (!file.open(QIODevice::ReadOnly | QFile::Text)) {
@@ -136,6 +96,8 @@ void Notepad::save()
// If we don't have a filename from before, get one.
if (currentFile.isEmpty()) {
fileName = QFileDialog::getSaveFileName(this, "Save");
+ if (fileName.isEmpty())
+ return;
currentFile = fileName;
} else {
fileName = currentFile;
@@ -155,6 +117,8 @@ void Notepad::save()
void Notepad::saveAs()
{
QString fileName = QFileDialog::getSaveFileName(this, "Save as");
+ if (fileName.isEmpty())
+ return;
QFile file(fileName);
if (!file.open(QFile::WriteOnly | QFile::Text)) {
@@ -182,42 +146,6 @@ void Notepad::print()
#endif // QT_CONFIG(printer)
}
-void Notepad::exit()
-{
- QCoreApplication::quit();
-}
-
-void Notepad::copy()
-{
-#if QT_CONFIG(clipboard)
- ui->textEdit->copy();
-#endif
-}
-
-void Notepad::cut()
-{
-#if QT_CONFIG(clipboard)
- ui->textEdit->cut();
-#endif
-}
-
-void Notepad::paste()
-{
-#if QT_CONFIG(clipboard)
- ui->textEdit->paste();
-#endif
-}
-
-void Notepad::undo()
-{
- ui->textEdit->undo();
-}
-
-void Notepad::redo()
-{
- ui->textEdit->redo();
-}
-
void Notepad::selectFont()
{
bool fontSelected;
@@ -244,8 +172,7 @@ void Notepad::setFontBold(bool bold)
void Notepad::about()
{
- QMessageBox::about(this, tr("About MDI"),
- tr("The <b>Notepad</b> example demonstrates how to code a basic "
- "text editor using QtWidgets"));
-
+ QMessageBox::about(this, tr("About Notepad"),
+ tr("The <b>Notepad</b> example demonstrates how to code a basic "
+ "text editor using QtWidgets"));
}
diff --git a/examples/widgets/tutorials/notepad/notepad.h b/examples/widgets/tutorials/notepad/notepad.h
index 5e44dfeedc..ae480ef788 100644
--- a/examples/widgets/tutorials/notepad/notepad.h
+++ b/examples/widgets/tutorials/notepad/notepad.h
@@ -1,122 +1,40 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef NOTEPAD_H
#define NOTEPAD_H
-//! [all]
-//! [1]
#include <QMainWindow>
-//! [1]
-//! [2]
QT_BEGIN_NAMESPACE
namespace Ui {
class Notepad;
}
QT_END_NAMESPACE
-//! [2]
-//! [3]
class Notepad : public QMainWindow
{
Q_OBJECT
-//! [3]
-//! [4]
public:
explicit Notepad(QWidget *parent = nullptr);
-//! [4]
-//! [5]
~Notepad();
-//! [5]
private slots:
void newDocument();
-
void open();
-
void save();
-
void saveAs();
-
void print();
-
- void exit();
-
- void copy();
-
- void cut();
-
- void paste();
-
- void undo();
-
- void redo();
-
void selectFont();
-
void setFontBold(bool bold);
-
void setFontUnderline(bool underline);
-
void setFontItalic(bool italic);
-
void about();
-//! [6]
private:
Ui::Notepad *ui;
QString currentFile;
-//! [6]
};
-//! [all]
#endif // NOTEPAD_H
diff --git a/examples/widgets/tutorials/notepad/notepad.ui b/examples/widgets/tutorials/notepad/notepad.ui
index 4b2a6a0675..b891dbae46 100644
--- a/examples/widgets/tutorials/notepad/notepad.ui
+++ b/examples/widgets/tutorials/notepad/notepad.ui
@@ -53,8 +53,15 @@
<addaction name="actionRedo"/>
<addaction name="actionFont"/>
</widget>
+ <widget class="QMenu" name="menuAbout">
+ <property name="title">
+ <string>About</string>
+ </property>
+ <addaction name="actionAbout"/>
+ </widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
+ <addaction name="menuAbout"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
@@ -171,8 +178,6 @@
<property name="toolTip">
<string>Exit notepad</string>
</property>
- <property name="shortcut">
- </property>
</action>
<action name="actionCopy">
<property name="icon">
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 1f4afee780..40590745a9 100644
--- a/examples/widgets/tutorials/widgets/CMakeLists.txt
+++ b/examples/widgets/tutorials/widgets/CMakeLists.txt
@@ -1,6 +1,7 @@
-# Generated from widgets.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(toplevel)
-add_subdirectory(childwidget)
-add_subdirectory(windowlayout)
-add_subdirectory(nestedlayouts)
+qt_internal_add_example(toplevel)
+qt_internal_add_example(childwidget)
+qt_internal_add_example(windowlayout)
+qt_internal_add_example(nestedlayouts)
diff --git a/examples/widgets/tutorials/widgets/childwidget/CMakeLists.txt b/examples/widgets/tutorials/widgets/childwidget/CMakeLists.txt
index c5852850ae..a4f8b5b8a2 100644
--- a/examples/widgets/tutorials/widgets/childwidget/CMakeLists.txt
+++ b/examples/widgets/tutorials/widgets/childwidget/CMakeLists.txt
@@ -1,39 +1,37 @@
-# Generated from childwidget.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(childwidget LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/widgets/childwidget")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(childwidget
main.cpp
)
+
set_target_properties(childwidget PROPERTIES
WIN32_EXECUTABLE TRUE
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/childwidget/main.cpp b/examples/widgets/tutorials/widgets/childwidget/main.cpp
index 2c54299693..13659ded3a 100644
--- a/examples/widgets/tutorials/widgets/childwidget/main.cpp
+++ b/examples/widgets/tutorials/widgets/childwidget/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [main program]
#include <QtWidgets>
diff --git a/examples/widgets/tutorials/widgets/nestedlayouts/CMakeLists.txt b/examples/widgets/tutorials/widgets/nestedlayouts/CMakeLists.txt
index b7aca1b946..cb6db0ec48 100644
--- a/examples/widgets/tutorials/widgets/nestedlayouts/CMakeLists.txt
+++ b/examples/widgets/tutorials/widgets/nestedlayouts/CMakeLists.txt
@@ -1,39 +1,37 @@
-# Generated from nestedlayouts.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(nestedlayouts LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/widgets/nestedlayouts")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(nestedlayouts
main.cpp
)
+
set_target_properties(nestedlayouts PROPERTIES
WIN32_EXECUTABLE TRUE
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/nestedlayouts/main.cpp b/examples/widgets/tutorials/widgets/nestedlayouts/main.cpp
index 8880dbe3d0..2709400776 100644
--- a/examples/widgets/tutorials/widgets/nestedlayouts/main.cpp
+++ b/examples/widgets/tutorials/widgets/nestedlayouts/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [main program]
//! [first part]
diff --git a/examples/widgets/tutorials/widgets/toplevel/CMakeLists.txt b/examples/widgets/tutorials/widgets/toplevel/CMakeLists.txt
index 35296c8621..2d241556f9 100644
--- a/examples/widgets/tutorials/widgets/toplevel/CMakeLists.txt
+++ b/examples/widgets/tutorials/widgets/toplevel/CMakeLists.txt
@@ -1,39 +1,37 @@
-# Generated from toplevel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(toplevel LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/widgets/toplevel")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(toplevel
main.cpp
)
+
set_target_properties(toplevel PROPERTIES
WIN32_EXECUTABLE TRUE
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/toplevel/main.cpp b/examples/widgets/tutorials/widgets/toplevel/main.cpp
index 310c146a97..04219b38e5 100644
--- a/examples/widgets/tutorials/widgets/toplevel/main.cpp
+++ b/examples/widgets/tutorials/widgets/toplevel/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [main program]
#include <QtWidgets>
diff --git a/examples/widgets/tutorials/widgets/windowlayout/CMakeLists.txt b/examples/widgets/tutorials/widgets/windowlayout/CMakeLists.txt
index 71f848d387..ea6e21e968 100644
--- a/examples/widgets/tutorials/widgets/windowlayout/CMakeLists.txt
+++ b/examples/widgets/tutorials/widgets/windowlayout/CMakeLists.txt
@@ -1,39 +1,37 @@
-# Generated from windowlayout.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(windowlayout LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/tutorials/widgets/windowlayout")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(windowlayout
main.cpp
)
+
set_target_properties(windowlayout PROPERTIES
WIN32_EXECUTABLE TRUE
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/tutorials/widgets/windowlayout/main.cpp b/examples/widgets/tutorials/widgets/windowlayout/main.cpp
index 99c16bc3ec..8e648c1d85 100644
--- a/examples/widgets/tutorials/widgets/windowlayout/main.cpp
+++ b/examples/widgets/tutorials/widgets/windowlayout/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [main program]
#include <QtWidgets>
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 8daf6a69ae..feb3067727 100644
--- a/examples/widgets/widgets/CMakeLists.txt
+++ b/examples/widgets/widgets/CMakeLists.txt
@@ -1,27 +1,14 @@
-# Generated from widgets.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(analogclock)
-add_subdirectory(calculator)
-add_subdirectory(calendarwidget)
-add_subdirectory(charactermap)
-add_subdirectory(codeeditor)
-add_subdirectory(digitalclock)
-add_subdirectory(elidedlabel)
-add_subdirectory(groupbox)
-add_subdirectory(icons)
-add_subdirectory(imageviewer)
-add_subdirectory(lineedits)
-add_subdirectory(movie)
-add_subdirectory(mousebuttons)
-add_subdirectory(scribble)
-add_subdirectory(shapedclock)
-add_subdirectory(sliders)
-add_subdirectory(spinboxes)
-add_subdirectory(styles)
-add_subdirectory(stylesheet)
-add_subdirectory(tablet)
-add_subdirectory(tetrix)
-add_subdirectory(tooltips)
-add_subdirectory(validators)
-add_subdirectory(wiggly)
-add_subdirectory(windowflags)
+qt_internal_add_example(analogclock)
+qt_internal_add_example(calculator)
+qt_internal_add_example(calendarwidget)
+qt_internal_add_example(lineedits)
+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(tablet)
+qt_internal_add_example(windowflags)
diff --git a/examples/widgets/widgets/analogclock/CMakeLists.txt b/examples/widgets/widgets/analogclock/CMakeLists.txt
index 50dc07919c..82b9ef3928 100644
--- a/examples/widgets/widgets/analogclock/CMakeLists.txt
+++ b/examples/widgets/widgets/analogclock/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from analogclock.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(analogclock LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/analogclock")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(analogclock
analogclock.cpp analogclock.h
main.cpp
)
+
set_target_properties(analogclock PROPERTIES
WIN32_EXECUTABLE TRUE
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 06e298659d..feb7f4e8b5 100644
--- a/examples/widgets/widgets/analogclock/analogclock.cpp
+++ b/examples/widgets/widgets/analogclock/analogclock.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "analogclock.h"
@@ -78,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]
@@ -102,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);
@@ -148,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/analogclock/analogclock.h b/examples/widgets/widgets/analogclock/analogclock.h
index e2486a915f..a268773782 100644
--- a/examples/widgets/widgets/analogclock/analogclock.h
+++ b/examples/widgets/widgets/analogclock/analogclock.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef ANALOGCLOCK_H
#define ANALOGCLOCK_H
diff --git a/examples/widgets/widgets/analogclock/main.cpp b/examples/widgets/widgets/analogclock/main.cpp
index 98de67b08a..0bba7b9ab4 100644
--- a/examples/widgets/widgets/analogclock/main.cpp
+++ b/examples/widgets/widgets/analogclock/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/widgets/calculator/CMakeLists.txt b/examples/widgets/widgets/calculator/CMakeLists.txt
index 5f961e350d..abf12d5663 100644
--- a/examples/widgets/widgets/calculator/CMakeLists.txt
+++ b/examples/widgets/widgets/calculator/CMakeLists.txt
@@ -1,41 +1,39 @@
-# Generated from calculator.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(calculator LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/calculator")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(calculator
button.cpp button.h
calculator.cpp calculator.h
main.cpp
)
+
set_target_properties(calculator PROPERTIES
WIN32_EXECUTABLE TRUE
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/button.cpp b/examples/widgets/widgets/calculator/button.cpp
index cc370a563c..b1d37d99a5 100644
--- a/examples/widgets/widgets/calculator/button.cpp
+++ b/examples/widgets/widgets/calculator/button.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "button.h"
diff --git a/examples/widgets/widgets/calculator/button.h b/examples/widgets/widgets/calculator/button.h
index 7c6f26867f..04a9f1e3dd 100644
--- a/examples/widgets/widgets/calculator/button.h
+++ b/examples/widgets/widgets/calculator/button.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef BUTTON_H
#define BUTTON_H
diff --git a/examples/widgets/widgets/calculator/calculator.cpp b/examples/widgets/widgets/calculator/calculator.cpp
index 2c3669b7a8..073b10f985 100644
--- a/examples/widgets/widgets/calculator/calculator.cpp
+++ b/examples/widgets/widgets/calculator/calculator.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "calculator.h"
#include "button.h"
@@ -76,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]
@@ -371,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 937de185e7..42e9ac5335 100644
--- a/examples/widgets/widgets/calculator/calculator.h
+++ b/examples/widgets/widgets/calculator/calculator.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CALCULATOR_H
#define CALCULATOR_H
@@ -86,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/calculator/main.cpp b/examples/widgets/widgets/calculator/main.cpp
index a034bb262e..38da9255a7 100644
--- a/examples/widgets/widgets/calculator/main.cpp
+++ b/examples/widgets/widgets/calculator/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/widgets/calendarwidget/CMakeLists.txt b/examples/widgets/widgets/calendarwidget/CMakeLists.txt
index 74c342ab73..9e8f7681ca 100644
--- a/examples/widgets/widgets/calendarwidget/CMakeLists.txt
+++ b/examples/widgets/widgets/calendarwidget/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from calendarwidget.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(calendarwidget LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/calendarwidget")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(calendarwidget
main.cpp
window.cpp window.h
)
+
set_target_properties(calendarwidget PROPERTIES
WIN32_EXECUTABLE TRUE
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/calendarwidget/main.cpp b/examples/widgets/widgets/calendarwidget/main.cpp
index 2582e83841..b2be8181cf 100644
--- a/examples/widgets/widgets/calendarwidget/main.cpp
+++ b/examples/widgets/widgets/calendarwidget/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/widgets/calendarwidget/window.cpp b/examples/widgets/widgets/calendarwidget/window.cpp
index 23010a6e1a..a26d28d242 100644
--- a/examples/widgets/widgets/calendarwidget/window.cpp
+++ b/examples/widgets/widgets/calendarwidget/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
@@ -237,6 +190,9 @@ void Window::createPreviewGroupBox()
}
//! [9]
+// TODO: use loc.name() as label (but has underscore in place of slash)
+// TODO: use locale() == loc instead of only comparing language and territory
+// Needs someone familiar with this example to work out ramifications
//! [10]
void Window::createGeneralOptionsGroupBox()
{
@@ -247,16 +203,16 @@ void Window::createGeneralOptionsGroupBox()
int index = 0;
for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) {
QLocale::Language lang = static_cast<QLocale::Language>(_lang);
- QList<QLocale::Country> countries = QLocale::countriesForLanguage(lang);
- for (int i = 0; i < countries.count(); ++i) {
- QLocale::Country country = countries.at(i);
+ const auto locales =
+ QLocale::matchingLocales(lang, QLocale::AnyScript, QLocale::AnyTerritory);
+ for (auto loc : locales) {
QString label = QLocale::languageToString(lang);
+ auto territory = loc.territory();
label += QLatin1Char('/');
- label += QLocale::countryToString(country);
- QLocale locale(lang, country);
- if (this->locale().language() == lang && this->locale().country() == country)
+ label += QLocale::territoryToString(territory);
+ if (locale().language() == lang && locale().territory() == territory)
curLocaleIndex = index;
- localeCombo->addItem(label, locale);
+ localeCombo->addItem(label, loc);
++index;
}
}
diff --git a/examples/widgets/widgets/calendarwidget/window.h b/examples/widgets/widgets/calendarwidget/window.h
index 1b673b8ce0..3e9785ec8a 100644
--- a/examples/widgets/widgets/calendarwidget/window.h
+++ b/examples/widgets/widgets/calendarwidget/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
diff --git a/examples/widgets/widgets/charactermap/CMakeLists.txt b/examples/widgets/widgets/charactermap/CMakeLists.txt
deleted file mode 100644
index 07791589c1..0000000000
--- a/examples/widgets/widgets/charactermap/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from charactermap.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(charactermap LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/charactermap")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 a9d5a06164..0000000000
--- a/examples/widgets/widgets/charactermap/characterwidget.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 67ac8a30bf..0000000000
--- a/examples/widgets/widgets/charactermap/characterwidget.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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/main.cpp b/examples/widgets/widgets/charactermap/main.cpp
deleted file mode 100644
index 1bf46b226f..0000000000
--- a/examples/widgets/widgets/charactermap/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- MainWindow window;
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/widgets/charactermap/mainwindow.cpp b/examples/widgets/widgets/charactermap/mainwindow.cpp
deleted file mode 100644
index cfe0be96ca..0000000000
--- a/examples/widgets/widgets/charactermap/mainwindow.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 79fe9f9cc8..0000000000
--- a/examples/widgets/widgets/charactermap/mainwindow.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 58665eca3c..0000000000
--- a/examples/widgets/widgets/codeeditor/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from codeeditor.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(codeeditor LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/codeeditor")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 e93a0251e5..0000000000
--- a/examples/widgets/widgets/codeeditor/codeeditor.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 283a4e0bdf..0000000000
--- a/examples/widgets/widgets/codeeditor/codeeditor.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 72d186553a..0000000000
--- a/examples/widgets/widgets/codeeditor/main.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 5cff6b456f..0000000000
--- a/examples/widgets/widgets/digitalclock/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from digitalclock.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(digitalclock LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/digitalclock")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 2b130ecda6..0000000000
--- a/examples/widgets/widgets/digitalclock/digitalclock.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 31c12f39ab..0000000000
--- a/examples/widgets/widgets/digitalclock/digitalclock.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 9440a81c91..0000000000
--- a/examples/widgets/widgets/digitalclock/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 338a6cfefe..0000000000
--- a/examples/widgets/widgets/elidedlabel/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from elidedlabel.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(elidedlabel LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/elidedlabel")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 e80f7a9894..0000000000
--- a/examples/widgets/widgets/elidedlabel/elidedlabel.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 0c8d96834e..0000000000
--- a/examples/widgets/widgets/elidedlabel/elidedlabel.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 1c620c1d41..0000000000
--- a/examples/widgets/widgets/elidedlabel/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 6e7930a359..0000000000
--- a/examples/widgets/widgets/elidedlabel/testwidget.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 bcb2f33044..0000000000
--- a/examples/widgets/widgets/elidedlabel/testwidget.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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
deleted file mode 100644
index 74f2fe037f..0000000000
--- a/examples/widgets/widgets/groupbox/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from groupbox.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(groupbox LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/groupbox")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(groupbox
- main.cpp
- window.cpp window.h
-)
-set_target_properties(groupbox PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(groupbox PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS groupbox
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/groupbox/groupbox.pro b/examples/widgets/widgets/groupbox/groupbox.pro
deleted file mode 100644
index 5fb6a14835..0000000000
--- a/examples/widgets/widgets/groupbox/groupbox.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QT += widgets
-
-HEADERS = window.h
-SOURCES = window.cpp \
- main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/groupbox
-INSTALLS += target
diff --git a/examples/widgets/widgets/groupbox/main.cpp b/examples/widgets/widgets/groupbox/main.cpp
deleted file mode 100644
index 99725195e5..0000000000
--- a/examples/widgets/widgets/groupbox/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "window.h"
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- Window window;
- window.show();
- return app.exec();
-}
diff --git a/examples/widgets/widgets/groupbox/window.cpp b/examples/widgets/widgets/groupbox/window.cpp
deleted file mode 100644
index 95c4f216fe..0000000000
--- a/examples/widgets/widgets/groupbox/window.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "window.h"
-
-#include <QCheckBox>
-#include <QGridLayout>
-#include <QGroupBox>
-#include <QMenu>
-#include <QPushButton>
-#include <QRadioButton>
-
-//! [0]
-Window::Window(QWidget *parent)
- : QWidget(parent)
-{
- QGridLayout *grid = new QGridLayout;
- grid->addWidget(createFirstExclusiveGroup(), 0, 0);
- grid->addWidget(createSecondExclusiveGroup(), 1, 0);
- grid->addWidget(createNonExclusiveGroup(), 0, 1);
- grid->addWidget(createPushButtonGroup(), 1, 1);
- setLayout(grid);
-
- setWindowTitle(tr("Group Boxes"));
- resize(480, 320);
-}
-//! [0]
-
-//! [1]
-QGroupBox *Window::createFirstExclusiveGroup()
-{
-//! [2]
- QGroupBox *groupBox = new QGroupBox(tr("Exclusive Radio Buttons"));
-
- QRadioButton *radio1 = new QRadioButton(tr("&Radio button 1"));
- QRadioButton *radio2 = new QRadioButton(tr("R&adio button 2"));
- QRadioButton *radio3 = new QRadioButton(tr("Ra&dio button 3"));
-
- radio1->setChecked(true);
-//! [1] //! [3]
-
- QVBoxLayout *vbox = new QVBoxLayout;
- vbox->addWidget(radio1);
- vbox->addWidget(radio2);
- vbox->addWidget(radio3);
- vbox->addStretch(1);
- groupBox->setLayout(vbox);
-//! [2]
-
- return groupBox;
-}
-//! [3]
-
-//! [4]
-QGroupBox *Window::createSecondExclusiveGroup()
-{
- QGroupBox *groupBox = new QGroupBox(tr("E&xclusive Radio Buttons"));
- groupBox->setCheckable(true);
- groupBox->setChecked(false);
-//! [4]
-
-//! [5]
- QRadioButton *radio1 = new QRadioButton(tr("Rad&io button 1"));
- QRadioButton *radio2 = new QRadioButton(tr("Radi&o button 2"));
- QRadioButton *radio3 = new QRadioButton(tr("Radio &button 3"));
- radio1->setChecked(true);
- QCheckBox *checkBox = new QCheckBox(tr("Ind&ependent checkbox"));
- checkBox->setChecked(true);
-//! [5]
-
-//! [6]
- QVBoxLayout *vbox = new QVBoxLayout;
- vbox->addWidget(radio1);
- vbox->addWidget(radio2);
- vbox->addWidget(radio3);
- vbox->addWidget(checkBox);
- vbox->addStretch(1);
- groupBox->setLayout(vbox);
-
- return groupBox;
-}
-//! [6]
-
-//! [7]
-QGroupBox *Window::createNonExclusiveGroup()
-{
- QGroupBox *groupBox = new QGroupBox(tr("Non-Exclusive Checkboxes"));
- groupBox->setFlat(true);
-//! [7]
-
-//! [8]
- QCheckBox *checkBox1 = new QCheckBox(tr("&Checkbox 1"));
- QCheckBox *checkBox2 = new QCheckBox(tr("C&heckbox 2"));
- checkBox2->setChecked(true);
- QCheckBox *tristateBox = new QCheckBox(tr("Tri-&state button"));
- tristateBox->setTristate(true);
-//! [8]
- tristateBox->setCheckState(Qt::PartiallyChecked);
-
-//! [9]
- QVBoxLayout *vbox = new QVBoxLayout;
- vbox->addWidget(checkBox1);
- vbox->addWidget(checkBox2);
- vbox->addWidget(tristateBox);
- vbox->addStretch(1);
- groupBox->setLayout(vbox);
-
- return groupBox;
-}
-//! [9]
-
-//! [10]
-QGroupBox *Window::createPushButtonGroup()
-{
- QGroupBox *groupBox = new QGroupBox(tr("&Push Buttons"));
- groupBox->setCheckable(true);
- groupBox->setChecked(true);
-//! [10]
-
-//! [11]
- QPushButton *pushButton = new QPushButton(tr("&Normal Button"));
- QPushButton *toggleButton = new QPushButton(tr("&Toggle Button"));
- toggleButton->setCheckable(true);
- toggleButton->setChecked(true);
- QPushButton *flatButton = new QPushButton(tr("&Flat Button"));
- flatButton->setFlat(true);
-//! [11]
-
-//! [12]
- QPushButton *popupButton = new QPushButton(tr("Pop&up Button"));
- QMenu *menu = new QMenu(this);
- menu->addAction(tr("&First Item"));
- menu->addAction(tr("&Second Item"));
- menu->addAction(tr("&Third Item"));
- menu->addAction(tr("F&ourth Item"));
- popupButton->setMenu(menu);
-//! [12]
-
- QAction *newAction = menu->addAction(tr("Submenu"));
- QMenu *subMenu = new QMenu(tr("Popup Submenu"));
- subMenu->addAction(tr("Item 1"));
- subMenu->addAction(tr("Item 2"));
- subMenu->addAction(tr("Item 3"));
- newAction->setMenu(subMenu);
-
-//! [13]
- QVBoxLayout *vbox = new QVBoxLayout;
- vbox->addWidget(pushButton);
- vbox->addWidget(toggleButton);
- vbox->addWidget(flatButton);
- vbox->addWidget(popupButton);
- vbox->addStretch(1);
- groupBox->setLayout(vbox);
-
- return groupBox;
-}
-//! [13]
diff --git a/examples/widgets/widgets/groupbox/window.h b/examples/widgets/widgets/groupbox/window.h
deleted file mode 100644
index 1f041fd003..0000000000
--- a/examples/widgets/widgets/groupbox/window.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QGroupBox;
-QT_END_NAMESPACE
-
-//! [0]
-class Window : public QWidget
-{
- Q_OBJECT
-
-public:
- Window(QWidget *parent = nullptr);
-
-private:
- QGroupBox *createFirstExclusiveGroup();
- QGroupBox *createSecondExclusiveGroup();
- QGroupBox *createNonExclusiveGroup();
- QGroupBox *createPushButtonGroup();
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/widgets/icons/.prev_CMakeLists.txt b/examples/widgets/widgets/icons/.prev_CMakeLists.txt
deleted file mode 100644
index ff25b3eaef..0000000000
--- a/examples/widgets/widgets/icons/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-# Generated from icons.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(icons LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/icons")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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/CMakeLists.txt b/examples/widgets/widgets/icons/CMakeLists.txt
deleted file mode 100644
index e14272e777..0000000000
--- a/examples/widgets/widgets/icons/CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-# Generated from icons.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(icons LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/icons")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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}" # special case
-)
-
-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 d0ee50fbb1..0000000000
--- a/examples/widgets/widgets/icons/iconpreviewarea.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "iconpreviewarea.h"
-
-#include <QGridLayout>
-#include <QLabel>
-
-//! [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()
-{
- QWindow *window = nullptr;
- if (const QWidget *nativeParent = nativeParentWidget())
- window = nativeParent->windowHandle();
- for (int column = 0; column < NumModes; ++column) {
- for (int row = 0; row < NumStates; ++row) {
- const QPixmap pixmap =
- icon.pixmap(window, size, 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 5387cb9f6d..0000000000
--- a/examples/widgets/widgets/icons/iconpreviewarea.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 8e6c654686..0000000000
--- a/examples/widgets/widgets/icons/iconsizespinbox.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 87415ac5d6..0000000000
--- a/examples/widgets/widgets/icons/iconsizespinbox.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 9f1e19c9eb..0000000000
--- a/examples/widgets/widgets/icons/imagedelegate.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 9d65304e2c..0000000000
--- a/examples/widgets/widgets/icons/imagedelegate.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 aff2d2013e..0000000000
--- a/examples/widgets/widgets/icons/main.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <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 7280ba9a42..0000000000
--- a/examples/widgets/widgets/icons/mainwindow.cpp
+++ /dev/null
@@ -1,525 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 cd77dae8e8..0000000000
--- a/examples/widgets/widgets/icons/mainwindow.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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/.prev_CMakeLists.txt b/examples/widgets/widgets/imageviewer/.prev_CMakeLists.txt
deleted file mode 100644
index 9603f8dcbd..0000000000
--- a/examples/widgets/widgets/imageviewer/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-# Generated from imageviewer.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(imageviewer LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/imageviewer")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-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()
-
-install(TARGETS imageviewer
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/imageviewer/CMakeLists.txt b/examples/widgets/widgets/imageviewer/CMakeLists.txt
deleted file mode 100644
index a52bc5fb34..0000000000
--- a/examples/widgets/widgets/imageviewer/CMakeLists.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-# Generated from imageviewer.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(imageviewer LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/imageviewer")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS PrintSupport) # special case
-
-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
-)
-# special case begin
-if (TARGET Qt::PrintSupport)
- target_link_libraries(imageviewer PUBLIC Qt::PrintSupport)
-endif()
-# special case end
-
-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 7de0c7c45b..0000000000
--- a/examples/widgets/widgets/imageviewer/imageviewer.cpp
+++ /dev/null
@@ -1,406 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 message = tr("Opened \"%1\", %2x%3, Depth: %4")
- .arg(QDir::toNativeSeparators(fileName)).arg(image.width()).arg(image.height()).arg(image.depth());
- 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");
- 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().first())) {}
-}
-//! [1]
-
-void ImageViewer::saveAs()
-{
- QFileDialog dialog(this, tr("Save File As"));
- initializeImageFileDialog(dialog, QFileDialog::AcceptSave);
-
- while (dialog.exec() == QDialog::Accepted && !saveFile(dialog.selectedFiles().first())) {}
-}
-
-//! [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"), &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 9c8388d470..0000000000
--- a/examples/widgets/widgets/imageviewer/imageviewer.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 035c769693..0000000000
--- a/examples/widgets/widgets/imageviewer/main.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <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().front())) {
- return -1;
- }
- imageViewer.show();
- return app.exec();
-}
diff --git a/examples/widgets/widgets/lineedits/CMakeLists.txt b/examples/widgets/widgets/lineedits/CMakeLists.txt
index 9e219e1038..9cfaa784c8 100644
--- a/examples/widgets/widgets/lineedits/CMakeLists.txt
+++ b/examples/widgets/widgets/lineedits/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from lineedits.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(lineedits LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/lineedits")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(lineedits
main.cpp
window.cpp window.h
)
+
set_target_properties(lineedits PROPERTIES
WIN32_EXECUTABLE TRUE
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/lineedits/main.cpp b/examples/widgets/widgets/lineedits/main.cpp
index 99725195e5..27409403a5 100644
--- a/examples/widgets/widgets/lineedits/main.cpp
+++ b/examples/widgets/widgets/lineedits/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/widgets/lineedits/window.cpp b/examples/widgets/widgets/lineedits/window.cpp
index 765f867deb..c8a47a1594 100644
--- a/examples/widgets/widgets/lineedits/window.cpp
+++ b/examples/widgets/widgets/lineedits/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
diff --git a/examples/widgets/widgets/lineedits/window.h b/examples/widgets/widgets/lineedits/window.h
index a31634f3a3..13fdcf64fa 100644
--- a/examples/widgets/widgets/lineedits/window.h
+++ b/examples/widgets/widgets/lineedits/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
diff --git a/examples/widgets/widgets/mousebuttons/CMakeLists.txt b/examples/widgets/widgets/mousebuttons/CMakeLists.txt
deleted file mode 100644
index 6a8a365d33..0000000000
--- a/examples/widgets/widgets/mousebuttons/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from mousebuttons.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(mousebuttons LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/mousebuttons")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 88dbbeda45..0000000000
--- a/examples/widgets/widgets/mousebuttons/buttontester.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Rick Stockton <rickstockton@reno-computerhelp.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 231733bd44..0000000000
--- a/examples/widgets/widgets/mousebuttons/buttontester.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Rick Stockton <rickstockton@reno-computerhelp.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef 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 e35a442181..0000000000
--- a/examples/widgets/widgets/mousebuttons/main.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Rick Stockton <rickstockton@reno-computerhelp.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 a990a98f48..0000000000
--- a/examples/widgets/widgets/movie/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from movie.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(movie LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/movie")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 7e5a07a394..0000000000
--- a/examples/widgets/widgets/movie/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 76849268ab..0000000000
--- a/examples/widgets/widgets/movie/movieplayer.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 7d143bd37c..0000000000
--- a/examples/widgets/widgets/movie/movieplayer.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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/.prev_CMakeLists.txt b/examples/widgets/widgets/scribble/.prev_CMakeLists.txt
deleted file mode 100644
index 2ce40dc8cb..0000000000
--- a/examples/widgets/widgets/scribble/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-# Generated from scribble.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(scribble LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/scribble")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(scribble
- main.cpp
- mainwindow.cpp mainwindow.h
- scribblearea.cpp scribblearea.h
-)
-set_target_properties(scribble PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(scribble PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-if(TARGET Qt::PrintSupport)
- target_link_libraries(scribble PUBLIC
- Qt::PrintSupport
- )
-endif()
-
-install(TARGETS scribble
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/widgets/scribble/CMakeLists.txt b/examples/widgets/widgets/scribble/CMakeLists.txt
index dc7f0f56bb..ec78b1ece8 100644
--- a/examples/widgets/widgets/scribble/CMakeLists.txt
+++ b/examples/widgets/widgets/scribble/CMakeLists.txt
@@ -1,53 +1,46 @@
-# Generated from scribble.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(scribble LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC 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
+)
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS PrintSupport) # special case
+qt_standard_project_setup()
qt_add_executable(scribble
main.cpp
mainwindow.cpp mainwindow.h
scribblearea.cpp scribblearea.h
)
+
set_target_properties(scribble PROPERTIES
WIN32_EXECUTABLE TRUE
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
)
-# special case begin
-if (TARGET Qt::PrintSupport)
- target_link_libraries(scribble PUBLIC Qt::PrintSupport)
-endif()
-# special case end
-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/main.cpp b/examples/widgets/widgets/scribble/main.cpp
index 1bf46b226f..7d7cf3e573 100644
--- a/examples/widgets/widgets/scribble/main.cpp
+++ b/examples/widgets/widgets/scribble/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/widgets/scribble/mainwindow.cpp b/examples/widgets/widgets/scribble/mainwindow.cpp
index c9a34796ac..0a0a658265 100644
--- a/examples/widgets/widgets/scribble/mainwindow.cpp
+++ b/examples/widgets/widgets/scribble/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "scribblearea.h"
@@ -200,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/scribble/mainwindow.h b/examples/widgets/widgets/scribble/mainwindow.h
index e57ff065ac..354fdc67a1 100644
--- a/examples/widgets/widgets/scribble/mainwindow.h
+++ b/examples/widgets/widgets/scribble/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/widgets/widgets/scribble/scribblearea.cpp b/examples/widgets/widgets/scribble/scribblearea.cpp
index 2ac293d55a..65021532ef 100644
--- a/examples/widgets/widgets/scribble/scribblearea.cpp
+++ b/examples/widgets/widgets/scribble/scribblearea.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "scribblearea.h"
diff --git a/examples/widgets/widgets/scribble/scribblearea.h b/examples/widgets/widgets/scribble/scribblearea.h
index ed3c8a2a15..2cea93334f 100644
--- a/examples/widgets/widgets/scribble/scribblearea.h
+++ b/examples/widgets/widgets/scribble/scribblearea.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SCRIBBLEAREA_H
#define SCRIBBLEAREA_H
diff --git a/examples/widgets/widgets/shapedclock/CMakeLists.txt b/examples/widgets/widgets/shapedclock/CMakeLists.txt
index de91c6410c..dd8dc217ef 100644
--- a/examples/widgets/widgets/shapedclock/CMakeLists.txt
+++ b/examples/widgets/widgets/shapedclock/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from shapedclock.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(shapedclock LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/shapedclock")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(shapedclock
main.cpp
shapedclock.cpp shapedclock.h
)
+
set_target_properties(shapedclock PROPERTIES
WIN32_EXECUTABLE TRUE
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/main.cpp b/examples/widgets/widgets/shapedclock/main.cpp
index 3437597b7a..599e4cc625 100644
--- a/examples/widgets/widgets/shapedclock/main.cpp
+++ b/examples/widgets/widgets/shapedclock/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/widgets/shapedclock/shapedclock.cpp b/examples/widgets/widgets/shapedclock/shapedclock.cpp
index 343ad7c43c..106b3454a6 100644
--- a/examples/widgets/widgets/shapedclock/shapedclock.cpp
+++ b/examples/widgets/widgets/shapedclock/shapedclock.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "shapedclock.h"
@@ -101,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);
@@ -125,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 a854d956b3..3dec93cc74 100644
--- a/examples/widgets/widgets/shapedclock/shapedclock.h
+++ b/examples/widgets/widgets/shapedclock/shapedclock.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SHAPEDCLOCK_H
#define SHAPEDCLOCK_H
@@ -66,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/shortcuteditor/main.cpp b/examples/widgets/widgets/shortcuteditor/main.cpp
new file mode 100644
index 0000000000..029f7a351a
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/main.cpp
@@ -0,0 +1,13 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "application.h"
+#include "mainwindow.h"
+
+int main(int argc, char *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/widgets/shortcuteditor/shortcuteditordelegate.h b/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h
new file mode 100644
index 0000000000..2818438db3
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h
@@ -0,0 +1,34 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SHORTCUTEDITORDELEGATE_H
+#define SHORTCUTEDITORDELEGATE_H
+
+#include <QStyledItemDelegate>
+
+//! [0]
+class ShortcutEditorDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
+
+public:
+ explicit ShortcutEditorDelegate(QObject *parent = nullptr);
+ ~ShortcutEditorDelegate() override = default;
+
+protected:
+ 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;
+
+ void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const override;
+
+private:
+ void commitAndCloseEditor();
+};
+//! [0]
+
+#endif
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 07dd0c0326..c4c9d11e03 100644
--- a/examples/widgets/widgets/sliders/CMakeLists.txt
+++ b/examples/widgets/widgets/sliders/CMakeLists.txt
@@ -1,41 +1,39 @@
-# Generated from sliders.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(sliders LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/sliders")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(sliders
main.cpp
slidersgroup.cpp slidersgroup.h
window.cpp window.h
)
+
set_target_properties(sliders PROPERTIES
WIN32_EXECUTABLE TRUE
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/main.cpp b/examples/widgets/widgets/sliders/main.cpp
index 99725195e5..27409403a5 100644
--- a/examples/widgets/widgets/sliders/main.cpp
+++ b/examples/widgets/widgets/sliders/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/widgets/sliders/slidersgroup.cpp b/examples/widgets/widgets/sliders/slidersgroup.cpp
index 912c9798ce..87841c43f9 100644
--- a/examples/widgets/widgets/sliders/slidersgroup.cpp
+++ b/examples/widgets/widgets/sliders/slidersgroup.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "slidersgroup.h"
@@ -56,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);
@@ -143,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 7be8a3b4f8..7e7d887018 100644
--- a/examples/widgets/widgets/sliders/slidersgroup.h
+++ b/examples/widgets/widgets/sliders/slidersgroup.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SLIDERSGROUP_H
#define SLIDERSGROUP_H
@@ -57,6 +10,7 @@ QT_BEGIN_NAMESPACE
class QDial;
class QScrollBar;
class QSlider;
+class QBoxLayout;
QT_END_NAMESPACE
//! [0]
@@ -65,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);
@@ -77,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 916f206379..c62c3b83f5 100644
--- a/examples/widgets/widgets/sliders/window.cpp
+++ b/examples/widgets/widgets/sliders/window.cpp
@@ -1,59 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "slidersgroup.h"
#include "window.h"
-
#include <QCheckBox>
#include <QComboBox>
-#include <QHBoxLayout>
#include <QLabel>
#include <QSpinBox>
#include <QStackedWidget>
@@ -62,28 +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);
-
- QHBoxLayout *layout = new QHBoxLayout;
+ layout = new QBoxLayout(QBoxLayout::LeftToRight);
layout->addWidget(controlsGroup);
- layout->addWidget(stackedWidget);
+ layout->addWidget(slidersGroup);
setLayout(layout);
minimumSpinBox->setValue(0);
@@ -92,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);
@@ -107,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);
@@ -121,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);
- connect(invertedAppearance, &QCheckBox::toggled,
- horizontalSliders, &SlidersGroup::invertAppearance);
+ slidersGroup, &SlidersGroup::setMaximum);
connect(invertedAppearance, &QCheckBox::toggled,
- verticalSliders, &SlidersGroup::invertAppearance);
+ slidersGroup, &SlidersGroup::invertAppearance);
connect(invertedKeyBindings, &QCheckBox::toggled,
- horizontalSliders, &SlidersGroup::invertKeyBindings);
- connect(invertedKeyBindings, &QCheckBox::toggled,
- verticalSliders, &SlidersGroup::invertKeyBindings);
+ slidersGroup, &SlidersGroup::invertKeyBindings);
QGridLayout *controlsLayout = new QGridLayout;
controlsLayout->addWidget(minimumLabel, 0, 0);
@@ -155,7 +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);
+
+}
+//! [6]
+
+
+//! [7]
+void Window::resizeEvent(QResizeEvent *)
+{
+ if (width() == 0 || height() == 0)
+ return;
+
+ const double aspectRatio = double(width()) / double(height());
+
+ 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);
+ }
}
-//! [8]
+//! [7]
diff --git a/examples/widgets/widgets/sliders/window.h b/examples/widgets/widgets/sliders/window.h
index 4894781ac2..8d7338f27c 100644
--- a/examples/widgets/widgets/sliders/window.h
+++ b/examples/widgets/widgets/sliders/window.h
@@ -1,57 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
#include <QWidget>
+#include <QGridLayout>
QT_BEGIN_NAMESPACE
class QCheckBox;
@@ -73,10 +27,9 @@ public:
private:
void createControls(const QString &title);
+ void resizeEvent(QResizeEvent *e);
- SlidersGroup *horizontalSliders;
- SlidersGroup *verticalSliders;
- QStackedWidget *stackedWidget;
+ SlidersGroup *slidersGroup;
QGroupBox *controlsGroup;
QLabel *minimumLabel;
@@ -87,7 +40,7 @@ private:
QSpinBox *minimumSpinBox;
QSpinBox *maximumSpinBox;
QSpinBox *valueSpinBox;
- QComboBox *orientationCombo;
+ QBoxLayout *layout;
};
//! [0]
diff --git a/examples/widgets/widgets/spinboxes/CMakeLists.txt b/examples/widgets/widgets/spinboxes/CMakeLists.txt
index ade330faf2..83e54166bb 100644
--- a/examples/widgets/widgets/spinboxes/CMakeLists.txt
+++ b/examples/widgets/widgets/spinboxes/CMakeLists.txt
@@ -1,40 +1,38 @@
-# Generated from spinboxes.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(spinboxes LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/spinboxes")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(spinboxes
main.cpp
window.cpp window.h
)
+
set_target_properties(spinboxes PROPERTIES
WIN32_EXECUTABLE TRUE
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/spinboxes/main.cpp b/examples/widgets/widgets/spinboxes/main.cpp
index 99725195e5..27409403a5 100644
--- a/examples/widgets/widgets/spinboxes/main.cpp
+++ b/examples/widgets/widgets/spinboxes/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/widgets/spinboxes/window.cpp b/examples/widgets/widgets/spinboxes/window.cpp
index 6aeb5a8f69..8e67074c1c 100644
--- a/examples/widgets/widgets/spinboxes/window.cpp
+++ b/examples/widgets/widgets/spinboxes/window.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "window.h"
diff --git a/examples/widgets/widgets/spinboxes/window.h b/examples/widgets/widgets/spinboxes/window.h
index 138773a5aa..421ab58c83 100644
--- a/examples/widgets/widgets/spinboxes/window.h
+++ b/examples/widgets/widgets/spinboxes/window.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WINDOW_H
#define WINDOW_H
diff --git a/examples/widgets/widgets/styles/CMakeLists.txt b/examples/widgets/widgets/styles/CMakeLists.txt
deleted file mode 100644
index c847af915c..0000000000
--- a/examples/widgets/widgets/styles/CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-# Generated from styles.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(styles LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/styles")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 471589d3ad..0000000000
--- a/examples/widgets/widgets/styles/main.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 34a63e0eea..0000000000
--- a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp
+++ /dev/null
@@ -1,357 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 62ca502d05..0000000000
--- a/examples/widgets/widgets/styles/norwegianwoodstyle.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 bf8e93feb4..0000000000
--- a/examples/widgets/widgets/styles/widgetgallery.cpp
+++ /dev/null
@@ -1,324 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 8c4c880536..0000000000
--- a/examples/widgets/widgets/styles/widgetgallery.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 ccfb15f68c..0000000000
--- a/examples/widgets/widgets/stylesheet/CMakeLists.txt
+++ /dev/null
@@ -1,88 +0,0 @@
-# Generated from stylesheet.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(stylesheet LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC 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 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 3b1168398a..0000000000
--- a/examples/widgets/widgets/stylesheet/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 a8bd20e964..0000000000
--- a/examples/widgets/widgets/stylesheet/mainwindow.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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()
-{
- QMessageBox::about(this, tr("About Style sheet"),
- tr("The <b>Style Sheet</b> example shows how widgets can be styled "
- "using <a href=\"http://doc.qt.io/qt-5/stylesheet.html\">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."));
-}
diff --git a/examples/widgets/widgets/stylesheet/mainwindow.h b/examples/widgets/widgets/stylesheet/mainwindow.h
deleted file mode 100644
index ba979a3881..0000000000
--- a/examples/widgets/widgets/stylesheet/mainwindow.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 f885964a31..0000000000
--- a/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 4105d61d5d..0000000000
--- a/examples/widgets/widgets/stylesheet/stylesheeteditor.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 c411cc4fef..caf9922741 100644
--- a/examples/widgets/widgets/tablet/CMakeLists.txt
+++ b/examples/widgets/widgets/tablet/CMakeLists.txt
@@ -1,23 +1,12 @@
-# Generated from tablet.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(qttablet LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/tablet")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(qttablet
main.cpp
@@ -25,16 +14,17 @@ qt_add_executable(qttablet
tabletapplication.cpp tabletapplication.h
tabletcanvas.cpp tabletcanvas.h
)
+
set_target_properties(qttablet PROPERTIES
WIN32_EXECUTABLE TRUE
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:
set(images_resource_files
@@ -44,7 +34,7 @@ set(images_resource_files
"images/cursor-pencil.png"
)
-qt6_add_resources(qttablet "images"
+qt_add_resources(qttablet "images"
PREFIX
"/"
FILES
@@ -52,7 +42,14 @@ qt6_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/tablet/main.cpp b/examples/widgets/widgets/tablet/main.cpp
index 0fec526de0..6fe3a65acd 100644
--- a/examples/widgets/widgets/tablet/main.cpp
+++ b/examples/widgets/widgets/tablet/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "tabletapplication.h"
diff --git a/examples/widgets/widgets/tablet/mainwindow.cpp b/examples/widgets/widgets/tablet/mainwindow.cpp
index 102fb813b8..1c5209195f 100644
--- a/examples/widgets/widgets/tablet/mainwindow.cpp
+++ b/examples/widgets/widgets/tablet/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "tabletcanvas.h"
@@ -155,13 +108,13 @@ void MainWindow::about()
void MainWindow::createMenus()
{
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(tr("&Open..."), this, &MainWindow::load, QKeySequence::Open);
- fileMenu->addAction(tr("&Save As..."), this, &MainWindow::save, QKeySequence::SaveAs);
- fileMenu->addAction(tr("&New"), this, &MainWindow::clear, QKeySequence::New);
- fileMenu->addAction(tr("E&xit"), this, &MainWindow::close, QKeySequence::Quit);
+ fileMenu->addAction(tr("&Open..."), QKeySequence::Open, this, &MainWindow::load);
+ fileMenu->addAction(tr("&Save As..."), QKeySequence::SaveAs, this, &MainWindow::save);
+ fileMenu->addAction(tr("&New"), QKeySequence::New, this, &MainWindow::clear);
+ fileMenu->addAction(tr("E&xit"), QKeySequence::Quit, this, &MainWindow::close);
QMenu *brushMenu = menuBar()->addMenu(tr("&Brush"));
- brushMenu->addAction(tr("&Brush Color..."), this, &MainWindow::setBrushColor, tr("Ctrl+B"));
+ brushMenu->addAction(tr("&Brush Color..."), tr("Ctrl+B"), this, &MainWindow::setBrushColor);
//! [8]
QMenu *tabletMenu = menuBar()->addMenu(tr("&Tablet"));
diff --git a/examples/widgets/widgets/tablet/mainwindow.h b/examples/widgets/widgets/tablet/mainwindow.h
index 3ea9af7ccf..c67065b6bf 100644
--- a/examples/widgets/widgets/tablet/mainwindow.h
+++ b/examples/widgets/widgets/tablet/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/widgets/widgets/tablet/tabletapplication.cpp b/examples/widgets/widgets/tablet/tabletapplication.cpp
index a27491a86c..0d50ef685a 100644
--- a/examples/widgets/widgets/tablet/tabletapplication.cpp
+++ b/examples/widgets/widgets/tablet/tabletapplication.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "tabletapplication.h"
diff --git a/examples/widgets/widgets/tablet/tabletapplication.h b/examples/widgets/widgets/tablet/tabletapplication.h
index 9b4a4f1886..cf18ae9cfb 100644
--- a/examples/widgets/widgets/tablet/tabletapplication.h
+++ b/examples/widgets/widgets/tablet/tabletapplication.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TABLETAPPLICATION_H
#define TABLETAPPLICATION_H
diff --git a/examples/widgets/widgets/tablet/tabletcanvas.cpp b/examples/widgets/widgets/tablet/tabletcanvas.cpp
index e397d70cd6..f28f765e36 100644
--- a/examples/widgets/widgets/tablet/tabletcanvas.cpp
+++ b/examples/widgets/widgets/tablet/tabletcanvas.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "tabletcanvas.h"
diff --git a/examples/widgets/widgets/tablet/tabletcanvas.h b/examples/widgets/widgets/tablet/tabletcanvas.h
index 4c10731b0f..8219b4d545 100644
--- a/examples/widgets/widgets/tablet/tabletcanvas.h
+++ b/examples/widgets/widgets/tablet/tabletcanvas.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TABLETCANVAS_H
#define TABLETCANVAS_H
diff --git a/examples/widgets/widgets/tetrix/CMakeLists.txt b/examples/widgets/widgets/tetrix/CMakeLists.txt
deleted file mode 100644
index 58237e2962..0000000000
--- a/examples/widgets/widgets/tetrix/CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-# Generated from tetrix.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(tetrix LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/tetrix")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 92f245ca14..0000000000
--- a/examples/widgets/widgets/tetrix/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 c1192f264d..0000000000
--- a/examples/widgets/widgets/tetrix/tetrixboard.cpp
+++ /dev/null
@@ -1,418 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 86bcfa4d6e..0000000000
--- a/examples/widgets/widgets/tetrix/tetrixboard.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 9f6f6e863a..0000000000
--- a/examples/widgets/widgets/tetrix/tetrixpiece.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 0a01c23423..0000000000
--- a/examples/widgets/widgets/tetrix/tetrixpiece.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 5aa5c3f615..0000000000
--- a/examples/widgets/widgets/tetrix/tetrixwindow.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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);
-#if __cplusplus >= 201402L
- 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));
-#else
- connect(board, &TetrixBoard::scoreChanged,
- scoreLcd, QOverload<int>::of(&QLCDNumber::display));
- connect(board, &TetrixBoard::levelChanged,
- levelLcd, QOverload<int>::of(&QLCDNumber::display));
- connect(board, &TetrixBoard::linesRemovedChanged,
- linesLcd, QOverload<int>::of(&QLCDNumber::display));
-#endif
-//! [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 3743d6cd2a..0000000000
--- a/examples/widgets/widgets/tetrix/tetrixwindow.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 bde6e4fc27..0000000000
--- a/examples/widgets/widgets/tooltips/CMakeLists.txt
+++ /dev/null
@@ -1,56 +0,0 @@
-# Generated from tooltips.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(tooltips LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/tooltips")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 0890020f77..0000000000
--- a/examples/widgets/widgets/tooltips/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "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 68cc744b84..0000000000
--- a/examples/widgets/widgets/tooltips/shapeitem.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 6ca7ac278e..0000000000
--- a/examples/widgets/widgets/tooltips/shapeitem.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 d993b098b2..0000000000
--- a/examples/widgets/widgets/tooltips/sortingbox.cpp
+++ /dev/null
@@ -1,316 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 3d0cecea2b..0000000000
--- a/examples/widgets/widgets/tooltips/sortingbox.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 d5ea9b833e..0000000000
--- a/examples/widgets/widgets/validators/CMakeLists.txt
+++ /dev/null
@@ -1,57 +0,0 @@
-# Generated from validators.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(validators LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC 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 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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"
-)
-
-qt6_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 462f416c86..0000000000
--- a/examples/widgets/widgets/validators/ledwidget.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 c4b406db23..0000000000
--- a/examples/widgets/widgets/validators/ledwidget.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 3dcd04d9ff..0000000000
--- a/examples/widgets/widgets/validators/localeselector.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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::AnyCountry);
- for (const QLocale &l : locales) {
- QString label = QLocale::languageToString(l.language());
- label += QLatin1Char('/');
- label += QLocale::countryToString(l.country());
- // distinguish locales by script, if there are more than one script for a language/country pair
- if (QLocale::matchingLocales(l.language(), QLocale::AnyScript, l.country()).size() > 1)
- label += QLatin1String(" (") + QLocale::scriptToString(l.script()) + QLatin1Char(')');
-
- addItem(label, QVariant::fromValue(l));
-
- if (l.language() == locale().language() && l.country() == locale().country()
- && (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 611e2da66e..0000000000
--- a/examples/widgets/widgets/validators/localeselector.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 1fbf12410d..0000000000
--- a/examples/widgets/widgets/validators/main.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 504eec4fe7..0000000000
--- a/examples/widgets/widgets/validators/validatorwidget.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 bcc4a9b91e..0000000000
--- a/examples/widgets/widgets/validators/validatorwidget.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <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..5dd8f5eedc 100644
--- a/examples/widgets/widgets/widgets.pro
+++ b/examples/widgets/widgets/widgets.pro
@@ -2,25 +2,10 @@ 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 daf816d46e..0000000000
--- a/examples/widgets/widgets/wiggly/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Generated from wiggly.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(wiggly LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/wiggly")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS 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 a7a72b3570..0000000000
--- a/examples/widgets/widgets/wiggly/dialog.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 357b6354b5..0000000000
--- a/examples/widgets/widgets/wiggly/dialog.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 cd888c4084..0000000000
--- a/examples/widgets/widgets/wiggly/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 ab549ef07c..0000000000
--- a/examples/widgets/widgets/wiggly/wigglywidget.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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 1d909c34da..0000000000
--- a/examples/widgets/widgets/wiggly/wigglywidget.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef 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 93ab0d9dbf..fbc1bf217b 100644
--- a/examples/widgets/widgets/windowflags/CMakeLists.txt
+++ b/examples/widgets/widgets/windowflags/CMakeLists.txt
@@ -1,41 +1,39 @@
-# Generated from windowflags.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(windowflags LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/windowflags")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(windowflags
controllerwindow.cpp controllerwindow.h
main.cpp
previewwindow.cpp previewwindow.h
)
+
set_target_properties(windowflags PROPERTIES
WIN32_EXECUTABLE TRUE
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/widgets/windowflags/controllerwindow.cpp b/examples/widgets/widgets/windowflags/controllerwindow.cpp
index 0e9a916988..80d5f9e59b 100644
--- a/examples/widgets/widgets/windowflags/controllerwindow.cpp
+++ b/examples/widgets/widgets/windowflags/controllerwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "controllerwindow.h"
diff --git a/examples/widgets/widgets/windowflags/controllerwindow.h b/examples/widgets/widgets/windowflags/controllerwindow.h
index 43ec67e27f..de76efbd20 100644
--- a/examples/widgets/widgets/windowflags/controllerwindow.h
+++ b/examples/widgets/widgets/windowflags/controllerwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CONTROLLERWINDOW_H
#define CONTROLLERWINDOW_H
diff --git a/examples/widgets/widgets/windowflags/main.cpp b/examples/widgets/widgets/windowflags/main.cpp
index 6732678047..b01716ddae 100644
--- a/examples/widgets/widgets/windowflags/main.cpp
+++ b/examples/widgets/widgets/windowflags/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/widgets/widgets/windowflags/previewwindow.cpp b/examples/widgets/widgets/windowflags/previewwindow.cpp
index d7ebed7b3c..bd4b7b4f40 100644
--- a/examples/widgets/widgets/windowflags/previewwindow.cpp
+++ b/examples/widgets/widgets/windowflags/previewwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "previewwindow.h"
@@ -124,6 +77,8 @@ void PreviewWindow::setWindowFlags(Qt::WindowFlags flags)
text += "\n| Qt::WindowShadeButtonHint";
if (flags & Qt::WindowStaysOnTopHint)
text += "\n| Qt::WindowStaysOnTopHint";
+ if (flags & Qt::WindowStaysOnBottomHint)
+ text += "\n| Qt::WindowStaysOnBottomHint";
if (flags & Qt::CustomizeWindowHint)
text += "\n| Qt::CustomizeWindowHint";
diff --git a/examples/widgets/widgets/windowflags/previewwindow.h b/examples/widgets/widgets/windowflags/previewwindow.h
index 9bb487e8ab..ada83c4c28 100644
--- a/examples/widgets/widgets/windowflags/previewwindow.h
+++ b/examples/widgets/widgets/windowflags/previewwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef PREVIEWWINDOW_H
#define PREVIEWWINDOW_H
diff --git a/examples/widgets/windowcontainer/CMakeLists.txt b/examples/widgets/windowcontainer/CMakeLists.txt
deleted file mode 100644
index 8348694666..0000000000
--- a/examples/widgets/windowcontainer/CMakeLists.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-# Generated from windowcontainer.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(windowcontainer LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/windowcontainer")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-find_package(Qt6 COMPONENTS OpenGL)
-
-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 a104949d1e..0000000000
--- a/examples/widgets/windowcontainer/windowcontainer.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "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)
diff --git a/examples/xml/CMakeLists.txt b/examples/xml/CMakeLists.txt
index 8e145b4ccb..aca12accfe 100644
--- a/examples/xml/CMakeLists.txt
+++ b/examples/xml/CMakeLists.txt
@@ -1,11 +1,6 @@
-# Generated from xml.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(htmlinfo)
-add_subdirectory(xmlstreamlint)
-if(TARGET Qt::Widgets)
- add_subdirectory(dombookmarks)
- add_subdirectory(streambookmarks)
-endif()
-if(TARGET Qt::Network AND TARGET Qt::Widgets)
- add_subdirectory(rsslisting)
+if(TARGET Qt6::Widgets)
+ qt_internal_add_example(dombookmarks)
endif()
diff --git a/examples/xml/dombookmarks/CMakeLists.txt b/examples/xml/dombookmarks/CMakeLists.txt
index 11e3fcc5e4..58efd94a55 100644
--- a/examples/xml/dombookmarks/CMakeLists.txt
+++ b/examples/xml/dombookmarks/CMakeLists.txt
@@ -1,43 +1,40 @@
-# Generated from dombookmarks.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(dombookmarks LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Xml)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/xml/dombookmarks")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Xml)
-find_package(Qt6 COMPONENTS Widgets)
+qt_standard_project_setup()
qt_add_executable(dombookmarks
main.cpp
mainwindow.cpp mainwindow.h
xbeltree.cpp xbeltree.h
)
+
set_target_properties(dombookmarks PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
-target_link_libraries(dombookmarks PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
- Qt::Xml
+
+target_link_libraries(dombookmarks PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+ Qt6::Xml
)
install(TARGETS dombookmarks
- 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 dombookmarks
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/xml/dombookmarks/doc/images/dombookmarks-example.png b/examples/xml/dombookmarks/doc/images/dombookmarks-example.png
deleted file mode 100644
index abacacbbfc..0000000000
--- a/examples/xml/dombookmarks/doc/images/dombookmarks-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/xml/dombookmarks/doc/images/screenshot.png b/examples/xml/dombookmarks/doc/images/screenshot.png
new file mode 100644
index 0000000000..462052ce8a
--- /dev/null
+++ b/examples/xml/dombookmarks/doc/images/screenshot.png
Binary files differ
diff --git a/examples/xml/dombookmarks/doc/src/dombookmarks.qdoc b/examples/xml/dombookmarks/doc/src/dombookmarks.qdoc
index 84ac1723d5..0b3ca2f47d 100644
--- a/examples/xml/dombookmarks/doc/src/dombookmarks.qdoc
+++ b/examples/xml/dombookmarks/doc/src/dombookmarks.qdoc
@@ -1,41 +1,96 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example dombookmarks
- \title DOM Bookmarks Example
+ \title DOM Bookmarks Application
+ \examplecategory {Data Processing & I/O}
\ingroup xml-examples
+ \meta tag {xml}
\brief Provides a reader for XML Bookmark Exchange Language files.
- The DOM Bookmarks example provides a reader for XML Bookmark Exchange Language (XBEL)
- files that uses Qt's DOM-based XML API to read and parse the files. The SAX Bookmarks
- example provides an alternative way to read this type of file.
+ The DOM Bookmarks Application provides a reader for XML Bookmark Exchange
+ Language (XBEL) files that uses Qt's DOM-based XML API to read and parse
+ the files. The \l {QXmlStream Bookmarks Example} provides an alternative
+ way to read this type of file.
- \image dombookmarks-example.png
+ \image screenshot.png
+
+ \section1 The XbelTree Class Definition
+
+ The XbelTree class has functions for reading and writing to the filesystem.
+ It inherits from the QTreeWidget class, contains the model for the
+ displaying of the bookmarks, and allows it to be edited.
+
+ \snippet dombookmarks/xbeltree.h 0
+
+ \section1 The XbelTree Class Implementation
+
+ The \c XbelTree constructor accepts a QWidget within which it is placed.
+ The \c folderIcon is set to QIcon::Normal mode where the pixmap is only
+ displayed when the user is not interacting with the icon. The
+ QStyle::SP_DirClosedIcon, QStyle::SP_DirOpenIcon, and QStyle::SP_FileIcon
+ correspond to standard pixmaps that follow the style of your GUI.
+
+ \snippet dombookmarks/xbeltree.cpp 0
+
+ The \c read() function opens the given QIODevice using
+ QDomDocument::setContent. If it succeeds opening the file and the top
+ level headers are verified, the contents of the class is cleared before
+ the file contents is parsed by iterating all the top level XML nodes and
+ calling \c parseFolderElement() on each of them.
+
+ \snippet dombookmarks/xbeltree.cpp 1
+
+ The \c parseFolderElement() function handles the different element types
+ and calls itself recursively if the element is a subfolder.
+
+ \snippet dombookmarks/xbeltree.cpp 3
+
+ The \c write() function saves the domDocument to the given QIODevice using
+ QDomDocument::save.
+
+ \snippet dombookmarks/xbeltree.cpp 2
+
+ \section1 The MainWindow Class Definition
+
+ The \c MainWindow class is a subclass of QMainWindow, with a
+ \c File menu and a \c Help menu.
+
+ \snippet dombookmarks/mainwindow.h 0
+
+ \section1 The MainWindow Class Implementation
+
+ The \c MainWindow constructor instantiates the member XbelTree object,
+ and sets its header with a QStringList object, \c labels.
+ The constructor also invokes \c createMenus() to set up the menus.
+ The \c statusBar() is used to display the message "Ready".
+
+ \snippet dombookmarks/mainwindow.cpp 0
+
+ The \c createMenus() function populates the menus and sets keyboard
+ shortcuts.
+
+ \snippet dombookmarks/mainwindow.cpp 4
+
+ The \c open() function enables the user to open an XBEL file using
+ QFileDialog. A warning message is displayed along
+ with the \c fileName and \c errorString if the file cannot be read or
+ if there is a parse error. If it succeeds it calls \c XbelTree::read().
+
+ \snippet dombookmarks/mainwindow.cpp 1
+
+ The \c saveAs() function displays a QFileDialog, prompting the user for
+ a \c fileName. Similar to the \c open() function, this function also
+ displays a warning message if the file cannot be written to. If this
+ succeeds it calls \c XbelTree::write().
+
+ \snippet dombookmarks/mainwindow.cpp 2
+
+ The \c about() function displays a QMessageBox with a brief description
+ of the example.
+
+ \snippet dombookmarks/mainwindow.cpp 3
See the \l{http://pyxml.sourceforge.net/topics/xbel/}{XML Bookmark Exchange Language
Resource Page} for more information about XBEL files.
diff --git a/examples/xml/dombookmarks/dombookmarks.pro b/examples/xml/dombookmarks/dombookmarks.pro
index 280207eebb..f6cf6ffc6d 100644
--- a/examples/xml/dombookmarks/dombookmarks.pro
+++ b/examples/xml/dombookmarks/dombookmarks.pro
@@ -6,7 +6,7 @@ SOURCES = main.cpp \
QT += xml widgets
requires(qtConfig(filedialog))
-EXAMPLE_FILES = frank.xbel jennifer.xbel
+EXAMPLE_FILES = jennifer.xbel
# install
target.path = $$[QT_INSTALL_EXAMPLES]/xml/dombookmarks
diff --git a/examples/xml/dombookmarks/jennifer.xbel b/examples/xml/dombookmarks/jennifer.xbel
index 2501c118af..d504236830 100644
--- a/examples/xml/dombookmarks/jennifer.xbel
+++ b/examples/xml/dombookmarks/jennifer.xbel
@@ -3,66 +3,66 @@
<xbel version="1.0">
<folder folded="no">
<title>Qt Resources</title>
- <bookmark href="http://qt.io/">
+ <bookmark href="https://www.qt.io/">
<title>Qt home page</title>
</bookmark>
- <bookmark href="https://www.qt.io/partners/">
+ <bookmark href="https://www.qt.io/contact-us/partners">
<title>Qt Partners</title>
</bookmark>
- <bookmark href="https://www.qt.io/qt-training/">
- <title>Training</title>
+ <bookmark href="https://www.qt.io/qt-professional-services">
+ <title>Professional Services</title>
</bookmark>
- <bookmark href="http://doc.qt.io/">
- <title>Qt 5 documentation</title>
- </bookmark>
- <bookmark href="http://qt-project.org/faq/">
- <title>Frequently Asked Questions</title>
+ <bookmark href="https://doc.qt.io/">
+ <title>Qt Documentation</title>
</bookmark>
<folder folded="yes">
<title>Community Resources</title>
- <bookmark href="http://www.qtcentre.org/content/">
+ <bookmark href="https://contribute.qt-project.org">
+ <title>The Qt Project</title>
+ </bookmark>
+ <bookmark href="https://www.qtcentre.org/content/">
<title>Qt Centre</title>
</bookmark>
- <bookmark href="http://www.qtforum.org/">
- <title>QtForum.org</title>
+ <bookmark href="https://forum.qt.io/">
+ <title>Forum.Qt.org</title>
</bookmark>
- <bookmark href="http://digitalfanatics.org/projects/qt_tutorial/">
+ <bookmark href="https://digitalfanatics.org/projects/qt_tutorial/">
<title>The Independent Qt Tutorial</title>
</bookmark>
- <bookmark href="http://www.qtforum.de/">
+ <bookmark href="https://www.qtforum.de/">
<title>German Qt Forum</title>
</bookmark>
- <bookmark href="http://www.korone.net/">
+ <bookmark href="https://www.qt-dev.com/">
<title>Korean Qt Community Site</title>
</bookmark>
- <bookmark href="http://prog.org.ru/">
+ <bookmark href="http://www.prog.org.ru/">
<title>Russian Qt Forum</title>
</bookmark>
</folder>
</folder>
<folder folded="no">
<title>Online Dictionaries</title>
- <bookmark href="http://www.dictionary.com/">
+ <bookmark href="https://www.dictionary.com/">
<title>Dictionary.com</title>
</bookmark>
- <bookmark href="http://www.m-w.com/">
+ <bookmark href="https://www.merriam-webster.com/">
<title>Merriam-Webster Online</title>
</bookmark>
- <bookmark href="http://dictionary.cambridge.org/">
+ <bookmark href="https://dictionary.cambridge.org/">
<title>Cambridge Dictionaries Online</title>
</bookmark>
- <bookmark href="http://www.onelook.com/">
+ <bookmark href="https://www.onelook.com/">
<title>OneLook Dictionary Search</title>
</bookmark>
<separator/>
- <bookmark href="http://dict.tu-chemnitz.de/">
- <title>TU Chemnitz German-English Dictionary</title>
+ <bookmark href="https://dict.tu-chemnitz.de/">
+ <title>BEOLINGUS, a service of TU Chemnitz</title>
</bookmark>
<separator/>
<bookmark href="http://atilf.atilf.fr/tlf.htm">
<title>Trésor de la Langue Française informatisé</title>
</bookmark>
- <bookmark href="http://dictionnaires.atilf.fr/dictionnaires/ACADEMIE/">
+ <bookmark href="https://www.dictionnaire-academie.fr/">
<title>Dictionnaire de l'Académie Française</title>
</bookmark>
</folder>
diff --git a/examples/xml/dombookmarks/main.cpp b/examples/xml/dombookmarks/main.cpp
index 0c175c9fc1..43f9088dad 100644
--- a/examples/xml/dombookmarks/main.cpp
+++ b/examples/xml/dombookmarks/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
diff --git a/examples/xml/dombookmarks/mainwindow.cpp b/examples/xml/dombookmarks/mainwindow.cpp
index b8f2e12918..5e6c68ce8d 100644
--- a/examples/xml/dombookmarks/mainwindow.cpp
+++ b/examples/xml/dombookmarks/mainwindow.cpp
@@ -1,58 +1,21 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "xbeltree.h"
+#include <QApplication>
+#include <QFileDialog>
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QStatusBar>
+
+#include <QAction>
+#include <QScreen>
+
+using namespace Qt::StringLiterals;
+
+//! [0]
MainWindow::MainWindow()
{
xbelTree = new XbelTree;
@@ -66,19 +29,20 @@ MainWindow::MainWindow()
const QSize availableSize = screen()->availableGeometry().size();
resize(availableSize.width() / 2, availableSize.height() / 3);
}
+//! [0]
+//! [1]
void MainWindow::open()
{
- QString fileName =
- QFileDialog::getOpenFileName(this, tr("Open Bookmark File"),
- QDir::currentPath(),
- tr("XBEL Files (*.xbel *.xml)"));
- if (fileName.isEmpty())
+ QFileDialog fileDialog(this, tr("Open Bookmark File"), QDir::currentPath());
+ fileDialog.setMimeTypeFilters({"application/x-xbel"_L1});
+ if (fileDialog.exec() != QDialog::Accepted)
return;
+ const QString fileName = fileDialog.selectedFiles().constFirst();
QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("SAX Bookmarks"),
+ QMessageBox::warning(this, tr("DOM Bookmarks"),
tr("Cannot read file %1:\n%2.")
.arg(QDir::toNativeSeparators(fileName),
file.errorString()));
@@ -88,19 +52,22 @@ void MainWindow::open()
if (xbelTree->read(&file))
statusBar()->showMessage(tr("File loaded"), 2000);
}
+//! [1]
+//! [2]
void MainWindow::saveAs()
{
- QString fileName =
- QFileDialog::getSaveFileName(this, tr("Save Bookmark File"),
- QDir::currentPath(),
- tr("XBEL Files (*.xbel *.xml)"));
- if (fileName.isEmpty())
+ QFileDialog fileDialog(this, tr("Save Bookmark File"), QDir::currentPath());
+ fileDialog.setAcceptMode(QFileDialog::AcceptSave);
+ fileDialog.setDefaultSuffix("xbel"_L1);
+ fileDialog.setMimeTypeFilters({"application/x-xbel"_L1});
+ if (fileDialog.exec() != QDialog::Accepted)
return;
+ const QString fileName = fileDialog.selectedFiles().constFirst();
QFile file(fileName);
if (!file.open(QFile::WriteOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("SAX Bookmarks"),
+ QMessageBox::warning(this, tr("DOM Bookmarks"),
tr("Cannot write file %1:\n%2.")
.arg(QDir::toNativeSeparators(fileName),
file.errorString()));
@@ -110,7 +77,9 @@ void MainWindow::saveAs()
if (xbelTree->write(&file))
statusBar()->showMessage(tr("File saved"), 2000);
}
+//! [2]
+//! [3]
void MainWindow::about()
{
QMessageBox::about(this, tr("About DOM Bookmarks"),
@@ -118,7 +87,9 @@ void MainWindow::about()
"use Qt's DOM classes to read and write XML "
"documents."));
}
+//! [3]
+//! [4]
void MainWindow::createMenus()
{
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
@@ -135,5 +106,6 @@ void MainWindow::createMenus()
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(tr("&About"), this, &MainWindow::about);
- helpMenu->addAction(tr("About &Qt"), qApp, &QCoreApplication::quit);
+ helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
}
+//! [4]
diff --git a/examples/xml/dombookmarks/mainwindow.h b/examples/xml/dombookmarks/mainwindow.h
index 0a8c7bdd82..82e29012f2 100644
--- a/examples/xml/dombookmarks/mainwindow.h
+++ b/examples/xml/dombookmarks/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@@ -55,6 +8,7 @@
class XbelTree;
+//! [0]
class MainWindow : public QMainWindow
{
Q_OBJECT
@@ -72,5 +26,6 @@ private:
XbelTree *xbelTree;
};
+//! [0]
#endif
diff --git a/examples/xml/dombookmarks/xbeltree.cpp b/examples/xml/dombookmarks/xbeltree.cpp
index cc2feea936..eff2fea8f0 100644
--- a/examples/xml/dombookmarks/xbeltree.cpp
+++ b/examples/xml/dombookmarks/xbeltree.cpp
@@ -1,77 +1,41 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "xbeltree.h"
+#include <QHeaderView>
+#include <QMenu>
+#include <QMessageBox>
+
+#include <QDesktopServices>
+#include <QGuiApplication>
+#if QT_CONFIG(clipboard) && QT_CONFIG(contextmenu)
+# include <QClipboard>
+# include <QContextMenuEvent>
+#endif
+
+#include <QUrl>
+
+using namespace Qt::StringLiterals;
+
enum { DomElementRole = Qt::UserRole + 1 };
Q_DECLARE_METATYPE(QDomElement)
-static inline QString titleElement() { return QStringLiteral("title"); }
-static inline QString folderElement() { return QStringLiteral("folder"); }
-static inline QString bookmarkElement() { return QStringLiteral("bookmark"); }
+static const auto titleElement = u"title"_s;
+static const auto folderElement = u"folder"_s;
+static const auto bookmarkElement = u"bookmark"_s;
-static inline QString versionAttribute() { return QStringLiteral("version"); }
-static inline QString hrefAttribute() { return QStringLiteral("href"); }
-static inline QString foldedAttribute() { return QStringLiteral("folded"); }
+static const auto versionAttribute = u"version"_s;
+static const auto hrefAttribute = u"href"_s;
+static const auto foldedAttribute = u"folded"_s;
+//! [0]
XbelTree::XbelTree(QWidget *parent)
: QTreeWidget(parent)
{
- QStringList labels;
- labels << tr("Title") << tr("Location");
-
header()->setSectionResizeMode(QHeaderView::Stretch);
- setHeaderLabels(labels);
+ setHeaderLabels({tr("Title"), tr("Location")});
folderIcon.addPixmap(style()->standardPixmap(QStyle::SP_DirClosedIcon),
QIcon::Normal, QIcon::Off);
@@ -79,8 +43,9 @@ XbelTree::XbelTree(QWidget *parent)
QIcon::Normal, QIcon::On);
bookmarkIcon.addPixmap(style()->standardPixmap(QStyle::SP_FileIcon));
}
+//! [0]
-#if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_CLIPBOARD)
+#if QT_CONFIG(clipboard) && QT_CONFIG(contextmenu)
void XbelTree::contextMenuEvent(QContextMenuEvent *event)
{
const QTreeWidgetItem *item = itemAt(event->pos());
@@ -96,21 +61,19 @@ void XbelTree::contextMenuEvent(QContextMenuEvent *event)
else if (action == openAction)
QDesktopServices::openUrl(QUrl(url));
}
-#endif // !QT_NO_CONTEXTMENU && !QT_NO_CLIPBOARD
+#endif // QT_CONFIG(clipboard) && QT_CONFIG(contextmenu)
+//! [1]
bool XbelTree::read(QIODevice *device)
{
- QString errorStr;
- int errorLine;
- int errorColumn;
-
- if (!domDocument.setContent(device, true, &errorStr, &errorLine,
- &errorColumn)) {
+ QDomDocument::ParseResult result =
+ domDocument.setContent(device, QDomDocument::ParseOption::UseNamespaceProcessing);
+ if (!result) {
QMessageBox::information(window(), tr("DOM Bookmarks"),
tr("Parse error at line %1, column %2:\n%3")
- .arg(errorLine)
- .arg(errorColumn)
- .arg(errorStr));
+ .arg(result.errorLine)
+ .arg(result.errorColumn)
+ .arg(result.errorMessage));
return false;
}
@@ -119,8 +82,8 @@ bool XbelTree::read(QIODevice *device)
QMessageBox::information(window(), tr("DOM Bookmarks"),
tr("The file is not an XBEL file."));
return false;
- } else if (root.hasAttribute(versionAttribute())
- && root.attribute(versionAttribute()) != QLatin1String("1.0")) {
+ } else if (root.hasAttribute(versionAttribute)
+ && root.attribute(versionAttribute) != "1.0"_L1) {
QMessageBox::information(window(), tr("DOM Bookmarks"),
tr("The file is not an XBEL version 1.0 "
"file."));
@@ -131,17 +94,19 @@ bool XbelTree::read(QIODevice *device)
disconnect(this, &QTreeWidget::itemChanged, this, &XbelTree::updateDomElement);
- QDomElement child = root.firstChildElement(folderElement());
+ QDomElement child = root.firstChildElement(folderElement);
while (!child.isNull()) {
parseFolderElement(child);
- child = child.nextSiblingElement(folderElement());
+ child = child.nextSiblingElement(folderElement);
}
connect(this, &QTreeWidget::itemChanged, this, &XbelTree::updateDomElement);
return true;
}
+//! [1]
+//! [2]
bool XbelTree::write(QIODevice *device) const
{
const int IndentSize = 4;
@@ -150,65 +115,70 @@ bool XbelTree::write(QIODevice *device) const
domDocument.save(out, IndentSize);
return true;
}
+//! [2]
void XbelTree::updateDomElement(const QTreeWidgetItem *item, int column)
{
QDomElement element = qvariant_cast<QDomElement>(item->data(0, DomElementRole));
if (!element.isNull()) {
if (column == 0) {
- QDomElement oldTitleElement = element.firstChildElement(titleElement());
- QDomElement newTitleElement = domDocument.createElement(titleElement());
+ QDomElement oldTitleElement = element.firstChildElement(titleElement);
+ QDomElement newTitleElement = domDocument.createElement(titleElement);
QDomText newTitleText = domDocument.createTextNode(item->text(0));
newTitleElement.appendChild(newTitleText);
element.replaceChild(newTitleElement, oldTitleElement);
} else {
- if (element.tagName() == bookmarkElement())
- element.setAttribute(hrefAttribute(), item->text(1));
+ if (element.tagName() == bookmarkElement)
+ element.setAttribute(hrefAttribute, item->text(1));
}
}
}
+//! [3]
void XbelTree::parseFolderElement(const QDomElement &element,
QTreeWidgetItem *parentItem)
{
QTreeWidgetItem *item = createItem(element, parentItem);
- QString title = element.firstChildElement(titleElement()).text();
+ QString title = element.firstChildElement(titleElement).text();
if (title.isEmpty())
- title = QObject::tr("Folder");
+ title = tr("Folder");
item->setFlags(item->flags() | Qt::ItemIsEditable);
item->setIcon(0, folderIcon);
item->setText(0, title);
- bool folded = (element.attribute(foldedAttribute()) != QLatin1String("no"));
+ bool folded = (element.attribute(foldedAttribute) != "no"_L1);
item->setExpanded(!folded);
+ constexpr char16_t midDot = u'\xB7';
+ static const QString dots = QString(30, midDot);
QDomElement child = element.firstChildElement();
while (!child.isNull()) {
- if (child.tagName() == folderElement()) {
+ if (child.tagName() == folderElement) {
parseFolderElement(child, item);
- } else if (child.tagName() == bookmarkElement()) {
+ } else if (child.tagName() == bookmarkElement) {
QTreeWidgetItem *childItem = createItem(child, item);
- QString title = child.firstChildElement(titleElement()).text();
+ QString title = child.firstChildElement(titleElement).text();
if (title.isEmpty())
- title = QObject::tr("Folder");
+ title = tr("Folder");
childItem->setFlags(item->flags() | Qt::ItemIsEditable);
childItem->setIcon(0, bookmarkIcon);
childItem->setText(0, title);
- childItem->setText(1, child.attribute(hrefAttribute()));
- } else if (child.tagName() == QLatin1String("separator")) {
+ childItem->setText(1, child.attribute(hrefAttribute));
+ } else if (child.tagName() == "separator"_L1) {
QTreeWidgetItem *childItem = createItem(child, item);
childItem->setFlags(item->flags() & ~(Qt::ItemIsSelectable | Qt::ItemIsEditable));
- childItem->setText(0, QString(30, u'\xB7'));
+ childItem->setText(0, dots);
}
child = child.nextSiblingElement();
}
}
+//! [3]
QTreeWidgetItem *XbelTree::createItem(const QDomElement &element,
QTreeWidgetItem *parentItem)
diff --git a/examples/xml/dombookmarks/xbeltree.h b/examples/xml/dombookmarks/xbeltree.h
index 989841d339..caaf4c0062 100644
--- a/examples/xml/dombookmarks/xbeltree.h
+++ b/examples/xml/dombookmarks/xbeltree.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef XBELTREE_H
#define XBELTREE_H
@@ -55,18 +8,19 @@
#include <QIcon>
#include <QTreeWidget>
+//! [0]
class XbelTree : public QTreeWidget
{
Q_OBJECT
public:
- XbelTree(QWidget *parent = nullptr);
+ explicit XbelTree(QWidget *parent = nullptr);
bool read(QIODevice *device);
bool write(QIODevice *device) const;
protected:
-#if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_CLIPBOARD)
+#if QT_CONFIG(clipboard) && QT_CONFIG(contextmenu)
void contextMenuEvent(QContextMenuEvent *event) override;
#endif
@@ -83,5 +37,6 @@ private:
QIcon folderIcon;
QIcon bookmarkIcon;
};
+//! [0]
#endif
diff --git a/examples/xml/htmlinfo/.prev_CMakeLists.txt b/examples/xml/htmlinfo/.prev_CMakeLists.txt
deleted file mode 100644
index 77fa423eff..0000000000
--- a/examples/xml/htmlinfo/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-# Generated from htmlinfo.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(htmlinfo LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-set(INSTALL_EXAMPLEDIR "examples/xml/htmlinfo")
-
-find_package(Qt6 COMPONENTS Core)
-
-add_executable(htmlinfo
- main.cpp
-)
-target_link_libraries(htmlinfo PUBLIC
- Qt::Core
-)
-
-
-# Resources:
-set(resources_resource_files
- "apache_org.html"
- "simpleexample.html"
- "trolltech_com.html"
- "w3c_org.html"
- "youtube_com.html"
-)
-
-qt6_add_resources(htmlinfo "resources"
- PREFIX
- "/"
- FILES
- ${resources_resource_files}
-)
-
-install(TARGETS htmlinfo
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/xml/htmlinfo/CMakeLists.txt b/examples/xml/htmlinfo/CMakeLists.txt
deleted file mode 100644
index 1afb256ff2..0000000000
--- a/examples/xml/htmlinfo/CMakeLists.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-# Generated from htmlinfo.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(htmlinfo LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/xml/htmlinfo")
-
-find_package(Qt6 COMPONENTS Core)
-
-qt_add_executable(htmlinfo
- main.cpp
-)
-set_target_properties(htmlinfo PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(htmlinfo PUBLIC
- Qt::Core
-)
-
-
-# Resources:
-set(resources_resource_files
- "apache_org.html"
- "simpleexample.html"
- "trolltech_com.html"
- "w3c_org.html"
- "youtube_com.html"
-)
-
-qt6_add_resources(htmlinfo "resources"
- PREFIX
- "/"
- FILES
- ${resources_resource_files}
-)
-
-install(TARGETS htmlinfo
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/xml/htmlinfo/apache_org.html b/examples/xml/htmlinfo/apache_org.html
deleted file mode 100644
index 9e5e4d3a68..0000000000
--- a/examples/xml/htmlinfo/apache_org.html
+++ /dev/null
@@ -1,281 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <!--
- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- This file is generated from XML source: DO NOT EDIT!
- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- -->
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <link rel="stylesheet" href="./style/compressed.css" type="text/css" media="screen, projection"/>
- <link rel="stylesheet" href="./style/style.css" type="text/css" media="screen, projection"/>
- <!--[if IE]><link rel="stylesheet" href="./style/ie.css" type="text/css" media="screen, projection"/><![endif]-->
-<link rel="alternate" title="announce@apache.org Archives" type="application/atom+xml" href="http://mail-archives.apache.org/mod_mbox/www-announce/?format=atom" />
- <meta name="author" content="The Apache Software Foundation" /><meta name="email" content="apache.AT.apache.DOT.org" />
- <title>Welcome! - The Apache Software Foundation</title>
- </head>
- <body>
- <div class="navigation">
- <ul>
- <li><a href="./foundation" title="About the Foundation">Foundation</a></li>
- <li><a href="http://projects.apache.org" title="Apache Projects">Projects</a></li>
- <li><a href="http://people.apache.org" title="Apache People">People</a></li>
- <li><a href="./foundation/getinvolved.html" title="Get involved in Apache">Get Involved</a></li>
- <li><a href="./foundation/sponsorship.html" title="Support the mission of Apache">Support Apache</a></li>
- <li class="dlink"><a href="./dyn/closer.cgi" title="Download Apache projects">Download</a></li>
- </ul>
- </div>
- <div class="container">
- <hr class="space col"/>
- <div class="block">
- <div class="column span-24">
- <div id="header">
- <h1>The Apache Software Foundation<br />
- <span class="alt"><small>Meritocracy in Action.</small></span></h1><p class="blurb">The Apache Software Foundation provides support for the Apache community of open-source software projects. The <a href="http://projects.apache.org/">Apache projects</a> are characterized by a collaborative, consensus based development process, an open and pragmatic software license, and a desire to create high quality software that leads the way in its field.</p><p class="highlight">We consider ourselves not simply a group of projects sharing a server, but rather a <em>community of developers and users</em>.</p>
- </div>
- </div>
- </div>
- <hr/>
- <div class="block">
- <div class="column span-15 first append-1">
- <h3>
- Latest News
- </h3>
- </div>
- <div class="column span-8 las search">
- <form action="http://www.google.com/search" method="get">
- <input value="*.apache.org" name="sitesearch" type="hidden"/>
- <input size="10" name="q" id="query" type="text"/>
- <input name="Search" value="Go" type="submit"/>
- </form>
- </div>
- </div>
- <div class="block content">
- <div class="column span-15 colborder">
-
-<div class="section-content">
-<p><em>If you would like to keep up with news and announcements from the
-foundation and all its projects, you can subscribe to the
-<a href="foundation/mailinglists.html#foundation-announce">Apache
-Announcements List</a></em>.</p>
-
-<h4 id="apachecon-eu">
- Free Video Streams from ApacheCon Europe 2008
-</h4>
-<div class="section-content">
-<a href="http://www.eu.apachecon.com/"><img src="images/eu_2008_logo.jpg" alt="ApacheCon Europe 2008" title="ApacheCon Europe 2008" border="0" align="right" /></a>
-<p>
-ApacheCon Europe 2008 held in Amsterdam was a great success, and attracted higher
-than ever attendance figures, with about 500 registered attendees. This
-figure represents an increase of more than 40% over the previous year,
-demonstrating the rapidly growing interest in Apache and Open Source software
-amongst European businesses.
-
-If you have not been able to attend ApacheCon Europe, you can still watch
-<a href="http://streaming.linux-magazin.de/en/archive_apachecon08eu.htm">videos of all keynotes and select talks online</a>. Keynote sessions
-and the opening plenary are available <b>free of charge</b>:</p>
-<ul>
-<li><a href="http://streaming.linux-magazin.de/events/apacheconfree/archive/jjagielski/frames-java.htm" onclick="window.open(this.href, '_blank', 'width=1024, height=768'); return false;">State of the Feather</a>
- by Jim Jagielski, Chairman of the Apache Software Foundation</li>
-<li><a href="http://streaming.linux-magazin.de/events/apacheconfree/archive/cschmidt/frames-java.htm" onclick="window.open(this.href, '_blank', 'width=1024, height=768'); return false;">Using Audio Technology and Open Content to Reduce Global Illiteracy, Poverty and Disease</a>
- by Cliff Schmidt, Executive Director of Literacy Bridge</li>
-<li><a href="http://streaming.linux-magazin.de/events/apacheconfree/archive/rghosh/frames-java.htm" onclick="window.open(this.href, '_blank', 'width=1024, height=768'); return false;">Apache and Steam Engines: the Magic of Collaborative Innovation</a>
- by Rishab Aiyer Ghosh, Open Source Initiative Board Member</li>
-<li><a href="http://streaming.linux-magazin.de/events/apacheconfree/archive/rfielding/frames-java.htm" onclick="window.open(this.href, '_blank', 'width=1024, height=768'); return false;">Apache 3.0 (a Tall Tale)</a>
- by Roy Fielding, Co-founder of The Apache Software Foundation,
- and Vice President, Apache HTTP Server</li>
-</ul>
-<p>The talks of the following select ApacheCon Europe tracks are
-available for just 49 Euro:
-<a href="http://streaming.linux-magazin.de/en/archive_apachecon08eu.htm#wednesday">System Administration</a>,
-<a href="http://streaming.linux-magazin.de/en/archive_apachecon08eu.htm#thursday">Web Security</a>,
-<a href="http://streaming.linux-magazin.de/en/archive_apachecon08eu.htm#friday">Web Services and Web 2.0</a>.
-</p>
-<hr />
-</div>
-
-<h4 id="apachecon-us">
- ApacheCon US 2008 in New Orleans!
-</h4>
-<div class="section-content">
-<p>
- ApacheCon US 2008 will be held 3 November through 7 November in
- New Orleans, Louisiana.
- The Call for Papers has already closed and the program and further
- information will be made available soon on the ApacheCon US 2008
- Web site <a href="http://www.us.apachecon.com/us2008/"><strong>www.us.apachecon.com</strong></a>.
- If you would like to receive information about ApacheCon US 2008, please
- <a href="mailto:announce-subscribe@apachecon.com">subscribe to
- the ApacheCon announcement mailing list</a>.
- </p>
-<hr />
-</div>
-
-<h4 id="sun_jck_letter">
- Notice regarding open letter to Sun Microsystems
-</h4>
-<div class="section-content">
-<p>
- The Apache Software Foundation has written an <a href="jcp/sunopenletter.html">open letter</a>
- to Sun Microsystems regarding our inabillity to acquire an acceptable license for the test kit
- for Java SE needed by <a href="http://harmony.apache.org">Apache Harmony</a>. For futher information
- please see the <a href="jcp/sunopenletterfaq.html">FAQ</a> and direct all questions to Apache's VP
- for JCP issues, geirm at apache dot org, or our regular press inquiry address, press at apache dot org.
- </p>
-</div>
-</div>
- </div>
- <div class="column span-8 last">
- <div class="block">
- <div class="nav column span-11">
- <div>
- <div class="menuheader"><a
-href="http://projects.apache.org/">Apache Projects</a></div>
- <ul>
- <li><a href="http://httpd.apache.org/" title="Apache Web Server (httpd)">HTTP Server</a></li>
- <li><a href="http://activemq.apache.org/" title="Distributed Messaging System">ActiveMQ</a></li>
- <li><a href="http://ant.apache.org/" title="Java-based build tool">Ant</a></li>
- <li><a href="http://apr.apache.org/" title="Apache Portable Runtime libraries">APR</a></li>
- <li><a href="http://archiva.apache.org/" title="Build Artifact Repository Manager">Archiva</a></li>
- <li><a href="http://beehive.apache.org/" title="Metadata frameworks for enterprise applications">Beehive</a></li>
- <li><a href="http://cayenne.apache.org/" title="User-friendly Java ORM with Tools">Cayenne</a></li>
- <li><a href="http://cocoon.apache.org/" title="Web development framework: separation of concerns, component-based">Cocoon</a></li>
- <li><a href="http://commons.apache.org/" title="Reusable Java components">Commons</a></li>
- <li><a href="http://continuum.apache.org/" title="Continuous Integration and Build Server">Continuum</a></li>
- <li><a href="http://cxf.apache.org/" title="Service Framework">CXF</a></li>
- <li><a href="http://db.apache.org/" title="Database access">DB</a></li>
- <li><a href="http://directory.apache.org/" title="Apache Directory Server">Directory</a></li>
- <li><a href="http://excalibur.apache.org/" title="Embeddable software libraries related to component and service management access">Excalibur</a></li>
- <li><a href="http://felix.apache.org/" title="OSGi Framework and components.">Felix</a></li>
- <li><a href="http://forrest.apache.org/" title="Aggregated multi-channel documentation, separation of concerns">Forrest</a></li>
- <li><a href="http://geronimo.apache.org/" title="Java2, Enterprise Edition (J2EE) container">Geronimo</a></li>
- <li><a href="http://gump.apache.org/" title="Continuous integration of open source projects">Gump</a></li>
- <li><a href="http://hadoop.apache.org/" title="Distributed computing platform">Hadoop</a></li>
- <li><a href="http://harmony.apache.org/" title="Open source implementation of Java SE">Harmony</a></li>
- <li><a href="http://hivemind.apache.org/" title="A services and configuration microkernel">HiveMind</a></li>
- <li><a href="http://hc.apache.org/" title="Java toolset of low level HTTP components">HttpComponents</a></li>
- <li><a href="http://ibatis.apache.org/" title="SQL Data Mapper for Java and .NET">iBATIS</a></li>
- <li><a href="http://incubator.apache.org/" title="Shepherd for new projects">Incubator</a></li>
- <li><a href="http://jackrabbit.apache.org/" title="Content Repository for Java">Jackrabbit</a></li>
- <li><a href="http://jakarta.apache.org/" title="Server-side Java">Jakarta</a></li>
- <li><a href="http://james.apache.org/" title="Java Apache Mail Enterprise Server">James</a></li>
- <li><a href="http://labs.apache.org/" title="The Innovation Laboratories of the Apache Software Foundation">Labs</a></li>
- <li><a href="http://lenya.apache.org/" title="Content Management System">Lenya</a></li>
- <li><a href="http://logging.apache.org/" title="Cross-language logging services">Logging</a></li>
- <li><a href="http://lucene.apache.org/" title="Search engine library">Lucene</a></li>
- <li><a href="http://maven.apache.org/" title="Java project management and comprehension tools">Maven</a></li>
- <li><a href="http://mina.apache.org/" title="Multipurpose Infrastructure for Network Application">Mina</a></li>
- <li><a href="http://myfaces.apache.org/" title="JavaServer(tm) Faces implementation and components">MyFaces</a></li>
- <li><a href="http://ode.apache.org/" title="Orchestration Director Engine: Business Process Management (BPM), Process Orchestration and Workflow through service compositioni.">ODE</a></li>
- <li><a href="http://ofbiz.apache.org/" title="Open for Business: enterprise automation software">OFBiz</a></li>
- <li><a href="http://openejb.apache.org/" title="OpenEJB: a modular, configurable, and extendable EJB Container System and Server">OpenEJB</a></li>
- <li><a href="http://openjpa.apache.org/" title="OpenJPA: Object Relational Mapping for Java">OpenJPA</a></li>
- <li><a href="http://perl.apache.org/" title="Dynamic websites using Perl">Perl</a></li>
- <li><a href="http://poi.apache.org/" title="Java API for OLE 2 Compound Documents">POI</a></li>
- <li><a href="http://portals.apache.org/" title="Portal technology">Portals</a></li>
- <li><a href="http://roller.apache.org/" title="Java blog server">Roller</a></li>
- <li><a href="http://santuario.apache.org/" title="XML Security in Java and C++">Santuario</a></li>
- <li><a href="http://servicemix.apache.org/" title="Enterprise Service Bus">ServiceMix</a></li>
- <li><a href="http://shale.apache.org/" title="Web application framework based on JavaServer(tm) Faces">Shale</a></li>
- <li><a href="http://spamassassin.apache.org/" title="Mail filter to identify spam">SpamAssassin</a></li>
- <li><a href="http://stdcxx.apache.org/" title="Apache C++ Standard Library">STDCXX</a></li>
- <li><a href="http://struts.apache.org/" title="Model 2 framework for building Java web applications">Struts</a></li>
- <li><a href="http://synapse.apache.org/" title="Enterprise Service Bus and Mediation Framework">Synapse</a></li>
- <li><a href="http://tapestry.apache.org/" title="Component-based Java Web Application Framework">Tapestry</a></li>
- <li><a href="http://tcl.apache.org/" title="Dynamic websites using TCL">TCL</a></li>
- <li><a href="http://tiles.apache.org/" title="A templating framework for web application user interfaces">Tiles</a></li>
- <li><a href="http://tomcat.apache.org/" title="A Java Servlet and JSP Container">Tomcat</a></li>
- <li><a href="http://turbine.apache.org/" title="A Java Servlet Web Application Framework and associated component library">
- Turbine</a></li>
- <li><a href="http://velocity.apache.org/" title="A Java Templating Engine">Velocity</a></li>
- <li><a href="http://wicket.apache.org/" title="Component-based Java Web Application Framework.">Wicket</a></li>
- <li><a href="http://ws.apache.org/">Web Services</a></li>
- <li><a href="http://xalan.apache.org/" title="XSLT processors in Java and C++">Xalan</a></li>
- <li><a href="http://xerces.apache.org/" title="XML parsers in Java, C++ and Perl">Xerces</a></li>
- <li><a href="http://xml.apache.org/" title="XML solutions focused on the web">XML</a></li>
- <li><a href="http://xmlbeans.apache.org/" title="XML-Java binding tool">XMLBeans</a></li>
- <li><a href="http://xmlgraphics.apache.org/" title="Conversion from XML to graphical output">XML Graphics</a></li>
- </ul>
- </div>
- </div>
- <div class="nav column prepend-1 span-12 last">
- <h6><a
-href="/foundation/">Foundation</a></h6>
- <ul>
- <li><a href="/foundation/faq.html">FAQ</a></li>
- <li><a href="/licenses/">Licenses</a></li>
- <li><a href="/foundation/news.html">News</a></li>
- <li><a href="/foundation/records/">Public Records</a></li>
- <li><a href="/foundation/sponsorship.html">Sponsorship</a></li>
- <li><a href="/foundation/contributing.html">Donations</a></li>
- <li><a href="/foundation/thanks.html">Thanks</a></li>
- <li><a href="/foundation/contact.html">Contact</a></li>
- </ul>
- <h6>Foundation Projects</h6>
- <ul>
- <li><a href="/foundation/conferences.html" title="Meetings of developers and users">Conferences</a></li>
- <li><a href="/dev/" title="ASF Infrastructure: Operations and howto documents for PMCs and contributors">Infrastructure</a></li>
- <li><a href="/jcp/" title="Apache and the Java Community Process">JCP</a></li>
- </ul>
- <h6>How it works</h6>
- <ul>
- <li><a href="/foundation/how-it-works.html">Introduction</a></li>
- <li><a href="/foundation/how-it-works.html#meritocracy">Meritocracy</a></li>
- <li><a href="/foundation/how-it-works.html#structure">Structure</a></li>
- <li><a href="/foundation/how-it-works.html#roles">Roles</a></li>
- <li><a href="/foundation/how-it-works.html#management">Collaboration</a></li>
- <li><a href="/foundation/how-it-works.html#infrastructure">Infrastructure</a></li>
- <li><a href="/foundation/how-it-works.html#incubator">Incubator</a></li>
- <li><a href="/foundation/how-it-works.html#other">Other entities</a></li>
- <li><a href="/foundation/glossary.html">Glossary</a></li>
- <li><a href="/foundation/voting.html">Voting</a></li>
- </ul>
- <h6><a
-href="/foundation/getinvolved.html">Get Involved</a></h6>
- <ul>
- <li><a href="/foundation/mailinglists.html">Mailing Lists</a></li>
- <li><a href="/dev/version-control.html">Version Control</a></li>
- <li><a href="/dev/">Developer Info</a></li>
- </ul>
- <h6>Download</h6>
- <ul>
- <li><a href="/dyn/closer.cgi">from a mirror</a></li>
- </ul>
- <h6>Related Sites</h6>
- <ul>
- <li><a href="http://apachecon.com/" title="Official Apache Conference">ApacheCon</a></li>
- <li><a href="http://apachebookstore.com/" title="Apache Books">Bookstore</a></li>
- <li><a href="http://feathercast.org/" title="Apache Podcasts">Feathercast</a></li>
- <li><a href="http://planetapache.org/" title="Apache Community Blogs">PlanetApache</a></li>
- </ul>
- </div>
- </div>
- </div>
- <div class="column span-24 footer">
- <hr/>
- <p>Copyright &#169; 2008 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
- </div>
- </div>
- </div>
-</body>
-</html>
-
diff --git a/examples/xml/htmlinfo/htmlinfo.pro b/examples/xml/htmlinfo/htmlinfo.pro
deleted file mode 100644
index 8fea3b38dd..0000000000
--- a/examples/xml/htmlinfo/htmlinfo.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-SOURCES += main.cpp
-QT -= gui
-
-RESOURCES = resources.qrc
-
-CONFIG += cmdline
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/xml/htmlinfo
-INSTALLS += target
diff --git a/examples/xml/htmlinfo/main.cpp b/examples/xml/htmlinfo/main.cpp
deleted file mode 100644
index bc19ae4a82..0000000000
--- a/examples/xml/htmlinfo/main.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore>
-
-void parseHtmlFile(QTextStream &out, const QString &fileName)
-{
- QFile file(fileName);
-
- out << "Analysis of HTML file: " << fileName << Qt::endl;
-
- if (!file.open(QIODevice::ReadOnly)) {
- out << " Couldn't open the file." << Qt::endl << Qt::endl << Qt::endl;
- return;
- }
-
-//! [0]
- QXmlStreamReader reader(&file);
-//! [0]
-
-//! [1]
- int paragraphCount = 0;
- QStringList links;
- QString title;
- while (!reader.atEnd()) {
- reader.readNext();
- if (reader.isStartElement()) {
- if (reader.name() == QLatin1String("title"))
- title = reader.readElementText();
- else if (reader.name() == QLatin1String("a"))
- links.append(reader.attributes().value(QLatin1String("href")).toString());
- else if (reader.name() == QLatin1String("p"))
- ++paragraphCount;
- }
- }
-//! [1]
-
-//! [2]
- if (reader.hasError()) {
- out << " The HTML file isn't well-formed: " << reader.errorString()
- << Qt::endl << Qt::endl << Qt::endl;
- return;
- }
-//! [2]
-
- out << " Title: \"" << title << '"' << Qt::endl
- << " Number of paragraphs: " << paragraphCount << Qt::endl
- << " Number of links: " << links.size() << Qt::endl
- << " Showing first few links:" << Qt::endl;
-
- while (links.size() > 5)
- links.removeLast();
-
- for (const QString &link : qAsConst(links))
- out << " " << link << Qt::endl;
- out << Qt::endl << Qt::endl;
-}
-
-int main(int argc, char **argv)
-{
- // initialize Qt Core application
- QCoreApplication app(argc, argv);
-
- // get a list of all html files in the current directory
- const QStringList filter = { QStringLiteral("*.htm"),
- QStringLiteral("*.html") };
-
- const QStringList htmlFiles = QDir(QStringLiteral(":/")).entryList(filter, QDir::Files);
-
- QTextStream out(stdout);
-
- if (htmlFiles.isEmpty()) {
- out << "No html files available.";
- return 1;
- }
-
- // parse each html file and write the result to file/stream
- for (const QString &file : htmlFiles)
- parseHtmlFile(out, QStringLiteral(":/") + file);
-
- return 0;
-}
diff --git a/examples/xml/htmlinfo/resources.qrc b/examples/xml/htmlinfo/resources.qrc
deleted file mode 100644
index f427d9db10..0000000000
--- a/examples/xml/htmlinfo/resources.qrc
+++ /dev/null
@@ -1,10 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>apache_org.html</file>
- <file>simpleexample.html</file>
- <file>trolltech_com.html</file>
- <file>w3c_org.html</file>
- <file>youtube_com.html</file>
- </qresource>
-</RCC>
-
diff --git a/examples/xml/htmlinfo/simpleexample.html b/examples/xml/htmlinfo/simpleexample.html
deleted file mode 100644
index 2963b22006..0000000000
--- a/examples/xml/htmlinfo/simpleexample.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<html>
- <head>
- <title>Qt is cute! Frans is too!</title>
- </head>
- <body>
- <p>A paragraph.</p>
- <p>A second paragraph. Check out our <a href="http://blog.qt.io/">developer blogs</a></p>
- <p>And the last paragraph. Or our <a href="http://doc.qt.io/">online documentation</a>.</p>
- </body>
-</html>
diff --git a/examples/xml/htmlinfo/trolltech_com.html b/examples/xml/htmlinfo/trolltech_com.html
deleted file mode 100644
index 180eb74358..0000000000
--- a/examples/xml/htmlinfo/trolltech_com.html
+++ /dev/null
@@ -1,955 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
- lang="en">
-
- <head>
- <meta http-equiv="Content-Type"
- content="text/html;charset=utf-8" />
-
- <title>
- Code Less. Create More. Deploy Everywhere.
- &mdash;
- Trolltech
- </title>
-
-
- <!-- ADD ON UPDATE -->
-
- <meta name="author" content="Trolltech" />
- <meta name="description"
- content="Trolltech creates application development platforms for desktop and mobile device innovation." />
- <meta name="keywords" content="" />
-
-<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"><!-- &nbsp;--></script>
-<script type="text/javascript">
- <!-- Urchin script
- _uacct = "UA-4457116-1";
- urchinTracker();
- -->
- </script>
-
- <base href="http://trolltech.com/homepage" />
-
-
-
- <meta name="generator" content="Plone - http://plone.org" />
-
-
- <!-- Plone ECMAScripts -->
-
-
-
-
- <script type="text/javascript"
- src="http://trolltech.com/portal_javascripts/TTSkin/ploneScripts2804.js">
- </script>
-
-
-
- <script type="text/javascript"
- src="http://trolltech.com/portal_javascripts/TTSkin/ploneScripts0445.js">
- </script>
-
-
-
- <script type="text/javascript"
- src="http://trolltech.com/portal_javascripts/TTSkin/ploneScripts5940.js">
- </script>
-
-
-
- <script type="text/javascript"
- src="http://trolltech.com/portal_javascripts/TTSkin/linkpopper.js">
- </script>
-
-
-
- <script type="text/javascript"
- src="http://trolltech.com/portal_javascripts/TTSkin/ploneScripts7743.js">
- </script>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <style type="text/css"><!-- @import url(http://trolltech.com/portal_css/TTSkin/ploneStyles1145.css); --></style>
-
-
-
-
-
-
-
-
- <style type="text/css"
- media="screen"><!-- @import url(http://trolltech.com/portal_css/TTSkin/ploneStyles8707.css); --></style>
-
-
-
-
-
-
-
-
-
-
- <!-- Internet Explorer CSS Fixes -->
- <!--[if IE]>
- <style type="text/css" media="all">@import url(http://trolltech.com/IEFixes.css);</style>
- <![endif]-->
-
- <link rel="shortcut icon" type="image/x-icon"
- href="http://trolltech.com/favicon.ico" />
-
- <link rel="home" href="http://trolltech.com"
- title="Front page" />
- <link rel="search"
- href="http://trolltech.com/search_form"
- title="Search this site" />
- <link rel="author"
- href="http://trolltech.com/author/admin"
- title="Author information" />
- <link rel="contents" href="http://trolltech.com/sitemap"
- title="Site Map" />
-
-
-
-
-
-
-
-
-
- <!-- Disable IE6 image toolbar -->
- <meta http-equiv="imagetoolbar" content="no" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- </head>
-
- <body class="section-homepage" dir="ltr">
- <div id="visual-portal-wrapper">
- <div id="portal-top">
-
- <div id="portal-header">
- <a class="hiddenStructure" accesskey="2"
- href="http://trolltech.com/#documentContent">Skip to content.</a>
-
- <a class="hiddenStructure" accesskey="6"
- href="http://trolltech.com/#portlet-navigation-tree">Skip to navigation</a>
-
- <div class="middlesex">
- <ul id="portal-siteactions">
-
- <li id="siteaction-sitemap"><a
- href="http://trolltech.com/sitemap" accesskey="3"
- title="Site Map">Site Map</a></li>
- <li id="siteaction-accessibility"><a
- href="http://trolltech.com/accessibility-info"
- accesskey="0" title="Accessibility">Accessibility</a></li>
- <li id="siteaction-contact"><a
- href="http://trolltech.com/contact" accesskey="9"
- title="Contact">Contact</a></li>
-
-</ul>
-
- <div id="portal-searchbox">
- <form name="searchform"
- action="http://trolltech.com/search"
- style="white-space:nowrap"
- onsubmit="return liveSearchSubmit()">
-
- <label for="searchGadget" class="hiddenStructure">Search Site</label>
-
- <div class="LSBox">
- <input id="searchGadget" name="SearchableText"
- type="text" size="15" title="Search Site"
- accesskey="4" class="visibility:visible" />
-
- <input class="searchButton" type="submit"
- value="Search" />
-
- <div class="LSResult" id="LSResult" style=""><div class="LSShadow" id="LSShadow"></div></div>
- </div>
- </form>
-
- <div id="portal-advanced-search" class="hiddenStructure">
- <a href="http://trolltech.com/search_form"
- accesskey="5">
- Advanced Search&hellip;
- </a>
- </div>
-
-</div>
-
- <div id="country-flags">
- <a href="/lang/cn/"><img class="flag"
- border="0" width="30" height="20" src="chineseflag.png" /></a>
- <a href="/lang/japanese/"><img
- class="flag" border="0" width="30" height="20"
- src="japaneseflag.png" /></a>
- </div>
- <h1 id="portal-logo">
- <a href="http://trolltech.com" accesskey="1">Trolltech</a>
-</h1>
-
- <div id="portal-skinswitcher">
-
-</div>
- </div>
-
-
- <h5 class="hiddenStructure">Sections</h5>
- <div id="portal-globalnav">
- <div class="middlesex">
- <ul>
- <li id="portaltab-index_html"
- class="selected indextab"><a
- href="http://trolltech.com">Home</a></li>
-
- <li id="portaltab-products"
- class="plain"><a
- href="http://trolltech.com/products" title="">Products and Services</a></li>
-
-
- <li id="portaltab-solutions"
- class="plain"><a
- href="http://trolltech.com/solutions" title="">Solutions</a></li>
-
-
- <li id="portaltab-developer"
- class="plain"><a
- href="http://trolltech.com/developer" title="">Developer Resources</a></li>
-
-
- <li id="portaltab-company" class="plain"><a
- href="http://trolltech.com/company" title="">Company</a></li>
-
-
- <li id="portaltab-downloads"
- class="plain"><a
- href="http://trolltech.com/downloads" title="">Downloads</a></li>
-
-
-
-
- </ul>
- </div>
- </div>
-
- </div>
- <div id="portal-personaltools-wrapper">
-
-<h5 class="hiddenStructure">Personal tools</h5>
-
-
-</div>
-
- <div class="middlesex">
- <div id="portal-breadcrumbs">
-
- <span id="breadcrumbs-you-are-here">You
-are here:</span>
- <a href="http://trolltech.com">Home</a>
-
-
-</div>
- </div>
- </div>
-
- <div class="visualClear"><!-- --></div>
-
-
- <table id="portal-columns">
- <tbody>
- <tr>
-
-
-
-
-
- <td id="portal-column-content">
-
-
- <div id="content" class="">
-
-
-
- <div class="documentContent" id="region-content">
-
- <a name="documentContent"></a>
-
-
-
-
-
-
-
-
-
-
-
- <!-- <table id="frontpagetable" cellpadding="0" cellspacing="0" tal:attributes="width pagew"> --> <!-- tal:on-error="string:replace with error template" Fetch image width here -->
- <table id="frontpagetable" cellpadding="0"
- cellspacing="0" width="712">
- <tr>
- <td colspan="2">
-
- <h2>Trolltech provides cross-platform software solutions for:</h2>
- <table id="fpSolutions" class="solutions" cellpadding="0" cellspacing="6" width="100%">
- <tbody>
- <tr>
- <td>
- <!-- GRANTHAM STYLE -->
- <a class="roundedButton"
- title=""
- href="http://trolltech.com/solutions/managing-development">
- <span class="buttonTop"><span class="roundedButtonTL"><span class="roundedButtonTR"></span></span></span>
- <span class="buttonLeft">
- <span class="buttonRight"><span
- class="buttonArrow">Software Development Managers</span></span>
- </span>
- <span class="buttonBottom"><span class="roundedButtonBL"><span class="roundedButtonBR"></span></span></span>
- </a>
- <!-- OLD STYLE
- <div class="roundedBlock"
- tal:attributes="title python:solution.Description();
- class python:test(repeat['solution'].odd(), 'roundedBlock odd', 'roundedBlock')">
- <span class="portletTopLeft"></span>
- <span class="portletTopRight"></span>
- <div class="innerRoundedBlock">
- <a href="#"
- tal:attributes="href python:solution.absolute_url()">
- <span class="arrow"></span>
- <strong tal:content="python:solution.Title()">
- Title
- </strong>
- </a>
- </div>
- <span class="portletBottomLeft"></span>
- <span class="portletBottomRight"></span>
- </div>
- -->
- </td>
- <td>
- <!-- GRANTHAM STYLE -->
- <a class="roundedButton"
- title=""
- href="http://trolltech.com/solutions/industrial-embedded-development">
- <span class="buttonTop"><span class="roundedButtonTL"><span class="roundedButtonTR"></span></span></span>
- <span class="buttonLeft">
- <span class="buttonRight"><span
- class="buttonArrow">Embedded Developers</span></span>
- </span>
- <span class="buttonBottom"><span class="roundedButtonBL"><span class="roundedButtonBR"></span></span></span>
- </a>
- <!-- OLD STYLE
- <div class="roundedBlock"
- tal:attributes="title python:solution.Description();
- class python:test(repeat['solution'].odd(), 'roundedBlock odd', 'roundedBlock')">
- <span class="portletTopLeft"></span>
- <span class="portletTopRight"></span>
- <div class="innerRoundedBlock">
- <a href="#"
- tal:attributes="href python:solution.absolute_url()">
- <span class="arrow"></span>
- <strong tal:content="python:solution.Title()">
- Title
- </strong>
- </a>
- </div>
- <span class="portletBottomLeft"></span>
- <span class="portletBottomRight"></span>
- </div>
- -->
- </td>
-
- </tr>
- <tr>
- <td>
- <!-- GRANTHAM STYLE -->
- <a class="roundedButton"
- title=""
- href="http://trolltech.com/solutions/ce-mobile-vendors">
- <span class="buttonTop"><span class="roundedButtonTL"><span class="roundedButtonTR"></span></span></span>
- <span class="buttonLeft">
- <span class="buttonRight"><span
- class="buttonArrow">Consumer Electronics Vendors</span></span>
- </span>
- <span class="buttonBottom"><span class="roundedButtonBL"><span class="roundedButtonBR"></span></span></span>
- </a>
- <!-- OLD STYLE
- <div class="roundedBlock"
- tal:attributes="title python:solution.Description();
- class python:test(repeat['solution'].odd(), 'roundedBlock odd', 'roundedBlock')">
- <span class="portletTopLeft"></span>
- <span class="portletTopRight"></span>
- <div class="innerRoundedBlock">
- <a href="#"
- tal:attributes="href python:solution.absolute_url()">
- <span class="arrow"></span>
- <strong tal:content="python:solution.Title()">
- Title
- </strong>
- </a>
- </div>
- <span class="portletBottomLeft"></span>
- <span class="portletBottomRight"></span>
- </div>
- -->
- </td>
- <td>
- <!-- GRANTHAM STYLE -->
- <a class="roundedButton"
- title=""
- href="http://trolltech.com/solutions/mobile-application-development">
- <span class="buttonTop"><span class="roundedButtonTL"><span class="roundedButtonTR"></span></span></span>
- <span class="buttonLeft">
- <span class="buttonRight"><span
- class="buttonArrow">Mobile Application Developers</span></span>
- </span>
- <span class="buttonBottom"><span class="roundedButtonBL"><span class="roundedButtonBR"></span></span></span>
- </a>
- <!-- OLD STYLE
- <div class="roundedBlock"
- tal:attributes="title python:solution.Description();
- class python:test(repeat['solution'].odd(), 'roundedBlock odd', 'roundedBlock')">
- <span class="portletTopLeft"></span>
- <span class="portletTopRight"></span>
- <div class="innerRoundedBlock">
- <a href="#"
- tal:attributes="href python:solution.absolute_url()">
- <span class="arrow"></span>
- <strong tal:content="python:solution.Title()">
- Title
- </strong>
- </a>
- </div>
- <span class="portletBottomLeft"></span>
- <span class="portletBottomRight"></span>
- </div>
- -->
- </td>
-
- </tr>
- <tr>
- <td>
- <!-- GRANTHAM STYLE -->
- <a class="roundedButton"
- title=""
- href="http://trolltech.com/solutions/application-development">
- <span class="buttonTop"><span class="roundedButtonTL"><span class="roundedButtonTR"></span></span></span>
- <span class="buttonLeft">
- <span class="buttonRight"><span
- class="buttonArrow">Cross-Platform Developers</span></span>
- </span>
- <span class="buttonBottom"><span class="roundedButtonBL"><span class="roundedButtonBR"></span></span></span>
- </a>
- <!-- OLD STYLE
- <div class="roundedBlock"
- tal:attributes="title python:solution.Description();
- class python:test(repeat['solution'].odd(), 'roundedBlock odd', 'roundedBlock')">
- <span class="portletTopLeft"></span>
- <span class="portletTopRight"></span>
- <div class="innerRoundedBlock">
- <a href="#"
- tal:attributes="href python:solution.absolute_url()">
- <span class="arrow"></span>
- <strong tal:content="python:solution.Title()">
- Title
- </strong>
- </a>
- </div>
- <span class="portletBottomLeft"></span>
- <span class="portletBottomRight"></span>
- </div>
- -->
- </td>
- <td>
- <!-- GRANTHAM STYLE -->
- <a class="roundedButton"
- title=""
- href="http://trolltech.com/solutions/solutions-opensource">
- <span class="buttonTop"><span class="roundedButtonTL"><span class="roundedButtonTR"></span></span></span>
- <span class="buttonLeft">
- <span class="buttonRight"><span
- class="buttonArrow">Open Source Developers</span></span>
- </span>
- <span class="buttonBottom"><span class="roundedButtonBL"><span class="roundedButtonBR"></span></span></span>
- </a>
- <!-- OLD STYLE
- <div class="roundedBlock"
- tal:attributes="title python:solution.Description();
- class python:test(repeat['solution'].odd(), 'roundedBlock odd', 'roundedBlock')">
- <span class="portletTopLeft"></span>
- <span class="portletTopRight"></span>
- <div class="innerRoundedBlock">
- <a href="#"
- tal:attributes="href python:solution.absolute_url()">
- <span class="arrow"></span>
- <strong tal:content="python:solution.Title()">
- Title
- </strong>
- </a>
- </div>
- <span class="portletBottomLeft"></span>
- <span class="portletBottomRight"></span>
- </div>
- -->
- </td>
-
- </tr>
- </tbody>
- </table>
-
- </td>
- </tr>
-
- <!-- BANNER -->
-
- <tr class="minspacerow">
- <td colspan="2">
-
- <div id="flashcontent">
-
-
- <!-- In case of no imagemap -->
- <a
- href="http://trolltech.com/products/qt/learnmore/whitepapers">
- <img border="0"
- src="http://trolltech.com/include/features/frontpage/whitepaper-feature/mainsplash"
- alt="Code Less. Create More. Deploy Everywhere."
- height="100" width="700" />
- </a>
-
-
- </div>
-
-
-
- </td>
- </tr>
-
- <!-- Product Feature rows -->
- <tr id="productfeatures" class="minspacerow">
- <td style="width:350px;">
- <div class="viewlet productviewlet">
-<p class="discreet"><a title="Downloads" href="downloads/index"><img class="image-right" src="images/frontpage/qt_download_90.png" alt="Download Qt Button: Grey BG" /></a></p>
-<h2>Qt</h2>
-<p>Qt is a cross-platform application framework.&nbsp; It includes:</p>
-<ul><li>An <a title="C++ Class Library" href="products/qt/features/library/index">intuitive class library</a></li><li>Integrated <a title="Development Tools" href="products/qt/features/tools/index">development tools</a></li><li>Support for <a title="C++ and Java Support" href="products/qt/features/language-support/index">C++ and Java development</a></li><li><a title="Cross-Platform Development" href="products/qt/features/platforms/index">Desktop and embedded</a> development support</li></ul>
-<p>&nbsp;</p>
-<p><strong><a title="Qt Cross-Platform Application Framework" href="products/qt/index"><span class="button">Learn More</span></a></strong> <strong><a title="How to order" href="products/qt/orderform"><span class="button">Buy Now</span></a></strong></p>
-<p>&nbsp;</p>
-<p>&nbsp;</p>
-<p>&nbsp;</p>
-</div>
- </td>
- <td style="width:350px;">
- <div class="viewlet productviewlet">
-<p><a title="Qtopia" href="products/qtopia"><img class="image-right" src="images/frontpage/qtopia_learn_more_90.png" alt="Qtopia Learn More button 90px" /></a></p>
-<h2>Qtopia</h2>
-<p><a title="The Qtopia application platform for embedded Linux" href="products/qtopia/index">Qtopia</a> is an application platform and UI for Linux-based <a title="Qtopia Phone Edition" href="products/qtopia/qtopia-product-family/qtopia-phone-edition">mobile</a>, <a title="Qtopia Platform" href="products/qtopia/qtopia-product-family/qtopia-platform">consumer electronics</a> and <a title="Qtopia Platform" href="products/qtopia/qtopia-product-family/qtopia-platform">embedded devices</a>. Qtopia offers:</p>
-<ul><li>Rich <a href="products/qt/features/tools/index">toolkit</a> and intuitive API</li><li>Fully customizable user interface</li><li>Highly efficient development framework</li></ul>
-<p>&nbsp;</p>
-<p><strong><a title="Customer Devices" href="company/customers/customer-devices"><span class="button">Customer Devices</span></a></strong>&nbsp;<strong><a title="Purchasing Qtopia" href="products/qtopia/orderinfo"><span class="button">Buy Now</span></a></strong></p>
-</div>
- </td>
- </tr>
- </table>
-
-
-
-
-
-
-
-
-
-
-
-
- </div>
-
- </div>
-
-
- </td>
-
-
-
-
- <!-- News/events -->
- <td id="frontpage-column-two">
-
- <div class="viewlet">
- <h3>Quick Links</h3>
-
-
- <!-- Smart folders -->
-
- <!-- Links -->
-
- <p class="smallerExtendedLink">
- <a href="http://trolltech.com/company/careers"
- title="Quick Links">Careers at Trolltech</a>
- </p>
-
-
- <p class="smallerExtendedLink">
- <a href="http://trolltech.com/products/qt/learnmore/whitepapers"
- title="Quick Links">Whitepapers</a>
- </p>
-
-
- <p class="smallerExtendedLink">
- <a href="http://trolltech.com/products/qt/learnmore/webinars-videos"
- title="Quick Links">Webinars and Videos</a>
- </p>
-
- </div>
-
-
- <div class="viewlet">
- <h3>Nokia Acquisition</h3>
-
- <div class="viewletBody">
-<p class="smallerExtendedLink"><a title="Nokia Acquires Trolltech" href="../../../28012008/28012008">Learn more about Nokia's acquisition of Trolltech<br /></a></p>
-</div>
- <!-- Smart folders -->
-
- <!-- Links -->
-
-
-
- </div>
-
-
- <div class="viewlet">
- <h3>News</h3>
-
-
- <!-- Smart folders -->
-
- <p class="smallerFont">
- <span>
- <a href="http://trolltech.com/company/newsroom/announcements/press.2008-06-03.1419977468">Trolltech Releases Qt Jambi 4.3.5</a>
- <!-- Dates for press release -->
-
-
- (Jun&nbsp;03)
- <!--(<tal:date tal:content="item_pressmonth"/>&nbsp;<tal:date tal:content="item_pressday"/>)-->
-
-
- <!-- Dates for events -->
-
- <!-- Dates for training -->
-
- </span>
- </p>
- <p class="smallerFont">
- <span>
- <a href="http://trolltech.com/company/newsroom/announcements/press.2008-05-28.9662742780">Trolltech releases Qt 4.3.5</a>
- <!-- Dates for press release -->
-
-
- (May&nbsp;28)
- <!--(<tal:date tal:content="item_pressmonth"/>&nbsp;<tal:date tal:content="item_pressday"/>)-->
-
-
- <!-- Dates for events -->
-
- <!-- Dates for training -->
-
- </span>
- </p>
- <p class="smallerFont">
- <span>
- <a href="http://trolltech.com/company/newsroom/announcements/press.2008-05-14.1108908046">Award From Qt Developers Recognizes Best Open Source Development Tools</a>
- <!-- Dates for press release -->
-
-
- (May&nbsp;14)
- <!--(<tal:date tal:content="item_pressmonth"/>&nbsp;<tal:date tal:content="item_pressday"/>)-->
-
-
- <!-- Dates for events -->
-
- <!-- Dates for training -->
-
- </span>
- </p>
- <p class="smallerFont">
- <span>
- <a href="http://trolltech.com/company/newsroom/announcements/press.2008-05-08.1819339587">Trolltech Delivered Revenues of NOK 55.6 Million</a>
- <!-- Dates for press release -->
-
-
- (May&nbsp;08)
- <!--(<tal:date tal:content="item_pressmonth"/>&nbsp;<tal:date tal:content="item_pressday"/>)-->
-
-
- <!-- Dates for events -->
-
- <!-- Dates for training -->
-
- </span>
- </p>
-
- <!-- Links -->
-
-
-
- </div>
-
-
- <div class="viewlet">
- <h3>Events</h3>
-
- <div class="viewletBody">
-<p>&nbsp;</p>
-</div>
- <!-- Smart folders -->
-
- <p class="smallerFont">
- <span>
- <a href="http://trolltech.com/company/newsroom/events/allevents/event.2008-05-15.0963129132">Qt Open Enrollment Training Class</a>
- <!-- Dates for press release -->
-
- <!-- Dates for events -->
-
-
- (Jun&nbsp;09&nbsp;-&nbsp;Jun&nbsp;13)
-
-
- <!-- Dates for training -->
-
- </span>
- </p>
- <p class="smallerFont">
- <span>
- <a href="http://trolltech.com/company/newsroom/events/allevents/event.2008-02-22.1032431617">Israel Qt User Group</a>
- <!-- Dates for press release -->
-
- <!-- Dates for events -->
-
-
- (Jun&nbsp;16)
-
-
- <!-- Dates for training -->
-
- </span>
- </p>
- <p class="smallerFont">
- <span>
- <a href="http://trolltech.com/company/newsroom/events/allevents/event.2008-05-19.5707721007">Webinar: Building Tomorrow’s Virtual Driver Control Center</a>
- <!-- Dates for press release -->
-
- <!-- Dates for events -->
-
-
- (Jun&nbsp;24)
-
-
- <!-- Dates for training -->
-
- </span>
- </p>
-
- <!-- Links -->
-
- <p class="smallerExtendedLink">
- <a href="http://trolltech.com/company/newsroom/events"
- title="Events">More events</a>
- </p>
-
-
-
- </div>
-
- </td>
-
-
- </tr>
- </tbody>
- </table>
-
-
- <div class="visualClear"><!-- --></div>
-
-
- <hr class="netscape4" />
-
-
-
- <div id="portal-footer">
-
-
-<p id="bottom-navigation">
- Trolltech&reg; - Code Less. Create More. Deploy Everywhere.
-
- <br />
-
- <a href="http://trolltech.com/company/contact-us/locations"
- title="Trolltech ASA">
- Trolltech ASA
- </a>
- <a href="http://trolltech.com/company/contact-us/locations"
- title="Address: Sandakerveien 116, Oslo">
- Sandakerveien 116, Oslo
- </a>
- <a href="http://trolltech.com/company/contact-us/locations"
- class="lastNavItem" title="Phone: +47 21 60 48 00">
- +47 21 60 48 00
- </a>
-
- <br />
-
- <a href="http://trolltech.com/company/contact-us/locations"
- title="International locations">
- International locations
- </a>
- <a href="/trolltech/privacypolicy" title="Privacy policy">
- Privacy Policy
- </a>
- <a href="/trolltech/copyright" title="Trolltech" class="lastNavItem"><span>2008</span> &copy; Trolltech ASA</a>
-</p>
-
-
-</div>
-
- <div id="portal-colophon">
-
-
- <a href="http://plone.org"
- class="colophonIcon colophonIconPlone"
- title="This Plone site was built using Plone CMS, the Open Source Content Management System. Click for more information.">
- Powered by Plone CMS, the Open Source Content Management System
- </a>
-
-
-
- <p class="discreet">
- This site conforms to the following standards:
- </p>
-
- <div class="colophonWrapper">
- <ul>
- <li>
- <a href="http://www.section508.gov"
- class="colophonIcon colophonIcon508"
- title="This Plone site conforms to the US Government Section 508 Accessibility Guidelines.">
- Section 508
- </a>
- </li>
- <li>
- <a href="http://www.w3.org/WAI/WCAG1AA-Conformance"
- class="colophonIcon colophonIconWAI"
- title="This Plone site conforms to the W3C-WAI Web Content Accessibility Guidelines.">
- WCAG
- </a>
- </li>
- <li>
- <a href="http://validator.w3.org/check/referer"
- class="colophonIcon colophonIconXHTML"
- title="This Plone site is valid XHTML.">
- Valid XHTML
- </a>
- </li>
- <li>
- <a href="http://jigsaw.w3.org/css-validator/check/referer&amp;warning=no&amp;profile=css3&amp;usermedium=all"
- class="colophonIcon colophonIconCSS"
- title="This Plone site was built with valid CSS.">
- Valid CSS
- </a>
- </li>
- <li>
- <a href="http://plone.org/browsersupport"
- class="colophonIcon colophonIconAnyBrowser"
- title="This Plone site is usable in any web browser.">
- Usable in any browser
- </a>
- </li>
- </ul>
- </div>
-
- </div>
-
- </div>
-<!-- ProspectXtractor tracker script -->
-<script type="text/javascript"><!--
-function _pxPar()
-{
-var p="";
-p+="&ref="+escape(top.document.referrer);
-p+="&dt="+escape(document.title);
-p+="&sr="+screen.width+"x"+screen.height;
-p+="&sd="+screen.colorDepth;
-p+="&fv="+_pxFV();
-return p;
-}
-function _pxFV()
-{
-var f=0,n=navigator;
-if (n.plugins && n.mimeTypes.length) {
-var x=n.plugins["Shockwave Flash"];
-if(x && x.description) {
-var y=x.description;
-f=y.charAt(y.indexOf('.')-1);
-}
-} else {
-r=false;
-for(var i=15;i>=3&&r!=true;i-=1){
-execScript('on error resume next: r=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
-f=i;
-}
-}
-return f;
-}
-document.write('<img src="http://pxreg.onlineservicesas.com/pxreg/?id=50C9FD2F-61D5-4824-B726-50D6B1F89999'+_pxPar()+'" width="1" heigth="1" />');
-//-->
-</script>
-<noscript>
-<div><img src="http://pxreg.onlineservicesas.com/pxreg/?id=50C9FD2F-61D5-4824-B726-50D6B1F89999" width="1" height="1" alt="" /></div>
-</noscript>
-<!-- END ProspectXtractor tracker script -->
-</body>
-</html>
-
diff --git a/examples/xml/htmlinfo/w3c_org.html b/examples/xml/htmlinfo/w3c_org.html
deleted file mode 100644
index 0fcce48e4a..0000000000
--- a/examples/xml/htmlinfo/w3c_org.html
+++ /dev/null
@@ -1,507 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
-<head profile="http://www.w3.org/2000/08/w3c-synd/#"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="HTML Tidy for Mac OS X (vers 1st March 2004), see www.w3.org" />
-
-<meta name="keywords" content="W3C, World Wide Web, Web, WWW, Consortium, computer, access, accessibility, semantic, worldwide, W3, HTML, XML, standard, language, technology, link, CSS, RDF, XSL, Berners-Lee, Berners, Lee, style sheet, cascading, schema, XHTML, mobile, SVG, PNG, PICS, DOM, SMIL, MathML, markup, Amaya, Jigsaw, free, open source, software" />
-<meta name="description" content="The World Wide Web Consortium (W3C) is an international consortium where Member organizations, a full-time staff, and the public work together to develop Web standards. W3C primarily pursues its mission through the creation of Web standards and guidelines designed to ensure long-term growth for the Web. Over 400 organizations are Members of the Consortium. W3C is jointly run by the MIT Computer Science and Artificial Intelligence Laboratory (MIT CSAIL) in the USA, the European Research Consortium for Informatics and Mathematics (ERCIM) headquartered in France, Keio University in Japan, and has additional Offices worldwide." />
-
-<title>World Wide Web Consortium - Web Standards</title>
-<link rel="meta" href="/Overview-about.rdf" />
-<link rel="stylesheet" type="text/css" href="/StyleSheets/home.css" />
-<link rel="bookmark" href="#technologies" title="Technologies |" />
-<link rel="bookmark" href="#news" title="News |" />
-<link rel="bookmark" href="#search" title="Search |" />
-<link rel="contents" href="#contents" title="Contents |" />
-<link rel="bookmark" href="#Offices" title="Offices |" />
-<link rel="bookmark" href="#systems" title="Systems |" />
-<link rel="bookmark" href="#donors" title="Supporters |" />
-<link rel="bookmark" href="#footnotes" title="Footnotes |" />
-<link rel="alternate" type="application/rss+xml" title="W3C Home Page News RSS Channel" href="http://www.w3.org/2000/08/w3c-synd/home.rss" />
-
-<style type="text/css">
-/**/
- div.spot-image img {
- margin-bottom: 20px;
- }
-/**/
-</style>
-</head>
-
-<body>
-<h1 id="logo"><img alt="The World Wide Web Consortium (W3C)" height="48" width="315" src="/Icons/w3c_main" /></h1>
-
-<h2 id="slogan">Leading the Web to Its Full Potential...</h2>
-
-<div>
-<map name="introLinks" id="introLinks" title="Introductory Links">
-<div class="banner">
-<span class="invisible"><a class="bannerLink" title="Skip introductory links and the mission statement" href="#technologies">Skip to Technologies</a> |</span> <a class="bannerLink" title="W3C Activities" accesskey="A" href="/Consortium/activities">Activities</a> | <a class="bannerLink" title="Technical Reports and Recommendations" accesskey="T" href="/TR/">Technical Reports</a> | <a class="bannerLink" title="Alphabetical Site Index" accesskey="S" href="/Consortium/siteindex">Site Index</a> | <a class="bannerLink" title="Help for new visitors" accesskey="N" href="/Consortium/new-to-w3c">New
-Visitors</a> | <a class="bannerLink" title="About W3C" accesskey="B" href="/Consortium/">About W3C</a> | <a class="bannerLink" title="Join W3C" accesskey="J" href="/Consortium/join">Join W3C</a> |
-<a class="bannerLink" title="Contact W3C" accesskey="C" href="/Consortium/contact">Contact W3C</a>
-</div>
-</map>
-</div>
-
-<p class="small">The World Wide Web Consortium (<acronym title="World Wide Web Consortium">W3C</acronym>) develops interoperable
-technologies (specifications, guidelines, software, and tools) to lead
-the Web to its full potential. W3C is a forum for information,
-commerce, communication, and collective understanding. On this page,
-you'll find <a href="#news">W3C news</a>, links to <a href="#technologies">W3C technologies</a> and ways to <a href="#contents">get involved</a>. New visitors can find help in
-<cite><a href="/Consortium/new-to-w3c">Finding Your Way at
-W3C</a></cite>. We encourage organizations to learn more <a href="/Consortium/">about W3C</a> and <a href="/Consortium/membership">about
-W3C Membership</a>.</p>
-
-<div class="navBlock">
-<h2 class="spot-head">XML10</h2>
-
-<div class="spot">
-<div class="spot-image">
-<a href="/2008/xml10/">
-<img src="/2008/xml10/xml-10.png" width="106" height="48" alt="XML 10" />
-</a>
-</div>
-<p class="spot-block">
-To celebrate
-<a href="/2008/xml10/">ten years of XML</a>,
-W3C invites you to
-<a href="/2008/xml10/card/greeting-form">send a greeting</a>
-and tell us about an XML-related blog or article.
-Many thanks to the FLWOR Foundation for their
-generous sponsorship of XML10.
-</p>
-</div>
-
-<h2 class="spot-head">W3C Supporters</h2>
-<div class="spot">
-<p class="spot-block">Help W3C by making a donation through the
-<a href="/Consortium/sup">W3C Supporters Program</a>.</p>
-</div>
-
-
-
-<h2 class="spot-head">Employment</h2>
-
-<div class="spot">
-<p class="spot-block">Current <a href="/Consortium/Recruitment/">job
-opportunities</a> at W3C: <a href="http://www.ercim.org/jobs/wai_consultant.html">Web Accessibility and Ageing Consultant</a>. Current <a href="/Consortium/Recruitment/Fellows#openings">W3C Fellows Program
-openings</a> are <a href="/2007/01/comm-fellow1">Business and
-Technology Communications Specialist</a>, <a href="/2007/01/comm-fellow2">Web / Graphic Designer</a>, and <a href="/2007/01/SysteamFellowsPosition">Software Engineer</a>.</p>
-</div>
-
-<h2 class="navhead"><a name="technologies" id="technologies">W3C A to
-Z</a></h2>
-
-<ul>
-<li class="invisible"><a class="navlink" title="Skip W3C A-Z" href="#news">Skip to News</a></li>
-
-<li><a href="/WAI/" class="navlink">Accessibility</a></li>
-
-<li><a href="/Amaya/" class="navlink">Amaya</a></li>
-
-<li><a href="/Mobile/CCPP/" class="navlink"><abbr title="Composite Capability/Preference Profiles">CC/PP</abbr></a></li>
-
-<li><a href="/2004/CDF/" class="navlink">Compound Document Formats
-(CDF)</a></li>
-
-<li><a href="/Style/CSS/" class="navlink"><abbr title="Cascading Style Sheets">CSS</abbr></a></li>
-
-<li><a href="http://jigsaw.w3.org/css-validator/" class="navlink"><abbr title="Cascading Style Sheets">CSS</abbr>
-Validator</a></li>
-
-<li><a href="/2002/ws/databinding/" class="navlink">Databinding</a></li>
-
-<li><a href="/DOM/" class="navlink"><acronym title="Document Object Model">DOM</acronym></a></li>
-
-<li><a href="/XML/EXI" class="navlink">Efficient XML
-Interchange</a></li>
-
-<li><a href="/2007/eGov/" class="navlink">eGovernment</a></li>
-
-<li><a href="/2001/sw/grddl-wg/" class="navlink"><acronym title="Gleaning Resource Descriptions from Dialects of Languages">GRDDL</acronym></a></li>
-
-<li><a href="/2001/sw/hcls/" class="navlink">Health Care and Life
-Sciences</a></li>
-
-<li><a href="/html/" class="navlink"><abbr title="HyperText Markup Language">HTML</abbr></a></li>
-
-<li><a href="/People/Raggett/tidy/" class="navlink"><abbr title="HyperText Markup Language">HTML</abbr> Tidy</a></li>
-
-<li><a href="http://validator.w3.org/" class="navlink"><abbr title="HyperText Markup Language">HTML</abbr> Validator</a></li>
-
-<li><a href="/Protocols/" class="navlink"><abbr title="Hypertext Transfer Protocol">HTTP</abbr></a></li>
-
-<li><a href="/2005/Incubator/" class="navlink">Incubator</a></li>
-
-<li><a href="/2002/mmi/ink" class="navlink">InkML</a></li>
-
-<li><a href="/International/" class="navlink">Internationalization</a></li>
-
-<li><a href="/Jigsaw/" class="navlink">Jigsaw</a></li>
-
-<li><a href="/Library/" class="navlink">Libwww</a></li>
-
-<li><a href="/Math/" class="navlink">MathML</a></li>
-
-<li><a href="/Mobile/" class="navlink">Mobile Web Initiative
-(W3C-MWI)</a></li>
-
-<li><a href="/2002/mmi/" class="navlink">Multimodal
-Interaction</a></li>
-
-<li><a href="/2004/OWL/" class="navlink"><acronym title="OWL Web Ontology Language">OWL</acronym></a></li>
-
-<li><a href="/2004/pp/" class="navlink">Patent Policy</a></li>
-
-<li><a href="/PICS/" class="navlink"><acronym title="Platform for Internet Content Selection">PICS</acronym></a></li>
-
-<li><a href="/Graphics/PNG/" class="navlink"><acronym title="Portable Network Graphics">PNG</acronym></a></li>
-
-<li><a href="/2007/powder/" class="navlink"><acronym title="Protocol for Web Description Resources">POWDER</acronym></a></li>
-
-<li><a href="/P3P/" class="navlink">Privacy and <abbr title="Platform for Privacy Preferences">P3P</abbr></a></li>
-
-<li><a href="/RDF/" class="navlink"><abbr title="Resource Description Framework">RDF</abbr></a></li>
-
-<li><a href="/2006/rwc/" class="navlink">Rich Web Clients</a></li>
-
-<li><a href="/2005/rules/" class="navlink">Rules</a></li>
-
-<li><a href="/Security/" class="navlink">Security</a></li>
-
-<li><a href="/2001/sw/" class="navlink">Semantic Web</a></li>
-
-<li><a href="/XML/SML" class="navlink">Service Modeling Language
-(<abbr title="Service Modeling Language">SML</abbr>)</a></li>
-
-<li><a href="/AudioVideo/" class="navlink"><acronym title="Synchronized Multimedia Integration Language">SMIL</acronym></a></li>
-
-<li><a href="/2000/xp/Group/" class="navlink"><acronym title="Soap">SOAP</acronym>/<abbr title="XML Protocol">XMLP</abbr></a></li>
-
-<li><a href="/2002/ws/soapjms/" class="navlink"><acronym title="Soap">SOAP-JMS</acronym></a></li>
-
-<li><a href="/2001/sw/DataAccess/" class="navlink"><acronym title="Simple Protocol and RDF Query Language">SPARQL</acronym></a></li>
-
-<li><a href="/Style/" class="navlink">Style</a></li>
-
-<li><a href="/Graphics/SVG/" class="navlink"><abbr title="Scalable Vector Graphics">SVG</abbr></a></li>
-
-<li><a href="/2001/tag/" class="navlink"><abbr title="Technical Architecture Group">TAG</abbr></a></li>
-
-<li><a href="/AudioVideo/TT/" class="navlink">Timed Text</a></li>
-
-<li><a href="/Addressing/" class="navlink"><abbr title="Uniform Resource Identifiers">URI/URL</abbr></a></li>
-
-<li><a href="/QA/Tools/#validators" class="navlink">Validators</a></li>
-
-<li><a href="/Voice/" class="navlink">Voice</a></li>
-
-<li><a href="/2007/uwa/" class="navlink">Ubiquitous Web
-Applications</a></li>
-
-<li><a href="/WAI/" class="navlink"><acronym title="Web Accessibility Initiative">WAI</acronym></a></li>
-
-<li><a href="/2006/webapi/" class="navlink">Web API</a></li>
-
-<li><a href="/2006/appformats/" class="navlink">Web Application
-Formats</a></li>
-
-<li><a href="/2001/tag/" class="navlink">Web Architecture
-(<acronym title="Technical Architecture Group">TAG</acronym>)</a></li>
-
-<li><a href="/Graphics/WebCGM/WG/" class="navlink"><abbr title="Web Computer Graphics Metafile">WebCGM</abbr></a></li>
-
-<li><a href="/2002/ws/" class="navlink">Web Services</a></li>
-
-<li><a href="/2002/ws/addr/" class="navlink"><abbr title="Web Services">WS</abbr>-Addressing</a></li>
-
-<li><a href="/2002/ws/chor/" class="navlink"><abbr title="Web Services Choreography Description Language">WS-CDL</abbr></a></li>
-
-<li><a href="/2002/ws/desc/" class="navlink"><acronym title="Web Services Description Language">WSDL</acronym></a></li>
-
-<li><a href="/2002/ws/policy/" class="navlink"><abbr title="Web Services">WS</abbr>-Policy</a></li>
-
-<li><a href="/MarkUp/Forms/" class="navlink"><acronym title="Next Generation Web Forms">XForms</acronym></a></li>
-
-<li><a href="/MarkUp/" class="navlink"><abbr title="Extensible HyperText Markup Language">XHTML</abbr></a></li>
-
-<li><a href="/MarkUp/" class="navlink"><abbr title="Extensible HyperText Markup Language">XHTML2</abbr></a></li>
-
-<li><a href="/XML/Linking" class="navlink"><acronym title="XML Link">XLink</acronym></a></li>
-
-<li><a href="/XML/" class="navlink"><abbr title="Extensible Markup Language">XML</abbr></a></li>
-
-<li><a href="/TR/xmlbase/" class="navlink"><abbr title="Extensible Markup Language">XML</abbr> Base</a></li>
-
-<li><a href="/2001/XKMS/" class="navlink"><abbr title="Extensible Markup Language">XML</abbr> Key Management</a></li>
-
-<li><a href="/XML/Processing/" class="navlink"><abbr title="Extensible Markup Language">XML</abbr> Processing</a></li>
-
-<li><a href="/XML/Query" class="navlink"><abbr title="Extensible Markup Language">XML</abbr> Query</a></li>
-
-<li><a href="/XML/Schema" class="navlink"><abbr title="Extensible Markup Language">XML</abbr> Schema</a></li>
-
-<li><a href="/2008/xmlsec/" class="navlink"><abbr title="Extensible Markup Language">XML</abbr> Signature
-and Encryption</a></li>
-
-<li><a href="/Style/XSL/" class="navlink">XPath</a></li>
-
-<li><a href="/XML/Linking" class="navlink">XPointer</a></li>
-
-<li><a href="/Style/XSL/" class="navlink"><acronym title="Extensible Stylesheet Language">XSL</acronym> and <acronym title="XSL Transformations">XSLT</acronym></a></li>
-</ul>
-
-<p><a href="/Consortium/siteindex" class="navlink">More
-topics...</a></p>
-</div>
-
-<div class="newsBlock">
-<h2 class="newsHeading"><a name="news" id="news">News</a></h2>
-
-<p class="invisible"><a title="Skip News" href="#search">Skip to
-Search</a></p>
-
-<div id="item103" class="item"><h3 class="headline">New eGovernment Activity to Help Improve Government through Better Use of the Web</h3>
-<p><a href="/2007/eGov/"><img class="newsImage" width="300" height="75" src="/2008/06/03-egov" alt="Crowd scene" /></a></p>
-<p><span class="date">2008-06-03:</span> W3C launches today a <a href="/2007/eGov/">new forum</a> for governments, citizens, researchers, and other stakeholders to investigate how best to use Web technology for good governance and citizen participation. "Open Standards, and in particular Semantic Web Standards, can help lower the cost of government, make it easier for independent agencies to work together, and increase flexibility in the face of change," said Tim Berners-Lee, W3C Director. W3C invites participation in the new <a href="/2007/eGov/IG/">eGovernment Interest Group</a>, which is open to the public. The group will identify best practices and guidelines in this area, document where current technology does not adequately address stakeholder needs, and suggest improvements via the standards process. Read the <a href="/2007/eGov/IG/faq">W3C eGovernment FAQ</a> and <a href="/2008/06/egov-pressrelease">press release</a>, and learn more about the <a href="/2007/eGov/">W3C eGovernment Activity</a>.<span class="archive"> (<a title="New eGovernment Activity to Help Improve Government through Better Use of the Web" href="/News/2008#item103" rel="details">Permalink</a>) </span></p></div>
-
-<div id="item105" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />Two Group Notes Published About Semantic Web and Life Sciences</h3><p><span class="date">2008-06-05:</span> The <a href="/2001/sw/hcls/">Semantic Web Health Care and Life Sciences Interest Group</a> has published two Group Notes: <a href="/TR/2008/NOTE-hcls-kb-20080604/">A Prototype Knowledge Base for the Life Sciences</a> and <a href="/TR/2008/NOTE-hcls-senselab-20080604/">Experiences with the conversion of SenseLab databases to RDF/OWL</a>. The former describes a prototype of a biomedical knowledge base that integrates 15 distinct data sources using currently available Semantic Web technologies including RDF and OWL. The Note outlines which resources were integrated, how the knowledge base was constructed using free and open source triple store technology, how it can be queried using SPARQL, and what resources and inferences are involved in answering complex queries. While the utility of the knowledge base is illustrated by identifying a set of genes involved in Alzheimer's Disease, the approach described here can be applied to any use case that integrates data from multiple domains. The second document describe the experience of converting SenseLab databases into OWL, an important step towards realizing the benefits of Semantic Web in integrative neuroscience research. Learn more about the <a href="/2001/sw/">Semantic Web Activity</a>.<span class="archive"> (<a title="Two Group Notes Published About Semantic Web and Life Sciences" href="/News/2008#item105" rel="details">Permalink</a>) </span></p></div>
-
-<div id="item104" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />Offline Web Applications Published as W3C Note</h3><p><span class="date">2008-06-03:</span> The <a href="/html/wg/">HTML Working Group</a> has published the <a href="/TR/2008/NOTE-offline-webapps-20080530/">Offline Web Applications</a> Group Note. <a href="/TR/html5/">HTML 5</a> contains several features that address the challenge of building Web applications that work while offline. This document highlights these features (SQL, offline application caching APIs as well as online/offline events, status, and the localStorage API) from HTML 5 and provides brief tutorials on how these features might be used to create Web applications that work offline. Learn more about the <a href="/MarkUp/Activity">HTML Activity</a>.<span class="archive"> (<a title="Offline Web Applications Published as W3C Note" href="/News/2008#item104" rel="details">Permalink</a>) </span></p></div>
-
-<div id="item102" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />W3C Advisory Committee Elects Advisory Board</h3><p><span class="date">2008-06-02:</span> The W3C Advisory Committee has filled six open seats on the <a href="/2002/ab/">W3C Advisory Board</a>. Created in 1998, the Advisory Board provides guidance to the Team on issues of strategy, management, legal matters, process, and conflict resolution. Beginning 1 July, the nine Advisory Board participants are Jean-François Abramatic (ILOG), Ann Bassetti (The Boeing Company), Jim Bell (HP), Don Deutsch (Oracle), Eduardo Gutentag (Sun Microsystems), Steve Holbrook (IBM), Ken Laskey (MITRE), Ora Lassila (Nokia), and Arun Ranganathan (Mozilla Foundation). Steve Zilles continues as interim Advisory Board Chair. Read more about the <a href="/2002/ab/">Advisory Board</a>.<span class="archive"> (<a title="W3C Advisory Committee Elects Advisory Board" href="/News/2008#item102" rel="details">Permalink</a>) </span></p></div>
-
-<div id="item101" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />W3C Talks in June</h3><p><span class="date">2008-06-02:</span> Browse <a href="/Talks/">W3C presentations and events</a> also available as an <abbr title="RDF Site Summary"><a href="/2004/08/TalkFiles/Talks.rss">RSS channel</a></abbr>. <span class="archive"> (<a title="W3C Talks in June" href="/News/2008#item101" rel="details">Permalink</a>) </span></p><ul><li><span class="talkstart">2 June, Västerås, Sweden: </span><span class="talktitle" lang="sv" xml:lang="sv">Framtidssäkra eFörvaltningen<span class="hide noprint">.</span></span><span class="talkdesc">Olle Olsson participates in a panel at <a href="http://www.offentligarummet.se/" lang="sv" xml:lang="sv">Offentliga Rummet 2008</a>. </span></li><li><span class="talkstart">4 June, Sao Paulo, Brazil: </span><span class="talktitle">Towards eGovernment 2.0 through better use of the Web<span class="hide noprint">.</span></span><span class="talkdesc">José Manuel Alonso presents at <a href="http://www.w3c.br/2008/launch/">W3C Brazil Office Public Launch</a>. </span></li><li><span class="talkstart">4 June, Sao Paolo, Brazil: </span><span class="talktitle">W3C - Web Open Standards<span class="hide noprint">.</span></span><span class="talkdesc">Daniel Dardailler presents at <a href="http://www.w3c.br/2008/lancamento/">W3C Brazil Office Launch event </a>. </span></li><li><span class="talkstart">10 June, Buenos Aires, Argentina: </span><span class="talktitle">Web Accessibility: People with Disabilities and Elderly Citizens<span class="hide noprint">.</span></span><span class="talkdesc">Shadi Abou-Zahra presents at <a href="http://www.isoc.org.ar/accesibilidad.html" lang="es" xml:lang="es">Web Sin Barreras</a>. </span></li><li><span class="talkstart">11 June, Nashville, TN, USA: </span><span class="talktitle">Color for the Global Web<span class="hide noprint">.</span></span><span class="talkdesc">Molly E Holzschlag presents at <a href="http://www.voicesthatmatter.com/webdesign2008/index.aspx">Voices That Matter</a>. </span></li><li><span class="talkstart">12 June, Nashville, TN, USA: </span><span class="talktitle">Designing for Today's Browsers<span class="hide noprint">.</span></span><span class="talkdesc">Molly E Holzschlag presents at <a href="http://www.voicesthatmatter.com/webdesign2008/index.aspx">Voices That Matter</a>. </span></li><li><span class="talkstart">17 June, New York, NY, USA: </span><span class="talktitle">Web of Data<span class="hide noprint">.</span></span><span class="talkdesc">Tim Berners-Lee presents at <a href="http://www.linkeddataplanet.com/index.php">LinkedData Planet Conference: exploring the new web of linked data</a>. </span></li><li><span class="talkstart">19 June, Tokyo, Japan: </span><span class="talktitle">Update on W3C/WAI Guidelines including WCAG 2.0<span class="hide noprint">.</span></span><span class="talkdesc">Judy Brewer presents at <a>Open Seminar of Information Accessibility</a>. </span></li><li><span class="talkstart">19 June, Nancy, France: </span><span class="talktitle" lang="fr" xml:lang="fr">États des lieux du Web sémantique<span class="hide noprint">.</span></span><span class="talkdesc">Ivan Herman gives a keynote at <a href="http://ic2008.loria.fr/" lang="fr" xml:lang="fr">19èmes Journées Francophones d'Ingénierie des Connaissances (IC2008)</a>. </span></li><li><span class="talkstart">19 June, Baltimore, Maryland, USA: </span><span class="talktitle">How New Web Accessibility Standards Impact User Experience Design<span class="hide noprint">.</span></span><span class="talkdesc">Shawn Henry presents at <a href="http://www.usabilityprofessionals.org/conference/2008/">Usability Professionals' Association International Conference 2008</a>. </span></li><li><span class="talkstart">26 June, Frankfurt, Germany: </span><span class="talktitle">Mobile Internet - the Way Forward<span class="hide noprint">.</span></span><span class="talkdesc">Steve Bratt participates in a panel at <a href="http://www.amiando.com/ngmn-2008">2nd NGMN Industry Conference 2008</a>. </span></li><li class="noprint showuris">View <a href="http://www.w3.org/2004/08/W3CTalks?date=Recent+and+upcoming&amp;countryListing=yes&amp;submit=Submit">upcoming talks by country</a></li><li class="noprint showuris"><a href="/Talks/">More talks...</a></li></ul></div>
-
-<div id="item100" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />W3C Launches Group to Help Bridge the Digital Divide</h3><p><a href="/2008/MW4D/"><img class="newsImage" alt="Phone bikes" src="/2008/05/voiturette-sb.png" /></a><span class="date">2008-05-27:</span> As part of the growing set of W3C initiatives related to social development, W3C invites participation in the new <a href="/2008/MW4D/">Mobile Web for Development (MW4D) interest Group</a>, chartered to explore the potential of mobile technology to help bridge the digital divide. "We need to solve important challenges, such as lack of standards in end-user devices, network constraints, service cost, issues of literacy, and an understanding of the real information needs of rural communities," said Ken Banks, kiwanja.net, who Chairs the group. "To do so requires an multidisciplinary approach, a step we take through the creation of this new group." Read more in the <a href="/2008/05/mw4dig-pressrelease">press release</a>. This launch is part of <a href="/Mobile">W3C's Mobile Web Initiative (MWI)</a>, which aims to identify and resolve challenges and issues of accessing the Web when on the move. This work takes place under the auspices of the <a href="http://cordis.europa.eu/fp7/ict/">European Union's 7th Research Framework Programme (FP7)</a>, part of the <a href="http://digitalworld.ercim.org/">Digital World Forum</a> project.<span class="archive"> (Photo credit: Stéphane Boyera. <a title="W3C Launches Group to Help Bridge the Digital Divide" href="/News/2008#item100" rel="details">Permalink</a>) </span></p></div>
-
-<div id="item99" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />Last Call: XHTML Access Module</h3><p><span class="date">2008-05-26:</span> The <a href="/MarkUp/">XHTML 2 Working Group</a> has published the Last Call Working Draft of <a href="/TR/2008/WD-xhtml-access-20080526/">XHTML Access Module</a>. This document is intended to help make XHTML-family markup languages more effective at supporting the needs of the accessibility community. It does so by providing a generic mechanism for defining the relationship between document components and well-known accessibility taxonomies. Comments are welcome through 16 June. Learn more about the <a href="/MarkUp/Activity">HTML Activity</a>. <span class="archive"> (<a title="Last Call: XHTML Access Module" href="/News/2008#item99" rel="details">Permalink</a>) </span></p></div>
-
-<div id="item98" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />W3C Invites Implementations of CSS Namespaces Module (Candidate Recommendation)</h3><p><span class="date">2008-05-23:</span> The <a href="/Style/CSS/members">Cascading Style Sheets (CSS) Working Group</a> has published the Candidate Recommendation of <a href="/TR/2008/CR-css3-namespace-20080523/">CSS Namespaces Module</a>. This CSS Namespaces module defines the syntax for using namespaces in CSS. It defines the @namespace rule for declaring the default namespace and binding namespaces to namespace prefixes, and it also defines a syntax that other specifications can adopt for using those prefixes in namespace-qualified names. Learn more about the <a href="/Style/">Style Activity</a>.<span class="archive"> (<a title="W3C Invites Implementations of CSS Namespaces Module (Candidate Recommendation)" href="/News/2008#item98" rel="details">Permalink</a>) </span></p></div>
-
-<div id="item97" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />Progress Events 1.0</h3><p><span class="date">2008-05-22:</span> The <a href="/2006/webapi/">Web API Working Group</a> has published a Working Draft of <a href="/TR/2008/WD-progress-events-20080521/">Progress Events 1.0</a>.This document describes event types that can be used for monitoring the progress of an operation. It is primarily intended for contexts such as data transfer operations specified by <a href="/TR/XMLHttpRequest">XMLHTTPRequest</a>, or <a href="/TR/MediaAccessEvents/">Media Access Events</a>. Learn more about the <a href="/2006/rwc/">Rich Web Client Activity</a>.<span class="archive"> (<a title="Progress Events 1.0" href="/News/2008#item97" rel="details">Permalink</a>) </span></p></div>
-
-<div id="item96" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />XML Security Working Group to Take Next Steps on XML Signature, Encryption</h3><p><span class="date">2008-05-21:</span> W3C is pleased to announce the creation of the <a href="/2008/xmlsec/">XML Security Working Group</a>, whose mission is to evaluate and act on <a href="/2007/xmlsec/ws/report">recommendations</a> from the <a href="/2007/xmlsec/ws/agenda.html">September 2007 Workshop on XML Signature and XML Encryption</a> regarding next steps for XML Security specifications. The group's <a href="/2008/02/xmlsec-charter.html#deliverables">deliverables</a> include new work on XML Signature Syntax and Processing and XML Encryption Syntax and Processing, as well as maintenance of related specifications. Frederick Hirsch (Nokia) will Chair the group, with Thomas Roessler (W3C) as Team Contact. Learn more about the <a href="/Security/">W3C Security Activity</a>. <span class="archive"> (<a title="XML Security Working Group to Take Next Steps on XML Signature, Encryption" href="/News/2008#item96" rel="details">Permalink</a>) </span></p></div>
-
-<div id="item94" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />Last Call: Cascading Style Sheets (CSS) Snapshot 2007</h3><p><span class="date">2008-05-16:</span> The <a href="/Style/CSS/members">Cascading Style Sheets (CSS) Working Group</a> has published the Last Call Working Draft of <a href="/TR/2008/WD-css-beijing-20080516/">Cascading Style Sheets (CSS) Snapshot 2007</a>. This document collects together into one definition all the specifications that together form the current state of Cascading Style Sheets (CSS). The primary audience is CSS implementors, not CSS authors, as this definition includes modules by specification stability, not Web browser adoption rate. Comments are welcome through 09 June. Learn more about the <a href="/Style/">Style Activity</a>.<span class="archive"> (<a title="Last Call: Cascading Style Sheets (CSS) Snapshot 2007" href="/News/2008#item94" rel="details">Permalink</a>) </span></p></div>
-
-<div id="item93" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />W3C Invites Implementations of XQuery and XPath Full Text 1.0 (Candidate Recommendation); Requirements and Use Cases Drafts Available</h3><p><span class="date">2008-05-16:</span> The W3C <a href="http://www.w3.org/XML/Query/">XML Query Working Group</a> and the W3C <a href="http://www.w3.org/Style/XSL/">XSL Working Group</a> jointly published today a Candidate Recommendation of <a href="/TR/2008/CR-xpath-full-text-10-20080516/">XQuery and XPath Full Text 1.0</a>. This document defines the syntax and formal semantics of XQuery and XPath Full Text 1.0 which is a language that extends XQuery 1.0 [XQuery 1.0: An XML Query Language] and XPath 2.0 [XML Path Language (XPath) 2.0] with full-text search capabilities. Implementors are encouraged to run the groups' <a href="http://dev.w3.org:/cvsweb/2007/xpath-full-text-10-test-suite/">test suite</a> and report their results. The Groups also published Working Drafts of <a href="/TR/2008/WD-xpath-full-text-10-requirements-20080516/">XQuery and XPath Full Text 1.0 Requirements</a> and <a href="/TR/2008/WD-xpath-full-text-10-use-cases-20080516/">Use Cases</a>. Learn more about the <a href="/XML/">XML Activity</a>.<span class="archive"> (<a title="W3C Invites Implementations of XQuery and XPath Full Text 1.0 (Candidate Recommendation); Requirements and Use Cases Drafts Available" href="/News/2008#item93" rel="details">Permalink</a>) </span></p></div>
-
-<div id="item95" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />State Chart XML (SCXML) Working Draft Published</h3><p><span class="date">2008-05-16:</span> The <a href="/Voice/">Voice Browser Working Group</a> has published an updated Working Draft of <a href="/TR/2008/WD-scxml-20080516/">State Chart XML (SCXML): State Machine Notation for Control Abstraction</a>. <abbr title="State Chart eXtensible Markup Language">SCXML</abbr> is an execution environment based on <a href="http://www.uml.org/#UML1.5"><abbr title="Unified Modeling Language">UML</abbr></a> Harel State Tables and <a href="/TR/ccxml/"><abbr title="Call Control eXtensible Markup Language">CCXML</abbr></a>. The main differences from the previous draft are (1) the modularization of the language, (2) the introduction of profiles and (3) a revision of the algorithm for document interpretation; the document as a whole has changed significantly and the group welcomes review. Learn more about the <a href="/Voice/">Voice Browser Activity</a>.<span class="archive"> (<a title="State Chart XML (SCXML) Working Draft Published" href="/News/2008#item95" rel="details">Permalink</a>) </span></p></div>
-
-<div id="item92" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />"Web Accessibility for Older Users: A Literature Review"; Comments Welcome on First Public Draft</h3><p><span class="date">2008-05-14:</span> The Web Accessibility Initiative (WAI) <a href="/WAI/EO/">Education and Outreach Working Group Working Group (EOWG)</a> has published <a href="/TR/2008/WD-wai-age-literature-20080514/">Web Accessibility for Older Users: A Literature Review</a> as a First Public Working Draft. The document includes reviews and analysis of guidelines and articles covering the requirements of people with Web accessibility needs related to ageing. This literature review will inform WAI efforts to promote accessibility solutions for older Web users and potentially to develop profiles or extensions to WAI guidelines. The literature review is a deliverable of the <a href="/WAI/WAI-AGE/">WAI-AGE Project</a> (Ageing Education and Harmonisation). See the <a href="http://lists.w3.org/Archives/Public/w3c-wai-ig/2008AprJun/0083.html">call for review and participation</a> for an introduction to the project and an invitation to contribute to the literature review and other WAI-AGE work; and about the <a href="/WAI/">Web Accessibility Initiative</a>.<span class="archive"> (<a title="Web Accessibility for Older Users: A Literature Review; Comments Welcome on First Public Draft" href="/News/2008#item92" rel="details">Permalink</a>) </span></p></div>
-
-<div id="item91" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />Last Call: CURIE Syntax 1.0</h3><p><span class="date">2008-05-08:</span> The <a href="/MarkUp/">XHTML2 Working Group</a> has published the Last Call Working Draft of <a href="/TR/2008/WD-curie-20080506">CURIE Syntax 1.0</a>, which outlines a syntax for expressing URIs in a generic, abbreviated syntax ("Compact URI"). The specification targets language designers who need a mechanism to permit the use of extensible value collections. Any language designer considering the use of QNames in attribute values should consider instead using CURIEs, since CURIEs are designed for this purpose, while QNames are not. Comments are welcome through 10 June. Learn more about the <a href="/MarkUp/Activity">HTML Activity</a>.<span class="archive"> (<a title="Last Call: CURIE Syntax 1.0" href="/News/2008#item91" rel="details">Permalink</a>) </span></p></div>
-
-
-
-<h3 class="pastNews"><a href="/News/2008">Past News</a></h3>
-</div>
-
-<div class="navBlock">
-<h2 class="navhead"><a name="search" id="search">Search</a></h2>
-
-<p class="invisible"><a class="navlink" title="Skip search" href="#contents">Skip to Contents</a></p>
-
-<form method="get" action="http://www.google.com/custom" enctype="application/x-www-form-urlencoded">
-<div>
-<a class="navlink" href="http://www.google.com"><img src="/Icons/Logo_25wht.gif" width="75" height="32" alt="Google" /></a><br />
-<label for="inputField">Search W3C<br />
-<input type="text" size="15" id="inputField" name="q" accesskey="E" maxlength="255" /></label> <input type="submit" value="Go" id="goButton" name="sa" accesskey="G" /><br />
-<input type="hidden" name="cof" value="T:black;LW:72;ALC:#ff3300;L:http://www.w3.org/Icons/w3c_home;LC:#000099;LH:48;BGC:white;AH:left;VLC:#660066;GL:0;AWFID:0b9847e42caf283e;" />
- <input type="hidden" id="searchW3C" name="sitesearch" checked="checked" value="www.w3.org" /><input type="hidden" name="domains" value="www.w3.org" />
-</div>
-</form>
-
-<p><a class="navlink" href="/Search/Mail/Public/">Search W3C Mailing
-Lists</a></p>
-
-<h2 class="navhead"><a name="contents" id="contents">Testimonials</a></h2>
-
-<div class="hpmt"><div class="hpmt-name">Fraunhofer Gesellschaft</div><div class="hpmt-logo"><a rel="nofollow" href="http://www.fraunhofer.de/"><img alt="Fraunhofer Gesellschaft" src="http://www.w3.org/Consortium/Member/Testimonial/Logo/119" /></a></div><p class="hpmt-testimonial">The Fraunhofer-Gesellschaft undertakes applied contract research in all fields of engineering sciences. Fraunhofer works with W3C to contribute to the development of Web technologies which are the base of many of our research activities. Fraunhofer hosts the W3C Office in Germany and Austria. <a class="hpmt-more" href="http://www.w3.org/Consortium/Member/Testimonial/List">(Member testimonials)</a></p></div>
-
-<h2 class="navhead">Members</h2>
-
-<ul>
-<li><a href="/Member/" class="navlink">Member Home Page</a></li>
-
-<li><a href="/Submission/" class="navlink">Member Submissions</a></li>
-
-<li><a href="/Consortium/Member/List" class="navlink">Current
-Members</a></li>
-
-<li><a href="/Consortium/meetings" class="navlink">Meetings</a></li>
-
-<li><a href="/Consortium/Recruitment/Fellows" class="navlink">Fellows</a> (<a href="/Consortium/Recruitment/Fellows#openings">New Openings</a>)</li>
-</ul>
-
-<h2 class="navhead">Get Involved</h2>
-
-<ul>
-<li><a href="/Consortium/membership-benefits" class="navlink">W3C
-Membership Benefits</a></li>
-
-<li><a href="/Consortium/membership#bizcase" class="navlink">Reasons to
-Join W3C</a></li>
-
-<li><a href="/Mail/" class="navlink">Mailing Lists</a></li>
-
-<li><a href="http://lists.w3.org/Archives/Public/public-new-work/latest">Potential
-New Work</a></li>
-
-<li><a href="/Consortium/Translation/" class="navlink">Translations</a></li>
-
-<li><a href="/2003/08/Workshops/" class="navlink">Workshops</a></li>
-
-<li><a href="/2001/11/StdLiaison" class="navlink">Liaisons</a></li>
-
-<li><a href="/Status" class="navlink">Open Source Software</a></li>
-
-<li><a href="/QA/" class="navlink">Q&amp;A Blog</a></li>
-
-<li><a href="/Consortium/Recruitment/" class="navlink">Employment</a></li>
-
-<li><span class="navText">More ways to</span> <a href="/Consortium/org#public" class="navlink">participate</a></li>
-</ul>
-
-<h2 class="navhead">Introduction</h2>
-
-<ul>
-<li><a href="/Consortium/" class="navlink">About W3C</a></li>
-
-<li><a href="/Consortium/faq" class="navlink">Frequently Asked
-Questions (FAQ)</a></li>
-
-<li><a href="/2003/glossary/" class="navlink">Glossary</a></li>
-
-<li><a href="/Consortium/Process/" class="navlink">Process
-Document</a></li>
-
-<li><a href="/2002/03/tutorials" class="navlink">Tutorials</a></li>
-
-<li><a href="/2002/03/new-to-w3c" class="navlink">More...</a></li>
-</ul>
-
-<h2 class="navhead">W3C Team</h2>
-
-<ul>
-<li><a href="/People/" class="navlink">People</a></li>
-
-<li><a href="/TeamSubmission/" class="navlink">Team
-Submissions</a></li>
-</ul>
-
-<h2 class="navhead">Presentations</h2>
-
-<ul>
-<li><a href="/Talks/" class="navlink">Public Presentations</a></li>
-</ul>
-
-<h2 class="navhead">News Room</h2>
-
-<ul>
-<li><a href="/News/" class="navlink">W3C News Archive</a> <span class="navText">(</span><a href="/2000/08/w3c-synd/home.rss" class="navlink">RSS</a><span class="navText">)</span></li>
-
-<li><a href="/News/Public/" class="navlink">Weekly Public Newsletter</a></li>
-
-<li><a href="/Press/" class="navlink">Press Releases</a></li>
-
-<li><a href="/Press/#rss" class="navlink">Multilingual Press Release
-RSS</a></li>
-
-<li><a href="/Press/Articles" class="navlink">W3C in the Press</a></li>
-</ul>
-
-<h2 class="navhead"><a name="Offices" id="Offices">World
-Offices</a></h2>
-
-<p class="navPara">The <a href="/Consortium/Offices/" class="navlink">W3C Offices</a>, part of the <a href="/2007/IntlRel.html">W3C
-International Relations team</a> translate many W3C home page news
-items. W3C Offices are located in these parts of the world:</p>
-
-<ul>
-<li><a href="http://www.w3c.org.au/" class="navlink" title="Australia">Australia</a></li>
-
-<li><a href="http://www.w3c.nl/index.shtml.nl" class="navlink" hreflang="nl" title="Benelux"><span xml:lang="nl" lang="nl">Benelux</span></a>/<a href="http://www.w3c.nl/index.shtml.fr" class="navlink" title="Benelux" hreflang="fr"><span xml:lang="fr" lang="fr">Bénélux</span></a></li>
-
-<li><a href="http://www.w3c.br/" class="navlink" title="Brazil" hreflang="pt-br"><span xml:lang="pt-br" lang="pt-br">Brasil</span>
-(Brazil)</a></li>
-
-<li><a href="http://www.chinaw3c.org/" class="navlink" title="China" hreflang="zh-hans"><span xml:lang="zh-hans" lang="zh-hans">中国</span>
-(China)</a></li>
-
-<li><a href="http://www.w3c.tut.fi/" class="navlink" title="Finland" hreflang="fi"><span xml:lang="fi" lang="fi">Suomi</span>
-(Finland)</a></li>
-
-<li><a href="http://www.w3c.de/" class="navlink" title="German and Austria" hreflang="de"><span xml:lang="de" lang="de">Deutschland und Österreich</span> (Germany and Austria)</a></li>
-
-<li><a href="http://www.w3c.gr/" class="navlink" title="Greece" hreflang="el"><span xml:lang="el" lang="el">Ελλάδα</span>
-(Greece)</a></li>
-
-<li><a href="http://www.w3c.hu/" class="navlink" title="Hungary" hreflang="hu"><span xml:lang="hu" lang="hu">Magyarország</span>
-(Hungary)</a></li>
-
-<li><a href="http://www.w3cindia.in/" class="navlink" title="India" hreflang="en"><span xml:lang="hi" lang="hi">भारत</span>
-(India)</a></li>
-
-<li><a href="http://www.w3c.org.il/" class="navlink" title="Israel" hreflang="he"><span xml:lang="he" lang="he">ישראל</span>
-(Israel)</a></li>
-
-<li><a href="http://www.w3c.it/" class="navlink" title="Italy" hreflang="it"><span xml:lang="it" lang="it">Italia</span>
-(Italy)</a></li>
-
-<li><a href="http://www.w3c.or.kr/" class="navlink" title="Korea" hreflang="ko"><span xml:lang="ko" lang="ko">한국</span> (Korea)</a></li>
-
-<li><a href="http://www.w3c.org.ma/" class="navlink" title="Morocco" hreflang="ar"><span xml:lang="ar" lang="ar">المغرب</span>
-(Morocco)</a></li>
-
-<li><a href="http://www.w3c.org.za/" class="navlink" title="Southern Africa" hreflang="en">Southern Africa</a></li>
-
-<li><a href="http://www.w3c.es/" class="navlink" title="Spain" hreflang="es"><span xml:lang="es" lang="es">España</span>
-(Spain)</a></li>
-
-<li><a href="http://www.w3c.se" class="navlink" title="Sweden" hreflang="sv"><span xml:lang="sv" lang="sv">Sverige</span>
-(Sweden)</a></li>
-
-<li><a href="http://www.w3c.rl.ac.uk/" class="navlink" title="UK and Ireland" hreflang="en-uk">United Kingdom and Ireland</a></li>
-</ul>
-
-<h2 class="navhead"><a name="systems" id="systems">Systems</a></h2>
-
-<ul>
-<li><a href="/Help/Account/" class="navlink">Get Password</a></li>
-
-<li><a href="/2003/08/system-status" class="navlink">System
-Status</a></li>
-</ul>
-</div>
-<hr class="hide" />
-
-<p class="small">W3C would like to thank the <a name="donors" id="donors" href="/Consortium/sup">Supporters</a> who have contributed
-financially or through a donation of goods to W3C.</p>
-
-<p class="small"><a name="footnotes" id="footnotes">Read</a> <a href="/2002/11/homepage">about the layout</a> and <a href="http://lists.w3.org/Archives/Public/site-comments/">send comments</a>
-about this page. <a href="/2000/08/w3c-synd/home.rss">Syndicate</a>
-this page with <a href="http://purl.org/rss/1.0/">RSS 1.0</a>, an
-<a href="/RDF/">RDF</a> vocabulary used for <a href="/2000/08/w3c-synd/#">site summaries</a>. </p>
-
-<address class="small">
-<a href="/Help/Webmaster">Webmaster</a> · Last modified:
- $Date: 2008/06/05 17:06:19 $
- <span class="whiteout">|</span><br />
-<a href="http://validator.w3.org/check?uri=referer"><img src="/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a> <span class="whiteout">|</span> <a href="http://jigsaw.w3.org/css-validator/"><img src="/Icons/valid-css" alt="Valid CSS!" height="31" width="88" /></a> <span class="whiteout">|</span> <a href="/WAI/WCAG1AA-Conformance" title="Explanation of Level Double-A Conformance"><img class="conform" height="31" width="88" src="/WAI/wcag1AA" alt="Level Double-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0" />
-</a> <span class="whiteout">|</span>
-</address>
-
-<p class="copyright"><a rel="Copyright" href="/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 1994-2007
-<a href="/"><acronym title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of Technology">MIT</acronym></a>, <a href="http://www.ercim.org/"><acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
-<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C
-<a href="/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
-<a href="/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>,
-<a rel="Copyright" href="/Consortium/Legal/copyright-documents">document use</a> and <a rel="Copyright" href="/Consortium/Legal/copyright-software">software
-licensing</a> rules apply. Your interactions with this site are in
-accordance with our <a href="/Consortium/Legal/privacy-statement#Public">public</a> and <a href="/Consortium/Legal/privacy-statement#Members">Member</a> privacy
-statements.</p>
-</body>
-</html>
diff --git a/examples/xml/htmlinfo/youtube_com.html b/examples/xml/htmlinfo/youtube_com.html
deleted file mode 100644
index 1de65a3aa5..0000000000
--- a/examples/xml/htmlinfo/youtube_com.html
+++ /dev/null
@@ -1,1585 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
-
-
- <html lang="en">
-
-<!-- machid: 519 -->
-<head>
-
- <title>YouTube - Broadcast Yourself.</title>
-
- <link rel="stylesheet" href="http://s.ytimg.com/yt/css/base_all-vfl42327.css" type="text/css">
-
- <link rel="search" type="application/opensearchdescription+xml" href="/opensearch?locale=en_US" title="YouTube Video Search">
- <link rel="icon" href="http://s.ytimg.com/yt/favicon-vfl1123.ico" type="image/x-icon">
- <link rel="shortcut icon" href="http://s.ytimg.com/yt/favicon-vfl1123.ico" type="image/x-icon">
-
-
- <meta name="description" content="Share your videos with friends and family">
- <meta name="keywords" content="video,sharing,camera phone,video phone,free">
-
- <link rel="alternate" type="application/rss+xml" title="YouTube - [RSS]" href="/rssls">
-
- <link rel="alternate" media="handheld" href="http://m.youtube.com/index?desktop_uri=%2F&">
-
- <script type="text/javascript">
- window.google={kHL:"en"};
- </script>
-
- <script type="text/javascript" src="http://s.ytimg.com/yt/js/base_all_with_bidi-vfl42302.js"></script>
-
- <script type="text/javascript">
-
- function _hbLink (a,b) { return false; }
- function urchinTracker (a,b) { }
-
-
- var gXSRF_token = '';
- var gXSRF_field_name = '';
- var gXSRF_ql_pair = '';
-
- gXSRF_token = 'fZg-xPKpfj11aUrz_5__moOGiAp8MTIxMjg1OTQ4OA==';
- gXSRF_field_name = 'session_token';
- onLoadFunctionList.push(populate_session_token);
-
- gXSRF_ql_pair = 'session_token=kVjpl8qnfp7RPuqnTrIu6Q8BT5d8MA==';
-
-
- var gQuickListTooltipText = 'Add Video to QuickList';
- var gPartnerVideoText = 'Partner Video';
- var gGoogleSuggest = true;
- var gPixelGif = 'http://s.ytimg.com/yt/img/pixel-vfl73.gif';
-
- var gInQuickListText = 'in <a href="/watch_queue?all">QuickList</a>';
- var gIsResultsPage = false;
- </script>
-
-
-
-<script type="text/javascript">
-
-function swapVideoList(linkObj)
-{
- var linkId = linkObj.id;
- var queryData = '';
- var newDivId = '';
- var headlineObj = document.getElementById('hpVideoListHead');
- var moreLinkObj = document.getElementById('homepage-featured-more-top');
- var bottomMoreLinkObj = document.getElementById('homepage-featured-more-bottom');
-
- if (linkId == 'hpMostViewedLink') {
- queryData = 'videoListType=mostViewed';
- newDivId = 'hpMostViewed';
- headlineObj.innerHTML = "Most Viewed Videos";
- moreLinkObj.innerHTML = "<a href=\"/browse?s=mp\">See More Most Viewed Videos</a>";
- bottomMoreLinkObj.innerHTML = "<a href=\"/browse?s=mp\">See More Most Viewed Videos</a>";
- }
- else if (linkId == 'hpMostDiscussedLink') {
- queryData = 'videoListType=mostDiscussed';
- newDivId = 'hpMostDiscussed';
- headlineObj.innerHTML = "Most Discussed Videos";
- moreLinkObj.innerHTML = "<a href=\"/browse?s=md\">See More Most Discussed Videos</a>";
- bottomMoreLinkObj.innerHTML = "<a href=\"/browse?s=md\">See More Most Discussed Videos</a>";
- }
- else if (linkId == 'hpTopFavoritesLink') {
- queryData = 'videoListType=topFavorites';
- newDivId = 'hpTopFavorites';
- headlineObj.innerHTML = "Top Favorites";
- moreLinkObj.innerHTML = "<a href=\"/browse?s=mf\">See More Top Favorites</a>";
- bottomMoreLinkObj.innerHTML = "<a href=\"/browse?s=mf\">See More Top Favorites</a>";
- }
- else if (linkId == 'hpFeaturedLink') {
- newDivId = 'hpFeatured';
- headlineObj.innerHTML = "Featured Videos";
- moreLinkObj.innerHTML = "<a href=\"/browse?s=rf\">See More Featured Videos</a>";
- bottomMoreLinkObj.innerHTML = "<a href=\"/browse?s=rf\">See More Featured Videos</a>";
- }
- self.containerDiv = 'homepage-video-list'
- self.fillDiv = fillDiv
- self.linkId = linkId
- self.newDivId = newDivId
- addClass(_gel(newDivId + 'Link'), 'hilite');
- if (newDivId != 'hpMostViewed') {
- removeClass(_gel('hpMostViewedLink'), 'hilite');
- }
- if (newDivId != 'hpMostDiscussed') {
- removeClass(_gel('hpMostDiscussedLink'), 'hilite');
- }
- if (newDivId != 'hpTopFavorites') {
- removeClass(_gel('hpTopFavoritesLink'), 'hilite');
- }
- if (newDivId != 'hpFeatured') {
- removeClass(_gel('hpFeaturedLink'), 'hilite');
- }
- if (document.getElementById(newDivId))
- {
- document.getElementById(newDivId).style.display = 'block';
- if (newDivId != 'hpMostViewed' && document.getElementById('hpMostViewed')) document.getElementById('hpMostViewed').style.display = 'none';
- if (newDivId != 'hpMostDiscussed' && document.getElementById('hpMostDiscussed')) document.getElementById('hpMostDiscussed').style.display = 'none';
- if (newDivId != 'hpTopFavorites' && document.getElementById('hpTopFavorites')) document.getElementById('hpTopFavorites').style.display = 'none';
- if (newDivId != 'hpFeatured' && document.getElementById('hpFeatured')) document.getElementById('hpFeatured').style.display = 'none';
- }
- else if (queryData != '') {
- postUrlXMLResponse('/ajax_video_list',queryData,self.fillDiv);
- }
-}
-function fillDiv(req)
-{
- if (document.getElementById('hpMostViewed')) document.getElementById('hpMostViewed').style.display = 'none';
- if (document.getElementById('hpMostDiscussed')) document.getElementById('hpMostDiscussed').style.display = 'none';
- if (document.getElementById('hpTopFavorites')) document.getElementById('hpTopFavorites').style.display = 'none';
- if (document.getElementById('hpFeatured')) document.getElementById('hpFeatured').style.display = 'none';
- var newContent = getNodeValue(req.responseXML, "html_content");
- var newdiv = document.createElement('div');
- newdiv.setAttribute("id",self.newDivId);
- newdiv.innerHTML = newContent;
- var container = document.getElementById(self.containerDiv);
- container.appendChild(newdiv);
- addQLIcons(container);
-}
-
-function hide_active_sharing() {
- hideDiv("active_sharing_div");
-}
-</script>
-
-</head>
-
-
-<body onload="performOnLoadFunctions();" class="en_US is-english">
-
-<div id="baseDiv" class="date-20080606">
-
- <div id="masthead">
- <a href="/" class="logo"><img src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" width="132" height="63" border="0" alt=""/></a>
- <div class="user-info">
-
- <div id="loginBoxZ">
- <div class="contentBox">
- <div>
- <div id="loginBoxZ-signup">
- <a href="/signup">Sign Up</a>
- | <a href="http://help.youtube.com/support/youtube/bin/topic.py?topic=10546&amp;hl=en_US">Help</a>
- </div>
- <div id="loginBoxZ-login">
- Login
- </div>
- <div class="clear"></div>
- </div>
-
- <form method="post" name="loginForm" id="loginFormZ" action="/signup">
- <input type="hidden" name="next" value="/" id="loginNextZ"/>
- <input type="hidden" name="current_form" value="loginForm" />
- <input type="hidden" name="action_login" value="1">
- <div id="loginBoxZ-container">
- <div id="loginBoxZ-labels" class="floatL">
- <label for="loginUserZ" class="nowrap">Username:</label>
- <label for="loginPassZ" class="nowrap">Password:</label>
- </div>
- <div class="floatL">
- <input id="loginUserZ" class="loginBoxZ-input" type="text" size="16" name="username" value=""><br/>
- <input id="loginPassZ" class="loginBoxZ-input" type="password" size="16" name="password"><br/>
- <input type="submit" class="smallText" value="Login">
- </div>
- <div class="clearL"></div>
- </div>
- </form>
- <div id="loginBoxZ-forgot">
- <a href="/forgot_username?next=/">Forgot Username</a>
- | <wbr><nobr><a href="/forgot?next=/">Forgot Password</a></nobr>
- </div>
- <div id="loginBoxZ-gaia">
- <a href="https://www.google.com/accounts/ServiceLogin?service=youtube&amp;hl=en_US&amp;continue=http%3A//www.youtube.com/signup%3Fhl%3Den_US&amp;passive=true">Login with your Google account</a>&nbsp;
- <a href="#" onClick="window.open('/t/help_gaia','login_help','width=580,height=480,resizable=yes,scrollbars=yes,status=0').focus();" rel="nofollow"><img src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" border="0" class="alignMid gaiaHelpBtn" alt=""></a>
- </div>
- </div>
- </div>
-
- <div id="localePickerBox">
- <div id="flagDiv">
- <script type="text/javascript">
- var gLocales = [
- ['ru_RU','&#x420;&#x43E;&#x441;&#x441;&#x438;&#x44F;'] , ['zh_TW','&#x53F0;&#x7063;'] , ['ja_JP','&#x65E5;&#x672C;'] , ['zh_HK','&#x9999;&#x6E2F;'] , ['ko_KR','&#xD55C;&#xAD6D;'] , ['en_AU','Australia'] , ['pt_BR','Brasil'] , ['en_CA','Canada'] , ['de_DE','Deutschland'] , ['es_ES','Espa&#xF1;a'] , ['fr_FR','France'] , ['en_US','Global'] , ['en_IN','India'] , ['en_IE','Ireland'] , ['it_IT','Italia'] , ['es_MX','M&#xE9;xico'] , ['nl_NL','Nederland'] , ['en_NZ','New Zealand'] , ['pl_PL','Polska'] , ['en_GB','United Kingdom']
- ];
- </script>
- <div id="flagDivInner">
- </div>
-
- <div class="alignR smallText"><a href="#" onclick="closeLocalePicker(); return false;">Close</a></div>
- </div>
- </div>
-
-
-
-
-
-
- <div id="util-links" class="normal-utility-links">
-
- <span class="util-item first"><b><a href="/signup" onclick="_hbLink('SignUp','UtilityLinks');">Sign Up</a></b></span>
- <span class="util-item"><a href="/watch_queue?all">QuickList</a> (<span id="quicklist-utility">0</span>)</span>
- <span class="util-item"><a href="http://help.youtube.com/support/youtube/bin/static.py?page=start.cs&amp;hl=en_US">Help</a></span>
- <span class="util-item"><a href="#" class="loginBoxZ eLink" onclick="return openLoginBox(event);">Log In</a></span>
- <span class="util-item"><a href="#" class="localePickerLink eLink" onclick="loadFlagImgs();toggleDisplay('localePickerBox');return false;">Site:</a></span>
- <span class="util-item first">&nbsp;<a href="#" class="localePickerLink" onclick="loadFlagImgs();toggleDisplay('localePickerBox');return false;"><img src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="currentFlag globalFlag" alt="Site:"></a></span>
- </div>
-
- <form name="logoutForm" method="post" target="_top" action="/index">
- <input type="hidden" name="action_logout" value="1">
- </form>
-
-
- </div>
- <div class="nav">
- <div class="nav-item first selected" id="nav-item-home">
- <span class="leftcap"></span>
- <a class="content" href="/">Home</a>
- <span class="rightcap"></span>
- </div>
- <div class="nav-item" id="nav-item-videos">
- <div class="nav-tab">
- <span class="leftcap"></span>
- <a class="content" href="/browse?s=mp">Videos</a>
- <span class="rightcap"></span>
- </div>
- </div>
- <div class="nav-item" id="nav-item-channels">
- <div class="nav-tab">
- <span class="leftcap"></span>
- <a class="content" href="/members">Channels</a>
- <span class="rightcap"></span>
- </div>
- </div>
- <div class="nav-item" id="nav-item-community">
- <div class="nav-tab">
- <span class="leftcap"></span>
- <a class="content" href="/community">Community</a>
- <span class="rightcap"></span>
- </div>
- </div>
- </div>
-
- <form autocomplete="off" action="/results" method="get" name="searchForm" onsubmit="return submitRegularSearchRequest()">
-
- <div class="bar">
- <span class="leftcap"></span>
- <div class="search-bar">
- <a href="/my_videos_upload" id="upload-button" class="action-button">
- <span class="action-button-leftcap"></span>
- <span class="action-button-text">Upload</span>
- <span class="action-button-rightcap"></span>
- </a>
- <div id="search-form">
- <input id="search-term" name="search_query" type="text" tabindex="1" onkeyup="goog.i18n.bidi.setDirAttribute(event,this)" value="" maxlength="128" />
- <select class="search-type" name="search_type">
- <option value="">Videos</option>
- <option value="search_users" >Channels</option>
- </select>
- <input id="search-button" type="submit" value="Search" />
- </div>
- <div class="search-settings-link">
- <a href="#" class="eLink" onClick="return toggleAdvSearch('', '', '', '', '', '')">
- advanced
- </a></div>
- </div>
- <span class="rightcap"></span>
- </div>
-
- </form>
-
- <div id="search-advanced-form" class="hid">
- <div class="search-setting-inner alignC">Loading...</div>
- </div>
-
- <div class="clear"></div>
- </div>
- <div id="search-settings-clr" class="hid"></div>
-
-
-
-
-
-
-<div id="homepage-main-content">
- <div>
- <div id="active_sharing_div" name="active_sharing_div" style="display:block"></div>
- <script type="text/javascript">
- // <![CDATA[
- var fo = new SWFObject("active_sharing.swf", "active_sharing", "550", "115", 7, "#FFFFFF");
- var showstr = "Videos being watched right now...";
- fo.addParam('wmode', 'opaque');
- fo.addVariable("t", showstr);
- fo.write("active_sharing_div");
- // ]]>
- </script>
-</div>
-
- <div class="homepage-content-block" style="margin-left:18px; border:0px #CCC solid;">
- <div class="homepage-block-heading homepage-block-heading-gray">Promoted Videos</div>
- <div>
- <div class="homepage-sponsored-video marB0">
- <div class="videoIconWrapperOuter">
- <div class="videoIconWrapperInner">
- <div class="vstill"><a href="/cthru?key=YSqt3w6VDhuNgxUzVZsryt0JX30ll7tCIrBT--_pvAtRC3KmvsBYFaUNR1qT0d0BnBJYjHz_G7LIr21ufG7W6gJL7zPdHNbcmuIxaafL1yry8cdcqeEOTitWLXkpm2q2QnTAlp4chC1jus7JLVCnCdacl0xUeDk4Vk8e6q9htmGbDZPN9QMnHsrX2RZnvDMx-3Im14C3GKi4jI8ee-jnOQ==" name="&lid=DV+-+BasiaBulatInTheNight+-+beggars&lpos=hp-s0"><img src="http://i.ytimg.com/vi/CebHAvPHyyU/default.jpg" class="vimg120"></a></div>
- </div>
- </div>
-
- <div class="vtitle smallText">
- <a href="/cthru?key=YSqt3w6VDhuNgxUzVZsryt0JX30ll7tCIrBT--_pvAtRC3KmvsBYFaUNR1qT0d0BnBJYjHz_G7LIr21ufG7W6gJL7zPdHNbcmuIxaafL1yry8cdcqeEOTitWLXkpm2q2QnTAlp4chC1jus7JLVCnCdacl0xUeDk4Vk8e6q9htmGbDZPN9QMnHsrX2RZnvDMx-3Im14C3GKi4jI8ee-jnOQ==" name="&lid=DV+-+BasiaBulatInTheNight+-+beggars&lpos=hp-s0">Basia Bulat - In Th...</a>
- </div>
- <div class="vfacets" style="margin-bottom: 0px;">
- <a href="/user/beggars" class="dg">beggars</a>
- </div>
- </div>
- <div class="homepage-sponsored-video marB0">
- <div class="videoIconWrapperOuter">
- <div class="videoIconWrapperInner">
- <div class="vstill"><a href="/cthru?key=FIUXMxdvOKhDw2_wpR7bE9L-XUsHMZBHRpS_s21B0Kq0RTWlGXSqQ8bjw6tBQOUczUtO8b6_mktukdd5ChseYAl10dE5JQrlpiOQE6HNMOAsszaA0M9qhzFnOkWPrkFGMDW5vvaAOkIwas6ksi4e_R8wkiIhlNYPDiqi2f4LpVzB2jpe0LobjIEF9czWjFx9ymrPg8wx2x6w00jF-BzRfQ==" name="&lid=DV+-+Perfection+-+corporalcadet&lpos=hp-s1"><img src="http://i.ytimg.com/vi/Np4bhsmr3iE/default.jpg" class="vimg120"></a></div>
- </div>
- </div>
-
- <div class="vtitle smallText">
- <a href="/cthru?key=FIUXMxdvOKhDw2_wpR7bE9L-XUsHMZBHRpS_s21B0Kq0RTWlGXSqQ8bjw6tBQOUczUtO8b6_mktukdd5ChseYAl10dE5JQrlpiOQE6HNMOAsszaA0M9qhzFnOkWPrkFGMDW5vvaAOkIwas6ksi4e_R8wkiIhlNYPDiqi2f4LpVzB2jpe0LobjIEF9czWjFx9ymrPg8wx2x6w00jF-BzRfQ==" name="&lid=DV+-+Perfection+-+corporalcadet&lpos=hp-s1">Perfection</a>
- </div>
- <div class="vfacets" style="margin-bottom: 0px;">
- <a href="/user/corporalcadet" class="dg">corporalcadet</a>
- </div>
- </div>
- <div class="homepage-sponsored-video marB0">
- <div class="videoIconWrapperOuter">
- <div class="videoIconWrapperInner">
- <div class="vstill"><a href="/cthru?key=1W2J508g9g7Bjsvodsvq3GHZo25JkqX7Js5JSHnyP1yZYB96KDh2LTC2pCKjeHc7LEiTUU4uhuwsrTzZfns_IR2dsA7leCUYMtvgq3noBHy-G0jTHmgiQtFUVTDU3jT2EkS39J6Ur2qxtHwAmybMcU83hK1guqpPdryKOfcbHovo-Kbwglzbbl28LrK1iNdz5E6NZ5CZCVZrYxldbWyjEA==" name="&lid=DV+-+WhatmatterstoyoumeVFS+-+Jr0canest&lpos=hp-s2"><img src="http://i.ytimg.com/vi/KExoP97KUnY/default.jpg" class="vimg120"></a></div>
- </div>
- </div>
-
- <div class="vtitle smallText">
- <a href="/cthru?key=1W2J508g9g7Bjsvodsvq3GHZo25JkqX7Js5JSHnyP1yZYB96KDh2LTC2pCKjeHc7LEiTUU4uhuwsrTzZfns_IR2dsA7leCUYMtvgq3noBHy-G0jTHmgiQtFUVTDU3jT2EkS39J6Ur2qxtHwAmybMcU83hK1guqpPdryKOfcbHovo-Kbwglzbbl28LrK1iNdz5E6NZ5CZCVZrYxldbWyjEA==" name="&lid=DV+-+WhatmatterstoyoumeVFS+-+Jr0canest&lpos=hp-s2">What matters to you...</a>
- </div>
- <div class="vfacets" style="margin-bottom: 0px;">
- <a href="/user/Jr0canest" class="dg">Jr0canest</a>
- </div>
- </div>
- <div class="homepage-sponsored-video marB0">
- <div class="videoIconWrapperOuter">
- <div class="videoIconWrapperInner">
- <div class="vstill"><a href="/cthru?key=idL1slcMKbuzX2MFZaS-nifq5PWrCKLUZMXEPqCthRVET6PQSkxlmKQVMNmQvlYpQlFISkRprfO113rH-ER0ytYh0zSMWI4XbaO74zcrIZiSpB3oISku9zIGUwS5WI03Y0ZiHbGAC9GIYziEcRcgzcEYuizlUwNvTWDgNSvrCJHcyPYokMUjLjcwqD2wEEAe7jfIfcJRNl3sW7ODuiN_MA==" name="&lid=DV+-+LIfeisaMasquerade+-+bananaruthy&lpos=hp-s3"><img src="http://i.ytimg.com/vi/l9gjk5hHiGM/default.jpg" class="vimg120"></a></div>
- </div>
- </div>
-
- <div class="vtitle smallText">
- <a href="/cthru?key=idL1slcMKbuzX2MFZaS-nifq5PWrCKLUZMXEPqCthRVET6PQSkxlmKQVMNmQvlYpQlFISkRprfO113rH-ER0ytYh0zSMWI4XbaO74zcrIZiSpB3oISku9zIGUwS5WI03Y0ZiHbGAC9GIYziEcRcgzcEYuizlUwNvTWDgNSvrCJHcyPYokMUjLjcwqD2wEEAe7jfIfcJRNl3sW7ODuiN_MA==" name="&lid=DV+-+LIfeisaMasquerade+-+bananaruthy&lpos=hp-s3">LIfe is a Masquerade.</a>
- </div>
- <div class="vfacets" style="margin-bottom: 0px;">
- <a href="/user/bananaruthy" class="dg">bananaruthy</a>
- </div>
- </div>
- <div class="clearL" style="height: 1px;"></div>
- </div>
- </div>
-
-
- <div id="homepage-featured-heading">
- <div id="homepage-featured-more-top"><a id="hpVideoListMoreLink" href="/browse?s=rf">See More Featured Videos</a></div>
- <h1 id="hpVideoListHead">Featured Videos</h1>
- </div>
-
- <div id="homepage-featured-tabs">
- <a href="#" id="hpTopFavoritesLink" name="&lid=hpTopFavoritesTab&lpos=hpTabs" onclick="swapVideoList(this); return false;">Top Favorites</a>
- <a href="#" id="hpMostDiscussedLink" name="&lid=hpMostDiscussedTab&lpos=hpTabs" onclick="swapVideoList(this); return false;">Most Discussed</a>
- <a href="#" id="hpMostViewedLink" name="&lid=hpMostViewedTab&lpos=hpTabs" onclick="swapVideoList(this); return false;">Most Viewed</a>
- <a href="#" id="hpFeaturedLink" name="&lid=hpFeaturedTab&lpos=hpTabs" onclick="swapVideoList(this); return false;" class="first hilite">Featured</a>
- <div class="clear"></div>
- </div>
-
-
-
- <div id="homepage-video-list" class="browseListView">
- <div id="hpFeatured">
-
-
-
-
- <div class="vlentry" >
-
- <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=uu-NTSZ27b0"><img src="http://i.ytimg.com/vi/uu-NTSZ27b0/default.jpg" class="vimg120" title="Caribbean PVC Marimba Children's Orchestra" qliconalt="uu-NTSZ27b0" alt="video"></a></div></div> </div>
-
- <div class="vldescbox">
- <div class="vltitle">
- <div class="vlshortTitle">
- <a href="/watch?v=uu-NTSZ27b0" title="Caribbean PVC Marimba Children's Orchestra" onclick="_hbLink('CaribbeanPVCMarimbaChildrensOrchestra','VidVert');">Caribbean PVC Marimba Children's...</a>
- </div>
- <div class="vllongTitle">
- <a href="/watch?v=uu-NTSZ27b0" title="Caribbean PVC Marimba Children's Orchestra" onclick="_hbLink('CaribbeanPVCMarimbaChildrensOrchestra','VidVert');">Caribbean PVC Marimba Children's Orchestra</a>
- </div>
- </div>
-
- <div class="vldesc">
-
-
- <span id="BeginvidDescuuNTSZ27b0">
- Michael Greiner who is a neighbor and good friend of mine asked me to upload several Marim
- </span>
-
- <span id="RemainvidDescuuNTSZ27b0" style="display: none">Michael Greiner who is a neighbor and good friend of mine asked me to upload several Marimba videos for him (that's him on the left in the middle row). He currently teaches the music program at Aveson Charter School http://aveson.org/ and constructs musical instruments in classes with students' participation.<br/><br/>Michael Greiner created this set of plastic pipe marimbas. On this clip are three generations of prototypes designed to be low cost for use by childrens' programming. The top one bass version costs around $200 in materials. The mallets are home made using foam flip-flops mounted to sticks. Filmed at Norma Coombs primary school in Altadena CA in 2007.<br/><br/>*** Edited to Add ****<br/>Wow, it looks like this video's hit YouTube's front page. Thank you for all the wonderfully kind and supportive comments!</span>
- <span id="MorevidDescuuNTSZ27b0" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescuuNTSZ27b0'); hideDiv('MorevidDescuuNTSZ27b0'); hideDiv('BeginvidDescuuNTSZ27b0'); showDiv('LessvidDescuuNTSZ27b0'); return false;">more</a>)</span>
- <span id="LessvidDescuuNTSZ27b0" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescuuNTSZ27b0'); hideDiv('LessvidDescuuNTSZ27b0'); showDiv('BeginvidDescuuNTSZ27b0'); showDiv('MorevidDescuuNTSZ27b0'); return false;">less</a>)</span>
-
-
-
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
- </div>
-
- <div class="vlfacets">
- <div class="vladded">
- </div>
- <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/PlayHanghang">PlayHanghang</a></span></div>
- <div class="clearL"></div>
- <span class="grayText">Views:</span> 3,853<br/>
-
- <div class="video-thumb-duration-rating">
-
-
- <div>
-
- <img class="ratingVS ratingVS-5.0" alt="4.84814814815" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" />
-
-
-
- </div>
-
-
-
- <div class="runtime">01:46</div>
- </div>
-
- <div class="clear"></div>
- <div class="vlcategory">
- <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=24">Entertainment</a>
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
-
- </div> <!-- end vEntry -->
-
-
-
-
-
-
- <div class="vlentry" >
-
- <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=CFJRn7akXeQ"><img src="http://i.ytimg.com/vi/CFJRn7akXeQ/default.jpg" class="vimg120" title="&quot;Sharp Teeth&quot; Excerpt #1" qliconalt="CFJRn7akXeQ" alt="video"></a></div></div> </div>
-
- <div class="vldescbox">
- <div class="vltitle">
- <div class="vlshortTitle">
- <a href="/watch?v=CFJRn7akXeQ" title="&quot;Sharp Teeth&quot; Excerpt #1" onclick="_hbLink('SharpTeethExcerpt1','VidVert');">&quot;Sharp Teeth&quot; Excerpt #1</a>
- </div>
- <div class="vllongTitle">
- <a href="/watch?v=CFJRn7akXeQ" title="&quot;Sharp Teeth&quot; Excerpt #1" onclick="_hbLink('SharpTeethExcerpt1','VidVert');">&quot;Sharp Teeth&quot; Excerpt #1</a>
- </div>
- </div>
-
- <div class="vldesc">
-
-
- <span id="BeginvidDescCFJRn7akXeQ">
- Check out the book "Sharp Teeth" on Amazon:<br/>http://www.amazon.com/Sharp-Teeth-Toby-Barlow
- </span>
-
- <span id="RemainvidDescCFJRn7akXeQ" style="display: none">Check out the book "Sharp Teeth" on Amazon:<br/>http://www.amazon.com/Sharp-Teeth-Toby-Barlow/dp/0061430226/ ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1212767529&sr=8-1<br/><br/>Animation directed by Limbert Fabian. Produced by Matt Thunell. For more information go to sharpteeththebook.com</span>
- <span id="MorevidDescCFJRn7akXeQ" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescCFJRn7akXeQ'); hideDiv('MorevidDescCFJRn7akXeQ'); hideDiv('BeginvidDescCFJRn7akXeQ'); showDiv('LessvidDescCFJRn7akXeQ'); return false;">more</a>)</span>
- <span id="LessvidDescCFJRn7akXeQ" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescCFJRn7akXeQ'); hideDiv('LessvidDescCFJRn7akXeQ'); showDiv('BeginvidDescCFJRn7akXeQ'); showDiv('MorevidDescCFJRn7akXeQ'); return false;">less</a>)</span>
-
-
-
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
- </div>
-
- <div class="vlfacets">
- <div class="vladded">
- </div>
- <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/tobybarlowny">tobybarlowny</a></span></div>
- <div class="clearL"></div>
- <span class="grayText">Views:</span> 67,438<br/>
-
- <div class="video-thumb-duration-rating">
-
-
- <div>
-
- <img class="ratingVS ratingVS-4.5" alt="4.39928057554" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" />
-
-
-
- </div>
-
-
-
- <div class="runtime">01:33</div>
- </div>
-
- <div class="clear"></div>
- <div class="vlcategory">
- <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=1">Film & Animation</a>
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
-
- </div> <!-- end vEntry -->
-
-
-
-
-
-
- <div class="vlentry" >
-
- <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=sNROaXA6OSI"><img src="http://i.ytimg.com/vi/sNROaXA6OSI/default.jpg" class="vimg120" title="Touring to Alaska on Vegetable Oil!" qliconalt="sNROaXA6OSI" alt="video"></a></div></div> </div>
-
- <div class="vldescbox">
- <div class="vltitle">
- <div class="vlshortTitle">
- <a href="/watch?v=sNROaXA6OSI" title="Touring to Alaska on Vegetable Oil!" onclick="_hbLink('TouringtoAlaskaonVegetableOil','VidVert');">Touring to Alaska on Vegetable Oil!</a>
- </div>
- <div class="vllongTitle">
- <a href="/watch?v=sNROaXA6OSI" title="Touring to Alaska on Vegetable Oil!" onclick="_hbLink('TouringtoAlaskaonVegetableOil','VidVert');">Touring to Alaska on Vegetable Oil!</a>
- </div>
- </div>
-
- <div class="vldesc">
-
-
- <span id="BeginvidDescsNROaXA6OSI">
- This video is for Mrs. Aderman's 1st Period Environmental Science Class.<br/><br/>We are Mose Gi
- </span>
-
- <span id="RemainvidDescsNROaXA6OSI" style="display: none">This video is for Mrs. Aderman's 1st Period Environmental Science Class.<br/><br/>We are Mose Giganticus and The Emotron and this year we are touring to Alaska on Vegetable Oil.</span>
- <span id="MorevidDescsNROaXA6OSI" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescsNROaXA6OSI'); hideDiv('MorevidDescsNROaXA6OSI'); hideDiv('BeginvidDescsNROaXA6OSI'); showDiv('LessvidDescsNROaXA6OSI'); return false;">more</a>)</span>
- <span id="LessvidDescsNROaXA6OSI" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescsNROaXA6OSI'); hideDiv('LessvidDescsNROaXA6OSI'); showDiv('BeginvidDescsNROaXA6OSI'); showDiv('MorevidDescsNROaXA6OSI'); return false;">less</a>)</span>
-
-
-
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
- </div>
-
- <div class="vlfacets">
- <div class="vladded">
- </div>
- <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/kylemotron">kylemotron</a></span></div>
- <div class="clearL"></div>
- <span class="grayText">Views:</span> 122,748<br/>
-
- <div class="video-thumb-duration-rating">
-
-
- <div>
-
- <img class="ratingVS ratingVS-4.5" alt="4.44329896907" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" />
-
-
-
- </div>
-
-
-
- <div class="runtime">04:02</div>
- </div>
-
- <div class="clear"></div>
- <div class="vlcategory">
- <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=27">Education</a>
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
-
- </div> <!-- end vEntry -->
-
-
-
-
-
-
- <div class="vlentry" >
-
- <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=6iC3b5JnSIE"><img src="http://i.ytimg.com/vi/6iC3b5JnSIE/default.jpg" class="vimg120" title="JCJC" qliconalt="6iC3b5JnSIE" alt="video"></a></div></div> </div>
-
- <div class="vldescbox">
- <div class="vltitle">
- <div class="vlshortTitle">
- <a href="/watch?v=6iC3b5JnSIE" title="JCJC" onclick="_hbLink('JCJC','VidVert');">JCJC</a>
- </div>
- <div class="vllongTitle">
- <a href="/watch?v=6iC3b5JnSIE" title="JCJC" onclick="_hbLink('JCJC','VidVert');">JCJC</a>
- </div>
- </div>
-
- <div class="vldesc">
-
-
- <span id="BeginvidDesc6iC3b5JnSIE">
- His name is Okotanpe. <br/>His mail addless is fuseloopa@hotmail.com <br/><br/>The name of this son
- </span>
-
- <span id="RemainvidDesc6iC3b5JnSIE" style="display: none">His name is Okotanpe. <br/>His mail addless is fuseloopa@hotmail.com <br/><br/>The name of this song is 300ml(milk).<br/>An artist name is Rei harakami. <br/>Check it out!</span>
- <span id="MorevidDesc6iC3b5JnSIE" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDesc6iC3b5JnSIE'); hideDiv('MorevidDesc6iC3b5JnSIE'); hideDiv('BeginvidDesc6iC3b5JnSIE'); showDiv('LessvidDesc6iC3b5JnSIE'); return false;">more</a>)</span>
- <span id="LessvidDesc6iC3b5JnSIE" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDesc6iC3b5JnSIE'); hideDiv('LessvidDesc6iC3b5JnSIE'); showDiv('BeginvidDesc6iC3b5JnSIE'); showDiv('MorevidDesc6iC3b5JnSIE'); return false;">less</a>)</span>
-
-
-
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
- </div>
-
- <div class="vlfacets">
- <div class="vladded">
- </div>
- <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/YoneyaYu">YoneyaYu</a></span></div>
- <div class="clearL"></div>
- <span class="grayText">Views:</span> 532,447<br/>
-
- <div class="video-thumb-duration-rating">
-
-
- <div>
-
- <img class="ratingVS ratingVS-5.0" alt="4.83995523223" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" />
-
-
-
- </div>
-
-
-
- <div class="runtime">05:26</div>
- </div>
-
- <div class="clear"></div>
- <div class="vlcategory">
- <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=24">Entertainment</a>
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
-
- </div> <!-- end vEntry -->
-
-
-
-
-
-
- <div class="vlentry" >
-
- <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=L9Wu1V1JAHw"><img src="http://i.ytimg.com/vi/L9Wu1V1JAHw/default.jpg" class="vimg120" title="Certainty In Freedom ~ A Song for Burma (Original Song)" qliconalt="L9Wu1V1JAHw" partner="true" alt="video"></a></div></div> </div>
-
- <div class="vldescbox">
- <div class="vltitle">
- <div class="vlshortTitle">
- <a href="/watch?v=L9Wu1V1JAHw" title="Certainty In Freedom ~ A Song for Burma (Original Song)" onclick="_hbLink('CertaintyInFreedomASongforBurmaOriginalSong','VidVert');">Certainty In Freedom ~ A Song fo...</a>
- </div>
- <div class="vllongTitle">
- <a href="/watch?v=L9Wu1V1JAHw" title="Certainty In Freedom ~ A Song for Burma (Original Song)" onclick="_hbLink('CertaintyInFreedomASongforBurmaOriginalSong','VidVert');">Certainty In Freedom ~ A Song for Burma (Original Song)</a>
- </div>
- </div>
-
- <div class="vldesc">
-
-
- <span id="BeginvidDescL9Wu1V1JAHw">
- I'm not a particularly political person, by which I mean I'd sooner just not get involved
- </span>
-
- <span id="RemainvidDescL9Wu1V1JAHw" style="display: none">I'm not a particularly political person, by which I mean I'd sooner just not get involved in conflict, but I realise that, at times, things happen outside your control which will you to say something or do something.<br/><br/>I got a comment on my last song from 'gersing' asking me if I'd sing a song for the monks and people of Burma. At first I misunderstood the comment but then it clicked and I felt compelled to offer something.. anything. <br/><br/>I know this song is going to change nothing; and I'm cautious calling it a protest song as I don't understand the situation fully (and I wouldn't want to upset anyone), but this is a tune I wrote in response to being repressed (I'm whatever guise) and how beautiful 'freedom' really is. I don't think anyone will ever understand that term fully but by singing and writing and thinking and speaking we can come somewhere close I'm sure. <br/><br/>As a disclaimer, I'd say that, personally, the chords and melody are arbitrary; merely the carrier of the sentiment...<br/><br/>Changing the subject ever so slightly I just wanted to say a big thank you to everyone that's shown support; it's overwhelming. An apology to anyone I've not yet responded to.. I've never been very good at juggling my time but I will be in touch.<br/><br/>Thanks again...<br/><br/>_________________<br/>Certainty In Freedom<br/><br/>If I had the will to talk<br/>I wonder if you'd give a thought <br/>To what I had to say - help make it go away<br/><br/>Cos there's certainty in freedom<br/>And in that we must believe in<br/>Cos I saw on the news today<br/><br/>If I saw you in the street now<br/>Would I look the other way?<br/>I hope I'm strong enough to say - help make it go away<br/><br/>When all you see is hatred<br/>Spirits crushed and souls deflated<br/>Easy to leave it for another day<br/><br/>Peace is pushing for love<br/>Love is leading the way<br/>You should follow its path<br/>Darkness leads you astray<br/>Peace is pushing for love<br/>Love is leading the way<br/><br/>So this, my only voice to speak<br/>My message strong, my tone is weak<br/>I find it hard to say - help make it go away<br/><br/>And if I come across obtuse<br/>I urge you now to cut the noose<br/>Don't leave it for another day<br/><br/>Peace is pushing for love<br/>Love is leading the way<br/>You should follow its path<br/>Darkness leads you astray<br/>Peace is pushing for love<br/>Love is leading the way<br/><br/>If I had the will to talk<br/>I wonder if you'd give a thought <br/>To what I had to say - help make it go away<br/><br/>Cos there's certainty in freedom<br/>And in that we must believe in<br/>Cos I saw on the news today<br/><br/>Peace is pushing for love<br/>Love is leading the way<br/>You should follow its path<br/>Darkness leads you astray<br/>Peace is pushing for love<br/>Love is leading the way<br/><br/>_____________________<br/>Peace<br/><br/>Available on the 'Unequal Measures', available through http://www.krisrowley.com<br/>© Kris Rowley 2007</span>
- <span id="MorevidDescL9Wu1V1JAHw" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescL9Wu1V1JAHw'); hideDiv('MorevidDescL9Wu1V1JAHw'); hideDiv('BeginvidDescL9Wu1V1JAHw'); showDiv('LessvidDescL9Wu1V1JAHw'); return false;">more</a>)</span>
- <span id="LessvidDescL9Wu1V1JAHw" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescL9Wu1V1JAHw'); hideDiv('LessvidDescL9Wu1V1JAHw'); showDiv('BeginvidDescL9Wu1V1JAHw'); showDiv('MorevidDescL9Wu1V1JAHw'); return false;">less</a>)</span>
-
-
-
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
- </div>
-
- <div class="vlfacets">
- <div class="vladded">
- </div>
- <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/zzzzzzzzap">zzzzzzzzap</a></span></div>
- <div class="clearL"></div>
- <span class="grayText">Views:</span> 136,222<br/>
-
- <div class="video-thumb-duration-rating">
-
-
- <div>
-
- <img class="ratingVS ratingVS-4.5" alt="4.65044814341" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" />
-
-
-
- </div>
-
-
-
- <div class="runtime">03:55</div>
- </div>
-
- <div class="clear"></div>
- <div class="vlcategory">
- <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=10">Music</a>
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
-
- </div> <!-- end vEntry -->
-
-
-
-
-
-
- <div class="vlentry" >
-
- <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=gQNY7Sti8FY"><img src="http://s4.ytimg.com/vi/gQNY7Sti8FY/default.jpg" class="vimg120" title="the world is at your fingertips" qliconalt="gQNY7Sti8FY" partner="true" alt="video"></a></div></div> </div>
-
- <div class="vldescbox">
- <div class="vltitle">
- <div class="vlshortTitle">
- <a href="/watch?v=gQNY7Sti8FY" title="the world is at your fingertips" onclick="_hbLink('theworldisatyourfingertips','VidVert');">the world is at your fingertips</a>
- </div>
- <div class="vllongTitle">
- <a href="/watch?v=gQNY7Sti8FY" title="the world is at your fingertips" onclick="_hbLink('theworldisatyourfingertips','VidVert');">the world is at your fingertips</a>
- </div>
- </div>
-
- <div class="vldesc">
-
-
- <span id="BeginvidDescgQNY7Sti8FY">
- for the taking.
- </span>
-
-
-
-
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
- </div>
-
- <div class="vlfacets">
- <div class="vladded">
- </div>
- <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/SupaDupaFlyGirl">SupaDupaFlyGirl</a></span></div>
- <div class="clearL"></div>
- <span class="grayText">Views:</span> 509,825<br/>
-
- <div class="video-thumb-duration-rating">
-
-
- <div>
-
- <img class="ratingVS ratingVS-4.0" alt="3.91057134971" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" />
-
-
-
- </div>
-
-
-
- <div class="runtime">05:15</div>
- </div>
-
- <div class="clear"></div>
- <div class="vlcategory">
- <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=28">Science & Technology</a>
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
-
- </div> <!-- end vEntry -->
-
-
-
-
-
-
- <div class="vlentry" >
-
- <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=rGUt7ropzNA"><img src="http://i.ytimg.com/vi/rGUt7ropzNA/default.jpg" class="vimg120" title="Aimee Mann Freeway Video Contest" qliconalt="rGUt7ropzNA" alt="video"></a></div></div> </div>
-
- <div class="vldescbox">
- <div class="vltitle">
- <div class="vlshortTitle">
- <a href="/watch?v=rGUt7ropzNA" title="Aimee Mann Freeway Video Contest" onclick="_hbLink('AimeeMannFreewayVideoContest','VidVert');">Aimee Mann Freeway Video Contest</a>
- </div>
- <div class="vllongTitle">
- <a href="/watch?v=rGUt7ropzNA" title="Aimee Mann Freeway Video Contest" onclick="_hbLink('AimeeMannFreewayVideoContest','VidVert');">Aimee Mann Freeway Video Contest</a>
- </div>
- </div>
-
- <div class="vldesc">
-
-
- <span id="BeginvidDescrGUt7ropzNA">
- Want a chance to sing with Aimee Mann live? Go to http://www.youtube.com/group/aimeemannco
- </span>
-
- <span id="RemainvidDescrGUt7ropzNA" style="display: none">Want a chance to sing with Aimee Mann live? Go to http://www.youtube.com/group/aimeemanncontest and upload a video of yourself singing Aimee Mann's new song "Freeway."<br/><br/>Aimee Mann and SuperEgo Records will pick their favorite entry to be featured on YouTube and www.aimeemann.com. The winner will have an opportunity to sing live with Aimee at one of her upcoming shows. Ten runners-up will receive an autographed copy of Aimee's new CD, @#%&*! Smilers.<br/><br/>Entrants can get the lyrics, the instrumental version of "Freeway" and contest details at: http://www.aimeemann.com/freewaycontest/<br/>Submissions must be received by July 7th 2008</span>
- <span id="MorevidDescrGUt7ropzNA" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescrGUt7ropzNA'); hideDiv('MorevidDescrGUt7ropzNA'); hideDiv('BeginvidDescrGUt7ropzNA'); showDiv('LessvidDescrGUt7ropzNA'); return false;">more</a>)</span>
- <span id="LessvidDescrGUt7ropzNA" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescrGUt7ropzNA'); hideDiv('LessvidDescrGUt7ropzNA'); showDiv('BeginvidDescrGUt7ropzNA'); showDiv('MorevidDescrGUt7ropzNA'); return false;">less</a>)</span>
-
-
-
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
- </div>
-
- <div class="vlfacets">
- <div class="vladded">
- </div>
- <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/aimeemann">aimeemann</a></span></div>
- <div class="clearL"></div>
- <span class="grayText">Views:</span> 283,776<br/>
-
- <div class="video-thumb-duration-rating">
-
-
- <div>
-
- <img class="ratingVS ratingVS-4.0" alt="3.79036827195" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" />
-
-
-
- </div>
-
-
-
- <div class="runtime">02:22</div>
- </div>
-
- <div class="clear"></div>
- <div class="vlcategory">
- <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=10">Music</a>
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
-
- </div> <!-- end vEntry -->
-
-
-
-
-
-
- <div class="vlentry" >
-
- <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=tbEei0I3kMQ"><img src="http://i.ytimg.com/vi/tbEei0I3kMQ/default.jpg" class="vimg120" title="Interactive card trick" qliconalt="tbEei0I3kMQ" alt="video"></a></div></div> </div>
-
- <div class="vldescbox">
- <div class="vltitle">
- <div class="vlshortTitle">
- <a href="/watch?v=tbEei0I3kMQ" title="Interactive card trick" onclick="_hbLink('Interactivecardtrick','VidVert');">Interactive card trick</a>
- </div>
- <div class="vllongTitle">
- <a href="/watch?v=tbEei0I3kMQ" title="Interactive card trick" onclick="_hbLink('Interactivecardtrick','VidVert');">Interactive card trick</a>
- </div>
- </div>
-
- <div class="vldesc">
-
-
- <span id="BeginvidDesctbEei0I3kMQ">
- This is the first interactive video on YouTube!<br/>Have fun and enjoy the show<br/>you can see
- </span>
-
- <span id="RemainvidDesctbEei0I3kMQ" style="display: none">This is the first interactive video on YouTube!<br/>Have fun and enjoy the show<br/>you can see our magician site:<br/>orenshalom.co.il</span>
- <span id="MorevidDesctbEei0I3kMQ" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDesctbEei0I3kMQ'); hideDiv('MorevidDesctbEei0I3kMQ'); hideDiv('BeginvidDesctbEei0I3kMQ'); showDiv('LessvidDesctbEei0I3kMQ'); return false;">more</a>)</span>
- <span id="LessvidDesctbEei0I3kMQ" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDesctbEei0I3kMQ'); hideDiv('LessvidDesctbEei0I3kMQ'); showDiv('BeginvidDesctbEei0I3kMQ'); showDiv('MorevidDesctbEei0I3kMQ'); return false;">less</a>)</span>
-
-
-
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
- </div>
-
- <div class="vlfacets">
- <div class="vladded">
- </div>
- <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/werneroi">werneroi</a></span></div>
- <div class="clearL"></div>
- <span class="grayText">Views:</span> 3,155,063<br/>
-
- <div class="video-thumb-duration-rating">
-
-
- <div>
-
- <img class="ratingVS ratingVS-3.5" alt="3.41263230956" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" />
-
-
-
- </div>
-
-
-
- <div class="runtime">01:10</div>
- </div>
-
- <div class="clear"></div>
- <div class="vlcategory">
- <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=22">People & Blogs</a>
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
-
- </div> <!-- end vEntry -->
-
-
-
-
-
-
- <div class="vlentry" >
-
- <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=irDEzQovftM"><img src="http://i.ytimg.com/vi/irDEzQovftM/default.jpg" class="vimg120" title="Biggest drawing in the world" qliconalt="irDEzQovftM" alt="video"></a></div></div> </div>
-
- <div class="vldescbox">
- <div class="vltitle">
- <div class="vlshortTitle">
- <a href="/watch?v=irDEzQovftM" title="Biggest drawing in the world" onclick="_hbLink('Biggestdrawingintheworld','VidVert');">Biggest drawing in the world</a>
- </div>
- <div class="vllongTitle">
- <a href="/watch?v=irDEzQovftM" title="Biggest drawing in the world" onclick="_hbLink('Biggestdrawingintheworld','VidVert');">Biggest drawing in the world</a>
- </div>
- </div>
-
- <div class="vldesc">
-
-
- <span id="BeginvidDescirDEzQovftM">
- making the biggest drawing in the world
- </span>
-
-
-
-
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
- </div>
-
- <div class="vlfacets">
- <div class="vladded">
- </div>
- <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/erikbjgn">erikbjgn</a></span></div>
- <div class="clearL"></div>
- <span class="grayText">Views:</span> 971,773<br/>
-
- <div class="video-thumb-duration-rating">
-
-
- <div>
-
- <img class="ratingVS ratingVS-4.5" alt="4.54770783066" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" />
-
-
-
- </div>
-
-
-
- <div class="runtime">04:04</div>
- </div>
-
- <div class="clear"></div>
- <div class="vlcategory">
- <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=1">Film & Animation</a>
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
-
- </div> <!-- end vEntry -->
-
-
-
-
-
-
- <div class="vlentry" >
-
- <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=iAKJKBCyPUY"><img src="http://i.ytimg.com/vi/iAKJKBCyPUY/default.jpg" class="vimg120" title="Checkmate" qliconalt="iAKJKBCyPUY" alt="video"></a></div></div> </div>
-
- <div class="vldescbox">
- <div class="vltitle">
- <div class="vlshortTitle">
- <a href="/watch?v=iAKJKBCyPUY" title="Checkmate" onclick="_hbLink('Checkmate','VidVert');">Checkmate</a>
- </div>
- <div class="vllongTitle">
- <a href="/watch?v=iAKJKBCyPUY" title="Checkmate" onclick="_hbLink('Checkmate','VidVert');">Checkmate</a>
- </div>
- </div>
-
- <div class="vldesc">
-
-
- <span id="BeginvidDesciAKJKBCyPUY">
- The Internets Celebrities Dallas Penn and Rafi Kam go in for an investigative report on Ch
- </span>
-
- <span id="RemainvidDesciAKJKBCyPUY" style="display: none">The Internets Celebrities Dallas Penn and Rafi Kam go in for an investigative report on Check-Cashing. Themes explored include usury, economic instability, commercial banks and their profit line, and the cycle of poverty. <br/><br/>Oh yeah, it's a comedy.<br/><br/>The video is shot on location in Bushwick and Carroll Gardens in Brooklyn, New York. Also stars special guest Internets Celebrity Ben Popken of Consumerist.com.<br/><br/>Directed by Casimir Nozkowski<br/>Shot by Ian Savage, Josh Weisbrot<br/>Music by El Keter; instrumental from song "The Bottom Line" off Sankofa's album The Tortoise Hustle. Used with full permission.<br/><br/>http://www.internetscelebrities.com</span>
- <span id="MorevidDesciAKJKBCyPUY" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDesciAKJKBCyPUY'); hideDiv('MorevidDesciAKJKBCyPUY'); hideDiv('BeginvidDesciAKJKBCyPUY'); showDiv('LessvidDesciAKJKBCyPUY'); return false;">more</a>)</span>
- <span id="LessvidDesciAKJKBCyPUY" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDesciAKJKBCyPUY'); hideDiv('LessvidDesciAKJKBCyPUY'); showDiv('BeginvidDesciAKJKBCyPUY'); showDiv('MorevidDesciAKJKBCyPUY'); return false;">less</a>)</span>
-
-
-
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
- </div>
-
- <div class="vlfacets">
- <div class="vladded">
- </div>
- <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/InternetsCelebrities">InternetsCel...</a></span></div>
- <div class="clearL"></div>
- <span class="grayText">Views:</span> 412,830<br/>
-
- <div class="video-thumb-duration-rating">
-
-
- <div>
-
- <img class="ratingVS ratingVS-4.5" alt="4.52936962751" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" />
-
-
-
- </div>
-
-
-
- <div class="runtime">09:45</div>
- </div>
-
- <div class="clear"></div>
- <div class="vlcategory">
- <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=25">News & Politics</a>
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
-
- </div> <!-- end vEntry -->
-
-
-
-
-
-
- <div class="vlentry" >
-
- <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=yLCl0xIg5-0"><img src="http://i.ytimg.com/vi/yLCl0xIg5-0/default.jpg" class="vimg120" title="Stories from the Front lines, Part 1" qliconalt="yLCl0xIg5-0" alt="video"></a></div></div> </div>
-
- <div class="vldescbox">
- <div class="vltitle">
- <div class="vlshortTitle">
- <a href="/watch?v=yLCl0xIg5-0" title="Stories from the Front lines, Part 1" onclick="_hbLink('StoriesfromtheFrontlinesPart1','VidVert');">Stories from the Front lines, Pa...</a>
- </div>
- <div class="vllongTitle">
- <a href="/watch?v=yLCl0xIg5-0" title="Stories from the Front lines, Part 1" onclick="_hbLink('StoriesfromtheFrontlinesPart1','VidVert');">Stories from the Front lines, Part 1</a>
- </div>
- </div>
-
- <div class="vldesc">
-
-
- <span id="BeginvidDescyLCl0xIg50">
- Stories from the men and women of the miltary, stationed in the Al Anbar Province. Right f
- </span>
-
- <span id="RemainvidDescyLCl0xIg50" style="display: none">Stories from the men and women of the miltary, stationed in the Al Anbar Province. Right from the mouths of the troops themselves. Part 1 of 4</span>
- <span id="MorevidDescyLCl0xIg50" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescyLCl0xIg50'); hideDiv('MorevidDescyLCl0xIg50'); hideDiv('BeginvidDescyLCl0xIg50'); showDiv('LessvidDescyLCl0xIg50'); return false;">more</a>)</span>
- <span id="LessvidDescyLCl0xIg50" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescyLCl0xIg50'); hideDiv('LessvidDescyLCl0xIg50'); showDiv('BeginvidDescyLCl0xIg50'); showDiv('MorevidDescyLCl0xIg50'); return false;">less</a>)</span>
-
-
-
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
- </div>
-
- <div class="vlfacets">
- <div class="vladded">
- </div>
- <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/3rdID8487">3rdID8487</a></span></div>
- <div class="clearL"></div>
- <span class="grayText">Views:</span> 367,189<br/>
-
- <div class="video-thumb-duration-rating">
-
-
- <div>
-
- <img class="ratingVS ratingVS-4.0" alt="4.2188365651" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" />
-
-
-
- </div>
-
-
-
- <div class="runtime">10:35</div>
- </div>
-
- <div class="clear"></div>
- <div class="vlcategory">
- <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=25">News & Politics</a>
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
-
- </div> <!-- end vEntry -->
-
-
-
-
-
-
- <div class="vlentry" >
-
- <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=rFItE14EeSU"><img src="http://i.ytimg.com/vi/rFItE14EeSU/default.jpg" class="vimg120" title="Amazing video of multiple tornadoes in Northwest Kansas" qliconalt="rFItE14EeSU" partner="true" alt="video"></a></div></div> </div>
-
- <div class="vldescbox">
- <div class="vltitle">
- <div class="vlshortTitle">
- <a href="/watch?v=rFItE14EeSU" title="Amazing video of multiple tornadoes in Northwest Kansas" onclick="_hbLink('AmazingvideoofmultipletornadoesinNorthwestKansas','VidVert');">Amazing video of multiple tornad...</a>
- </div>
- <div class="vllongTitle">
- <a href="/watch?v=rFItE14EeSU" title="Amazing video of multiple tornadoes in Northwest Kansas" onclick="_hbLink('AmazingvideoofmultipletornadoesinNorthwestKansas','VidVert');">Amazing video of multiple tornadoes in Northwest Kansas</a>
- </div>
- </div>
-
- <div class="vldesc">
-
-
- <span id="BeginvidDescrFItE14EeSU">
- Video from TornadoVideos.net Live Stream Unit 3 of several tornadoes from close range.. In
- </span>
-
- <span id="RemainvidDescrFItE14EeSU" style="display: none">Video from TornadoVideos.net Live Stream Unit 3 of several tornadoes from close range.. Including one beautiful but strong rope and a large wedge tornado from within 1/2 mile. Check out TornadoVdeos.net for live streaming video, breaking weather news, and more extreme tornado footage.</span>
- <span id="MorevidDescrFItE14EeSU" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescrFItE14EeSU'); hideDiv('MorevidDescrFItE14EeSU'); hideDiv('BeginvidDescrFItE14EeSU'); showDiv('LessvidDescrFItE14EeSU'); return false;">more</a>)</span>
- <span id="LessvidDescrFItE14EeSU" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescrFItE14EeSU'); hideDiv('LessvidDescrFItE14EeSU'); showDiv('BeginvidDescrFItE14EeSU'); showDiv('MorevidDescrFItE14EeSU'); return false;">less</a>)</span>
-
-
-
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
- </div>
-
- <div class="vlfacets">
- <div class="vladded">
- </div>
- <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/TornadoVideosdotnet">TornadoVideo...</a></span></div>
- <div class="clearL"></div>
- <span class="grayText">Views:</span> 797,370<br/>
-
- <div class="video-thumb-duration-rating">
-
-
- <div>
-
- <img class="ratingVS ratingVS-4.5" alt="4.28912552436" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" />
-
-
-
- </div>
-
-
-
- <div class="runtime">07:10</div>
- </div>
-
- <div class="clear"></div>
- <div class="vlcategory">
- <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=25">News & Politics</a>
- </div>
- </div>
-
- <div class="vlclearaltl"></div>
-
-
-
- </div> <!-- end vEntry -->
-
-
- </div>
- </div> <!-- end Video List -->
- <div id="homepage-featured-more-bottom">
- <div class="floatR"><a href="/browse?s=rf">See More Featured Videos</a></div>
- <div class="clear"></div>
- </div>
-</div>
-
-
-<div id="homepage-side-content" style="white-space: normal;">
- <div>
-
-
-
-
- <!-- Begin ad tag -->
-
- <input type="hidden" id="pvaHl" value="en"/>
- <input type="hidden" id="pvaTag" value="http://n4061ad.doubleclick.net/adj/com.ythome/_default;sz=399x299;kl=N;kga=-1;kgg=-1;tile=1;dcopt=ist;"/>
- <input type="hidden" id="burl" value="http://www.youtube.com/pva/"/>
- <input type="hidden" id="canv" value="False"/>
- <div id="myAd_banner" style="visibility:hidden;height:35px;"></div>
- <div id="myAd_pva">
-
-
-
-
- <script type="text/javascript">
- ord=Math.random()*10000000000000000 + 3;
- if (false) {
- ord = 1234567890;
- }
- document.write('<script language="JavaScript" src="http://n4061ad.doubleclick.net/adj/com.ythome/_default;sz=399x299;kl=N;kga=-1;kgg=-1;tile=1;dcopt=ist;ord=' + ord + '?" type="text/javascript"><\/script>');
- </script>
- <noscript><a
- href="http://n4061ad.doubleclick.net/jump/_default;sz=399x299;ord=123456789?" target="_blank"><img
- src="http://n4061ad.doubleclick.net/ad/_default;sz=399x299;ord=123456789?" width="399" height="299" border="0" alt=""></a>
- </noscript>
-
- </div>
-
-
- <!-- End ad tag -->
-
- </div>
-
- <div class="homepage-content-block">
- <div class="contentBox">
- <div>
- <div class="floatR"><span class="smallText"><b><a href="/signup">Sign Up</a> | <a href="http://help.youtube.com/support/youtube/bin/topic.py?topic=10546&amp;hl=en_US">Help</a></b></div>
- <div class="floatL">
- <span class="headerTitle homepage-block-heading-gray"> Login </span>
- </div>
- <div class="clear"></div>
- </div>
-
- <form method="post" name="loginForm" id="loginForm" action="signup">
- <input type="hidden" name="action_login" value="1">
- <table width="270">
- <tr>
- <td align="right"><label for="homeUsername"><span class="smallText"><b>Username:</b></span></label></td>
- <td align="left"><input id="homeUsername" tabindex="101" class="smallText" type="text" size="16" name="username" value=""></td>
- </tr>
- <tr>
- <td align="right"><label for="homePassword"><span class="smallText"><b>Password:</b></span></label></td>
- <td align="left"><input id="homePassword" tabindex="102" class="smallText" type="password" size="16" name="password">
- </tr>
- <tr>
- <td></td>
- <td align="left">
- <span><input type="submit" class="smallText" value="Login"></span>
- </td>
- </tr>
- </table>
- </form>
- <div class="padT10 smallText">
- <p align="center" class="marT0 marB0"><a href="/forgot_username?next=/">Forgot Username</a> | <a href="/forgot?next=/">Forgot Password</a></p>
- </div>
- <div class="homepage-border-dotted"></div>
- <div class="alignC"><span class="smallText"><b><a href="
-https://www.google.com/accounts/ServiceLogin?service=youtube&hl=en_US&continue=http%3A//www.youtube.com/signup%3Fhl%3Den_US&passive=true">Login with your Google account</a>&nbsp; <a href="#" onClick="window.open('/t/help_gaia','login_help','width=580,height=480,resizable=yes,scrollbars=yes,status=0').focus();" rel="nofollow"><img src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" border="0" class="alignMid gaiaHelpBtn" alt=""></a></b></span></div>
- </div>
- </div> <!-- end homepage-content-block -->
-
-
- <div class="homepage-content-block padT10">
-
-
-
-
- <!-- Begin ad tag -->
-
-
-
- <script type="text/javascript">
- ord=Math.random()*10000000000000000 + 6;
- if (false) {
- ord = 1234567890;
- }
- document.write('<script language="JavaScript" src="http://n4061ad.doubleclick.net/adj/com.ythome/promo1;sz=300x50;kl=N;kga=-1;kgg=-1;tile=2;ord=' + ord + '?" type="text/javascript"><\/script>');
- </script>
- <noscript><a
- href="http://n4061ad.doubleclick.net/jump/promo1;sz=300x50;ord=123456789?" target="_blank"><img
- src="http://n4061ad.doubleclick.net/ad/promo1;sz=300x50;ord=123456789?" width="300" height="50" border="0" alt=""></a>
- </noscript>
-
-
- <!-- End ad tag -->
-
- </div>
-
- <div class="homepage-content-block padT10">
-
-
-
-
- <!-- Begin ad tag -->
-
-
-
- <script type="text/javascript">
- ord=Math.random()*10000000000000000 + 6;
- if (false) {
- ord = 1234567890;
- }
- document.write('<script language="JavaScript" src="http://n4061ad.doubleclick.net/adj/com.ythome/promo3;sz=300x50;kl=N;kga=-1;kgg=-1;tile=4;ord=' + ord + '?" type="text/javascript"><\/script>');
- </script>
- <noscript><a
- href="http://n4061ad.doubleclick.net/jump/promo3;sz=300x50;ord=123456789?" target="_blank"><img
- src="http://n4061ad.doubleclick.net/ad/promo3;sz=300x50;ord=123456789?" width="300" height="50" border="0" alt=""></a>
- </noscript>
-
-
- <!-- End ad tag -->
-
- </div>
-
- <div class="homepage-side-block padT10">
- <div class="homepage-yellow-block">
- <div class="homepage-block-heading" style="color:#CC6600">What's New</div>
-
- <div class="homepage-whatsnew-entry">
- <div class="homepage-whatsnew-image"><a href="/t/annotations_about"><img src="http://s.ytimg.com/yt/img/whats_new/annotation-vfl42087.gif" border="0" width="30" height="37"/></a></div>
- <div class="homepage-whatsnew-desc">
- <b><a href="/t/annotations_about">Video Annotations</a></b><br/>Add interactive commentary and links to your videos
- </div>
- </div><div class="clear"></div>
-
- <div class="homepage-whatsnew-entry">
- <div class="homepage-whatsnew-image"><a href="/address_book"><img src="http://s.ytimg.com/yt/img/whats_new/addybook-vfl39351.gif" border="0" width="30" height="37"/></a></div>
- <div class="homepage-whatsnew-desc">
- <b><a href="/address_book">New Address Book</a></b><br/>Organizing your YouTube friends and contacts just got a lot simpler
- </div>
- </div><div class="clear"></div>
-
- <div class="homepage-whatsnew-entry">
- <div class="homepage-whatsnew-image"><a href="/inbox"><img src="http://s.ytimg.com/yt/img/whats_new/inbox-vfl39351.gif" border="0" width="30" height="37"/></a></div>
- <div class="homepage-whatsnew-desc">
- <b><a href="/inbox">Updated Inbox</a></b><br/>Manage your messages and invites with ease
- </div>
- </div><div class="clear"></div>
-
-
- <div class="homepage-whatsnew-entry">
- <div class="homepage-whatsnew-image"><a href="/mobile"><img src="http://s.ytimg.com/yt/img/whats_new/pic_home_mobile_30x37-vfl37458.gif" border="0" width="30" height="37"/></a></div>
- <div class="homepage-whatsnew-desc">
- <b><a href="/mobile">YouTube Mobile</a></b><br/> Watch and upload YouTube videos on your mobile device.
- </div>
- </div><div class="clear"></div>
-
- <div class="bottomBorderDotted"></div>
- <b><a href="/blog" style="color:#CC6600">Hear Ye, Hear Ye: Calling all Reporters</a></b><br>
- Today we announce the launch of a new type of YouTube account: the Reporter. Reporter channels are just like the other YouTube channel types, but are specifically intended for citizens and profess...
- <div class="alignR padT5">
- <a href="/blog" style="color:#CC6600">Read more in our Blog</a>
- </div>
- <div style="font-size: 1px; height: 1px;"><br/></div>
- </div><img class="homepage-yellow-block-bot" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" />
-</div>
-
-
- <div class="homepage-side-block">
-
-
-
-
- <!-- Begin ad tag -->
-
-
-
- <script type="text/javascript">
- ord=Math.random()*10000000000000000 + 6;
- if (false) {
- ord = 1234567890;
- }
- document.write('<script language="JavaScript" src="http://n4061ad.doubleclick.net/adj/com.ythome/promo2;sz=300x50;kl=N;kga=-1;kgg=-1;tile=3;ord=' + ord + '?" type="text/javascript"><\/script>');
- </script>
- <noscript><a
- href="http://n4061ad.doubleclick.net/jump/promo2;sz=300x50;ord=123456789?" target="_blank"><img
- src="http://n4061ad.doubleclick.net/ad/promo2;sz=300x50;ord=123456789?" width="300" height="50" border="0" alt=""></a>
- </noscript>
-
-
- <!-- End ad tag -->
-
- </div>
-
-
-</div> <!-- end homepage-side-content -->
-
-<div class="clear"></div>
-
-
-
- <div class="clear"></div>
- <div id="footer">
- <div class="search">
- <div class="promo">
- <a href="/youchoose" onclick="_hbLink('FooterPromo','Footer');"><img id="debates_footer_img" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" alt="footer-promo" /></a>
- <a href="/youchoose" onclick="_hbLink('FooterPromo','Footer');">Face The Candidates</a>
- </div>
- <form autocomplete="off" name="footer-search-form" method="get" action="/results" style="width: 73.5%;">
- <a href="http://www.google.com/webmasters/igoogle/youtube.html"><img id="igoogle_footer_img" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" alt=""/> <em id="igoogle_footer_text">Add to iGoogle</em></a>
- <input type="text" name="search_query" maxlength="128" class="query" onkeyup="goog.i18n.bidi.setDirAttribute(event,this)" value="" id="footer-search-term">
- <select class="search-type" name="search_type">
- <option value="">Videos</option>
- <option value="search_users" >Channels</option>
- </select>
- <input type="submit" name="search" value="Search" class="submit-button">
- </form>
- </div>
- <div class="links">
- <table cellpadding="0" cellspacing="0">
- <tr>
- <th colspan="2">Your Account</th>
- <th class="separator" colspan="2">Help &amp; Info</th>
- <th class="separator" colspan="2">YouTube</th>
- </tr>
- <tr>
- <td><a href="/my_videos">Videos</a></td>
- <td><a href="/inbox">Inbox</a></td>
- <td class="separator"><a href="http://help.youtube.com/support/youtube/bin/static.py?page=start.cs&amp;hl=en_US">Help Resources</a></td>
- <td><a href="/t/safety">Safety Tips</a></td>
- <td class="separator"><a href="/t/about">Company Info</a></td>
- <td><a href="/press_room">Press</a></td>
- </tr>
- <tr>
- <td><a href="/my_favorites">Favorites</a></td>
- <td><a href="/subscription_center">Subscriptions</a></td>
- <td class="separator"><a href="/t/video_toolbox">Video Toolbox</a></td>
- <td><a href="/t/dmca_policy">Copyright Notices</a></td>
- <td class="separator"><a href="/testtube">TestTube</a></td>
- <td><a href="/t/contact_us">Contact</a></td>
- </tr>
- <tr>
- <td><a href="/my_playlists">Playlists</a></td>
- <td><a href="/my_account">more...</a></td>
- <td class="separator"><a href="/dev">Developer APIs</a></td>
- <td><a href="/t/community_guidelines">Community Guidelines</a></td>
- <td class="separator"><a href="/t/terms">Terms of Use</a></td>
- <td>
- <a href="/blog">Blog</a>
- </td>
- </tr>
- <tr>
- <td colspan="2">&nbsp;</td>
- <td class="separator"><a href="/advertise">Advertising</a></td>
- <td><a href="/youtubeonyoursite">YouTube On Your Site</a></td>
- <td class="separator"><a href="/t/privacy">Privacy Policy</a></td>
- <td>
- <a href="http://www.google.com/jobs/youtube">Jobs</a><br/>
- </td>
- </tr>
-
-
-
- </table>
- </div>
- </div>
- <div id="copyright">
- &copy; 2008 YouTube, LLC
- </div>
-
-
-</div> <!-- end baseDiv -->
-
-</body>
-<script type="text/javascript">
- window.setTimeout('window.google.ac.install(document.searchForm,document.searchForm.search_query,"yt",true,"close",true,"Suggestions")',100);
-</script>
-
-
-
-</html> \ No newline at end of file
diff --git a/examples/xml/rsslisting/CMakeLists.txt b/examples/xml/rsslisting/CMakeLists.txt
deleted file mode 100644
index 9ee2c69c54..0000000000
--- a/examples/xml/rsslisting/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-# Generated from rsslisting.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(rsslisting LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/xml/rsslisting")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Xml)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(rsslisting
- main.cpp
- rsslisting.cpp rsslisting.h
-)
-set_target_properties(rsslisting PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(rsslisting PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Network
- Qt::Widgets
- Qt::Xml
-)
-
-install(TARGETS rsslisting
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/xml/rsslisting/main.cpp b/examples/xml/rsslisting/main.cpp
deleted file mode 100644
index 13f092781d..0000000000
--- a/examples/xml/rsslisting/main.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*
-main.cpp
-
-Provides the main function for the RSS news reader example.
-*/
-
-#include <QtWidgets>
-
-#include "rsslisting.h"
-
-/*!
- Create an application and a main widget. Open the main widget for
- user input, and exit with an appropriate return value when it is
- closed.
-*/
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
- RSSListing *rsslisting = new RSSListing;
- rsslisting->show();
- return app.exec();
-}
diff --git a/examples/xml/rsslisting/rsslisting.cpp b/examples/xml/rsslisting/rsslisting.cpp
deleted file mode 100644
index 0d68d1792a..0000000000
--- a/examples/xml/rsslisting/rsslisting.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*
-rsslisting.cpp
-
-Provides a widget for displaying news items from RDF news sources.
-RDF is an XML-based format for storing items of information (see
-http://www.w3.org/RDF/ for details).
-
-The widget itself provides a simple user interface for specifying
-the URL of a news source, and controlling the downloading of news.
-
-The widget downloads and parses the XML asynchronously, feeding the
-data to an XML reader in pieces. This allows the user to interrupt
-its operation, and also allows very large data sources to be read.
-*/
-
-
-#include <QtCore>
-#include <QtWidgets>
-#include <QtNetwork>
-
-#include "rsslisting.h"
-
-
-/*
- Constructs an RSSListing widget with a simple user interface, and sets
- up the XML reader to use a custom handler class.
-
- The user interface consists of a line edit, a push button, and a
- list view widget. The line edit is used for entering the URLs of news
- sources; the push button starts the process of reading the
- news.
-*/
-
-RSSListing::RSSListing(QWidget *parent)
- : QWidget(parent), currentReply(0)
-{
-
- lineEdit = new QLineEdit(this);
- lineEdit->setText("http://blog.qt.io/feed/");
-
- fetchButton = new QPushButton(tr("Fetch"), this);
-
- treeWidget = new QTreeWidget(this);
- connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
- this, SLOT(itemActivated(QTreeWidgetItem*)));
- QStringList headerLabels;
- headerLabels << tr("Title") << tr("Link");
- treeWidget->setHeaderLabels(headerLabels);
- treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
-
- connect(&manager, SIGNAL(finished(QNetworkReply*)),
- this, SLOT(finished(QNetworkReply*)));
-
- connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(fetch()));
- connect(fetchButton, SIGNAL(clicked()), this, SLOT(fetch()));
-
- QVBoxLayout *layout = new QVBoxLayout(this);
-
- QHBoxLayout *hboxLayout = new QHBoxLayout;
-
- hboxLayout->addWidget(lineEdit);
- hboxLayout->addWidget(fetchButton);
-
- layout->addLayout(hboxLayout);
- layout->addWidget(treeWidget);
-
- setWindowTitle(tr("RSS listing example"));
- resize(640,480);
-}
-
-/*
- Starts the network request and connects the needed signals
-*/
-void RSSListing::get(const QUrl &url)
-{
- QNetworkRequest request(url);
- if (currentReply) {
- currentReply->disconnect(this);
- currentReply->deleteLater();
- }
- currentReply = manager.get(request);
- connect(currentReply, SIGNAL(readyRead()), this, SLOT(readyRead()));
- connect(currentReply, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged()));
- connect(currentReply, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError)));
-}
-
-/*
- Starts fetching data from a news source specified in the line
- edit widget.
-
- The line edit is made read only to prevent the user from modifying its
- contents during the fetch; this is only for cosmetic purposes.
- The fetch button is disabled, the list view is cleared, and we
- define the last list view item to be 0, meaning that there are no
- existing items in the list.
-
- A URL is created with the raw contents of the line edit and
- a get is initiated.
-*/
-
-void RSSListing::fetch()
-{
- lineEdit->setReadOnly(true);
- fetchButton->setEnabled(false);
- treeWidget->clear();
-
- xml.clear();
-
- QUrl url(lineEdit->text());
- get(url);
-}
-
-void RSSListing::metaDataChanged()
-{
- QUrl redirectionTarget = currentReply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
- if (redirectionTarget.isValid()) {
- get(redirectionTarget);
- }
-}
-
-/*
- Reads data received from the RDF source.
-
- We read all the available data, and pass it to the XML
- stream reader. Then we call the XML parsing function.
-*/
-
-void RSSListing::readyRead()
-{
- int statusCode = currentReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
- if (statusCode >= 200 && statusCode < 300) {
- QByteArray data = currentReply->readAll();
- xml.addData(data);
- parseXml();
- }
-}
-
-/*
- Finishes processing an HTTP request.
-
- The default behavior is to keep the text edit read only.
-
- If an error has occurred, the user interface is made available
- to the user for further input, allowing a new fetch to be
- started.
-
- If the HTTP get request has finished, we make the
- user interface available to the user for further input.
-*/
-
-void RSSListing::finished(QNetworkReply *reply)
-{
- Q_UNUSED(reply);
- lineEdit->setReadOnly(false);
- fetchButton->setEnabled(true);
-}
-
-
-/*
- Parses the XML data and creates treeWidget items accordingly.
-*/
-void RSSListing::parseXml()
-{
- while (!xml.atEnd()) {
- xml.readNext();
- if (xml.isStartElement()) {
- if (xml.name() == u"item")
- linkString = xml.attributes().value("rss:about").toString();
- currentTag = xml.name().toString();
- } else if (xml.isEndElement()) {
- if (xml.name() == u"item") {
-
- QTreeWidgetItem *item = new QTreeWidgetItem;
- item->setText(0, titleString);
- item->setText(1, linkString);
- treeWidget->addTopLevelItem(item);
-
- titleString.clear();
- linkString.clear();
- }
-
- } else if (xml.isCharacters() && !xml.isWhitespace()) {
- if (currentTag == "title")
- titleString += xml.text();
- else if (currentTag == "link")
- linkString += xml.text();
- }
- }
- if (xml.error() && xml.error() != QXmlStreamReader::PrematureEndOfDocumentError) {
- qWarning() << "XML ERROR:" << xml.lineNumber() << ": " << xml.errorString();
- }
-}
-
-/*
- Open the link in the browser
-*/
-void RSSListing::itemActivated(QTreeWidgetItem * item)
-{
- QDesktopServices::openUrl(QUrl(item->text(1)));
-}
-
-void RSSListing::error(QNetworkReply::NetworkError)
-{
- qWarning("error retrieving RSS feed");
- currentReply->disconnect(this);
- currentReply->deleteLater();
- currentReply = 0;
-}
diff --git a/examples/xml/rsslisting/rsslisting.h b/examples/xml/rsslisting/rsslisting.h
deleted file mode 100644
index 9f4fb2e7df..0000000000
--- a/examples/xml/rsslisting/rsslisting.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef RSSLISTING_H
-#define RSSLISTING_H
-
-#include <QNetworkAccessManager>
-#include <QNetworkReply>
-#include <QWidget>
-#include <QBuffer>
-#include <QXmlStreamReader>
-#include <QUrl>
-
-
-QT_BEGIN_NAMESPACE
-class QLineEdit;
-class QTreeWidget;
-class QTreeWidgetItem;
-class QPushButton;
-QT_END_NAMESPACE
-
-class RSSListing : public QWidget
-{
- Q_OBJECT
-public:
- RSSListing(QWidget *widget = nullptr);
-
-public slots:
- void fetch();
- void finished(QNetworkReply *reply);
- void readyRead();
- void metaDataChanged();
- void itemActivated(QTreeWidgetItem * item);
- void error(QNetworkReply::NetworkError);
-
-private:
- void parseXml();
- void get(const QUrl &url);
-
- QXmlStreamReader xml;
- QString currentTag;
- QString linkString;
- QString titleString;
-
- QNetworkAccessManager manager;
- QNetworkReply *currentReply;
-
- QLineEdit *lineEdit;
- QTreeWidget *treeWidget;
- QPushButton *fetchButton;
-
-};
-
-#endif
-
diff --git a/examples/xml/rsslisting/rsslisting.pro b/examples/xml/rsslisting/rsslisting.pro
deleted file mode 100644
index b6a00aa0c6..0000000000
--- a/examples/xml/rsslisting/rsslisting.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-HEADERS += rsslisting.h
-SOURCES += main.cpp rsslisting.cpp
-QT += network xml widgets
-requires(qtConfig(treewidget))
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/xml/rsslisting
-INSTALLS += target
diff --git a/examples/xml/streambookmarks/CMakeLists.txt b/examples/xml/streambookmarks/CMakeLists.txt
deleted file mode 100644
index 51393a2727..0000000000
--- a/examples/xml/streambookmarks/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-# Generated from streambookmarks.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(streambookmarks LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/xml/streambookmarks")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Xml)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(streambookmarks
- main.cpp
- mainwindow.cpp mainwindow.h
- xbelreader.cpp xbelreader.h
- xbelwriter.cpp xbelwriter.h
-)
-set_target_properties(streambookmarks PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(streambookmarks PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
- Qt::Xml
-)
-
-install(TARGETS streambookmarks
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/xml/streambookmarks/doc/images/xmlstreamexample-filemenu.png b/examples/xml/streambookmarks/doc/images/xmlstreamexample-filemenu.png
deleted file mode 100644
index e074fb7c41..0000000000
--- a/examples/xml/streambookmarks/doc/images/xmlstreamexample-filemenu.png
+++ /dev/null
Binary files differ
diff --git a/examples/xml/streambookmarks/doc/images/xmlstreamexample-helpmenu.png b/examples/xml/streambookmarks/doc/images/xmlstreamexample-helpmenu.png
deleted file mode 100644
index 0dc4392b94..0000000000
--- a/examples/xml/streambookmarks/doc/images/xmlstreamexample-helpmenu.png
+++ /dev/null
Binary files differ
diff --git a/examples/xml/streambookmarks/doc/images/xmlstreamexample-screenshot.png b/examples/xml/streambookmarks/doc/images/xmlstreamexample-screenshot.png
deleted file mode 100644
index bbaa423061..0000000000
--- a/examples/xml/streambookmarks/doc/images/xmlstreamexample-screenshot.png
+++ /dev/null
Binary files differ
diff --git a/examples/xml/streambookmarks/doc/src/qxmlstreambookmarks.qdoc b/examples/xml/streambookmarks/doc/src/qxmlstreambookmarks.qdoc
deleted file mode 100644
index aa0ddd4991..0000000000
--- a/examples/xml/streambookmarks/doc/src/qxmlstreambookmarks.qdoc
+++ /dev/null
@@ -1,194 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example streambookmarks
- \title QXmlStream Bookmarks Example
- \brief Demonstrates how to read and write to XBEL files.
- \ingroup xml-examples
-
- The QXmlStream Bookmarks example provides a reader for XML Bookmark
- Exchange Language (XBEL) files using Qt's QXmlStreamReader class
- for reading, and QXmlStreamWriter class for writing the files.
-
- \image xmlstreamexample-screenshot.png
-
- \section1 XbelWriter Class Definition
-
- The \c XbelWriter class contains a private instance of QXmlStreamWriter,
- which provides an XML writer with a streaming API. \c XbelWriter also
- has a reference to the QTreeWidget instance where the bookmark hierarchy
- is stored.
-
- \snippet streambookmarks/xbelwriter.h 0
-
- \section1 XbelWriter Class Implementation
-
- The \c XbelWriter constructor accepts a \a treeWidget to initialize within
- its definition. We enable \l{QXmlStreamWriter}'s auto-formatting property
- to ensure line-breaks and indentations are added automatically to empty
- sections between elements, increasing readability as the data is split into
- several lines.
-
- \snippet streambookmarks/xbelwriter.cpp 0
-
- The \c writeFile() function accepts a QIODevice object and sets it using
- \c setDevice(). This function then writes the document type
- definition(DTD), the start element, the version, and \c{treeWidget}'s
- top-level items.
-
- \snippet streambookmarks/xbelwriter.cpp 1
-
- The \c writeItem() function accepts a QTreeWidgetItem object and writes it
- to the stream, depending on its \c tagName, which can either be a "folder",
- "bookmark", or "separator".
-
- \snippet streambookmarks/xbelwriter.cpp 2
-
- \section1 XbelReader Class Definition
-
- The \c XbelReader contains a private instance of QXmlStreamReader, the
- companion class to QXmlStreamWriter. \c XbelReader also contains a
- reference to the QTreeWidget that is used to group the bookmarks according
- to their hierarchy.
-
- \snippet streambookmarks/xbelreader.h 0
-
- \section1 XbelReader Class Implementation
-
- The \c XbelReader constructor accepts a QTreeWidget to initialize the
- \c treeWidget within its definition. A QStyle object is used to set
- \c{treeWidget}'s style property. The \c folderIcon is set to QIcon::Normal
- mode where the pixmap is only displayed when the user is not interacting
- with the icon. The QStyle::SP_DirClosedIcon, QStyle::SP_DirOpenIcon, and
- QStyle::SP_FileIcon correspond to standard pixmaps that follow the style
- of your GUI.
-
- \snippet streambookmarks/xbelreader.cpp 0
-
- The \c read() function accepts a QIODevice and sets it using
- \l{QXmlStreamReader::}{setDevice()}. The actual process of reading only
- takes place if the file is a valid XBEL 1.0 file. Note that the XML input
- needs to be well-formed to be accepted by QXmlStreamReader. Otherwise, the
- \l{QXmlStreamReader::}{raiseError()} function is used to display an error
- message. Since the XBEL reader is only concerned with reading XML elements,
- it makes extensive use of the \l{QXmlStreamReader::}{readNextStartElement()}
- convenience function.
-
- \snippet streambookmarks/xbelreader.cpp 1
-
- The \c errorString() function is used if an error occurred, in order to
- obtain a description of the error complete with line and column number
- information.
-
- \snippet streambookmarks/xbelreader.cpp 2
-
- The \c readXBEL() function reads the name of a startElement and calls
- the appropriate function to read it, depending on whether if its a
- "folder", "bookmark" or "separator". Otherwise, it calls
- \l{QXmlStreamReader::}{skipCurrentElement()}. The Q_ASSERT() macro is used
- to provide a pre-condition for the function.
-
- \snippet streambookmarks/xbelreader.cpp 3
-
- The \c readTitle() function reads the bookmark's title.
-
- \snippet streambookmarks/xbelreader.cpp 4
-
- The \c readSeparator() function creates a separator and sets its flags.
- The text is set to 30 "0xB7", the HEX equivalent for period. The element
- is then skipped using \l{QXmlStreamReader::}{skipCurrentElement()}.
-
- \snippet streambookmarks/xbelreader.cpp 5
-
- \section1 MainWindow Class Definition
-
- The \c MainWindow class is a subclass of QMainWindow, with a
- \c File menu and a \c Help menu.
-
- \snippet streambookmarks/mainwindow.h 0
-
- \section1 MainWindow Class Implementation
-
- The \c MainWindow constructor instantiates the QTreeWidget object, \c
- treeWidget and sets its header with a QStringList object, \c labels.
- The constructor also invokes \c createActions() and \c createMenus()
- to set up the menus and their corresponding actions. The \c statusBar()
- is used to display the message "Ready" and the window's size is fixed
- to 480x320 pixels.
-
- \snippet streambookmarks/mainwindow.cpp 0
-
- The \c open() function enables the user to open an XBEL file using
- QFileDialog::getOpenFileName(). A warning message is displayed along
- with the \c fileName and \c errorString if the file cannot be read or
- if there is a parse error.
-
- \snippet streambookmarks/mainwindow.cpp 1
-
- The \c saveAs() function displays a QFileDialog, prompting the user for
- a \c fileName using QFileDialog::getSaveFileName(). Similar to the
- \c open() function, this function also displays a warning message if
- the file cannot be written to.
-
- \snippet streambookmarks/mainwindow.cpp 2
-
- The \c about() function displays a QMessageBox with a brief description
- of the example.
-
- \snippet streambookmarks/mainwindow.cpp 3
-
- In order to implement the \c open(), \c saveAs(), \c exit(), \c about()
- and \c aboutQt() functions, we connect them to QAction objects and
- add them to the \c fileMenu and \c helpMenu. The connections are as shown
- below:
-
- \snippet streambookmarks/mainwindow.cpp 5
-
- The \c createMenus() function creates the \c fileMenu and \c helpMenu
- and adds the QAction objects to them in order to create the menu shown
- in the screenshot below:
-
- \table
- \row
- \li \inlineimage xmlstreamexample-filemenu.png
- \li \inlineimage xmlstreamexample-helpmenu.png
- \endtable
-
- \snippet streambookmarks/mainwindow.cpp 5
-
- \section1 \c{main()} Function
-
- The \c main() function instantiates \c MainWindow and invokes the \c show()
- function.
-
- \snippet streambookmarks/main.cpp 0
-
- See the \l{http://pyxml.sourceforge.net/topics/xbel/}
- {XML Bookmark Exchange Language Resource Page} for more information
- about XBEL files.
-*/
diff --git a/examples/xml/streambookmarks/jennifer.xbel b/examples/xml/streambookmarks/jennifer.xbel
deleted file mode 100644
index 2501c118af..0000000000
--- a/examples/xml/streambookmarks/jennifer.xbel
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE xbel>
-<xbel version="1.0">
- <folder folded="no">
- <title>Qt Resources</title>
- <bookmark href="http://qt.io/">
- <title>Qt home page</title>
- </bookmark>
- <bookmark href="https://www.qt.io/partners/">
- <title>Qt Partners</title>
- </bookmark>
- <bookmark href="https://www.qt.io/qt-training/">
- <title>Training</title>
- </bookmark>
- <bookmark href="http://doc.qt.io/">
- <title>Qt 5 documentation</title>
- </bookmark>
- <bookmark href="http://qt-project.org/faq/">
- <title>Frequently Asked Questions</title>
- </bookmark>
- <folder folded="yes">
- <title>Community Resources</title>
- <bookmark href="http://www.qtcentre.org/content/">
- <title>Qt Centre</title>
- </bookmark>
- <bookmark href="http://www.qtforum.org/">
- <title>QtForum.org</title>
- </bookmark>
- <bookmark href="http://digitalfanatics.org/projects/qt_tutorial/">
- <title>The Independent Qt Tutorial</title>
- </bookmark>
- <bookmark href="http://www.qtforum.de/">
- <title>German Qt Forum</title>
- </bookmark>
- <bookmark href="http://www.korone.net/">
- <title>Korean Qt Community Site</title>
- </bookmark>
- <bookmark href="http://prog.org.ru/">
- <title>Russian Qt Forum</title>
- </bookmark>
- </folder>
- </folder>
- <folder folded="no">
- <title>Online Dictionaries</title>
- <bookmark href="http://www.dictionary.com/">
- <title>Dictionary.com</title>
- </bookmark>
- <bookmark href="http://www.m-w.com/">
- <title>Merriam-Webster Online</title>
- </bookmark>
- <bookmark href="http://dictionary.cambridge.org/">
- <title>Cambridge Dictionaries Online</title>
- </bookmark>
- <bookmark href="http://www.onelook.com/">
- <title>OneLook Dictionary Search</title>
- </bookmark>
- <separator/>
- <bookmark href="http://dict.tu-chemnitz.de/">
- <title>TU Chemnitz German-English Dictionary</title>
- </bookmark>
- <separator/>
- <bookmark href="http://atilf.atilf.fr/tlf.htm">
- <title>Trésor de la Langue Française informatisé</title>
- </bookmark>
- <bookmark href="http://dictionnaires.atilf.fr/dictionnaires/ACADEMIE/">
- <title>Dictionnaire de l'Académie Française</title>
- </bookmark>
- </folder>
-</xbel>
diff --git a/examples/xml/streambookmarks/main.cpp b/examples/xml/streambookmarks/main.cpp
deleted file mode 100644
index 23a36183f7..0000000000
--- a/examples/xml/streambookmarks/main.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-
-#include "mainwindow.h"
-
-//! [0]
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- MainWindow mainWin;
- mainWin.show();
- mainWin.open();
- return app.exec();
-}
-//! [0]
diff --git a/examples/xml/streambookmarks/mainwindow.cpp b/examples/xml/streambookmarks/mainwindow.cpp
deleted file mode 100644
index d0e7bf30c9..0000000000
--- a/examples/xml/streambookmarks/mainwindow.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "mainwindow.h"
-#include "xbelreader.h"
-#include "xbelwriter.h"
-
-//! [0]
-MainWindow::MainWindow()
-{
- QStringList labels;
- labels << tr("Title") << tr("Location");
-
- treeWidget = new QTreeWidget;
- treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch);
- treeWidget->setHeaderLabels(labels);
-#if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_CLIPBOARD)
- treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(treeWidget, &QWidget::customContextMenuRequested,
- this, &MainWindow::onCustomContextMenuRequested);
-#endif
- setCentralWidget(treeWidget);
-
- createMenus();
-
- statusBar()->showMessage(tr("Ready"));
-
- setWindowTitle(tr("QXmlStream Bookmarks"));
- const QSize availableSize = screen()->availableGeometry().size();
- resize(availableSize.width() / 2, availableSize.height() / 3);
-}
-//! [0]
-
-#if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_CLIPBOARD)
-void MainWindow::onCustomContextMenuRequested(const QPoint &pos)
-{
- const QTreeWidgetItem *item = treeWidget->itemAt(pos);
- if (!item)
- return;
- const QString url = item->text(1);
- QMenu contextMenu;
- QAction *copyAction = contextMenu.addAction(tr("Copy Link to Clipboard"));
- QAction *openAction = contextMenu.addAction(tr("Open"));
- QAction *action = contextMenu.exec(treeWidget->viewport()->mapToGlobal(pos));
- if (action == copyAction)
- QGuiApplication::clipboard()->setText(url);
- else if (action == openAction)
- QDesktopServices::openUrl(QUrl(url));
-}
-#endif // !QT_NO_CONTEXTMENU && !QT_NO_CLIPBOARD
-
-//! [1]
-void MainWindow::open()
-{
- QString fileName =
- QFileDialog::getOpenFileName(this, tr("Open Bookmark File"),
- QDir::currentPath(),
- tr("XBEL Files (*.xbel *.xml)"));
- if (fileName.isEmpty())
- return;
-
- treeWidget->clear();
-
-
- QFile file(fileName);
- if (!file.open(QFile::ReadOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("QXmlStream Bookmarks"),
- tr("Cannot read file %1:\n%2.")
- .arg(QDir::toNativeSeparators(fileName),
- file.errorString()));
- return;
- }
-
- XbelReader reader(treeWidget);
- if (!reader.read(&file)) {
- QMessageBox::warning(this, tr("QXmlStream Bookmarks"),
- tr("Parse error in file %1:\n\n%2")
- .arg(QDir::toNativeSeparators(fileName),
- reader.errorString()));
- } else {
- statusBar()->showMessage(tr("File loaded"), 2000);
- }
-
-}
-//! [1]
-
-//! [2]
-void MainWindow::saveAs()
-{
- QString fileName =
- QFileDialog::getSaveFileName(this, tr("Save Bookmark File"),
- QDir::currentPath(),
- tr("XBEL Files (*.xbel *.xml)"));
- if (fileName.isEmpty())
- return;
-
- QFile file(fileName);
- if (!file.open(QFile::WriteOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("QXmlStream Bookmarks"),
- tr("Cannot write file %1:\n%2.")
- .arg(QDir::toNativeSeparators(fileName),
- file.errorString()));
- return;
- }
-
- XbelWriter writer(treeWidget);
- if (writer.writeFile(&file))
- statusBar()->showMessage(tr("File saved"), 2000);
-}
-//! [2]
-
-//! [3]
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About QXmlStream Bookmarks"),
- tr("The <b>QXmlStream Bookmarks</b> example demonstrates how to use Qt's "
- "QXmlStream classes to read and write XML documents."));
-}
-//! [3]
-
-//! [5]
-void MainWindow::createMenus()
-{
- QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
- QAction *openAct = fileMenu->addAction(tr("&Open..."), this, &MainWindow::open);
- openAct->setShortcuts(QKeySequence::Open);
-
- QAction *saveAsAct = fileMenu->addAction(tr("&Save As..."), this, &MainWindow::saveAs);
- saveAsAct->setShortcuts(QKeySequence::SaveAs);
-
- QAction *exitAct = fileMenu->addAction(tr("E&xit"), this, &QWidget::close);
- exitAct->setShortcuts(QKeySequence::Quit);
-
- menuBar()->addSeparator();
-
- QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(tr("&About"), this, &MainWindow::about);
- helpMenu->addAction(tr("About &Qt"), qApp, &QCoreApplication::quit);
-}
-//! [5]
diff --git a/examples/xml/streambookmarks/mainwindow.h b/examples/xml/streambookmarks/mainwindow.h
deleted file mode 100644
index fbdc1e0c62..0000000000
--- a/examples/xml/streambookmarks/mainwindow.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QTreeWidget;
-QT_END_NAMESPACE
-
-//! [0]
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
-public slots:
- void open();
- void saveAs();
- void about();
-#if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_CLIPBOARD)
- void onCustomContextMenuRequested(const QPoint &pos);
-#endif
-private:
- void createMenus();
-
- QTreeWidget *treeWidget;
-};
-//! [0]
-
-#endif
diff --git a/examples/xml/streambookmarks/streambookmarks.pro b/examples/xml/streambookmarks/streambookmarks.pro
deleted file mode 100644
index 8c2fc3fa19..0000000000
--- a/examples/xml/streambookmarks/streambookmarks.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-HEADERS = mainwindow.h \
- xbelreader.h \
- xbelwriter.h
-SOURCES = main.cpp \
- mainwindow.cpp \
- xbelreader.cpp \
- xbelwriter.cpp
-QT += xml widgets
-requires(qtConfig(filedialog))
-
-EXAMPLE_FILES = frank.xbel jennifer.xbel
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/xml/streambookmarks
-INSTALLS += target
diff --git a/examples/xml/streambookmarks/xbelreader.cpp b/examples/xml/streambookmarks/xbelreader.cpp
deleted file mode 100644
index cdaa247e46..0000000000
--- a/examples/xml/streambookmarks/xbelreader.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "xbelreader.h"
-
-//! [0]
-XbelReader::XbelReader(QTreeWidget *treeWidget)
- : treeWidget(treeWidget)
-{
- QStyle *style = treeWidget->style();
-
- folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon),
- QIcon::Normal, QIcon::Off);
- folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon),
- QIcon::Normal, QIcon::On);
- bookmarkIcon.addPixmap(style->standardPixmap(QStyle::SP_FileIcon));
-}
-//! [0]
-
-//! [1]
-bool XbelReader::read(QIODevice *device)
-{
- xml.setDevice(device);
-
- if (xml.readNextStartElement()) {
- if (xml.name() == QLatin1String("xbel")
- && xml.attributes().value(versionAttribute()) == QLatin1String("1.0")) {
- readXBEL();
- } else {
- xml.raiseError(QObject::tr("The file is not an XBEL version 1.0 file."));
- }
- }
-
- return !xml.error();
-}
-//! [1]
-
-//! [2]
-QString XbelReader::errorString() const
-{
- return QObject::tr("%1\nLine %2, column %3")
- .arg(xml.errorString())
- .arg(xml.lineNumber())
- .arg(xml.columnNumber());
-}
-//! [2]
-
-//! [3]
-void XbelReader::readXBEL()
-{
- Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("xbel"));
-
- while (xml.readNextStartElement()) {
- if (xml.name() == QLatin1String("folder"))
- readFolder(0);
- else if (xml.name() == QLatin1String("bookmark"))
- readBookmark(0);
- else if (xml.name() == QLatin1String("separator"))
- readSeparator(0);
- else
- xml.skipCurrentElement();
- }
-}
-//! [3]
-
-//! [4]
-void XbelReader::readTitle(QTreeWidgetItem *item)
-{
- Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("title"));
-
- QString title = xml.readElementText();
- item->setText(0, title);
-}
-//! [4]
-
-//! [5]
-void XbelReader::readSeparator(QTreeWidgetItem *item)
-{
- Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("separator"));
-
- QTreeWidgetItem *separator = createChildItem(item);
- separator->setFlags(item->flags() & ~Qt::ItemIsSelectable);
- separator->setText(0, QString(30, u'\xB7'));
- xml.skipCurrentElement();
-}
-//! [5]
-
-void XbelReader::readFolder(QTreeWidgetItem *item)
-{
- Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("folder"));
-
- QTreeWidgetItem *folder = createChildItem(item);
- bool folded = (xml.attributes().value(foldedAttribute()) != QLatin1String("no"));
- folder->setExpanded(!folded);
-
- while (xml.readNextStartElement()) {
- if (xml.name() == QLatin1String("title"))
- readTitle(folder);
- else if (xml.name() == QLatin1String("folder"))
- readFolder(folder);
- else if (xml.name() == QLatin1String("bookmark"))
- readBookmark(folder);
- else if (xml.name() == QLatin1String("separator"))
- readSeparator(folder);
- else
- xml.skipCurrentElement();
- }
-}
-
-void XbelReader::readBookmark(QTreeWidgetItem *item)
-{
- Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("bookmark"));
-
- QTreeWidgetItem *bookmark = createChildItem(item);
- bookmark->setFlags(bookmark->flags() | Qt::ItemIsEditable);
- bookmark->setIcon(0, bookmarkIcon);
- bookmark->setText(0, QObject::tr("Unknown title"));
- bookmark->setText(1, xml.attributes().value(hrefAttribute()).toString());
-
- while (xml.readNextStartElement()) {
- if (xml.name() == QLatin1String("title"))
- readTitle(bookmark);
- else
- xml.skipCurrentElement();
- }
-}
-
-QTreeWidgetItem *XbelReader::createChildItem(QTreeWidgetItem *item)
-{
- QTreeWidgetItem *childItem;
- if (item) {
- childItem = new QTreeWidgetItem(item);
- } else {
- childItem = new QTreeWidgetItem(treeWidget);
- }
- childItem->setData(0, Qt::UserRole, xml.name().toString());
- return childItem;
-}
diff --git a/examples/xml/streambookmarks/xbelreader.h b/examples/xml/streambookmarks/xbelreader.h
deleted file mode 100644
index fd486a430f..0000000000
--- a/examples/xml/streambookmarks/xbelreader.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef XBELREADER_H
-#define XBELREADER_H
-
-#include <QIcon>
-#include <QXmlStreamReader>
-
-QT_BEGIN_NAMESPACE
-class QTreeWidget;
-class QTreeWidgetItem;
-QT_END_NAMESPACE
-
-//! [0]
-class XbelReader
-{
-public:
-//! [1]
- XbelReader(QTreeWidget *treeWidget);
-//! [1]
-
- bool read(QIODevice *device);
-
- QString errorString() const;
-
- static inline QString versionAttribute() { return QStringLiteral("version"); }
- static inline QString hrefAttribute() { return QStringLiteral("href"); }
- static inline QString foldedAttribute() { return QStringLiteral("folded"); }
-
-private:
-//! [2]
- void readXBEL();
- void readTitle(QTreeWidgetItem *item);
- void readSeparator(QTreeWidgetItem *item);
- void readFolder(QTreeWidgetItem *item);
- void readBookmark(QTreeWidgetItem *item);
-
- QTreeWidgetItem *createChildItem(QTreeWidgetItem *item);
-
- QXmlStreamReader xml;
- QTreeWidget *treeWidget;
-//! [2]
-
- QIcon folderIcon;
- QIcon bookmarkIcon;
-};
-//! [0]
-
-#endif
diff --git a/examples/xml/streambookmarks/xbelwriter.cpp b/examples/xml/streambookmarks/xbelwriter.cpp
deleted file mode 100644
index 7cc16494e2..0000000000
--- a/examples/xml/streambookmarks/xbelwriter.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "xbelwriter.h"
-#include "xbelreader.h"
-
-static inline QString yesValue() { return QStringLiteral("yes"); }
-static inline QString noValue() { return QStringLiteral("no"); }
-static inline QString titleElement() { return QStringLiteral("title"); }
-
-//! [0]
-XbelWriter::XbelWriter(const QTreeWidget *treeWidget)
- : treeWidget(treeWidget)
-{
- xml.setAutoFormatting(true);
-}
-//! [0]
-
-//! [1]
-bool XbelWriter::writeFile(QIODevice *device)
-{
- xml.setDevice(device);
-
- xml.writeStartDocument();
- xml.writeDTD(QStringLiteral("<!DOCTYPE xbel>"));
- xml.writeStartElement(QStringLiteral("xbel"));
- xml.writeAttribute(XbelReader::versionAttribute(), QStringLiteral("1.0"));
- for (int i = 0; i < treeWidget->topLevelItemCount(); ++i)
- writeItem(treeWidget->topLevelItem(i));
-
- xml.writeEndDocument();
- return true;
-}
-//! [1]
-
-//! [2]
-void XbelWriter::writeItem(const QTreeWidgetItem *item)
-{
- QString tagName = item->data(0, Qt::UserRole).toString();
- if (tagName == QLatin1String("folder")) {
- bool folded = !item->isExpanded();
- xml.writeStartElement(tagName);
- xml.writeAttribute(XbelReader::foldedAttribute(), folded ? yesValue() : noValue());
- xml.writeTextElement(titleElement(), item->text(0));
- for (int i = 0; i < item->childCount(); ++i)
- writeItem(item->child(i));
- xml.writeEndElement();
- } else if (tagName == QLatin1String("bookmark")) {
- xml.writeStartElement(tagName);
- if (!item->text(1).isEmpty())
- xml.writeAttribute(XbelReader::hrefAttribute(), item->text(1));
- xml.writeTextElement(titleElement(), item->text(0));
- xml.writeEndElement();
- } else if (tagName == QLatin1String("separator")) {
- xml.writeEmptyElement(tagName);
- }
-}
-//! [2]
diff --git a/examples/xml/streambookmarks/xbelwriter.h b/examples/xml/streambookmarks/xbelwriter.h
deleted file mode 100644
index 465d8f0dc4..0000000000
--- a/examples/xml/streambookmarks/xbelwriter.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef XBELWRITER_H
-#define XBELWRITER_H
-
-#include <QXmlStreamWriter>
-
-QT_BEGIN_NAMESPACE
-class QTreeWidget;
-class QTreeWidgetItem;
-QT_END_NAMESPACE
-
-//! [0]
-class XbelWriter
-{
-public:
- explicit XbelWriter(const QTreeWidget *treeWidget);
- bool writeFile(QIODevice *device);
-
-private:
- void writeItem(const QTreeWidgetItem *item);
- QXmlStreamWriter xml;
- const QTreeWidget *treeWidget;
-};
-//! [0]
-
-#endif
diff --git a/examples/xml/xml.pro b/examples/xml/xml.pro
index b0750574f4..d80d8193ed 100644
--- a/examples/xml/xml.pro
+++ b/examples/xml/xml.pro
@@ -1,11 +1,5 @@
TEMPLATE = subdirs
-SUBDIRS = htmlinfo \
- xmlstreamlint
qtHaveModule(widgets) {
- SUBDIRS += dombookmarks \
- streambookmarks
-
- qtHaveModule(network): SUBDIRS += \
- rsslisting
+ SUBDIRS += dombookmarks
}
diff --git a/examples/xml/xmlstreamlint/.prev_CMakeLists.txt b/examples/xml/xmlstreamlint/.prev_CMakeLists.txt
deleted file mode 100644
index 23d62e7b1c..0000000000
--- a/examples/xml/xmlstreamlint/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# Generated from xmlstreamlint.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(xmlstreamlint LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/xml/xmlstreamlint")
-
-find_package(Qt6 COMPONENTS Core)
-
-qt_add_executable(xmlstreamlint
- main.cpp
-)
-set_target_properties(xmlstreamlint PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(xmlstreamlint PUBLIC
- Qt::Core
-)
-
-install(TARGETS xmlstreamlint
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/xml/xmlstreamlint/CMakeLists.txt b/examples/xml/xmlstreamlint/CMakeLists.txt
deleted file mode 100644
index 8f3a02826b..0000000000
--- a/examples/xml/xmlstreamlint/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated from xmlstreamlint.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(xmlstreamlint LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/xml/xmlstreamlint")
-
-find_package(Qt6 COMPONENTS Core Xml) # special case
-
-qt_add_executable(xmlstreamlint
- main.cpp
-)
-set_target_properties(xmlstreamlint PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-target_link_libraries(xmlstreamlint PUBLIC
- Qt::Core
- Qt::Xml # special case: add
-)
-
-install(TARGETS xmlstreamlint
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/xml/xmlstreamlint/doc/src/xmlstreamlint.qdoc b/examples/xml/xmlstreamlint/doc/src/xmlstreamlint.qdoc
deleted file mode 100644
index 9a821342eb..0000000000
--- a/examples/xml/xmlstreamlint/doc/src/xmlstreamlint.qdoc
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example xmlstreamlint
- \title XML Stream Lint Example
- \ingroup xml-examples
- \brief A commandline tool reading from an input file and writing to
- the standard output file.
-
- The XML Stream Lint example provides a simple command line utility that
- accepts a file name as its single argument and writes it to the standard
- output file.
-
- The specified file is parsed using an QXmlStreamReader object and written
- to the standard output file using an QXmlStreamWriter object. If the file
- does not contain a well-formed XML document or the use of namespaces in
- the document is incorrect, a description of the error is printed to
- the standard error file and will appear in the console.
-
- \section1 Basic Operation
-
- The main function of the example opens the file specified by the user
- for input (\c inputFile), and it uses QFile to access the standard output
- file.
-
- Reading XML is handled by an instance of the QXmlStreamReader class, which
- operates on the input file object; writing is handled by an instance of
- QXmlStreamWriter operating on the output file object:
-
- \snippet xmlstreamlint/main.cpp 0
-
- The work of parsing and rewriting the XML is done in a while loop, and is
- driven by input from the reader:
-
- \snippet xmlstreamlint/main.cpp 1
-
- If more input is available, the next token from the input file is read
- and parsed. If an error occurred, information is written to the standard
- error file via a stream, and the example exits by returning a non-zero
- value from the main function.
-
- \snippet xmlstreamlint/main.cpp 2
-
- For valid input, the writer is fed the current token from the reader,
- and this is written to the output file that was specified when it was
- constructed.
-
- When there is no more input, the loop terminates, and the example can
- exit successfully.
-*/
diff --git a/examples/xml/xmlstreamlint/main.cpp b/examples/xml/xmlstreamlint/main.cpp
deleted file mode 100644
index 5f8b06a771..0000000000
--- a/examples/xml/xmlstreamlint/main.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QCoreApplication>
-#include <QFile>
-#include <QStringList>
-#include <QTextStream>
-#include <QXmlStreamReader>
-
-/*
- This class exists for the sole purpose of creating a translation context.
-*/
-class XmlStreamLint
-{
-public:
- Q_DECLARE_TR_FUNCTIONS(XmlStreamLint)
-};
-
-int main(int argc, char *argv[])
-{
- enum ExitCode
- {
- Success,
- ParseFailure,
- ArgumentError,
- WriteError,
- FileFailure
- };
-
- QCoreApplication app(argc, argv);
-
- QTextStream errorStream(stderr);
-
- if (argc != 2)
- {
- errorStream << XmlStreamLint::tr(
- "Usage: xmlstreamlint <path to XML file>\n");
- return ArgumentError;
- }
-
- QString inputFilePath(QCoreApplication::arguments().at(1));
- QFile inputFile(inputFilePath);
-
- if (!QFile::exists(inputFilePath))
- {
- errorStream << XmlStreamLint::tr(
- "File %1 does not exist.\n").arg(inputFilePath);
- return FileFailure;
-
- } else if (!inputFile.open(QIODevice::ReadOnly)) {
- errorStream << XmlStreamLint::tr(
- "Failed to open file %1.\n").arg(inputFilePath);
- return FileFailure;
- }
-
- QFile outputFile;
- if (!outputFile.open(stdout, QIODevice::WriteOnly))
- {
- errorStream << XmlStreamLint::tr("Failed to open stdout.");
- return WriteError;
- }
-
-//! [0]
- QXmlStreamReader reader(&inputFile);
- QXmlStreamWriter writer(&outputFile);
-//! [0]
-
-//! [1]
- while (!reader.atEnd())
- {
- reader.readNext();
-
- if (reader.error())
- {
- errorStream << XmlStreamLint::tr(
- "Error: %1 in file %2 at line %3, column %4.\n").arg(
- reader.errorString(), inputFilePath,
- QString::number(reader.lineNumber()),
- QString::number(reader.columnNumber()));
- return ParseFailure;
-//! [1]
-
-//! [2]
- } else
- writer.writeCurrentToken(reader);
- }
-//! [2]
-
- return Success;
-}
diff --git a/examples/xml/xmlstreamlint/xmlstreamlint.pro b/examples/xml/xmlstreamlint/xmlstreamlint.pro
deleted file mode 100644
index 90a6387afe..0000000000
--- a/examples/xml/xmlstreamlint/xmlstreamlint.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += cmdline
-QT -= gui
-SOURCES += main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/xml/xmlstreamlint
-INSTALLS += target