From 87a9f2f0d1f6ea54da085fc1d610dcd98bf2ec49 Mon Sep 17 00:00:00 2001 From: Gammasoft71 Date: Mon, 11 May 2020 22:19:40 +0200 Subject: [PATCH] add wiggly example --- CMakeLists.txt.user | 388 +++++++++++++++++- Qt.Tests/TestConsole/CMakeLists.txt | 2 +- .../Application/DarkMode/src/DarkMode.h | 1 + .../CommonControls/CheckBox/src/CheckBox.h | 1 + .../CheckedListWidget/src/CheckedListWidget.h | 1 + .../CommonControls/ComboBox/src/ComboBox.h | 1 + .../DoubleSpinBox/src/DoubleSpinBox.h | 1 + .../CommonControls/LCDNumber/src/LCDNumber.h | 1 + Qt.Widgets/CommonControls/Label/src/Label.h | 1 + .../CommonControls/LineEdit/src/LineEdit.h | 1 + .../PictureBox/src/PictureBox.h | 1 + .../PictureBox2/src/PictureBox2.h | 1 + .../ProgressBar/src/ProgressBar.h | 1 + .../PushButton/src/PushButton.h | 1 + .../RadioButton/src/RadioButton.h | 1 + Qt.Widgets/CommonControls/Slider/src/Slider.h | 1 + .../CommonControls/SpinBox/src/SpinBox.h | 1 + .../SpinButton/src/SpinButton.h | 1 + .../ToggleButton/src/ToggleButton.h | 1 + Qt.Widgets/CommonControls/Widget/src/Widget.h | 1 + Qt.Widgets/Components/Cursors/src/Cursors.h | 1 + Qt.Widgets/Components/Timer/src/Timer.h | 1 + Qt.Widgets/Containers/Frame/src/Frame.h | 1 + Qt.Widgets/Containers/GroupBox/src/GroupBox.h | 1 + .../Containers/TabWidget/src/TabWidget.h | 1 + Qt.Widgets/Containers/Window/src/Window.h | 1 + .../Dialogs/ColorDialog/src/ColorDialog.h | 1 + .../src/FolderBrowserDialog.h | 1 + .../Dialogs/FontDialog/src/FontDialog.h | 1 + .../Dialogs/MessageBox/src/MessageBox.h | 1 + .../OpenFileDialog/src/OpenFileDialog.h | 1 + .../SaveFileDialog/src/SaveFileDialog.h | 1 + .../src/HelloWorldEmoticons.h | 5 +- .../HelloWorldLabel/src/HelloWorldLabel.h | 5 +- .../src/HelloWorldMessageBox.h | 1 + .../HelloWorldPaint/src/HelloWorldPaint.h | 5 +- .../MenusAndToolbars/MenuBar/src/MenuBar.h | 1 + .../StatusBar/src/StatusBar.h | 1 + Qt.Widgets/Others/CMakeLists.txt | 1 + Qt.Widgets/Others/LCDNumber2/src/LCDNumber2.h | 1 + Qt.Widgets/Others/Others.pro | 1 + Qt.Widgets/Others/Wiggly/CMakeLists.txt | 17 + Qt.Widgets/Others/Wiggly/Wiggly.pro | 4 + Qt.Widgets/Others/Wiggly/src/Wiggly.cpp | 11 + Qt.Widgets/Others/Wiggly/src/Wiggly.h | 80 ++++ README.md | 72 ++-- 46 files changed, 579 insertions(+), 46 deletions(-) create mode 100644 Qt.Widgets/Others/Wiggly/CMakeLists.txt create mode 100644 Qt.Widgets/Others/Wiggly/Wiggly.pro create mode 100644 Qt.Widgets/Others/Wiggly/src/Wiggly.cpp create mode 100644 Qt.Widgets/Others/Wiggly/src/Wiggly.h diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user index 78efb31..b0079ee 100644 --- a/CMakeLists.txt.user +++ b/CMakeLists.txt.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -77,7 +77,7 @@ qt.qt5.5142.clang_64_kit 0 0 - 27 + 43 CMAKE_BUILD_TYPE:STRING=Debug @@ -1179,7 +1179,7 @@ false true - /Users/yves/Projects/Examples/Examples_Qt/build/Qt.Widgets/MenusAndToolbars/MainMenu/MainMenu.app/Contents/MacOS + dwarf @@ -2777,6 +2777,82 @@ /Users/yves/Projects/Examples/Examples_Qt/build/Qt.Widgets/Containers/Window/Window.app/Contents/MacOS + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + MenuBar + CMakeProjectManager.CMakeRunConfiguration.MenuBar + MenuBar + + false + + false + true + false + true + false + false + true + + /Users/yves/Projects/Examples/Examples_Qt/build/Qt.Widgets/MenusAndToolbars/MenuBar/MenuBar.app/Contents/MacOS + dwarf @@ -2853,6 +2929,310 @@ /Users/yves/Projects/Examples/Examples_Qt/build/Qt.Widgets/CommonControls/ComboBox/ComboBox.app/Contents/MacOS + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + HelloWorldEmoticons + CMakeProjectManager.CMakeRunConfiguration.HelloWorldEmoticons + HelloWorldEmoticons + + false + + false + true + false + true + false + false + true + + /Users/yves/Projects/Examples/Examples_Qt/build/Qt.Widgets/HelloWorld/HelloWorldEmoticons/HelloWorldEmoticons.app/Contents/MacOS + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + HelloWorldMessageBox + CMakeProjectManager.CMakeRunConfiguration.HelloWorldMessageBox + HelloWorldMessageBox + + false + + false + true + false + true + false + false + true + + /Users/yves/Projects/Examples/Examples_Qt/build/Qt.Widgets/HelloWorld/HelloWorldMessageBox/HelloWorldMessageBox.app/Contents/MacOS + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + HelloWorldPaint + CMakeProjectManager.CMakeRunConfiguration.HelloWorldPaint + HelloWorldPaint + + false + + false + true + false + true + false + false + true + + /Users/yves/Projects/Examples/Examples_Qt/build/Qt.Widgets/HelloWorld/HelloWorldPaint/HelloWorldPaint.app/Contents/MacOS + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + Wiggly + CMakeProjectManager.CMakeRunConfiguration.Wiggly + Wiggly + + false + + false + true + false + true + false + false + true + + /Users/yves/Projects/Examples/Examples_Qt/build/Qt.Widgets/Others/Wiggly/Wiggly.app/Contents/MacOS + dwarf @@ -3233,7 +3613,7 @@ /Users/yves/Projects/Examples/Examples_Qt/build/Qt.Widgets/Dialogs/FolderBrowserDialog/FolderBrowserDialog.app/Contents/MacOS - 39 + 44 diff --git a/Qt.Tests/TestConsole/CMakeLists.txt b/Qt.Tests/TestConsole/CMakeLists.txt index 6c4832d..d5fbc19 100644 --- a/Qt.Tests/TestConsole/CMakeLists.txt +++ b/Qt.Tests/TestConsole/CMakeLists.txt @@ -10,4 +10,4 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # Application add_executable(TestConsole src/main.cpp) -target_link_libraries(TestConsole Qt5::Core) +target_link_libraries(TestConsole Qt5::Core Qt5::Widgets) diff --git a/Qt.Widgets/Application/DarkMode/src/DarkMode.h b/Qt.Widgets/Application/DarkMode/src/DarkMode.h index fb33c1d..b36fa46 100644 --- a/Qt.Widgets/Application/DarkMode/src/DarkMode.h +++ b/Qt.Widgets/Application/DarkMode/src/DarkMode.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/CheckBox/src/CheckBox.h b/Qt.Widgets/CommonControls/CheckBox/src/CheckBox.h index ed00372..fceca83 100644 --- a/Qt.Widgets/CommonControls/CheckBox/src/CheckBox.h +++ b/Qt.Widgets/CommonControls/CheckBox/src/CheckBox.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/CheckedListWidget/src/CheckedListWidget.h b/Qt.Widgets/CommonControls/CheckedListWidget/src/CheckedListWidget.h index 24e3ba5..f304a8f 100644 --- a/Qt.Widgets/CommonControls/CheckedListWidget/src/CheckedListWidget.h +++ b/Qt.Widgets/CommonControls/CheckedListWidget/src/CheckedListWidget.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/ComboBox/src/ComboBox.h b/Qt.Widgets/CommonControls/ComboBox/src/ComboBox.h index b7274fb..51458c4 100644 --- a/Qt.Widgets/CommonControls/ComboBox/src/ComboBox.h +++ b/Qt.Widgets/CommonControls/ComboBox/src/ComboBox.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/DoubleSpinBox/src/DoubleSpinBox.h b/Qt.Widgets/CommonControls/DoubleSpinBox/src/DoubleSpinBox.h index f189d77..468729b 100644 --- a/Qt.Widgets/CommonControls/DoubleSpinBox/src/DoubleSpinBox.h +++ b/Qt.Widgets/CommonControls/DoubleSpinBox/src/DoubleSpinBox.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/LCDNumber/src/LCDNumber.h b/Qt.Widgets/CommonControls/LCDNumber/src/LCDNumber.h index 9f183df..26e71d3 100644 --- a/Qt.Widgets/CommonControls/LCDNumber/src/LCDNumber.h +++ b/Qt.Widgets/CommonControls/LCDNumber/src/LCDNumber.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/Label/src/Label.h b/Qt.Widgets/CommonControls/Label/src/Label.h index d7b171b..7a6e510 100644 --- a/Qt.Widgets/CommonControls/Label/src/Label.h +++ b/Qt.Widgets/CommonControls/Label/src/Label.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/LineEdit/src/LineEdit.h b/Qt.Widgets/CommonControls/LineEdit/src/LineEdit.h index be4bd71..10a7c45 100644 --- a/Qt.Widgets/CommonControls/LineEdit/src/LineEdit.h +++ b/Qt.Widgets/CommonControls/LineEdit/src/LineEdit.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/PictureBox/src/PictureBox.h b/Qt.Widgets/CommonControls/PictureBox/src/PictureBox.h index 1c97283..a73cd04 100644 --- a/Qt.Widgets/CommonControls/PictureBox/src/PictureBox.h +++ b/Qt.Widgets/CommonControls/PictureBox/src/PictureBox.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/PictureBox2/src/PictureBox2.h b/Qt.Widgets/CommonControls/PictureBox2/src/PictureBox2.h index 8d7b781..d69777c 100644 --- a/Qt.Widgets/CommonControls/PictureBox2/src/PictureBox2.h +++ b/Qt.Widgets/CommonControls/PictureBox2/src/PictureBox2.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/ProgressBar/src/ProgressBar.h b/Qt.Widgets/CommonControls/ProgressBar/src/ProgressBar.h index 6719b77..d331889 100644 --- a/Qt.Widgets/CommonControls/ProgressBar/src/ProgressBar.h +++ b/Qt.Widgets/CommonControls/ProgressBar/src/ProgressBar.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/PushButton/src/PushButton.h b/Qt.Widgets/CommonControls/PushButton/src/PushButton.h index a3f6a21..f1bf131 100644 --- a/Qt.Widgets/CommonControls/PushButton/src/PushButton.h +++ b/Qt.Widgets/CommonControls/PushButton/src/PushButton.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/RadioButton/src/RadioButton.h b/Qt.Widgets/CommonControls/RadioButton/src/RadioButton.h index fb17ff3..9a1fdfb 100644 --- a/Qt.Widgets/CommonControls/RadioButton/src/RadioButton.h +++ b/Qt.Widgets/CommonControls/RadioButton/src/RadioButton.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/Slider/src/Slider.h b/Qt.Widgets/CommonControls/Slider/src/Slider.h index 5cda08e..b123096 100644 --- a/Qt.Widgets/CommonControls/Slider/src/Slider.h +++ b/Qt.Widgets/CommonControls/Slider/src/Slider.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/SpinBox/src/SpinBox.h b/Qt.Widgets/CommonControls/SpinBox/src/SpinBox.h index 89b5ce1..e2263d4 100644 --- a/Qt.Widgets/CommonControls/SpinBox/src/SpinBox.h +++ b/Qt.Widgets/CommonControls/SpinBox/src/SpinBox.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/SpinButton/src/SpinButton.h b/Qt.Widgets/CommonControls/SpinButton/src/SpinButton.h index 9e0b1f4..03ab137 100644 --- a/Qt.Widgets/CommonControls/SpinButton/src/SpinButton.h +++ b/Qt.Widgets/CommonControls/SpinButton/src/SpinButton.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/ToggleButton/src/ToggleButton.h b/Qt.Widgets/CommonControls/ToggleButton/src/ToggleButton.h index cd436e4..a344649 100644 --- a/Qt.Widgets/CommonControls/ToggleButton/src/ToggleButton.h +++ b/Qt.Widgets/CommonControls/ToggleButton/src/ToggleButton.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/CommonControls/Widget/src/Widget.h b/Qt.Widgets/CommonControls/Widget/src/Widget.h index e214ea7..19753db 100644 --- a/Qt.Widgets/CommonControls/Widget/src/Widget.h +++ b/Qt.Widgets/CommonControls/Widget/src/Widget.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/Components/Cursors/src/Cursors.h b/Qt.Widgets/Components/Cursors/src/Cursors.h index 0b08e54..535e775 100644 --- a/Qt.Widgets/Components/Cursors/src/Cursors.h +++ b/Qt.Widgets/Components/Cursors/src/Cursors.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/Components/Timer/src/Timer.h b/Qt.Widgets/Components/Timer/src/Timer.h index a996446..531b8d2 100644 --- a/Qt.Widgets/Components/Timer/src/Timer.h +++ b/Qt.Widgets/Components/Timer/src/Timer.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/Containers/Frame/src/Frame.h b/Qt.Widgets/Containers/Frame/src/Frame.h index 6c18070..18926e5 100644 --- a/Qt.Widgets/Containers/Frame/src/Frame.h +++ b/Qt.Widgets/Containers/Frame/src/Frame.h @@ -1,3 +1,4 @@ +#pragma once #include #include diff --git a/Qt.Widgets/Containers/GroupBox/src/GroupBox.h b/Qt.Widgets/Containers/GroupBox/src/GroupBox.h index 1f7420d..c05ca25 100644 --- a/Qt.Widgets/Containers/GroupBox/src/GroupBox.h +++ b/Qt.Widgets/Containers/GroupBox/src/GroupBox.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/Containers/TabWidget/src/TabWidget.h b/Qt.Widgets/Containers/TabWidget/src/TabWidget.h index f947b7d..19f61e9 100644 --- a/Qt.Widgets/Containers/TabWidget/src/TabWidget.h +++ b/Qt.Widgets/Containers/TabWidget/src/TabWidget.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/Containers/Window/src/Window.h b/Qt.Widgets/Containers/Window/src/Window.h index a6d7222..ba51f27 100644 --- a/Qt.Widgets/Containers/Window/src/Window.h +++ b/Qt.Widgets/Containers/Window/src/Window.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/Dialogs/ColorDialog/src/ColorDialog.h b/Qt.Widgets/Dialogs/ColorDialog/src/ColorDialog.h index 727d4e3..c0776ed 100644 --- a/Qt.Widgets/Dialogs/ColorDialog/src/ColorDialog.h +++ b/Qt.Widgets/Dialogs/ColorDialog/src/ColorDialog.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/Dialogs/FolderBrowserDialog/src/FolderBrowserDialog.h b/Qt.Widgets/Dialogs/FolderBrowserDialog/src/FolderBrowserDialog.h index 75388d9..c4cb715 100644 --- a/Qt.Widgets/Dialogs/FolderBrowserDialog/src/FolderBrowserDialog.h +++ b/Qt.Widgets/Dialogs/FolderBrowserDialog/src/FolderBrowserDialog.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/Dialogs/FontDialog/src/FontDialog.h b/Qt.Widgets/Dialogs/FontDialog/src/FontDialog.h index 9c86472..db9a399 100644 --- a/Qt.Widgets/Dialogs/FontDialog/src/FontDialog.h +++ b/Qt.Widgets/Dialogs/FontDialog/src/FontDialog.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/Dialogs/MessageBox/src/MessageBox.h b/Qt.Widgets/Dialogs/MessageBox/src/MessageBox.h index b0c0467..71c804f 100644 --- a/Qt.Widgets/Dialogs/MessageBox/src/MessageBox.h +++ b/Qt.Widgets/Dialogs/MessageBox/src/MessageBox.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/Dialogs/OpenFileDialog/src/OpenFileDialog.h b/Qt.Widgets/Dialogs/OpenFileDialog/src/OpenFileDialog.h index d61dcdb..e5bd498 100644 --- a/Qt.Widgets/Dialogs/OpenFileDialog/src/OpenFileDialog.h +++ b/Qt.Widgets/Dialogs/OpenFileDialog/src/OpenFileDialog.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/Dialogs/SaveFileDialog/src/SaveFileDialog.h b/Qt.Widgets/Dialogs/SaveFileDialog/src/SaveFileDialog.h index a69d4da..6416e60 100644 --- a/Qt.Widgets/Dialogs/SaveFileDialog/src/SaveFileDialog.h +++ b/Qt.Widgets/Dialogs/SaveFileDialog/src/SaveFileDialog.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/HelloWorld/HelloWorldEmoticons/src/HelloWorldEmoticons.h b/Qt.Widgets/HelloWorld/HelloWorldEmoticons/src/HelloWorldEmoticons.h index 679688d..ab1641a 100644 --- a/Qt.Widgets/HelloWorld/HelloWorldEmoticons/src/HelloWorldEmoticons.h +++ b/Qt.Widgets/HelloWorld/HelloWorldEmoticons/src/HelloWorldEmoticons.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include @@ -6,11 +7,11 @@ namespace Examples { #if defined(__APPLE__) - int pointsToNativeFontGraphicsUntit(int size) { + inline int pointsToNativeFontGraphicsUntit(int size) { return static_cast(size) /QApplication::primaryScreen()->logicalDotsPerInch() * 96.0f; // font is in pixels and not in points } #else - int pointsToNativeFontGraphicsUntit(int size) { + inline int pointsToNativeFontGraphicsUntit(int size) { return size; // font is in points } #endif diff --git a/Qt.Widgets/HelloWorld/HelloWorldLabel/src/HelloWorldLabel.h b/Qt.Widgets/HelloWorld/HelloWorldLabel/src/HelloWorldLabel.h index 2fbd170..7f6f49c 100644 --- a/Qt.Widgets/HelloWorld/HelloWorldLabel/src/HelloWorldLabel.h +++ b/Qt.Widgets/HelloWorld/HelloWorldLabel/src/HelloWorldLabel.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include @@ -6,11 +7,11 @@ namespace Examples { #if defined(__APPLE__) - int pointsToNativeFontGraphicsUntit(int size) { + inline int pointsToNativeFontGraphicsUntit(int size) { return static_cast(size) /QApplication::primaryScreen()->logicalDotsPerInch() * 96.0f; // font is in pixels and not in points } #else - int pointsToNativeFontGraphicsUntit(int size) { + inline int pointsToNativeFontGraphicsUntit(int size) { return size; // font is in points } #endif diff --git a/Qt.Widgets/HelloWorld/HelloWorldMessageBox/src/HelloWorldMessageBox.h b/Qt.Widgets/HelloWorld/HelloWorldMessageBox/src/HelloWorldMessageBox.h index 1f638fb..53f5093 100644 --- a/Qt.Widgets/HelloWorld/HelloWorldMessageBox/src/HelloWorldMessageBox.h +++ b/Qt.Widgets/HelloWorld/HelloWorldMessageBox/src/HelloWorldMessageBox.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/HelloWorld/HelloWorldPaint/src/HelloWorldPaint.h b/Qt.Widgets/HelloWorld/HelloWorldPaint/src/HelloWorldPaint.h index dcda207..c8be86f 100644 --- a/Qt.Widgets/HelloWorld/HelloWorldPaint/src/HelloWorldPaint.h +++ b/Qt.Widgets/HelloWorld/HelloWorldPaint/src/HelloWorldPaint.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include @@ -7,11 +8,11 @@ namespace Examples { #if defined(__APPLE__) - int pointsToNativeFontGraphicsUntit(int size) { + inline int pointsToNativeFontGraphicsUntit(int size) { return static_cast(size) /QApplication::primaryScreen()->logicalDotsPerInch() * 96.0f; // font is in pixels and not in points } #else - int pointsToNativeFontGraphicsUntit(int size) { + inline int pointsToNativeFontGraphicsUntit(int size) { return size; // font is in points } #endif diff --git a/Qt.Widgets/MenusAndToolbars/MenuBar/src/MenuBar.h b/Qt.Widgets/MenusAndToolbars/MenuBar/src/MenuBar.h index bd9a9be..04f5c30 100644 --- a/Qt.Widgets/MenusAndToolbars/MenuBar/src/MenuBar.h +++ b/Qt.Widgets/MenusAndToolbars/MenuBar/src/MenuBar.h @@ -1,6 +1,7 @@ #include #include #include +#pragma once #include #include #include diff --git a/Qt.Widgets/MenusAndToolbars/StatusBar/src/StatusBar.h b/Qt.Widgets/MenusAndToolbars/StatusBar/src/StatusBar.h index 7780f36..1aa4345 100644 --- a/Qt.Widgets/MenusAndToolbars/StatusBar/src/StatusBar.h +++ b/Qt.Widgets/MenusAndToolbars/StatusBar/src/StatusBar.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/Others/CMakeLists.txt b/Qt.Widgets/Others/CMakeLists.txt index 02a70b7..7a14d91 100644 --- a/Qt.Widgets/Others/CMakeLists.txt +++ b/Qt.Widgets/Others/CMakeLists.txt @@ -5,3 +5,4 @@ project(Others) # Others add_subdirectory(LCDNumber2) +add_subdirectory(Wiggly) diff --git a/Qt.Widgets/Others/LCDNumber2/src/LCDNumber2.h b/Qt.Widgets/Others/LCDNumber2/src/LCDNumber2.h index fe78302..a70ff91 100644 --- a/Qt.Widgets/Others/LCDNumber2/src/LCDNumber2.h +++ b/Qt.Widgets/Others/LCDNumber2/src/LCDNumber2.h @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/Qt.Widgets/Others/Others.pro b/Qt.Widgets/Others/Others.pro index d89f271..3a91f34 100644 --- a/Qt.Widgets/Others/Others.pro +++ b/Qt.Widgets/Others/Others.pro @@ -1,3 +1,4 @@ TEMPLATE = subdirs SUBDIRS = \ LCDNumber2 \ + Wiggly | diff --git a/Qt.Widgets/Others/Wiggly/CMakeLists.txt b/Qt.Widgets/Others/Wiggly/CMakeLists.txt new file mode 100644 index 0000000..ab4c1f7 --- /dev/null +++ b/Qt.Widgets/Others/Wiggly/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.1) + +# Project +project(Wiggly) +find_package(Qt5Widgets CONFIG REQUIRED) + +# Options +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Application +add_executable(Wiggly WIN32 MACOSX_BUNDLE src/Wiggly.cpp src/Wiggly.h) +target_link_libraries(Wiggly Qt5::Widgets) + diff --git a/Qt.Widgets/Others/Wiggly/Wiggly.pro b/Qt.Widgets/Others/Wiggly/Wiggly.pro new file mode 100644 index 0000000..04dbdee --- /dev/null +++ b/Qt.Widgets/Others/Wiggly/Wiggly.pro @@ -0,0 +1,4 @@ +CONFIG += c++17 +QT = widgets +SOURCES = src/Wiggly.cpp +HEADERS = src/Wiggly.h diff --git a/Qt.Widgets/Others/Wiggly/src/Wiggly.cpp b/Qt.Widgets/Others/Wiggly/src/Wiggly.cpp new file mode 100644 index 0000000..496087f --- /dev/null +++ b/Qt.Widgets/Others/Wiggly/src/Wiggly.cpp @@ -0,0 +1,11 @@ +#include +#include "Wiggly.h" + +using namespace Examples; + +int main(int argc, char *argv[]) { + QApplication application(argc, argv); + Window1 window1; + window1.show(); + return application.exec(); +} diff --git a/Qt.Widgets/Others/Wiggly/src/Wiggly.h b/Qt.Widgets/Others/Wiggly/src/Wiggly.h new file mode 100644 index 0000000..9c4f741 --- /dev/null +++ b/Qt.Widgets/Others/Wiggly/src/Wiggly.h @@ -0,0 +1,80 @@ +#pragma once +#include +#include +#include +#include +#include +#include +#include + +namespace Examples { + class WigglyWidget : public QWidget { + Q_OBJECT + public: + WigglyWidget(QWidget *parent = nullptr) : QWidget(parent) { + setBackgroundRole(QPalette::Midlight); + setAutoFillBackground(true); + + auto newFont = font(); + newFont.setPointSize(newFont.pointSize() + 20); + setFont(newFont); + + timer.start(60, this); + } + +public slots: + void setText(const QString &newText) {text = newText;} + +protected: + void paintEvent(QPaintEvent *) override { + static const std::vector sins = {0, 38, 71, 92, 100, 92, 71, 38, 0, -38, -71, -92, -100, -92, -71, -38}; + QFontMetrics metrics(font()); + auto pos = QPoint {(width() - metrics.horizontalAdvance(text)) / 2, (height() + metrics.ascent() - metrics.descent()) / 2}; + QPainter painter(this); + for (auto i = 0; i < text.size(); ++i) { + auto index = (step + i) % sins.size(); + painter.setPen(QColor::fromHsv(360.0f / sins.size() * index, 255, 191)); + painter.drawText(pos - QPoint {0, (sins[index] * metrics.height()) / 400}, QString(text[i])); + pos.setX(pos.x() + metrics.horizontalAdvance(text[i])); + } + } + + void timerEvent(QTimerEvent *event) override { + if (event->timerId() == timer.timerId()) { + ++step; + update(); + } else + QWidget::timerEvent(event); + } + +private: + QBasicTimer timer; + QString text; + int step = 0; + }; + + class Window1 : public QMainWindow { + Q_OBJECT + public: + Window1() { + setCentralWidget(&frame); + setWindowTitle("Wiggly"); + resize(330, 130); + connect(&lineEdit, &QLineEdit::textChanged, &wigglyWidget, &WigglyWidget::setText); + + wigglyWidget.setGeometry(20, 20, 290, 60); + + layout.addWidget(&wigglyWidget); + layout.addWidget(&lineEdit); + lineEdit.move(20, 90); + lineEdit.setGeometry(20, 90, 290, lineEdit.height()); + lineEdit.setText("Habemus papam"); + } + + private: + QFrame frame; + QVBoxLayout layout {&frame}; + WigglyWidget wigglyWidget; + QLineEdit lineEdit; + }; +} diff --git a/README.md b/README.md index 83dd632..38121b7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Qt Examples -Shows how to use Qt widgets only by programming code (c++17). +shows how to use Qt widgets only by programming code (c++17). ## Hello World @@ -15,85 +15,87 @@ Shows how to use Qt widgets only by programming code (c++17). ## Application and messages -[Application](Qt.Widgets/Application/Application) Shows how to create an application with QApplication. +[Application](Qt.Widgets/Application/Application) shows how to create an application with QApplication. -[DarkMode](Qt.Widgets/Application/DarkMode) Shows how to create a dark mode application. +[DarkMode](Qt.Widgets/Application/DarkMode) shows how to create a dark mode application. ## Common Controls -[CheckBox](Qt.Widgets/CommonControls/CheckBox) Shows how to create a check box with QCheckBox. +[CheckBox](Qt.Widgets/CommonControls/CheckBox) shows how to create a check box with QCheckBox. -[CheckedListWidget](Qt.Widgets/CommonControls/CheckedListWidget) Shows how to create a checked list widget with QListWidget. +[CheckedListWidget](Qt.Widgets/CommonControls/CheckedListWidget) shows how to create a checked list widget with QListWidget. -[ComboBox](Qt.Widgets/CommonControls/ComboBox) Shows how to create a combo box with QComboBox. +[ComboBox](Qt.Widgets/CommonControls/ComboBox) shows how to create a combo box with QComboBox. -[DoubleSpinBox](Qt.Widgets/CommonControls/DoubleSpinBox) Shows how to create a double spin box with QDoubleSpinBox. +[DoubleSpinBox](Qt.Widgets/CommonControls/DoubleSpinBox) shows how to create a double spin box with QDoubleSpinBox. -[LCDNumber](Qt.Widgets/CommonControls/LCDNumber) Shows how to create a LCD number with QLCDNumber. +[LCDNumber](Qt.Widgets/CommonControls/LCDNumber) shows how to create a LCD number with QLCDNumber. -[Label](Qt.Widgets/CommonControls/Label) Shows how to create a label with QLabel. +[Label](Qt.Widgets/CommonControls/Label) shows how to create a label with QLabel. -[LineEdit](Qt.Widgets/CommonControls/LineEdit) Shows how to create a line edit with QLineEdit. +[LineEdit](Qt.Widgets/CommonControls/LineEdit) shows how to create a line edit with QLineEdit. -[PictureBox](Qt.Widgets/CommonControls/PictureBox) Shows how to create a picture box with QLabel. +[PictureBox](Qt.Widgets/CommonControls/PictureBox) shows how to create a picture box with QLabel. -[PictureBox2](Qt.Widgets/CommonControls/PictureBox2) Shows how to create a picture box with QGraphicsPixmapItem. +[PictureBox2](Qt.Widgets/CommonControls/PictureBox2) shows how to create a picture box with QGraphicsPixmapItem. -[ProgressBar](Qt.Widgets/CommonControls/ProgressBar) Shows how to create a ProgressBar with QProgress. +[ProgressBar](Qt.Widgets/CommonControls/ProgressBar) shows how to create a ProgressBar with QProgress. -[PushButton](Qt.Widgets/CommonControls/PushButton) Shows how to create a button and Event Click with QPushButton. +[PushButton](Qt.Widgets/CommonControls/PushButton) shows how to create a button and Event Click with QPushButton. -[RadioButton](Qt.Widgets/CommonControls/RadioButton) Shows how to create a radio button with QRadioButton. +[RadioButton](Qt.Widgets/CommonControls/RadioButton) shows how to create a radio button with QRadioButton. -[Slider](Qt.Widgets/CommonControls/Slider) Shows how to create a slider with QSlider. +[Slider](Qt.Widgets/CommonControls/Slider) shows how to create a slider with QSlider. -[SpinBox](Qt.Widgets/CommonControls/SpinBox) Shows how to create a spin box with QSpinBox. +[SpinBox](Qt.Widgets/CommonControls/SpinBox) shows how to create a spin box with QSpinBox. -[SpinButton](Qt.Widgets/CommonControls/SpinButton) Shows how to create a spin button with QSpinBox. +[SpinButton](Qt.Widgets/CommonControls/SpinButton) shows how to create a spin button with QSpinBox. -[ToggleButton](Qt.Widgets/CommonControls/ToggleButton) Shows how to create a toggle button with QPushButton. +[ToggleButton](Qt.Widgets/CommonControls/ToggleButton) shows how to create a toggle button with QPushButton. -[Widget](Qt.Widgets/CommonControls/ToggleButton) Shows how to create a widget with QWidget. +[Widget](Qt.Widgets/CommonControls/ToggleButton) shows how to create a widget with QWidget. ## Containers -[Frame](Qt.Widgets/Containers/Frame) Shows how to create a frame with QFrame. +[Frame](Qt.Widgets/Containers/Frame) shows how to create a frame with QFrame. -[GroupBox](Qt.Widgets/Containers/GroupBox) Shows how to create a group box with QGroupBox. +[GroupBox](Qt.Widgets/Containers/GroupBox) shows how to create a group box with QGroupBox. -[TabWidget](Qt.Widgets/Containers/TabWidget) Shows how to create a tab widget with QTabWidget. +[TabWidget](Qt.Widgets/Containers/TabWidget) shows how to create a tab widget with QTabWidget. -[Window](Qt.Widgets/Containers/Window) Shows how to create a window with QMainWindow. +[Window](Qt.Widgets/Containers/Window) shows how to create a window with QMainWindow. ## Menus and toolbars -[MenuBar](Qt.Widgets/MenusAndToolbars/MenuBar) Shows how to create a menu bar with QMenu and QAction. +[MenuBar](Qt.Widgets/MenusAndToolbars/MenuBar) shows how to create a menu bar with QMenu and QAction. -[StatusBar](Qt.Widgets/MenusAndToolbars/StatusBar) Shows how to create a status bar with QStatusBar. +[StatusBar](Qt.Widgets/MenusAndToolbars/StatusBar) shows how to create a status bar with QStatusBar. ## Components -[Cursors](Qt.Widgets/Components/Cursors) Shows how to associate cursor to widget with QCursor. +[Cursors](Qt.Widgets/Components/Cursors) shows how to associate cursor to widget with QCursor. -[Timer](Qt.Widgets/Components/Timer) Shows how to create a Timer with QTimer. +[Timer](Qt.Widgets/Components/Timer) shows how to create a Timer with QTimer. ## Dialogs -[ColorDialog](Qt.Widgets/Dialogs/ColorDialog) Shows how to create a ColorDialog with QColorDalog. +[ColorDialog](Qt.Widgets/Dialogs/ColorDialog) shows how to create a ColorDialog with QColorDalog. -[FolderBrowserDialog](Qt.Widgets/Dialogs/FolderBrowserDialog) Shows how to create a FolderBrowserDialog with QFileDialog. +[FolderBrowserDialog](Qt.Widgets/Dialogs/FolderBrowserDialog) shows how to create a FolderBrowserDialog with QFileDialog. -[FontDialog](Qt.Widgets/Dialogs/FontDialog) Shows how to create a FontDialog with QFontDialog. +[FontDialog](Qt.Widgets/Dialogs/FontDialog) shows how to create a FontDialog with QFontDialog. -[MessageBox](Qt.Widgets/Dialogs/MessageBox) Shows how to create a MessageBox with QMessageBox. +[MessageBox](Qt.Widgets/Dialogs/MessageBox) shows how to create a MessageBox with QMessageBox. -[OpenFileDialog](Qt.Widgets/Dialogs/OpenFileDialog) Shows how to create an OpenFileDialog with QFileDialog. +[OpenFileDialog](Qt.Widgets/Dialogs/OpenFileDialog) shows how to create an OpenFileDialog with QFileDialog. -[SaveFileDialog](Qt.Widgets/Dialogs/SaveFileDialog) Shows how to create an SaveFileDialog with QFileDialog. +[SaveFileDialog](Qt.Widgets/Dialogs/SaveFileDialog) shows how to create an SaveFileDialog with QFileDialog. ## Others -[LCDNumber2](Qt.Widgets/Others/LCDNumber2) Shows how to create a LCD number with QLCDNumber. +[LCDNumber2](Qt.Widgets/Others/LCDNumber2) shows how to create a LCD number with QLCDNumber. + +[Wiggly](Qt.Widgets/Others/Wiggly) shows how to animate a user control using QBasicTimer and timerEvent(). In addition, the example demonstrates how to use QFontMetrics to determine the size of text on screen. ## Download