├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE.md ├── Qt.Core ├── CMakeLists.txt ├── Collections │ ├── CMakeLists.txt │ ├── Collections.pro │ ├── List │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── List.pro │ │ ├── README.md │ │ └── src │ │ │ └── List.cpp │ └── README.md ├── Console │ ├── CMakeLists.txt │ ├── Console.pro │ ├── Console │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── Console.pro │ │ ├── README.md │ │ └── src │ │ │ └── Console.cpp │ ├── ConsoleColor │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── ConsoleColor.pro │ │ ├── README.md │ │ └── src │ │ │ └── ConsoleColor.cpp │ └── README.md ├── HelloWorlds │ ├── .gitignore │ ├── CMakeLists.txt │ ├── HelloWorldConsole │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── HelloWorldConsole.pro │ │ ├── README.md │ │ └── src │ │ │ └── HelloWorldConsole.cpp │ ├── HelloWorlds.pro │ └── README.md ├── Qt.Core.pro ├── README.md ├── Strings │ ├── CMakeLists.txt │ ├── README.md │ ├── StringSplit │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── StringSplit.pro │ │ └── src │ │ │ └── StringSplit.cpp │ ├── StringUnicode │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── StringUnicode.pro │ │ └── src │ │ │ └── StringUnicode.cpp │ ├── StringUnicode2 │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── StringUnicode2.pro │ │ └── src │ │ │ └── StringUnicode2.cpp │ └── Strings.pro └── Tests │ ├── CMakeLists.txt │ ├── TestConsole │ ├── .gitignore │ ├── CMakeLists.txt │ ├── TestConsole.pro │ └── src │ │ └── main.cpp │ └── Tests.pro ├── Qt.Examples.pro ├── Qt.Quick ├── ControlsQuick │ ├── ButtonQuick │ │ ├── ButtonQuick.pro │ │ ├── ButtonsClicked.h │ │ ├── main.cpp │ │ ├── main.qml │ │ └── qml.qrc │ ├── CheckBoxQuick │ │ ├── CheckBoxQuick.pro │ │ ├── main.cpp │ │ ├── main.qml │ │ └── qml.qrc │ ├── ControlsQuick.pro │ └── README.md ├── HelloWorldsQuick │ ├── HelloWorldMessageQuick │ │ ├── HelloWorldMessageQuick.pro │ │ ├── main.cpp │ │ ├── main.qml │ │ └── qml.qrc │ ├── HelloWorldQuick │ │ ├── HelloWorldQuick.pro │ │ ├── main.cpp │ │ ├── main.qml │ │ └── qml.qrc │ ├── HelloWorldsQuick.pro │ └── README.md ├── Qt.Quick.pro └── README.md ├── Qt.Test ├── CMakeLists.txt ├── HelloWorldsUnitTest │ ├── CMakeLists.txt │ ├── HelloWorldUnitTest │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── HelloWorldUnitTest.pro │ │ ├── README.md │ │ └── src │ │ │ └── HelloWorldUnitTest.cpp │ ├── HelloWorldsUnitTest.pro │ └── README.md ├── Qt.Test.pro └── README.md ├── Qt.Widgets ├── Applications │ ├── Application │ │ ├── Application.pro │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── src │ │ │ └── Application.cpp │ ├── ApplicationAndException │ │ ├── ApplicationAndException.pro │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── src │ │ │ ├── ApplicationAndException.cpp │ │ │ └── ApplicationAndException.h │ ├── Applications.pro │ ├── CMakeLists.txt │ ├── DarkMode │ │ ├── CMakeLists.txt │ │ ├── DarkMode.pro │ │ ├── README.md │ │ └── src │ │ │ ├── DarkMode.cpp │ │ │ └── DarkMode.h │ └── README.md ├── CMakeLists.txt ├── Components │ ├── CMakeLists.txt │ ├── Components.pro │ ├── Cursors │ │ ├── CMakeLists.txt │ │ ├── Cursors.pro │ │ ├── README.md │ │ └── src │ │ │ ├── Cursors.cpp │ │ │ └── Cursors.h │ ├── README.md │ └── Timer │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── Timer.pro │ │ └── src │ │ ├── Timer.cpp │ │ └── Timer.h ├── Containers │ ├── CMakeLists.txt │ ├── Containers.pro │ ├── Frame │ │ ├── CMakeLists.txt │ │ ├── Frame.pro │ │ ├── README.md │ │ └── src │ │ │ ├── Frame.cpp │ │ │ └── Frame.h │ ├── GroupBox │ │ ├── CMakeLists.txt │ │ ├── GroupBox.pro │ │ ├── README.md │ │ └── src │ │ │ ├── GroupBox.cpp │ │ │ └── GroupBox.h │ ├── README.md │ └── TabWidget │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── TabWidget.pro │ │ └── src │ │ ├── TabWidget.cpp │ │ └── TabWidget.h ├── Controls │ ├── CMakeLists.txt │ ├── CheckBox │ │ ├── CMakeLists.txt │ │ ├── CheckBox.pro │ │ ├── README.md │ │ └── src │ │ │ ├── CheckBox.cpp │ │ │ └── CheckBox.h │ ├── CheckedListWidget │ │ ├── CMakeLists.txt │ │ ├── CheckedListWidget.pro │ │ ├── README.md │ │ └── src │ │ │ ├── CheckedListWidget.cpp │ │ │ └── CheckedListWidget.h │ ├── ComboBox │ │ ├── CMakeLists.txt │ │ ├── ComboBox.pro │ │ ├── README.md │ │ └── src │ │ │ ├── ComboBox.cpp │ │ │ └── ComboBox.h │ ├── Controls.pro │ ├── Dial │ │ ├── CMakeLists.txt │ │ ├── Dial.pro │ │ ├── README.md │ │ └── src │ │ │ ├── Dial.cpp │ │ │ └── Dial.h │ ├── DoubleSpinBox │ │ ├── CMakeLists.txt │ │ ├── DoubleSpinBox.pro │ │ ├── README.md │ │ └── src │ │ │ ├── DoubleSpinBox.cpp │ │ │ └── DoubleSpinBox.h │ ├── LCDNumber │ │ ├── CMakeLists.txt │ │ ├── LCDNumber.pro │ │ ├── README.md │ │ └── src │ │ │ ├── LCDNumber.cpp │ │ │ └── LCDNumber.h │ ├── Label │ │ ├── CMakeLists.txt │ │ ├── Label.pro │ │ ├── README.md │ │ └── src │ │ │ ├── Label.cpp │ │ │ └── Label.h │ ├── LineEdit │ │ ├── CMakeLists.txt │ │ ├── LineEdit.pro │ │ ├── README.md │ │ └── src │ │ │ ├── LineEdit.cpp │ │ │ └── LineEdit.h │ ├── ListView │ │ ├── CMakeLists.txt │ │ ├── ListView.pro │ │ ├── README.md │ │ └── src │ │ │ ├── Ai48.xpm │ │ │ ├── Avi48.xpm │ │ │ ├── Bmp48.xpm │ │ │ ├── ListView.cpp │ │ │ └── ListView.h │ ├── ListView2 │ │ ├── CMakeLists.txt │ │ ├── ListView2.pro │ │ ├── README.md │ │ └── src │ │ │ ├── Ai16.xpm │ │ │ ├── Avi16.xpm │ │ │ ├── Bmp16.xpm │ │ │ ├── ListView2.cpp │ │ │ └── ListView2.h │ ├── ListWidget │ │ ├── CMakeLists.txt │ │ ├── ListWidget.pro │ │ ├── README.md │ │ └── src │ │ │ ├── ListWidget.cpp │ │ │ └── ListWidget.h │ ├── PictureBox │ │ ├── CMakeLists.txt │ │ ├── PictureBox.pro │ │ ├── PictureBox.qrc │ │ ├── README.md │ │ ├── Resources │ │ │ └── Logo.png │ │ └── src │ │ │ ├── PictureBox.cpp │ │ │ └── PictureBox.h │ ├── PictureBox2 │ │ ├── CMakeLists.txt │ │ ├── PictureBox2.pro │ │ ├── PictureBox2.qrc │ │ ├── README.md │ │ ├── Resources │ │ │ └── Logo.png │ │ └── src │ │ │ ├── PictureBox2.cpp │ │ │ └── PictureBox2.h │ ├── ProgressBar │ │ ├── CMakeLists.txt │ │ ├── ProgressBar.pro │ │ ├── README.md │ │ └── src │ │ │ ├── ProgressBar.cpp │ │ │ └── ProgressBar.h │ ├── PushButton │ │ ├── CMakeLists.txt │ │ ├── PushButton.pro │ │ ├── README.md │ │ └── src │ │ │ ├── PushButton.cpp │ │ │ └── PushButton.h │ ├── README.md │ ├── RadioButton │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── RadioButton.pro │ │ └── src │ │ │ ├── RadioButton.cpp │ │ │ └── RadioButton.h │ ├── Slider │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── Slider.pro │ │ └── src │ │ │ ├── Slider.cpp │ │ │ └── Slider.h │ ├── SpinBox │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── SpinBox.pro │ │ └── src │ │ │ ├── SpinBox.cpp │ │ │ └── SpinBox.h │ ├── SpinButton │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── SpinButton.pro │ │ └── src │ │ │ ├── SpinButton.cpp │ │ │ └── SpinButton.h │ ├── ToggleButton │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── ToggleButton.pro │ │ └── src │ │ │ ├── ToggleButton.cpp │ │ │ └── ToggleButton.h │ ├── TreeView │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── TreeView.pro │ │ └── src │ │ │ ├── TreeView.cpp │ │ │ └── TreeView.h │ ├── TreeWidget │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── TreeWidget.pro │ │ └── src │ │ │ ├── TreeWidget.cpp │ │ │ └── TreeWidget.h │ └── Widget │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── Widget.pro │ │ └── src │ │ ├── Widget.cpp │ │ └── Widget.h ├── Dialogs │ ├── AboutBox │ │ ├── AboutBox.pro │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── src │ │ │ ├── AboutBox.cpp │ │ │ └── AboutBox.h │ ├── CMakeLists.txt │ ├── ColorDialog │ │ ├── CMakeLists.txt │ │ ├── ColorDialog.pro │ │ ├── README.md │ │ └── src │ │ │ ├── ColorDialog.cpp │ │ │ └── ColorDialog.h │ ├── Dialogs.pro │ ├── FolderBrowserDialog │ │ ├── CMakeLists.txt │ │ ├── FolderBrowserDialog.pro │ │ ├── README.md │ │ └── src │ │ │ ├── FolderBrowserDialog.cpp │ │ │ └── FolderBrowserDialog.h │ ├── FontDialog │ │ ├── CMakeLists.txt │ │ ├── FontDialog.pro │ │ ├── README.md │ │ └── src │ │ │ ├── FontDialog.cpp │ │ │ └── FontDialog.h │ ├── InputDialog │ │ ├── CMakeLists.txt │ │ ├── InputDialog.pro │ │ ├── README.md │ │ └── src │ │ │ ├── InputDialog.cpp │ │ │ └── InputDialog.h │ ├── MessageBox │ │ ├── CMakeLists.txt │ │ ├── MessageBox.pro │ │ ├── README.md │ │ └── src │ │ │ ├── MessageBox.cpp │ │ │ └── MessageBox.h │ ├── OpenFileDialog │ │ ├── CMakeLists.txt │ │ ├── OpenFileDialog.pro │ │ ├── README.md │ │ └── src │ │ │ ├── OpenFileDialog.cpp │ │ │ └── OpenFileDialog.h │ ├── README.md │ └── SaveFileDialog │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── SaveFileDialog.pro │ │ └── src │ │ ├── SaveFileDialog.cpp │ │ └── SaveFileDialog.h ├── HelloWorlds │ ├── CMakeLists.txt │ ├── HelloWorldEmoticons │ │ ├── CMakeLists.txt │ │ ├── HelloWorldEmoticons.pro │ │ ├── README.md │ │ └── src │ │ │ ├── HelloWorldEmoticons.cpp │ │ │ └── HelloWorldEmoticons.h │ ├── HelloWorldLabel │ │ ├── CMakeLists.txt │ │ ├── HelloWorldLabel.pro │ │ ├── README.md │ │ └── src │ │ │ ├── HelloWorldLabel.cpp │ │ │ └── HelloWorldLabel.h │ ├── HelloWorldMessageBox │ │ ├── CMakeLists.txt │ │ ├── HelloWorldMessageBox.pro │ │ ├── README.md │ │ └── src │ │ │ ├── HelloWorldMessageBox.cpp │ │ │ └── HelloWorldMessageBox.h │ ├── HelloWorldPaint │ │ ├── CMakeLists.txt │ │ ├── HelloWorldPaint.pro │ │ ├── README.md │ │ └── src │ │ │ ├── HelloWorldPaint.cpp │ │ │ └── HelloWorldPaint.h │ ├── HelloWorlds.pro │ └── README.md ├── MenusAndToolbars │ ├── CMakeLists.txt │ ├── MenuBar │ │ ├── CMakeLists.txt │ │ ├── MenuBar.pro │ │ ├── README.md │ │ └── src │ │ │ ├── MenuBar.cpp │ │ │ └── MenuBar.h │ ├── MenusAndToolbars.pro │ ├── README.md │ ├── StatusBar │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── StatusBar.pro │ │ └── src │ │ │ ├── StatusBar.cpp │ │ │ └── StatusBar.h │ └── ToolBar │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── ToolBar.pro │ │ └── src │ │ ├── ToolBar.cpp │ │ └── ToolBar.h ├── Others │ ├── ButtonWithStyleSheet │ │ ├── ButtonWithStyleSheet.pro │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── src │ │ │ ├── ButtonWithStyleSheet.cpp │ │ │ └── ButtonWithStyleSheet.h │ ├── CMakeLists.txt │ ├── InputDialogMultiline │ │ ├── CMakeLists.txt │ │ ├── InputDialogMultiline.pro │ │ ├── README.md │ │ └── src │ │ │ ├── InputDialogMultiline.cpp │ │ │ └── InputDialogMultiline.h │ ├── InputDialogPassword │ │ ├── CMakeLists.txt │ │ ├── InputDialogPassword.pro │ │ ├── README.md │ │ └── src │ │ │ ├── InputDialogPassword.cpp │ │ │ └── InputDialogPassword.h │ ├── LCDNumber2 │ │ ├── CMakeLists.txt │ │ ├── LCDNumber2.pro │ │ ├── README.md │ │ └── src │ │ │ ├── LCDNumber2.cpp │ │ │ └── LCDNumber2.h │ ├── Others.pro │ ├── README.md │ ├── Wiggly │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── Wiggly.pro │ │ └── src │ │ │ ├── Wiggly.cpp │ │ │ └── Wiggly.h │ └── WindowShowHide │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── WindowShowHide.pro │ │ └── src │ │ ├── WindowShowHide.cpp │ │ └── WindowShowHide.h ├── Qt.Widgets.pro ├── README.md ├── Tests │ ├── CMakeLists.txt │ ├── README.md │ ├── TestWidgets │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── TestWidgets.pro │ │ └── src │ │ │ └── TestWidgets.cpp │ └── Tests.pro ├── UserControls │ ├── CMakeLists.txt │ ├── Line │ │ ├── CMakeLists.txt │ │ ├── Line.pro │ │ ├── README.md │ │ └── src │ │ │ ├── Line.cpp │ │ │ └── Line.h │ ├── README.md │ └── UserControls.pro └── Windows │ ├── CMakeLists.txt │ ├── MainWindow │ ├── CMakeLists.txt │ ├── MainWindow.pro │ ├── README.md │ └── src │ │ ├── MainWindow.cpp │ │ └── MainWindow.h │ ├── README.md │ └── Windows.pro ├── README.md └── docs └── Pictures ├── AboutBox.png ├── AboutBoxQt.png ├── Application.png ├── ApplicationAndException.png ├── ButtonWithStyleSheet.png ├── CheckBox.png ├── CheckedListWidget.png ├── ColorDialog.png ├── ComboBox.png ├── Cursors.png ├── DarkMode.png ├── Dial.png ├── DoubleSpinBox.png ├── FolderBrowserDialog.png ├── FontDialog.png ├── Forms ├── HelloWorldForms.png ├── PictureBox.png ├── ProgressBar.png ├── TabControl.png └── TrackBar.png ├── Frame.png ├── GroupBox.png ├── HelloWorldEmoticons.png ├── HelloWorldLabel.png ├── HelloWorldMessageBox.png ├── HelloWorldPaint.png ├── HelloWorldUnitTest.png ├── InputDialog.png ├── InputDialogMultiline.png ├── InputDialogPassword.png ├── LCDNumber.png ├── LCDNumber2.png ├── Label.png ├── Line.png ├── LineEdit.png ├── ListView.png ├── ListView2.png ├── ListWidget.png ├── Logo.png ├── MainWindow.png ├── MenuBar.png ├── MessageBox.png ├── OpenFileDialog.png ├── PictureBox.png ├── PictureBox2.png ├── ProgressBar.png ├── PushButton.png ├── RadioButton.png ├── SaveFileDialog.png ├── Slider.png ├── SpinBox.png ├── SpinButton.png ├── StatusBar.png ├── TabWidget.png ├── Timer.png ├── ToggleButton.png ├── ToolBar.png ├── TreeView.png ├── TreeWidget.png ├── Widget.png ├── Wiggly.png ├── WindowShowHide.png └── qt_header.png /.gitignore: -------------------------------------------------------------------------------- 1 | # build folders 2 | build 3 | build* 4 | cmake-build* 5 | 6 | # macOS files 7 | .DS_Store 8 | 9 | # Windows files 10 | Thumbs.db 11 | 12 | # CLion files 13 | .idea 14 | 15 | # Visual Studio files 16 | .vs 17 | 18 | # Visual Studio Code files 19 | .vscode 20 | 21 | # Qt user config make files 22 | CMakeLists.txt.user 23 | *.pro.user 24 | 25 | # Visual Studio user config cmake files 26 | CMakeSettings.json 27 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | dist: xenial 3 | 4 | before_install: 5 | - sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa 6 | - sudo apt-get update -qq 7 | - sudo apt-get install qtbase5-dev qtdeclarative5-dev libQt6webkit5-dev libsqlite3-dev 8 | - sudo apt-get install Qt6-default qttools5-dev-tools 9 | os: linux 10 | script: 11 | - cd Qt.Core 12 | - qmake -project 13 | - qmake Qt.Core.pro 14 | - make 15 | - cd ../Qt.Widgets 16 | - qmake -project 17 | - qmake Qt.Widgets.pro 18 | - make 19 | - cd .. 20 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Qt.Examples) 4 | 5 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 6 | 7 | add_subdirectory(Qt.Core) 8 | add_subdirectory(Qt.Widgets) 9 | #add_subdirectory(Qt.Quick) 10 | add_subdirectory(Qt.Test) 11 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 [Gammasoft](https://gammasoft71.wixsite.com/gammasoft). 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Qt.Core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Qt.Core) 4 | 5 | add_subdirectory(HelloWorlds) 6 | add_subdirectory(Collections) 7 | add_subdirectory(Console) 8 | add_subdirectory(Strings) 9 | add_subdirectory(Tests) 10 | -------------------------------------------------------------------------------- /Qt.Core/Collections/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Collections) 4 | 5 | add_subdirectory(List) 6 | -------------------------------------------------------------------------------- /Qt.Core/Collections/Collections.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | List 4 | -------------------------------------------------------------------------------- /Qt.Core/Collections/List/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /Qt.Core/Collections/List/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(List) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core) 13 | endif () 14 | 15 | add_executable(${PROJECT_NAME} src/List.cpp) 16 | target_link_libraries(${PROJECT_NAME} Qt::Core) 17 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Core/Collections") 18 | -------------------------------------------------------------------------------- /Qt.Core/Collections/List/List.pro: -------------------------------------------------------------------------------- 1 | CONFIG += console c++17 2 | CONFIG -= app_bundle 3 | QT = core 4 | SOURCES = \ 5 | src/List.cpp 6 | -------------------------------------------------------------------------------- /Qt.Core/Collections/README.md: -------------------------------------------------------------------------------- 1 | # Collections 2 | 3 | Contains Collections examples. 4 | 5 | * [List](List/README.md) shows how to use QList. 6 | 7 | ## Generate and build 8 | 9 | ### Qt Creator 10 | 11 | To build these projects, open `Collections.pro` file with Qt Creator. 12 | 13 | ### CMake 14 | 15 | To build this project, open "Terminal" and type following lines: 16 | 17 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 18 | 19 | #### Windows : 20 | 21 | ``` cmake 22 | mkdir build 23 | cd build 24 | cmake .. 25 | start ./Collections.sln 26 | ``` 27 | 28 | #### macOS : 29 | 30 | ``` cmake 31 | mkdir build 32 | cd build 33 | cmake .. -G "Xcode" 34 | open ./Collections.xcodeproj 35 | ``` 36 | 37 | #### Linux with Code::Blocks : 38 | 39 | ``` cmake 40 | mkdir build 41 | cd build 42 | cmake .. -G "CodeBlocks - Unix Makefiles" 43 | xdg-open ./Collections.cbp > /dev/null 2>&1 44 | ``` 45 | 46 | #### Linux : 47 | 48 | ``` cmake 49 | mkdir build 50 | cd build 51 | cmake .. 52 | cmake --build . --config Debug 53 | ./AnyProject 54 | ``` 55 | -------------------------------------------------------------------------------- /Qt.Core/Console/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Console) 4 | 5 | add_subdirectory(Console) 6 | add_subdirectory(ConsoleColor) 7 | -------------------------------------------------------------------------------- /Qt.Core/Console/Console.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | Console \ 4 | ConsoleColor 5 | -------------------------------------------------------------------------------- /Qt.Core/Console/Console/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /Qt.Core/Console/Console/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Console) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} src/Console.cpp) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Core/Console") 21 | -------------------------------------------------------------------------------- /Qt.Core/Console/Console/Console.pro: -------------------------------------------------------------------------------- 1 | CONFIG += console c++17 2 | CONFIG -= app_bundle 3 | QT = core 4 | SOURCES = src/Console.cpp 5 | -------------------------------------------------------------------------------- /Qt.Core/Console/Console/README.md: -------------------------------------------------------------------------------- 1 | # Console 2 | 3 | Shows how to use QTextStream stream with stdin and stdout. 4 | 5 | ## Sources 6 | 7 | [src/Console.cpp](src/Console.cpp) 8 | 9 | [CMakeLists.txt](CMakeLists.txt) 10 | 11 | ## Output 12 | 13 | ``` 14 | Hello World! 15 | Enter your name: James 16 | Good day, James! 17 | ``` 18 | 19 | ## Generate and build 20 | 21 | ### Qt Creator 22 | 23 | To build these projects, open `Console.pro` file with Qt Creator. 24 | 25 | ### CMake 26 | 27 | To build this project, open "Terminal" and type following lines: 28 | 29 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 30 | 31 | #### Windows : 32 | 33 | ``` cmake 34 | mkdir build 35 | cd build 36 | cmake .. 37 | start ./Console.sln 38 | ``` 39 | 40 | #### macOS : 41 | 42 | ``` cmake 43 | mkdir build 44 | cd build 45 | cmake .. -G "Xcode" 46 | open ./Console.xcodeproj 47 | ``` 48 | 49 | #### Linux with Code::Blocks : 50 | 51 | ``` cmake 52 | mkdir build 53 | cd build 54 | cmake .. -G "CodeBlocks - Unix Makefiles" 55 | xdg-open ./Console.cbp > /dev/null 2>&1 56 | ``` 57 | 58 | #### Linux : 59 | 60 | ``` cmake 61 | mkdir build 62 | cd build 63 | cmake .. 64 | cmake --build . --config Debug 65 | ./Console 66 | ``` 67 | -------------------------------------------------------------------------------- /Qt.Core/Console/Console/src/Console.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | auto out = QTextStream {stdout}; 6 | out << "Hello "; 7 | out << "World!" << Qt::endl; 8 | out << "Enter your name: "; 9 | out.flush(); 10 | 11 | auto in = QTextStream {stdin}; 12 | auto name = QString {}; 13 | in >> name; 14 | out << "Good day, "; 15 | out << name; 16 | out << "!" << Qt::endl; 17 | } 18 | -------------------------------------------------------------------------------- /Qt.Core/Console/ConsoleColor/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /Qt.Core/Console/ConsoleColor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(ConsoleColor) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(ConsoleColor src/ConsoleColor.cpp) 19 | target_link_libraries(ConsoleColor Qt::Core) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Core/Console") 21 | -------------------------------------------------------------------------------- /Qt.Core/Console/ConsoleColor/ConsoleColor.pro: -------------------------------------------------------------------------------- 1 | CONFIG += console c++17 2 | CONFIG -= app_bundle 3 | QT = core 4 | SOURCES = src/ConsoleColor.cpp 5 | -------------------------------------------------------------------------------- /Qt.Core/Console/README.md: -------------------------------------------------------------------------------- 1 | # Console 2 | 3 | Contains console examples. 4 | 5 | * [Console](Console/README.md) shows how to use QTextStream stream with stdin and stdout. 6 | * [ConsoleColor](ConsoleColor/README.md) shows how to use QTextStream stream with stdout and ANSI colors. 7 | 8 | ## Generate and build 9 | 10 | ### Qt Creator 11 | 12 | To build these projects, open `Console.pro` file with Qt Creator. 13 | 14 | ### CMake 15 | 16 | To build this project, open "Terminal" and type following lines: 17 | 18 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 19 | 20 | #### Windows : 21 | 22 | ``` cmake 23 | mkdir build 24 | cd build 25 | cmake .. 26 | start ./Console.sln 27 | ``` 28 | 29 | #### macOS : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. -G "Xcode" 35 | open ./Console.xcodeproj 36 | ``` 37 | 38 | #### Linux with Code::Blocks : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "CodeBlocks - Unix Makefiles" 44 | xdg-open ./Console.cbp > /dev/null 2>&1 45 | ``` 46 | 47 | #### Linux : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. 53 | cmake --build . --config Debug 54 | ./AnyProject 55 | ``` 56 | -------------------------------------------------------------------------------- /Qt.Core/HelloWorlds/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /Qt.Core/HelloWorlds/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(HelloWorlds) 4 | 5 | add_subdirectory(HelloWorldConsole) 6 | -------------------------------------------------------------------------------- /Qt.Core/HelloWorlds/HelloWorldConsole/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /Qt.Core/HelloWorlds/HelloWorldConsole/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(HelloWorldConsole) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} src/HelloWorldConsole.cpp) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Core/HelloWorlds") 21 | -------------------------------------------------------------------------------- /Qt.Core/HelloWorlds/HelloWorldConsole/HelloWorldConsole.pro: -------------------------------------------------------------------------------- 1 | CONFIG += console c++17 2 | CONFIG -= app_bundle 3 | QT = core 4 | SOURCES = src/HelloWorldConsole.cpp 5 | -------------------------------------------------------------------------------- /Qt.Core/HelloWorlds/HelloWorldConsole/src/HelloWorldConsole.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | auto out = QTextStream {stdout}; 5 | out << "Hello, World!" << Qt::endl; 6 | } 7 | 8 | // This code produces the following output : 9 | // 10 | // Hello, World! 11 | -------------------------------------------------------------------------------- /Qt.Core/HelloWorlds/HelloWorlds.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | HelloWorldConsole 4 | -------------------------------------------------------------------------------- /Qt.Core/HelloWorlds/README.md: -------------------------------------------------------------------------------- 1 | # HelloWorlds 2 | 3 | Contains Qt.Core "Hello, World!" examples. 4 | 5 | * [HelloWorldConsole](HelloWorldConsole/README.md) The classic first application "Hello, world!" with QTextStream stream. 6 | 7 | ## Generate and build 8 | 9 | ### Qt Creator 10 | 11 | To build these projects, open `HelloWorlds.pro` file with Qt Creator. 12 | 13 | ### CMake 14 | 15 | To build this project, open "Terminal" and type following lines: 16 | 17 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 18 | 19 | #### Windows : 20 | 21 | ``` cmake 22 | mkdir build 23 | cd build 24 | cmake .. 25 | start ./HelloWorlds.sln 26 | ``` 27 | 28 | #### macOS : 29 | 30 | ``` cmake 31 | mkdir build 32 | cd build 33 | cmake .. -G "Xcode" 34 | open ./HelloWorlds.xcodeproj 35 | ``` 36 | 37 | #### Linux with Code::Blocks : 38 | 39 | ``` cmake 40 | mkdir build 41 | cd build 42 | cmake .. -G "CodeBlocks - Unix Makefiles" 43 | xdg-open ./HelloWorlds.cbp > /dev/null 2>&1 44 | ``` 45 | 46 | #### Linux : 47 | 48 | ``` cmake 49 | mkdir build 50 | cd build 51 | cmake .. 52 | cmake --build . --config Debug 53 | ./AnyProject 54 | ``` 55 | -------------------------------------------------------------------------------- /Qt.Core/Qt.Core.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | HelloWorlds \ 4 | Console \ 5 | Collections \ 6 | Strings \ 7 | Tests 8 | -------------------------------------------------------------------------------- /Qt.Core/Strings/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Strings) 4 | 5 | add_subdirectory(StringSplit) 6 | add_subdirectory(StringUnicode) 7 | add_subdirectory(StringUnicode2) 8 | -------------------------------------------------------------------------------- /Qt.Core/Strings/README.md: -------------------------------------------------------------------------------- 1 | # Strings 2 | 3 | Contains string examples. 4 | 5 | * [StringSplit](StringSplit/README.md) shows how to use QString::split method. 6 | * [StringUnicode](StringUnicode/README.md) shows how to use QTextStream and QString with unicode. 7 | * [StringUnicode2](StringUnicode2/README.md) shows how to use QTextStream and QString with unicode. 8 | 9 | ## Generate and build 10 | 11 | ### Qt Creator 12 | 13 | To build these projects, open `Strings.pro` file with Qt Creator. 14 | 15 | ### CMake 16 | 17 | To build this project, open "Terminal" and type following lines: 18 | 19 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 20 | 21 | #### Windows : 22 | 23 | ``` cmake 24 | mkdir build 25 | cd build 26 | cmake .. 27 | start ./Strings.sln 28 | ``` 29 | 30 | #### macOS : 31 | 32 | ``` cmake 33 | mkdir build 34 | cd build 35 | cmake .. -G "Xcode" 36 | open ./Strings.xcodeproj 37 | ``` 38 | 39 | #### Linux with Code::Blocks : 40 | 41 | ``` cmake 42 | mkdir build 43 | cd build 44 | cmake .. -G "CodeBlocks - Unix Makefiles" 45 | xdg-open ./Strings.cbp > /dev/null 2>&1 46 | ``` 47 | 48 | #### Linux : 49 | 50 | ``` cmake 51 | mkdir build 52 | cd build 53 | cmake .. 54 | cmake --build . --config Debug 55 | ./AnyProject 56 | ``` 57 | -------------------------------------------------------------------------------- /Qt.Core/Strings/StringSplit/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /Qt.Core/Strings/StringSplit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(StringSplit) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} src/StringSplit.cpp) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Core/Strings") 21 | -------------------------------------------------------------------------------- /Qt.Core/Strings/StringSplit/README.md: -------------------------------------------------------------------------------- 1 | # StringSplit 2 | 3 | Shows how to use QString::split method. 4 | 5 | ## Sources 6 | 7 | [src/StringSplit.cpp](src/StringSplit.cpp) 8 | 9 | [CMakeLists.txt](CMakeLists.txt) 10 | 11 | ## Output 12 | 13 | ``` 14 | strings.count() = 5 15 | One 16 | Two 17 | Three 18 | Four 19 | Five 20 | ``` 21 | 22 | ## Generate and build 23 | 24 | ### Qt Creator 25 | 26 | To build these projects, open `StringSplit.pro` file with Qt Creator. 27 | 28 | ### CMake 29 | 30 | To build this project, open "Terminal" and type following lines: 31 | 32 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 33 | 34 | #### Windows : 35 | 36 | ``` cmake 37 | mkdir build 38 | cd build 39 | cmake .. 40 | start ./StringSplit.sln 41 | ``` 42 | 43 | #### macOS : 44 | 45 | ``` cmake 46 | mkdir build 47 | cd build 48 | cmake .. -G "Xcode" 49 | open ./StringSplit.xcodeproj 50 | ``` 51 | 52 | #### Linux with Code::Blocks : 53 | 54 | ``` cmake 55 | mkdir build 56 | cd build 57 | cmake .. -G "CodeBlocks - Unix Makefiles" 58 | xdg-open ./StringSplit.cbp > /dev/null 2>&1 59 | ``` 60 | 61 | #### Linux : 62 | 63 | ``` cmake 64 | mkdir build 65 | cd build 66 | cmake .. 67 | cmake --build . --config Debug 68 | ./StringSplit 69 | ``` 70 | -------------------------------------------------------------------------------- /Qt.Core/Strings/StringSplit/StringSplit.pro: -------------------------------------------------------------------------------- 1 | CONFIG += console c++17 2 | CONFIG -= app_bundle 3 | QT = core 4 | SOURCES = \ 5 | src/StringSplit.cpp 6 | -------------------------------------------------------------------------------- /Qt.Core/Strings/StringSplit/src/StringSplit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace Qt; 6 | 7 | int main() { 8 | auto strings = QString("One Two Three Four\nFive").split(QRegularExpression("(\x9|\xA|\xB|\xC|\xD|\x20)+")); 9 | 10 | QTextStream out(stdout); 11 | out << QString("strings.count() = %1").arg(strings.count()) << Qt::endl; 12 | for (auto& s : strings) 13 | out << s << Qt::endl; 14 | } 15 | 16 | // This code produces the following output: 17 | // 18 | // strings.count() = 5 19 | // One 20 | // Two 21 | // Three 22 | // Four 23 | // Five 24 | -------------------------------------------------------------------------------- /Qt.Core/Strings/StringUnicode/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /Qt.Core/Strings/StringUnicode/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(StringUnicode) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} src/StringUnicode.cpp) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Core/Strings") 21 | -------------------------------------------------------------------------------- /Qt.Core/Strings/StringUnicode/StringUnicode.pro: -------------------------------------------------------------------------------- 1 | CONFIG += console c++17 2 | CONFIG -= app_bundle 3 | QT = core 4 | SOURCES = \ 5 | src/StringUnicode.cpp 6 | -------------------------------------------------------------------------------- /Qt.Core/Strings/StringUnicode2/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /Qt.Core/Strings/StringUnicode2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(StringUnicode2) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} src/StringUnicode2.cpp) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Core/Strings") 21 | -------------------------------------------------------------------------------- /Qt.Core/Strings/StringUnicode2/StringUnicode2.pro: -------------------------------------------------------------------------------- 1 | CONFIG += console c++17 2 | CONFIG -= app_bundle 3 | QT = core 4 | SOURCES = \ 5 | src/StringUnicode2.cpp 6 | -------------------------------------------------------------------------------- /Qt.Core/Strings/StringUnicode2/src/StringUnicode2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace Qt; 5 | 6 | int main() { 7 | QTextStream out(stdout); 8 | QString str = u8"\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A\u002c\u0020\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA\U0001F428\u0021"; 9 | 10 | // Remarks : the koala character (\U0001F428) is splitted into two utf16... 11 | QString result = ""; 12 | for(auto c : str) 13 | result += QString("%1 ").arg(c); 14 | out << result << Qt::endl; 15 | 16 | // Remarks : the koala character (\U0001F428) is splitted into two utf16... 17 | result = ""; 18 | for(auto c : str) 19 | result += QString("\\u%1").arg(c.unicode(), 4, 16, QChar('0')); 20 | out << result << Qt::endl; 21 | } 22 | 23 | // This code produces the following output: 24 | // 25 | // 日 本 語 の ひ ら が な , 漢 字 と カ タ カ ナ ? ? ! 26 | // \u65e5\u672c\u8a9e\u306e\u3072\u3089\u304c\u306a\u002c\u0020\u6f22\u5b57\u3068\u30ab\u30bf\u30ab\u30ca\ud83d\udc28\u0021 27 | -------------------------------------------------------------------------------- /Qt.Core/Strings/Strings.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | StringSplit \ 4 | StringUnicode \ 5 | StringUnicode2 6 | -------------------------------------------------------------------------------- /Qt.Core/Tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Tests) 4 | 5 | add_subdirectory(TestConsole) 6 | -------------------------------------------------------------------------------- /Qt.Core/Tests/TestConsole/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /Qt.Core/Tests/TestConsole/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(TestConsole) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(TestConsole src/main.cpp) 19 | target_link_libraries(TestConsole Qt::Core) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Core/tests") 21 | -------------------------------------------------------------------------------- /Qt.Core/Tests/TestConsole/TestConsole.pro: -------------------------------------------------------------------------------- 1 | CONFIG -= app_bundle 2 | CONFIG += c++17 3 | QT = core 4 | SOURCES = src/main.cpp 5 | -------------------------------------------------------------------------------- /Qt.Core/Tests/TestConsole/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace Qt; 4 | 5 | int main() { 6 | QTextStream out(stdout); 7 | out << "Hello, World!" << Qt::endl; 8 | } 9 | -------------------------------------------------------------------------------- /Qt.Core/Tests/Tests.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | TestConsole 4 | -------------------------------------------------------------------------------- /Qt.Examples.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | Qt.Core \ 4 | Qt.Widgets \ 5 | #Qt.Quick \ 6 | Qt.Test \ 7 | -------------------------------------------------------------------------------- /Qt.Quick/ControlsQuick/ButtonQuick/ButtonQuick.pro: -------------------------------------------------------------------------------- 1 | QT += quick 2 | CONFIG += c++17 3 | 4 | QML_IMPORT_PATH = 5 | QML_DESIGNER_IMPORT_PATH = 6 | 7 | qnx: target.path = /tmp/$${TARGET}/bin 8 | else: unix:!android: target.path = /opt/$${TARGET}/bin 9 | !isEmpty(target.path): INSTALLS += target 10 | 11 | HEADERS = ButtonsClicked.h 12 | 13 | SOURCES = main.cpp 14 | 15 | RESOURCES += qml.qrc 16 | -------------------------------------------------------------------------------- /Qt.Quick/ControlsQuick/ButtonQuick/ButtonsClicked.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class ButtonsClicked : public QObject { 5 | Q_OBJECT 6 | public: 7 | explicit ButtonsClicked (QObject* parent = nullptr) : QObject(parent) {} 8 | 9 | Q_INVOKABLE QString button1Clicked() { 10 | static int counter = 0; 11 | return QString("button1 clicked %1 times").arg(++counter); 12 | } 13 | 14 | Q_INVOKABLE QString button2Clicked() { 15 | static int counter = 0; 16 | return QString("button2 clicked %1 times").arg(++counter); 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /Qt.Quick/ControlsQuick/ButtonQuick/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "ButtonsClicked.h" 5 | 6 | int main(int argc, char *argv[]) { 7 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 8 | QGuiApplication app(argc, argv); 9 | QQmlApplicationEngine engine; 10 | 11 | ButtonsClicked buttonsClicked; 12 | engine.rootContext()->setContextProperty("buttonsClicked", &buttonsClicked); 13 | 14 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 15 | if (engine.rootObjects().isEmpty()) 16 | return -1; 17 | 18 | return app.exec(); 19 | } 20 | -------------------------------------------------------------------------------- /Qt.Quick/ControlsQuick/ButtonQuick/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.9 2 | import QtQuick.Window 2.2 3 | import QtQuick.Controls 2.2 4 | 5 | Window { 6 | visible: true 7 | width: 300 8 | height: 300 9 | title: "" 10 | 11 | Button { 12 | id: button1 13 | x: 50 14 | y: 50 15 | text: "button1" 16 | onClicked: label1.text = buttonsClicked.button1Clicked() 17 | } 18 | 19 | Button { 20 | id: button2 21 | x: 50 22 | y: 100 23 | width: 200 24 | height: 75 25 | text: "button2" 26 | onClicked: label2.text = buttonsClicked.button2Clicked() 27 | } 28 | 29 | Label { 30 | id: label1 31 | x: 50 32 | y: 200 33 | text: "button1 clicked 0 times" 34 | 35 | } 36 | 37 | Label { 38 | id: label2 39 | x: 50 40 | y: 230 41 | text: "button2 clicked 0 times" 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Qt.Quick/ControlsQuick/ButtonQuick/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /Qt.Quick/ControlsQuick/CheckBoxQuick/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char *argv[]) { 6 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 7 | QGuiApplication app(argc, argv); 8 | QQmlApplicationEngine engine; 9 | 10 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 11 | if (engine.rootObjects().isEmpty()) 12 | return -1; 13 | 14 | return app.exec(); 15 | } 16 | -------------------------------------------------------------------------------- /Qt.Quick/ControlsQuick/CheckBoxQuick/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.9 2 | import QtQuick.Window 2.2 3 | import QtQuick.Controls 2.2 4 | 5 | Window { 6 | visible: true 7 | width: 300 8 | height: 300 9 | title: "CheckBox examples" 10 | 11 | CheckBox { 12 | id: checkBox1 13 | x: 30 14 | y: 30 15 | text: qsTr("Checked") 16 | checkState: Qt.Checked 17 | } 18 | 19 | CheckBox { 20 | id: checkBox2 21 | x: 30 22 | y: 70 23 | text: qsTr("Unchecked") 24 | checkState: Qt.Unchecked 25 | } 26 | 27 | CheckBox { 28 | id: checkBox3 29 | x: 30 30 | y: 110 31 | text: qsTr("Indeterminate") 32 | checkState: Qt.PartiallyChecked 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Qt.Quick/ControlsQuick/CheckBoxQuick/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /Qt.Quick/ControlsQuick/ControlsQuick.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | ButtonQuick \ 4 | CheckBoxQuick 5 | -------------------------------------------------------------------------------- /Qt.Quick/ControlsQuick/README.md: -------------------------------------------------------------------------------- 1 | # ControlsQuick 2 | 3 | [This folder](.) contains controls examples. 4 | 5 | * [ButtonQuick](ButtonQuick/README.md) shows how to use Button. 6 | * [CheckBoxQuick](CheckBoxQuick/README.md) shows how to use CheckBox. 7 | 8 | ## Generate and build 9 | 10 | ### Qt Creator 11 | 12 | To build these projects, open `ControlsQuick.pro` file with Qt Creator. 13 | 14 | ### CMake 15 | 16 | To build this project, open "Terminal" and type following lines: 17 | 18 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 19 | 20 | #### Windows : 21 | 22 | ``` cmake 23 | mkdir build 24 | cd build 25 | cmake .. 26 | start ./ControlsQuick.sln 27 | ``` 28 | 29 | #### macOS : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. -G "Xcode" 35 | open ./ControlsQuick.xcodeproj 36 | ``` 37 | 38 | #### Linux with Code::Blocks : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "CodeBlocks - Unix Makefiles" 44 | xdg-open ./ControlsQuick.cbp > /dev/null 2>&1 45 | ``` 46 | 47 | #### Linux : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. 53 | cmake --build . --config Debug 54 | ./AnyProject 55 | ``` 56 | -------------------------------------------------------------------------------- /Qt.Quick/HelloWorldsQuick/HelloWorldMessageQuick/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char *argv[]) { 6 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 7 | QGuiApplication app(argc, argv); 8 | QQmlApplicationEngine engine; 9 | 10 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 11 | if (engine.rootObjects().isEmpty()) 12 | return -1; 13 | 14 | return app.exec(); 15 | } 16 | -------------------------------------------------------------------------------- /Qt.Quick/HelloWorldsQuick/HelloWorldMessageQuick/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.9 2 | import QtQuick.Window 2.2 3 | import QtQuick.Controls 2.2 4 | import QtQuick.Dialogs 1.2 5 | 6 | Window { 7 | visible: true 8 | width: 300 9 | height: 300 10 | title: "Hello World Form" 11 | 12 | MessageDialog { 13 | id: messageBox 14 | text: "Hello, World!" 15 | } 16 | 17 | Button { 18 | id: button1 19 | x: 10 20 | y: 10 21 | text: "Click me" 22 | onClicked: messageBox.visible = true 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Qt.Quick/HelloWorldsQuick/HelloWorldMessageQuick/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /Qt.Quick/HelloWorldsQuick/HelloWorldQuick/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char *argv[]) { 6 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 7 | QGuiApplication app(argc, argv); 8 | QQmlApplicationEngine engine; 9 | 10 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 11 | if (engine.rootObjects().isEmpty()) 12 | return -1; 13 | 14 | return app.exec(); 15 | } 16 | -------------------------------------------------------------------------------- /Qt.Quick/HelloWorldsQuick/HelloWorldQuick/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.9 2 | import QtQuick.Window 2.2 3 | import QtQuick.Controls 2.2 4 | 5 | Window { 6 | visible: true 7 | width: 300 8 | height: 300 9 | title: "My first application" 10 | 11 | Label { 12 | id: label1 13 | x: 5 14 | y: 100 15 | width: 290 16 | height: 100 17 | text: "Hello, World!" 18 | color: "darkGreen" 19 | font.family: "Arial" 20 | font.pointSize: 45 21 | font.bold: true 22 | font.italic: true 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Qt.Quick/HelloWorldsQuick/HelloWorldQuick/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /Qt.Quick/HelloWorldsQuick/HelloWorldsQuick.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | HelloWorldMessageQuick \ 4 | HelloWorldQuick 5 | -------------------------------------------------------------------------------- /Qt.Quick/Qt.Quick.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | ControlsQuick \ 4 | HelloWorldsQuick 5 | -------------------------------------------------------------------------------- /Qt.Test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Qt.Test) 4 | 5 | add_subdirectory(HelloWorldsUnitTest) 6 | -------------------------------------------------------------------------------- /Qt.Test/HelloWorldsUnitTest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(HelloWorldsUnitTest) 4 | 5 | add_subdirectory(HelloWorldUnitTest) 6 | -------------------------------------------------------------------------------- /Qt.Test/HelloWorldsUnitTest/HelloWorldUnitTest/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /Qt.Test/HelloWorldsUnitTest/HelloWorldUnitTest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(HelloWorldUnitTest) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Test) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Test) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} src/HelloWorldUnitTest.cpp) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Test) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Test/HelloWorldsUnitTest") 21 | -------------------------------------------------------------------------------- /Qt.Test/HelloWorldsUnitTest/HelloWorldUnitTest/HelloWorldUnitTest.pro: -------------------------------------------------------------------------------- 1 | CONFIG += console c++17 2 | CONFIG -= app_bundle 3 | QT = core testlib 4 | SOURCES = src/HelloWorldUnitTest.cpp 5 | -------------------------------------------------------------------------------- /Qt.Test/HelloWorldsUnitTest/HelloWorldUnitTest/src/HelloWorldUnitTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace UnitTests { 5 | class HelloWorldTest : public QObject{ 6 | Q_OBJECT 7 | private slots: 8 | void CreateStringFromLiteral() { 9 | auto s = QString {"Hello, World!"}; 10 | QCOMPARE(s.size(), 13); 11 | QCOMPARE(s, "Hello, World!"); 12 | } 13 | }; 14 | } 15 | 16 | QTEST_MAIN(UnitTests::HelloWorldTest) 17 | #include "HelloWorldUnitTest.moc" 18 | 19 | // This code can produce the following output : 20 | // 21 | // ********* Start testing of UnitTests::HelloWorldTest ********* 22 | // Config: Using QtTest library 6.6.0, Qt 6.6.0 (arm64-little_endian-lp64 shared (dynamic) release build; by Apple LLVM 15.0.0 (clang-1500.0.40.1)), macos 14.2 23 | // PASS : UnitTests::HelloWorldTest::initTestCase() 24 | // PASS : UnitTests::HelloWorldTest::CreateStringFromLiteral() 25 | // PASS : UnitTests::HelloWorldTest::cleanupTestCase() 26 | // Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 1ms 27 | // ********* Finished testing of UnitTests::HelloWorldTest ********* 28 | -------------------------------------------------------------------------------- /Qt.Test/HelloWorldsUnitTest/HelloWorldsUnitTest.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | HelloWorldUnitTest 4 | -------------------------------------------------------------------------------- /Qt.Test/HelloWorldsUnitTest/README.md: -------------------------------------------------------------------------------- 1 | # HelloWorldsUnitTest 2 | 3 | [This folder](.) contains Qt.Test "Hello, world!" examples. 4 | 5 | * [HelloWorldUnitTest](HelloWorldUnitTest/README.md) The classic first application "Hello, World!". 6 | 7 | ## Generate and build 8 | 9 | ### Qt Creator 10 | 11 | To build these projects, open `HelloWorldsUnitTest.pro` file with Qt Creator. 12 | 13 | ### CMake 14 | 15 | To build this project, open "Terminal" and type following lines: 16 | 17 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 18 | 19 | #### Windows : 20 | 21 | ``` cmake 22 | mkdir build 23 | cd build 24 | cmake .. 25 | start ./HelloWorldsUnitTest.sln 26 | ``` 27 | 28 | #### macOS : 29 | 30 | ``` cmake 31 | mkdir build 32 | cd build 33 | cmake .. -G "Xcode" 34 | open ./HelloWorldsUnitTest.xcodeproj 35 | ``` 36 | 37 | #### Linux with Code::Blocks : 38 | 39 | ``` cmake 40 | mkdir build 41 | cd build 42 | cmake .. -G "CodeBlocks - Unix Makefiles" 43 | xdg-open ./HelloWorldsUnitTest.cbp > /dev/null 2>&1 44 | ``` 45 | 46 | #### Linux : 47 | 48 | ``` cmake 49 | mkdir build 50 | cd build 51 | cmake .. 52 | cmake --build . --config Debug 53 | ./AnyProject 54 | ``` 55 | -------------------------------------------------------------------------------- /Qt.Test/Qt.Test.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | HelloWorldsUnitTest 4 | -------------------------------------------------------------------------------- /Qt.Widgets/Applications/Application/Application.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/Application.cpp 4 | -------------------------------------------------------------------------------- /Qt.Widgets/Applications/Application/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Application) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/Application.cpp) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Applications") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Applications/Application/README.md: -------------------------------------------------------------------------------- 1 | 2 | Shows how to create an application with QApplication. 3 | 4 | ## Sources 5 | 6 | [src/Application.cpp](src/Application.cpp) 7 | 8 | [CMakeLists.txt](CMakeLists.txt) 9 | 10 | ## Output 11 | 12 | ![Screenshot](../../../docs/Pictures/Application.png) 13 | 14 | ## Generate and build 15 | 16 | ### Qt Creator 17 | 18 | To build these projects, open `Application.pro` file with Qt Creator. 19 | 20 | ### CMake 21 | 22 | To build this project, open "Terminal" and type following lines: 23 | 24 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 25 | 26 | #### Windows : 27 | 28 | ``` cmake 29 | mkdir build 30 | cd build 31 | cmake .. 32 | start ./Application.sln 33 | ``` 34 | 35 | #### macOS : 36 | 37 | ``` cmake 38 | mkdir build 39 | cd build 40 | cmake .. -G "Xcode" 41 | open ./Application.xcodeproj 42 | ``` 43 | 44 | #### Linux with Code::Blocks : 45 | 46 | ``` cmake 47 | mkdir build 48 | cd build 49 | cmake .. -G "CodeBlocks - Unix Makefiles" 50 | xdg-open ./Application.cbp > /dev/null 2>&1 51 | ``` 52 | 53 | #### Linux : 54 | 55 | ``` cmake 56 | mkdir build 57 | cd build 58 | cmake .. 59 | cmake --build . --config Debug 60 | ./Application 61 | ``` 62 | -------------------------------------------------------------------------------- /Qt.Widgets/Applications/Application/src/Application.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) { 5 | auto application = QApplication {argc, argv}; 6 | auto window1 = QMainWindow {}; 7 | window1.show(); 8 | return application.exec(); 9 | } 10 | -------------------------------------------------------------------------------- /Qt.Widgets/Applications/ApplicationAndException/ApplicationAndException.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/ApplicationAndException.cpp 4 | HEADERS = src/ApplicationAndException.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Applications/ApplicationAndException/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(ApplicationAndException) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/ApplicationAndException.cpp src/ApplicationAndException.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Applications") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Applications/Applications.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | Application \ 4 | ApplicationAndException \ 5 | DarkMode 6 | -------------------------------------------------------------------------------- /Qt.Widgets/Applications/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Applications) 4 | 5 | # Application and messages 6 | add_subdirectory(Application) 7 | add_subdirectory(ApplicationAndException) 8 | add_subdirectory(DarkMode) 9 | #add_subdirectory(ApplicationWithMessageLoop) 10 | -------------------------------------------------------------------------------- /Qt.Widgets/Applications/DarkMode/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(DarkMode) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(DarkMode WIN32 MACOSX_BUNDLE src/DarkMode.cpp src/DarkMode.h) 19 | target_link_libraries(DarkMode Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Applications") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Applications/DarkMode/DarkMode.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/DarkMode.cpp 4 | HEADERS = src/DarkMode.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Applications/DarkMode/README.md: -------------------------------------------------------------------------------- 1 | # DarkMode 2 | 3 | Shows how to create a dark mode application. 4 | 5 | ## Sources 6 | 7 | [src/DarkMode.h](src/DarkMode.h) 8 | 9 | [src/DarkMode.cpp](src/DarkMode.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/DarkMode.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `DarkMode.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./DarkMode.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./DarkMode.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./DarkMode.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./DarkMode 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Applications/DarkMode/src/DarkMode.cpp: -------------------------------------------------------------------------------- 1 | #include "DarkMode.h" 2 | 3 | using namespace Examples; 4 | 5 | int main(int argc, char *argv[]) { 6 | auto application = Application {argc, argv}; 7 | auto window1 = Window1 {}; 8 | window1.show(); 9 | return application.exec(); 10 | } 11 | -------------------------------------------------------------------------------- /Qt.Widgets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Qt.Widgets) 4 | 5 | add_subdirectory(HelloWorlds) 6 | add_subdirectory(Applications) 7 | add_subdirectory(Windows) 8 | add_subdirectory(Dialogs) 9 | add_subdirectory(MenusAndToolbars) 10 | add_subdirectory(Containers) 11 | add_subdirectory(Controls) 12 | add_subdirectory(Components) 13 | add_subdirectory(UserControls) 14 | add_subdirectory(Others) 15 | add_subdirectory(Tests) 16 | -------------------------------------------------------------------------------- /Qt.Widgets/Components/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Components) 4 | 5 | # Components 6 | add_subdirectory(Cursors) 7 | add_subdirectory(Timer) 8 | -------------------------------------------------------------------------------- /Qt.Widgets/Components/Components.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | Cursors \ 4 | Timer 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Components/Cursors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Cursors) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/Cursors.cpp src/Cursors.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Components") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Components/Cursors/Cursors.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/Cursors.cpp 4 | HEADERS = src/Cursors.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Components/Cursors/README.md: -------------------------------------------------------------------------------- 1 | # Cursors 2 | 3 | Shows how to associate cursor to widget with QCursors. 4 | 5 | ## Sources 6 | 7 | [src/Cursors.h](src/Cursors.h) 8 | 9 | [src/Cursors.cpp](src/Cursors.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/Cursors.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `Cursors.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./Cursors.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./Cursors.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./Cursors.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./Cursors 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Components/Cursors/src/Cursors.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Cursors.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Components/README.md: -------------------------------------------------------------------------------- 1 | # Components 2 | 3 | [THis folder](.) contains components examples. 4 | 5 | * [Cursors](Cursors/README.md) shows how to associate cursor to widget with QCursor. 6 | * [Timer](Timer/README.md) shows how to create a Timer with QTimer. 7 | 8 | ## Generate and build 9 | 10 | ### Qt Creator 11 | 12 | To build these projects, open `Components.pro` file with Qt Creator. 13 | 14 | ### CMake 15 | 16 | To build this project, open "Terminal" and type following lines: 17 | 18 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 19 | 20 | #### Windows : 21 | 22 | ``` cmake 23 | mkdir build 24 | cd build 25 | cmake .. 26 | start ./Components.sln 27 | ``` 28 | 29 | #### macOS : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. -G "Xcode" 35 | open ./Components.xcodeproj 36 | ``` 37 | 38 | #### Linux with Code::Blocks : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "CodeBlocks - Unix Makefiles" 44 | xdg-open ./Components.cbp > /dev/null 2>&1 45 | ``` 46 | 47 | #### Linux : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. 53 | cmake --build . --config Debug 54 | ./AnyProject 55 | ``` 56 | -------------------------------------------------------------------------------- /Qt.Widgets/Components/Timer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Timer) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/Timer.cpp src/Timer.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Components") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Components/Timer/README.md: -------------------------------------------------------------------------------- 1 | # Timer 2 | 3 | Shows how to create a Timer with QTimer. 4 | 5 | ## Sources 6 | 7 | [src/Timer.h](src/Timer.h) 8 | 9 | [src/Timer.cpp](src/Timer.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/Timer.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `Timer.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./Timer.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./Timer.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./Timer.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./Timer 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Components/Timer/Timer.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/Timer.cpp 4 | HEADERS = src/Timer.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Components/Timer/src/Timer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Timer.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Containers) 4 | 5 | add_subdirectory(Frame) 6 | add_subdirectory(GroupBox) 7 | add_subdirectory(TabWidget) 8 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/Containers.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | Frame \ 4 | GroupBox \ 5 | TabWidget 6 | 7 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/Frame/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Frame) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/Frame.cpp src/Frame.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Containers") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/Frame/Frame.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/Frame.cpp 4 | HEADERS = src/Frame.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/Frame/README.md: -------------------------------------------------------------------------------- 1 | # Frame 2 | 3 | Shows how to create a frame with QFrame. 4 | 5 | ## Sources 6 | 7 | [src/Frame.h](src/Frame.h) 8 | 9 | [src/Frame.cpp](src/Frame.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/Frame.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `Frame.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./Frame.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./Frame.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./Frame.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./Frame 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/Frame/src/Frame.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Frame.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/Frame/src/Frame.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace Examples { 6 | class Window1 : public QMainWindow { 7 | Q_OBJECT 8 | public: 9 | Window1() { 10 | frame1.setFrameStyle(QFrame::StyledPanel | QFrame::Raised); 11 | frame1.move(10, 10); 12 | frame1.resize(305, 460); 13 | 14 | 15 | frame2.setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); 16 | frame2.move(325, 10); 17 | frame2.resize(305, 460); 18 | 19 | setCentralWidget(&frame); 20 | setWindowTitle("Frame example"); 21 | resize(640, 480); 22 | } 23 | 24 | private: 25 | QFrame frame; 26 | QFrame frame1 {&frame}; 27 | QFrame frame2 {&frame}; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/GroupBox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(GroupBox) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/GroupBox.cpp src/GroupBox.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Containers") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/GroupBox/GroupBox.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/GroupBox.cpp 4 | HEADERS = src/GroupBox.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/GroupBox/README.md: -------------------------------------------------------------------------------- 1 | # GroupBox 2 | 3 | Shows how to create a group box with QGroupBox. 4 | 5 | ## Sources 6 | 7 | [src/GroupBox.h](src/GroupBox.h) 8 | 9 | [src/GroupBox.cpp](src/GroupBox.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/GroupBox.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `GroupBox.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./GroupBox.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./GroupBox.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./GroupBox.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./GroupBox 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/GroupBox/src/GroupBox.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "GroupBox.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/GroupBox/src/GroupBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace Examples { 7 | class Window1 : public QMainWindow { 8 | Q_OBJECT 9 | public: 10 | Window1() { 11 | groupBox1.setTitle("GroupBox 1"); 12 | groupBox1.move(10, 10); 13 | groupBox1.resize(305, 460); 14 | 15 | groupBox2.move(325, 10); 16 | groupBox2.resize(305, 460); 17 | 18 | setCentralWidget(&frame); 19 | setWindowTitle("Group box example"); 20 | resize(640, 480); 21 | } 22 | 23 | private: 24 | QFrame frame; 25 | QGroupBox groupBox1 {&frame}; 26 | QGroupBox groupBox2 {&frame}; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/TabWidget/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(TabWidget) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/TabWidget.cpp src/TabWidget.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Containers") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/TabWidget/TabWidget.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/TabWidget.cpp 4 | HEADERS = src/TabWidget.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/TabWidget/src/TabWidget.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "TabWidget.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Containers/TabWidget/src/TabWidget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace Examples { 7 | class Window1 : public QMainWindow { 8 | Q_OBJECT 9 | public: 10 | Window1() { 11 | tabWidget1.move(10, 10); 12 | tabWidget1.resize(370, 250); 13 | tabWidget1.addTab(&tabPage1, "Tab page 1"); 14 | tabWidget1.addTab(&tabPage2, "Tab page 2"); 15 | tabWidget1.addTab(&tabPage3, "Tab page 3"); 16 | 17 | setCentralWidget(&frame); 18 | setWindowTitle("Tab widget example"); 19 | resize(390, 270); 20 | } 21 | 22 | private: 23 | QFrame frame; 24 | QTabWidget tabWidget1 {&frame}; 25 | QFrame tabPage1; 26 | QFrame tabPage2; 27 | QFrame tabPage3; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Controls) 4 | 5 | add_subdirectory(CheckBox) 6 | add_subdirectory(CheckedListWidget) 7 | add_subdirectory(ComboBox) 8 | add_subdirectory(DoubleSpinBox) 9 | add_subdirectory(Dial) 10 | add_subdirectory(Label) 11 | add_subdirectory(LCDNumber) 12 | add_subdirectory(LineEdit) 13 | add_subdirectory(ListView) 14 | add_subdirectory(ListView2) 15 | add_subdirectory(ListWidget) 16 | add_subdirectory(PictureBox) 17 | add_subdirectory(PictureBox2) 18 | add_subdirectory(ProgressBar) 19 | add_subdirectory(PushButton) 20 | add_subdirectory(RadioButton) 21 | add_subdirectory(Slider) 22 | add_subdirectory(SpinBox) 23 | add_subdirectory(SpinButton) 24 | add_subdirectory(ToggleButton) 25 | add_subdirectory(TreeView) 26 | add_subdirectory(TreeWidget) 27 | add_subdirectory(Widget) 28 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/CheckBox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(CheckBox) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/CheckBox.h src/CheckBox.cpp) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/CheckBox/CheckBox.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/CheckBox.cpp 4 | HEADERS = src/CheckBox.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/CheckBox/README.md: -------------------------------------------------------------------------------- 1 | # CheckBox 2 | 3 | Shows how to create a check box with QCheckBox. 4 | 5 | ## Sources 6 | 7 | [src/CheckBox.h](src/CheckBox.h) 8 | 9 | [src/CheckBox.cpp](src/CheckBox.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/CheckBox.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `CheckBox.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./CheckBox.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./CheckBox.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./CheckBox.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./CheckBox 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/CheckBox/src/CheckBox.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "CheckBox.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/CheckedListWidget/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(CheckedListWidget) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/CheckedListWidget.cpp src/CheckedListWidget.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/CheckedListWidget/CheckedListWidget.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/CheckedListWidget.cpp 4 | HEADERS = src/CheckedListWidget.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/CheckedListWidget/src/CheckedListWidget.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "CheckedListWidget.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ComboBox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(ComboBox) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/ComboBox.cpp src/ComboBox.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ComboBox/ComboBox.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/ComboBox.cpp 4 | HEADERS = src/ComboBox.h -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ComboBox/README.md: -------------------------------------------------------------------------------- 1 | # ComboBox 2 | 3 | Shows how to create a combo box with QComboBox. 4 | 5 | ## Sources 6 | 7 | [src/ComboBox.h](src/ComboBox.h) 8 | 9 | [src/ComboBox.cpp](src/ComboBox.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/ComboBox.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `ComboBox.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./ComboBox.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./ComboBox.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./ComboBox.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./ComboBox 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ComboBox/src/ComboBox.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ComboBox.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Controls.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | CheckBox \ 4 | CheckedListWidget \ 5 | ComboBox \ 6 | DoubleSpinBox \ 7 | Dial \ 8 | Label \ 9 | LCDNumber \ 10 | LineEdit \ 11 | ListView \ 12 | ListView2 \ 13 | ListWidget \ 14 | PictureBox \ 15 | PictureBox2 \ 16 | ProgressBar \ 17 | PushButton \ 18 | RadioButton \ 19 | Slider \ 20 | SpinBox \ 21 | SpinButton \ 22 | ToggleButton \ 23 | TreeView \ 24 | TreeWidget \ 25 | Widget 26 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Dial/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Dial) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/Dial.cpp src/Dial.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Dial/Dial.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/Dial.cpp 4 | HEADERS = src/Dial.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Dial/README.md: -------------------------------------------------------------------------------- 1 | # Dial 2 | 3 | Shows how to create a dial with QDial. 4 | 5 | ## Sources 6 | 7 | [src/Dial.h](src/Dial.h) 8 | 9 | [src/Dial.cpp](src/Dial.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/Dial.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `Dial.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./Dial.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./Dial.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./Dial.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./Dial 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Dial/src/Dial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Dial.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Dial/src/Dial.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace Examples { 8 | class Window1 : public QMainWindow { 9 | Q_OBJECT 10 | public: 11 | Window1() { 12 | dial1.setMaximum(200); 13 | dial1.setValue(100); 14 | dial1.move(10, 10); 15 | connect(&dial1, &QDial::valueChanged, [&] { 16 | label1.setText(QString("%1").arg(dial1.value())); 17 | }); 18 | 19 | label1.move(10, 150); 20 | label1.resize(200, 20); 21 | label1.setText(QString("%1").arg(dial1.value())); 22 | 23 | setCentralWidget(&frame); 24 | setWindowTitle("Dial example"); 25 | resize(300, 300); 26 | } 27 | 28 | private: 29 | QFrame frame; 30 | QDial dial1 {&frame}; 31 | QLabel label1 {&frame}; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/DoubleSpinBox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(DoubleSpinBox) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/DoubleSpinBox.cpp src/DoubleSpinBox.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/DoubleSpinBox/DoubleSpinBox.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/DoubleSpinBox.cpp 4 | HEADERS = src/DoubleSpinBox.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/DoubleSpinBox/src/DoubleSpinBox.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "DoubleSpinBox.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/DoubleSpinBox/src/DoubleSpinBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace Examples { 8 | class Window1 : public QMainWindow { 9 | Q_OBJECT 10 | public: 11 | Window1() { 12 | doubleSpinBox.move(80, 50); 13 | doubleSpinBox.setRange(10.0, 11.0); 14 | doubleSpinBox.setDecimals(2); 15 | doubleSpinBox.setSingleStep(0.01); 16 | connect(&doubleSpinBox, qOverload(&QDoubleSpinBox::valueChanged), [&] { 17 | label.setText(QString("value = %1").arg(QString::number(doubleSpinBox.value(), 'f', 2))); 18 | }); 19 | 20 | label.move(80, 100); 21 | label.setText("value = 10.00"); 22 | 23 | setCentralWidget(&frame); 24 | setWindowTitle("Spin box example"); 25 | resize(300, 300); 26 | } 27 | 28 | private: 29 | QFrame frame; 30 | QDoubleSpinBox doubleSpinBox {&frame}; 31 | QLabel label {&frame}; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/LCDNumber/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(LCDNumber) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/LCDNumber.cpp src/LCDNumber.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/LCDNumber/LCDNumber.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/LCDNumber.cpp 4 | HEADERS = src/LCDNumber.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/LCDNumber/README.md: -------------------------------------------------------------------------------- 1 | # LCDNumber 2 | 3 | Shows how to create a LCD number with QLCDNumber. 4 | 5 | ## Sources 6 | 7 | [src/LCDNumber.h](src/LCDNumber.h) 8 | 9 | [src/LCDNumber.cpp](src/LCDNumber.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/LCDNumber.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `LCDNumber.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./LCDNumber.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./LCDNumber.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./LCDNumber.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./LCDNumber 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/LCDNumber/src/LCDNumber.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "LCDNumber.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/LCDNumber/src/LCDNumber.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Examples { 9 | class Window1 : public QMainWindow { 10 | Q_OBJECT 11 | public: 12 | Window1() { 13 | doubleSpinBox.move(10, 10); 14 | doubleSpinBox.setDecimals(2); 15 | doubleSpinBox.setRange(0, 15000000); 16 | doubleSpinBox.setSingleStep(0.01); 17 | doubleSpinBox.setValue(12345678.90); 18 | connect(&doubleSpinBox, qOverload(&QDoubleSpinBox::valueChanged), [&] { 19 | lcdNumber.display(QString::number(doubleSpinBox.value(), 'f', 2)); 20 | }); 21 | 22 | lcdNumber.setSegmentStyle(QLCDNumber::SegmentStyle::Flat); 23 | lcdNumber.setDigitCount(11); 24 | lcdNumber.display("12345678.90"); 25 | lcdNumber.move(10, 50); 26 | lcdNumber.setFrameStyle(QFrame::NoFrame); 27 | 28 | setCentralWidget(&frame); 29 | setWindowTitle("LCD number example"); 30 | resize(300, 300); 31 | } 32 | 33 | private: 34 | QFrame frame; 35 | QDoubleSpinBox doubleSpinBox {&frame}; 36 | QLCDNumber lcdNumber {&frame}; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Label/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Label) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/Label.cpp src/Label.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Label/Label.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/Label.cpp 4 | HEADERS = src/Label.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Label/README.md: -------------------------------------------------------------------------------- 1 | # Label 2 | 3 | Shows how to create a label with QLabel. 4 | 5 | ## Sources 6 | 7 | [src/Label.h](src/Label.h) 8 | 9 | [src/Label.cpp](src/Label.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/Label.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `Label.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./Label.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./Label.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./Label.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./Label 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Label/src/Label.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Label.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/LineEdit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(LineEdit) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/LineEdit.cpp src/LineEdit.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/LineEdit/LineEdit.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/LineEdit.cpp 4 | HEADERS = src/LineEdit.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/LineEdit/README.md: -------------------------------------------------------------------------------- 1 | # LineEdit 2 | 3 | Shows how to create a line edit with QLineEdit. 4 | 5 | ## Sources 6 | 7 | [src/LineEdit.h](src/LineEdit.h) 8 | 9 | [src/LineEdit.cpp](src/LineEdit.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/LineEdit.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `LineEdit.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./LineEdit.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./LineEdit.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./LineEdit.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./LineEdit 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/LineEdit/src/LineEdit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "LineEdit.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/LineEdit/src/LineEdit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace Examples { 7 | class Window1 : public QMainWindow { 8 | Q_OBJECT 9 | public: 10 | Window1() { 11 | lineEdit1.setText("line edit"); 12 | lineEdit1.move(10, 10); 13 | connect(&lineEdit1, &QLineEdit::textChanged, [&] { 14 | if (lineEdit2.text() != lineEdit1.text()) 15 | lineEdit2.setText(lineEdit1.text()); 16 | }); 17 | 18 | lineEdit2.setText("lineEdit"); 19 | lineEdit2.move(10, 50); 20 | connect(&lineEdit2, &QLineEdit::textChanged, [&] { 21 | if (lineEdit1.text() != lineEdit2.text()) 22 | lineEdit1.setText(lineEdit2.text()); 23 | }); 24 | 25 | setCentralWidget(&frame); 26 | setWindowTitle("Line edit example"); 27 | resize(300, 300); 28 | } 29 | 30 | private: 31 | QFrame frame; 32 | QLineEdit lineEdit1 {&frame}; 33 | QLineEdit lineEdit2 {&frame}; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ListView/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(ListView) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/ListView.cpp src/ListView.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ListView/ListView.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/ListView.cpp 4 | HEADERS = src/ListView.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ListView/README.md: -------------------------------------------------------------------------------- 1 | # ListView 2 | 3 | Shows how to create a list view with QListView. 4 | 5 | ## Sources 6 | 7 | [src/ListView.h](src/ListView.h) 8 | 9 | [src/ListView.cpp](src/ListView.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/ListView.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `ListView.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./ListView.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./ListView.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./ListView.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./ListView 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ListView/src/ListView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ListView.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ListView2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(ListView2) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/ListView2.cpp src/ListView2.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ListView2/ListView2.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/ListView2.cpp 4 | HEADERS = src/ListView2.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ListView2/README.md: -------------------------------------------------------------------------------- 1 | # ListView2 2 | 3 | Shows how to create a list view with QTreeView. 4 | 5 | ## Sources 6 | 7 | [src/ListView2.h](src/ListView2.h) 8 | 9 | [src/ListView2.cpp](src/ListView2.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/ListView2.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `ListView2.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./ListView2.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./ListView2.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./ListView2.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./ListView2 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ListView2/src/ListView2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ListView2.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ListWidget/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(ListWidget) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/ListWidget.cpp src/ListWidget.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ListWidget/ListWidget.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/ListWidget.cpp 4 | HEADERS = src/ListWidget.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ListWidget/src/ListWidget.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ListWidget.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PictureBox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(PictureBox) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | set(CMAKE_AUTORCC ON) 18 | 19 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/PictureBox.cpp src/PictureBox.h PictureBox.qrc) 20 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 21 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 22 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PictureBox/PictureBox.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | RESOURCES = PictureBox.qrc 4 | SOURCES = src/PictureBox.cpp 5 | HEADERS = src/PictureBox.h 6 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PictureBox/PictureBox.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Resources/Logo.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PictureBox/Resources/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/Qt.Widgets/Controls/PictureBox/Resources/Logo.png -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PictureBox/src/PictureBox.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "PictureBox.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PictureBox/src/PictureBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace Examples { 8 | using PictureBox = QLabel; 9 | 10 | class Window1 : public QMainWindow { 11 | Q_OBJECT 12 | public: 13 | Window1() { 14 | pictureBox1.move(10, 10); 15 | pictureBox1.resize(280, 280); 16 | pictureBox1.setFrameStyle(QFrame::StyledPanel|QFrame::Plain); 17 | pictureBox1.setAutoFillBackground(true); 18 | pictureBox1.setAlignment (Qt::AlignCenter); 19 | pictureBox1.setPixmap(QPixmap(":/Logo")); 20 | 21 | setCentralWidget(&frame); 22 | setWindowTitle("Picture box example"); 23 | resize(300, 300); 24 | } 25 | 26 | private: 27 | QFrame frame; 28 | PictureBox pictureBox1 {&frame}; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PictureBox2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(PictureBox2) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | set(CMAKE_AUTORCC ON) 18 | 19 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/PictureBox2.cpp src/PictureBox2.h PictureBox2.qrc) 20 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 21 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 22 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PictureBox2/PictureBox2.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | RESOURCES = PictureBox2.qrc 4 | SOURCES = src/PictureBox2.cpp 5 | HEADERS = src/PictureBox2.h 6 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PictureBox2/PictureBox2.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Resources/Logo.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PictureBox2/Resources/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/Qt.Widgets/Controls/PictureBox2/Resources/Logo.png -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PictureBox2/src/PictureBox2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "PictureBox2.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PictureBox2/src/PictureBox2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace Examples { 10 | class Window1 : public QMainWindow { 11 | Q_OBJECT 12 | public: 13 | Window1() { 14 | view.move(10, 10); 15 | view.resize(280, 280); 16 | view.setFrameStyle(QFrame::StyledPanel|QFrame::Plain); 17 | view.setAlignment(Qt::AlignCenter); 18 | item.setPixmap(QPixmap(":/Logo")); 19 | scene.addItem(&item); 20 | 21 | setCentralWidget(&frame); 22 | setWindowTitle("Picture box 2 example"); 23 | resize(300, 300); 24 | } 25 | 26 | private: 27 | QFrame frame; 28 | QGraphicsScene scene; 29 | QGraphicsView view {&scene, &frame}; 30 | QGraphicsPixmapItem item; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ProgressBar/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(ProgressBar) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/ProgressBar.cpp src/ProgressBar.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ProgressBar/ProgressBar.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/ProgressBar.cpp 4 | HEADERS = src/ProgressBar.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ProgressBar/src/ProgressBar.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ProgressBar.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PushButton/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(PushButton) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/PushButton.cpp src/PushButton.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PushButton/PushButton.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/PushButton.cpp 4 | HEADERS = src/PushButton.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/PushButton/src/PushButton.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "PushButton.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/RadioButton/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(RadioButton) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/RadioButton.cpp src/RadioButton.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/RadioButton/RadioButton.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/RadioButton.cpp 4 | HEADERS = src/RadioButton.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/RadioButton/src/RadioButton.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "RadioButton.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/RadioButton/src/RadioButton.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace Examples { 7 | class Window1 : public QMainWindow { 8 | Q_OBJECT 9 | public: 10 | Window1() { 11 | radioButton1.setText("Radio 1"); 12 | radioButton1.move(30, 30); 13 | radioButton1.setChecked(true); 14 | 15 | radioButton2.setText("Radio 2"); 16 | radioButton2.move(30, 60); 17 | 18 | radioButton3.setText("Radio 3"); 19 | radioButton3.move(30, 90); 20 | 21 | setCentralWidget(&frame); 22 | setWindowTitle("Radio button example"); 23 | resize(300, 300); 24 | } 25 | 26 | private: 27 | QFrame frame; 28 | QRadioButton radioButton1 {&frame}; 29 | QRadioButton radioButton2 {&frame}; 30 | QRadioButton radioButton3 {&frame}; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Slider/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Slider) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/Slider.cpp src/Slider.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Slider/README.md: -------------------------------------------------------------------------------- 1 | # Slider 2 | 3 | Shows how to create a slider with QSlider. 4 | 5 | ## Sources 6 | 7 | [src/Slider.h](src/Slider.h) 8 | 9 | [src/Slider.cpp](src/Slider.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/Slider.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `Slider.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./Slider.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./Slider.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./Slider.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./Slider 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Slider/Slider.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/Slider.cpp 4 | HEADERS = src/Slider.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Slider/src/Slider.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Slider.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/SpinBox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(SpinBox) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/SpinBox.cpp src/SpinBox.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/SpinBox/README.md: -------------------------------------------------------------------------------- 1 | # SpinBox 2 | 3 | Shows how to create a spin box with QSpinBox. 4 | 5 | ## Sources 6 | 7 | [src/SpinBox.h](src/SpinBox.h) 8 | 9 | [src/SpinBox.cpp](src/SpinBox.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/SpinBox.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `SpinBox.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./SpinBox.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./SpinBox.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./SpinBox.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./SpinBox 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/SpinBox/SpinBox.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/SpinBox.cpp 4 | HEADERS = src/SpinBox.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/SpinBox/src/SpinBox.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SpinBox.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/SpinBox/src/SpinBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace Examples { 8 | class Window1 : public QMainWindow { 9 | Q_OBJECT 10 | public: 11 | Window1() { 12 | spinBox.move(80, 50); 13 | spinBox.setRange(0, 100); 14 | spinBox.setValue(50); 15 | connect(&spinBox, qOverload(&QSpinBox::valueChanged), [&] { 16 | label.setText(QString("value = %1").arg(spinBox.value())); 17 | }); 18 | 19 | label.move(80, 100); 20 | label.setText("value = 50"); 21 | 22 | setCentralWidget(&frame); 23 | setWindowTitle("Spin box example"); 24 | resize(300, 300); 25 | } 26 | 27 | private: 28 | QFrame frame; 29 | QSpinBox spinBox {&frame}; 30 | QLabel label {&frame}; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/SpinButton/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(SpinButton) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/SpinButton.cpp src/SpinButton.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/SpinButton/SpinButton.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/SpinButton.cpp 4 | HEADERS = src/SpinButton.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/SpinButton/src/SpinButton.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SpinButton.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ToggleButton/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(ToggleButton) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/ToggleButton.cpp src/ToggleButton.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ToggleButton/ToggleButton.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/ToggleButton.cpp 4 | HEADERS = src/ToggleButton.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/ToggleButton/src/ToggleButton.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ToggleButton.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/TreeView/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(TreeView) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/TreeView.cpp src/TreeView.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/TreeView/README.md: -------------------------------------------------------------------------------- 1 | # TreeView 2 | 3 | Shows how to create a three view with QTreeView. 4 | 5 | ## Sources 6 | 7 | [src/TreeView.h](src/TreeView.h) 8 | 9 | [src/TreeView.cpp](src/TreeView.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/TreeView.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `TreeView.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./TreeView.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./TreeView.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./TreeView.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./TreeView 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/TreeView/TreeView.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/TreeView.cpp 4 | HEADERS = src/TreeView.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/TreeView/src/TreeView.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "TreeView.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/TreeWidget/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(TreeWidget) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/TreeWidget.cpp src/TreeWidget.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/TreeWidget/TreeWidget.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/TreeWidget.cpp 4 | HEADERS = src/TreeWidget.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/TreeWidget/src/TreeWidget.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "TreeWidget.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Widget/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Widget) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/Widget.cpp src/Widget.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Controls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Widget/README.md: -------------------------------------------------------------------------------- 1 | # Widget 2 | 3 | Shows how to create a widget with QWidget. 4 | 5 | ## Sources 6 | 7 | [src/Widget.h](src/Widget.h) 8 | 9 | [src/Widget.cpp](src/Widget.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/Widget.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `Widget.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./Widget.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./Widget.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./Widget.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./Widget 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Widget/Widget.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/Widget.cpp 4 | HEADERS = src/Widget.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Widget/src/Widget.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Widget.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Controls/Widget/src/Widget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace Examples { 7 | class Window1 : public QMainWindow { 8 | Q_OBJECT 9 | public: 10 | Window1() { 11 | widget1.move(50, 50); 12 | widget1.setAutoFillBackground(true); 13 | widget1.setPalette({QColor(0x0, 0xFf, 0x7F)}); 14 | 15 | setCentralWidget(&frame); 16 | setWindowTitle("Widget example"); 17 | resize(300, 300); 18 | } 19 | 20 | private: 21 | QFrame frame; 22 | QWidget widget1 {&frame}; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/AboutBox/AboutBox.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/AboutBox.cpp 4 | HEADERS = src/AboutBox.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/AboutBox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(AboutBox) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/AboutBox.cpp src/AboutBox.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Dialogs") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/AboutBox/README.md: -------------------------------------------------------------------------------- 1 | # AboutBox 2 | 3 | Shows how to create an about box with QMessageBox. 4 | 5 | ## Sources 6 | 7 | [src/AboutBox.h](src/AboutBox.h) 8 | 9 | [src/AboutBox.cpp](src/AboutBox.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/AboutBox.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `AboutBox.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./AboutBox.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./AboutBox.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./AboutBox.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./AboutBox 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/AboutBox/src/AboutBox.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AboutBox.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Dialogs) 4 | 5 | # Dialogs 6 | add_subdirectory(AboutBox) 7 | add_subdirectory(ColorDialog) 8 | add_subdirectory(FolderBrowserDialog) 9 | add_subdirectory(FontDialog) 10 | add_subdirectory(InputDialog) 11 | add_subdirectory(MessageBox) 12 | add_subdirectory(OpenFileDialog) 13 | add_subdirectory(SaveFileDialog) 14 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/ColorDialog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(ColorDialog) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/ColorDialog.cpp src/ColorDialog.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Dialogs") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/ColorDialog/ColorDialog.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/ColorDialog.cpp 4 | HEADERS = src/ColorDialog.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/ColorDialog/src/ColorDialog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ColorDialog.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/ColorDialog/src/ColorDialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace Examples { 8 | class Window1 : public QMainWindow { 9 | public: 10 | Window1() { 11 | button.setText("Color..."); 12 | button.move(10, 10); 13 | connect(&button, &QPushButton::clicked, [&] { 14 | QColorDialog colorDialog; 15 | colorDialog.setCurrentColor(palette().color(QPalette::Window)); 16 | colorDialog.setOption(QColorDialog::ShowAlphaChannel); 17 | colorDialog.setParent(this); 18 | if (colorDialog.exec() == QDialog::Accepted) 19 | setPalette({colorDialog.selectedColor()}); 20 | }); 21 | 22 | setCentralWidget(&frame); 23 | setWindowTitle("Color dialog example"); 24 | resize(300, 300); 25 | } 26 | 27 | private: 28 | QFrame frame; 29 | QPushButton button {&frame}; 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/Dialogs.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | AboutBox \ 4 | ColorDialog \ 5 | FolderBrowserDialog \ 6 | FontDialog \ 7 | InputDialog \ 8 | MessageBox \ 9 | OpenFileDialog \ 10 | SaveFileDialog 11 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/FolderBrowserDialog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(FolderBrowserDialog) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/FolderBrowserDialog.cpp src/FolderBrowserDialog.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Dialogs") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/FolderBrowserDialog/FolderBrowserDialog.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/FolderBrowserDialog.cpp 4 | HEADERS = src/FolderBrowserDialog.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/FolderBrowserDialog/src/FolderBrowserDialog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "FolderBrowserDialog.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/FontDialog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(FontDialog) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/FontDialog.cpp src/FontDialog.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Dialogs") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/FontDialog/FontDialog.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/FontDialog.cpp 4 | HEADERS = src/FontDialog.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/FontDialog/src/FontDialog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "FontDialog.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/InputDialog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(InputDialog) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/InputDialog.cpp src/InputDialog.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Dialogs") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/InputDialog/InputDialog.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/InputDialog.cpp 4 | HEADERS = src/InputDialog.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/InputDialog/src/InputDialog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "InputDialog.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/InputDialog/src/InputDialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Examples { 9 | class Window1 : public QMainWindow { 10 | Q_OBJECT 11 | public: 12 | Window1() { 13 | button1.setText("Text..."); 14 | button1.move(10, 10); 15 | connect(&button1, &QPushButton::clicked, [&] { 16 | QInputDialog inputDialog(this); 17 | inputDialog.setWindowTitle("Caption text"); 18 | inputDialog.setLabelText("Message text"); 19 | inputDialog.setTextValue(label1.text()); 20 | QDialog::DialogCode dialogCode = static_cast(inputDialog.exec()); 21 | if (dialogCode == QDialog::Accepted) 22 | label1.setText(inputDialog.textValue()); 23 | }); 24 | 25 | label1.move(10, 50); 26 | label1.setText("Default value"); 27 | 28 | setCentralWidget(&frame); 29 | setWindowTitle("Input dialog example"); 30 | resize(300, 300); 31 | } 32 | 33 | private: 34 | QFrame frame; 35 | QPushButton button1 {&frame}; 36 | QLabel label1 {&frame}; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/MessageBox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(MessageBox) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/MessageBox.cpp src/MessageBox.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Dialogs") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/MessageBox/MessageBox.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/MessageBox.cpp 4 | HEADERS = src/MessageBox.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/MessageBox/src/MessageBox.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "MessageBox.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/MessageBox/src/MessageBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Examples { 9 | class Window1 : public QMainWindow { 10 | Q_OBJECT 11 | public: 12 | Window1() { 13 | buttonShowMessage.setText("Message..."); 14 | buttonShowMessage.move(10, 10); 15 | connect(&buttonShowMessage, &QPushButton::clicked, [&] { 16 | QMessageBox::StandardButton result = QMessageBox::information(this, "Message", "Hello, World!", QMessageBox::StandardButton::Ok|QMessageBox::StandardButton::Cancel); 17 | labelStandardButton.setText(QString("StandardButton = %1").arg(result == QMessageBox::StandardButton::Ok ? "Ok" : "Cancel")); 18 | labelStandardButton.resize(labelStandardButton.sizeHint()); 19 | }); 20 | 21 | labelStandardButton.move(10, 50); 22 | 23 | setCentralWidget(&frame); 24 | setWindowTitle("Message box example"); 25 | resize(300, 300); 26 | } 27 | 28 | private: 29 | QFrame frame; 30 | QPushButton buttonShowMessage {&frame}; 31 | QLabel labelStandardButton {&frame}; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/OpenFileDialog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(OpenFileDialog) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/OpenFileDialog.cpp src/OpenFileDialog.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Dialogs") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/OpenFileDialog/OpenFileDialog.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/OpenFileDialog.cpp 4 | HEADERS = src/OpenFileDialog.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/OpenFileDialog/src/OpenFileDialog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "OpenFileDialog.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/SaveFileDialog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(SaveFileDialog) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/SaveFileDialog.cpp src/SaveFileDialog.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Dialogs") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/SaveFileDialog/SaveFileDialog.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/SaveFileDialog.cpp 4 | HEADERS = src/SaveFileDialog.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Dialogs/SaveFileDialog/src/SaveFileDialog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SaveFileDialog.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(HelloWorld) 4 | 5 | add_subdirectory(HelloWorldEmoticons) 6 | add_subdirectory(HelloWorldLabel) 7 | add_subdirectory(HelloWorldMessageBox) 8 | add_subdirectory(HelloWorldPaint) 9 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldEmoticons/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(HelloWorldEmoticons) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/HelloWorldEmoticons.cpp src/HelloWorldEmoticons.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/HelloWorlds") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldEmoticons/HelloWorldEmoticons.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/HelloWorldEmoticons.cpp 4 | HEADERS = src/HelloWorldEmoticons.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldEmoticons/src/HelloWorldEmoticons.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "HelloWorldEmoticons.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldEmoticons/src/HelloWorldEmoticons.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Examples { 9 | class Window1 : public QMainWindow { 10 | public: 11 | Window1() { 12 | label1.setText("\U0001F44B, \U0001F30E\U00002757"); 13 | label1.setFont({label1.font().family(), 72}); 14 | label1.resize(label1.sizeHint()); 15 | 16 | setCentralWidget(&frame); 17 | setWindowTitle("Hello world (emoticons)"); 18 | resize(label1.sizeHint()); 19 | } 20 | 21 | private: 22 | QFrame frame; 23 | QLabel label1 {&frame}; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldLabel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(HelloWorldLabel) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/HelloWorldLabel.cpp src/HelloWorldLabel.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/HelloWorlds") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldLabel/HelloWorldLabel.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/HelloWorldLabel.cpp 4 | HEADERS = src/HelloWorldLabel.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldLabel/src/HelloWorldLabel.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "HelloWorldLabel.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldLabel/src/HelloWorldLabel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Examples { 9 | class Window1 : public QMainWindow { 10 | public: 11 | Window1() { 12 | label1.setText("Hello, World!"); 13 | QPalette palette; 14 | palette.setColor(QPalette::WindowText, Qt::GlobalColor::darkGreen); 15 | label1.setPalette(palette); 16 | label1.setFont({label1.font().family(), 34, QFont::Bold, true}); 17 | label1.setAlignment(Qt::AlignCenter | Qt::AlignVCenter); 18 | label1.setWordWrap(true); 19 | 20 | setCentralWidget(&label1); 21 | setWindowTitle("Hello world (label)"); 22 | resize(300, 300); 23 | } 24 | 25 | private: 26 | QLabel label1 {this}; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldMessageBox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(HelloWorldMessageBox) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/HelloWorldMessageBox.cpp src/HelloWorldMessageBox.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/HelloWorlds") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldMessageBox/HelloWorldMessageBox.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/HelloWorldMessageBox.cpp 4 | HEADERS = src/HelloWorldMessageBox.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldMessageBox/src/HelloWorldMessageBox.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "HelloWorldMessageBox.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldMessageBox/src/HelloWorldMessageBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace Examples { 8 | class Window1 : public QMainWindow { 9 | Q_OBJECT 10 | public: 11 | Window1() { 12 | buttonClickMe.setText("Click me"); 13 | buttonClickMe.move(10, 10); 14 | connect(&buttonClickMe, &QPushButton::clicked, [&] { 15 | QMessageBox(QMessageBox::Icon::NoIcon, "", "Hello, World!").exec(); 16 | }); 17 | 18 | setCentralWidget(&frame); 19 | setWindowTitle("Hello world (Message box)"); 20 | resize(300, 300); 21 | } 22 | 23 | private: 24 | QFrame frame; 25 | QPushButton buttonClickMe {&frame}; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldPaint/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(HelloWorldPaint) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/HelloWorldPaint.cpp src/HelloWorldPaint.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/HelloWorlds") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldPaint/HelloWorldPaint.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/HelloWorldPaint.cpp 4 | HEADERS = src/HelloWorldPaint.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldPaint/src/HelloWorldPaint.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "HelloWorldPaint.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorldPaint/src/HelloWorldPaint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace Examples { 10 | class Window1 : public QMainWindow { 11 | public: 12 | Window1() { 13 | setWindowTitle("Hello world (paint)"); 14 | resize(300, 300); 15 | } 16 | 17 | protected: 18 | void paintEvent(QPaintEvent* e) override { 19 | QPainter painter(this); 20 | painter.setPen(Qt::GlobalColor::blue); 21 | painter.setFont({font().family(), 34, QFont::Bold, true}); 22 | painter.drawText(e->rect(), "Hello, World!", QTextOption(Qt::AlignmentFlag::AlignHCenter|Qt::AlignmentFlag::AlignVCenter)); 23 | } 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /Qt.Widgets/HelloWorlds/HelloWorlds.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | HelloWorldEmoticons \ 4 | HelloWorldLabel \ 5 | HelloWorldMessageBox \ 6 | HelloWorldPaint 7 | -------------------------------------------------------------------------------- /Qt.Widgets/MenusAndToolbars/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(MenusAndToolbars) 4 | 5 | # MenusAndToolbars 6 | add_subdirectory(MenuBar) 7 | add_subdirectory(StatusBar) 8 | add_subdirectory(ToolBar) 9 | -------------------------------------------------------------------------------- /Qt.Widgets/MenusAndToolbars/MenuBar/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(MenuBar) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/MenuBar.cpp src/MenuBar.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/MenuAndToolbars") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/MenusAndToolbars/MenuBar/MenuBar.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/MenuBar.cpp 4 | HEADERS = src/MenuBar.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/MenusAndToolbars/MenuBar/README.md: -------------------------------------------------------------------------------- 1 | # MenuBar 2 | 3 | Shows how to create a menu bar with QMenu and QAction. 4 | 5 | ## Sources 6 | 7 | [src/MenuBar.h](src/MenuBar.h) 8 | 9 | [src/MenuBar.cpp](src/MenuBar.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/MenuBar.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `MenuBar.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./MenuBar.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./MenuBar.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./MenuBar.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./MenuBar 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/MenusAndToolbars/MenuBar/src/MenuBar.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "MenuBar.h" 5 | 6 | using namespace Examples; 7 | 8 | int main(int argc, char *argv[]) { 9 | auto application = QApplication {argc, argv}; 10 | #if defined(Q_OS_MACOS) 11 | QIcon::setThemeSearchPaths(QStringList {":macos-icon-theme"}); 12 | QIcon::setThemeName("macos-icon-theme"); 13 | #elif defined(Q_OS_WINDOWS) 14 | QIcon::setThemeSearchPaths(QStringList {":windows-icon-theme"}); 15 | QIcon::setThemeName("windows-icon-theme"); 16 | #endif 17 | auto window1 = Window1 {}; 18 | window1.show(); 19 | return application.exec(); 20 | } 21 | -------------------------------------------------------------------------------- /Qt.Widgets/MenusAndToolbars/MenusAndToolbars.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | MenuBar \ 4 | StatusBar \ 5 | ToolBar 6 | -------------------------------------------------------------------------------- /Qt.Widgets/MenusAndToolbars/StatusBar/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(StatusBar) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/StatusBar.cpp src/StatusBar.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/MenuAndToolbars") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/MenusAndToolbars/StatusBar/StatusBar.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/StatusBar.cpp 4 | HEADERS = src/StatusBar.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/MenusAndToolbars/StatusBar/src/StatusBar.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "StatusBar.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/MenusAndToolbars/ToolBar/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(ToolBar) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/ToolBar.cpp src/ToolBar.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/MenuAndToolbars") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/MenusAndToolbars/ToolBar/README.md: -------------------------------------------------------------------------------- 1 | # ToolBar 2 | 3 | Shows how to create a toolbar bar with QToolsBar. 4 | 5 | ## Sources 6 | 7 | [src/ToolBar.h](src/ToolBar.h) 8 | 9 | [src/ToolBar.cpp](src/ToolBar.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/ToolBar.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `ToolBar.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./ToolBar.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./ToolBar.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./ToolBar.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./ToolBar 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/MenusAndToolbars/ToolBar/ToolBar.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/ToolBar.cpp 4 | HEADERS = src/ToolBar.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/MenusAndToolbars/ToolBar/src/ToolBar.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ToolBar.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/ButtonWithStyleSheet/ButtonWithStyleSheet.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/ButtonWithStyleSheet.cpp 4 | HEADERS = src/ButtonWithStyleSheet.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/ButtonWithStyleSheet/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(ButtonWithStyleSheet) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/ButtonWithStyleSheet.cpp src/ButtonWithStyleSheet.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Others") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/ButtonWithStyleSheet/src/ButtonWithStyleSheet.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ButtonWithStyleSheet.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/ButtonWithStyleSheet/src/ButtonWithStyleSheet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace Examples { 7 | class Window1 : public QMainWindow { 8 | Q_OBJECT 9 | public: 10 | Window1() { 11 | button1.setText("Click me"); 12 | button1.move(10, 10); 13 | button1.resize(75, 25); 14 | button1.setStyleSheet(buttonStyleSheets); 15 | 16 | setCentralWidget(&frame); 17 | setWindowTitle("Button with style sheet example"); 18 | resize(300, 300); 19 | } 20 | 21 | private: 22 | QString buttonStyleSheets = 23 | "QPushButton {\n" 24 | " background-color: #666666;\n" 25 | " margin: 2px 1px 0px 1px;\n" 26 | " border-style: Solid;\n" 27 | " border-width: 1px;\n" 28 | " border-color: #666666;\n" 29 | " border-radius: 6px 6px;\n" 30 | "}\n" 31 | "QPushButton:pressed {\n" 32 | " background-color: #007AFF;\n" 33 | "color: #FFFFFF;\n" 34 | "}\n" 35 | ; 36 | 37 | QFrame frame; 38 | QPushButton button1 {&frame}; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Others) 4 | 5 | # Others 6 | add_subdirectory(ButtonWithStyleSheet) 7 | add_subdirectory(InputDialogMultiline) 8 | add_subdirectory(InputDialogPassword) 9 | add_subdirectory(LCDNumber2) 10 | add_subdirectory(Wiggly) 11 | add_subdirectory(WindowShowHide) 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/InputDialogMultiline/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(InputDialogMultiline) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/InputDialogMultiline.cpp src/InputDialogMultiline.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Others") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/InputDialogMultiline/InputDialogMultiline.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/InputDialogMultiline.cpp 4 | HEADERS = src/InputDialogMultiline.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/InputDialogMultiline/src/InputDialogMultiline.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "InputDialogMultiline.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/InputDialogMultiline/src/InputDialogMultiline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Examples { 9 | class Window1 : public QMainWindow { 10 | Q_OBJECT 11 | public: 12 | Window1() { 13 | button1.setText("Text..."); 14 | button1.move(10, 10); 15 | connect(&button1, &QPushButton::clicked, [&] { 16 | QInputDialog inputDialog(this); 17 | bool ok = false; 18 | auto result = QInputDialog::getMultiLineText(this, "Caption text", "Message text", label1.text(), &ok); 19 | if (ok) label1.setText(result); 20 | label1.adjustSize(); 21 | }); 22 | 23 | label1.move(10, 50); 24 | label1.setText("line 1\nline 2"); 25 | 26 | setCentralWidget(&frame); 27 | setWindowTitle("Input dialog multiline example"); 28 | resize(300, 300); 29 | } 30 | 31 | private: 32 | QFrame frame; 33 | QPushButton button1 {&frame}; 34 | QLabel label1 {&frame}; 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/InputDialogPassword/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(InputDialogPassword) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/InputDialogPassword.cpp src/InputDialogPassword.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Others") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/InputDialogPassword/InputDialogPassword.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/InputDialogPassword.cpp 4 | HEADERS = src/InputDialogPassword.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/InputDialogPassword/src/InputDialogPassword.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "InputDialogPassword.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/InputDialogPassword/src/InputDialogPassword.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Examples { 9 | class Window1 : public QMainWindow { 10 | Q_OBJECT 11 | public: 12 | Window1() { 13 | button1.setText("Password..."); 14 | button1.move(10, 10); 15 | connect(&button1, &QPushButton::clicked, [&] { 16 | QInputDialog inputDialog(this); 17 | bool ok = false; 18 | auto result = QInputDialog::getText(this, "User password", "user: admin", QLineEdit::Password, label1.text(), &ok); 19 | if (ok) label1.setText(result); 20 | label1.adjustSize(); 21 | }); 22 | 23 | label1.move(10, 50); 24 | label1.setText("sysad47@74dasys"); 25 | 26 | setCentralWidget(&frame); 27 | setWindowTitle("Input dialog password example"); 28 | resize(300, 300); 29 | } 30 | 31 | private: 32 | QFrame frame; 33 | QPushButton button1 {&frame}; 34 | QLabel label1 {&frame}; 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/LCDNumber2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(LCDNumber2) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/LCDNumber2.cpp src/LCDNumber2.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Others") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/LCDNumber2/LCDNumber2.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/LCDNumber2.cpp 4 | HEADERS = src/LCDNumber2.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/LCDNumber2/src/LCDNumber2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "LCDNumber2.h" 3 | 4 | int main(int argc, char *argv[]) { 5 | auto application = QApplication {argc, argv}; 6 | auto window1 = Window1 {}; 7 | window1.show(); 8 | return application.exec(); 9 | } 10 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/Others.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | ButtonWithStyleSheet \ 4 | InputDialogMultiline \ 5 | InputDialogPassword \ 6 | LCDNumber2 \ 7 | Wiggly \ 8 | WindowShowHide 9 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/Wiggly/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Wiggly) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/Wiggly.cpp src/Wiggly.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Others") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/Wiggly/Wiggly.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/Wiggly.cpp 4 | HEADERS = src/Wiggly.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/Wiggly/src/Wiggly.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Wiggly.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/WindowShowHide/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(WindowShowHide) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/WindowShowHide.cpp src/WindowShowHide.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Others") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/WindowShowHide/WindowShowHide.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/WindowShowHide.cpp 4 | HEADERS = src/WindowShowHide.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Others/WindowShowHide/src/WindowShowHide.cpp: -------------------------------------------------------------------------------- 1 | #include "WindowShowHide.h" 2 | 3 | using namespace Examples; 4 | 5 | int main(int argc, char *argv[]) { 6 | auto application = QApplication {argc, argv}; 7 | auto window1 = Window1 {}; 8 | window1.show(); 9 | return application.exec(); 10 | } 11 | -------------------------------------------------------------------------------- /Qt.Widgets/Qt.Widgets.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | HelloWorlds \ 4 | Applications \ 5 | Windows \ 6 | Dialogs \ 7 | MenusAndToolbars \ 8 | Containers \ 9 | Controls \ 10 | Components \ 11 | UserControls \ 12 | Others \ 13 | Tests 14 | -------------------------------------------------------------------------------- /Qt.Widgets/Tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Tests) 4 | 5 | add_subdirectory(TestWidgets) 6 | -------------------------------------------------------------------------------- /Qt.Widgets/Tests/README.md: -------------------------------------------------------------------------------- 1 | # Tests 2 | 3 | [This folder](.) contains tests examples. 4 | 5 | * [TestWidgets]([TestWidgets]/README.md) is use to test Widgets. 6 | 7 | ## Generate and build 8 | 9 | ### Qt Creator 10 | 11 | To build these projects, open `Tests.pro` file with Qt Creator. 12 | 13 | ### CMake 14 | 15 | To build this project, open "Terminal" and type following lines: 16 | 17 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 18 | 19 | #### Windows : 20 | 21 | ``` cmake 22 | mkdir build 23 | cd build 24 | cmake .. 25 | start ./Tests.sln 26 | ``` 27 | 28 | #### macOS : 29 | 30 | ``` cmake 31 | mkdir build 32 | cd build 33 | cmake .. -G "Xcode" 34 | open ./Tests.xcodeproj 35 | ``` 36 | 37 | #### Linux with Code::Blocks : 38 | 39 | ``` cmake 40 | mkdir build 41 | cd build 42 | cmake .. -G "CodeBlocks - Unix Makefiles" 43 | xdg-open ./Tests.cbp > /dev/null 2>&1 44 | ``` 45 | 46 | #### Linux : 47 | 48 | ``` cmake 49 | mkdir build 50 | cd build 51 | cmake .. 52 | cmake --build . --config Debug 53 | ./AnyProject 54 | ``` 55 | -------------------------------------------------------------------------------- /Qt.Widgets/Tests/TestWidgets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(TestWidgets) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/TestWidgets.cpp) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/tests") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Tests/TestWidgets/README.md: -------------------------------------------------------------------------------- 1 | # TestWidgets 2 | 3 | Is use to test Widgets. 4 | 5 | ## Sources 6 | 7 | [src/TestWidgets.h](src/TestWidgets.h) 8 | 9 | [src/TestWidgets.cpp](src/TestWidgets.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Generate and build 14 | 15 | ### Qt Creator 16 | 17 | To build these projects, open `TestWidgets.pro` file with Qt Creator. 18 | 19 | ### CMake 20 | 21 | To build this project, open "Terminal" and type following lines: 22 | 23 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 24 | 25 | #### Windows : 26 | 27 | ``` cmake 28 | mkdir build 29 | cd build 30 | cmake .. 31 | start ./TestWidgets.sln 32 | ``` 33 | 34 | #### macOS : 35 | 36 | ``` cmake 37 | mkdir build 38 | cd build 39 | cmake .. -G "Xcode" 40 | open ./TestWidgets.xcodeproj 41 | ``` 42 | 43 | #### Linux with Code::Blocks : 44 | 45 | ``` cmake 46 | mkdir build 47 | cd build 48 | cmake .. -G "CodeBlocks - Unix Makefiles" 49 | xdg-open ./TestWidgets.cbp > /dev/null 2>&1 50 | ``` 51 | 52 | #### Linux : 53 | 54 | ``` cmake 55 | mkdir build 56 | cd build 57 | cmake .. 58 | cmake --build . --config Debug 59 | ./TestWidgets 60 | ``` 61 | -------------------------------------------------------------------------------- /Qt.Widgets/Tests/TestWidgets/TestWidgets.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/TestWidgets.cpp 4 | -------------------------------------------------------------------------------- /Qt.Widgets/Tests/Tests.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | TestWidgets 4 | -------------------------------------------------------------------------------- /Qt.Widgets/UserControls/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(UserControls) 4 | 5 | # CustomControl 6 | add_subdirectory(Line) 7 | -------------------------------------------------------------------------------- /Qt.Widgets/UserControls/Line/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Line) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/Line.cpp src/Line.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/UserControls") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/UserControls/Line/Line.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/Line.cpp 4 | HEADERS = src/Line.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/UserControls/Line/README.md: -------------------------------------------------------------------------------- 1 | # Line 2 | 3 | Shows how to create a custom widget line with QFrame. 4 | 5 | ## Sources 6 | 7 | [src/Line.h](src/Line.h) 8 | 9 | [src/Line.cpp](src/Line.cpp) 10 | 11 | [CMakeLists.txt](CMakeLists.txt) 12 | 13 | ## Output 14 | 15 | ![Screenshot](../../../docs/Pictures/Line.png) 16 | 17 | ## Generate and build 18 | 19 | ### Qt Creator 20 | 21 | To build these projects, open `Line.pro` file with Qt Creator. 22 | 23 | ### CMake 24 | 25 | To build this project, open "Terminal" and type following lines: 26 | 27 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 28 | 29 | #### Windows : 30 | 31 | ``` cmake 32 | mkdir build 33 | cd build 34 | cmake .. 35 | start ./Line.sln 36 | ``` 37 | 38 | #### macOS : 39 | 40 | ``` cmake 41 | mkdir build 42 | cd build 43 | cmake .. -G "Xcode" 44 | open ./Line.xcodeproj 45 | ``` 46 | 47 | #### Linux with Code::Blocks : 48 | 49 | ``` cmake 50 | mkdir build 51 | cd build 52 | cmake .. -G "CodeBlocks - Unix Makefiles" 53 | xdg-open ./Line.cbp > /dev/null 2>&1 54 | ``` 55 | 56 | #### Linux : 57 | 58 | ``` cmake 59 | mkdir build 60 | cd build 61 | cmake .. 62 | cmake --build . --config Debug 63 | ./Line 64 | ``` 65 | -------------------------------------------------------------------------------- /Qt.Widgets/UserControls/Line/src/Line.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Line.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | auto window1 = Window1 {}; 9 | window1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/UserControls/README.md: -------------------------------------------------------------------------------- 1 | # User Controls 2 | 3 | [This folder](.) contains user controls examples 4 | 5 | * [Line](Line/README.md) shows how to create a custom widget line with QFrame. 6 | 7 | ## Generate and build 8 | 9 | ### Qt Creator 10 | 11 | To build these projects, open `UserControls.pro` file with Qt Creator. 12 | 13 | ### CMake 14 | 15 | To build this project, open "Terminal" and type following lines: 16 | 17 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 18 | 19 | #### Windows : 20 | 21 | ``` cmake 22 | mkdir build 23 | cd build 24 | cmake .. 25 | start ./UserControls.sln 26 | ``` 27 | 28 | #### macOS : 29 | 30 | ``` cmake 31 | mkdir build 32 | cd build 33 | cmake .. -G "Xcode" 34 | open ./UserControls.xcodeproj 35 | ``` 36 | 37 | #### Linux with Code::Blocks : 38 | 39 | ``` cmake 40 | mkdir build 41 | cd build 42 | cmake .. -G "CodeBlocks - Unix Makefiles" 43 | xdg-open ./UserControls.cbp > /dev/null 2>&1 44 | ``` 45 | 46 | #### Linux : 47 | 48 | ``` cmake 49 | mkdir build 50 | cd build 51 | cmake .. 52 | cmake --build . --config Debug 53 | ./AnyProject 54 | ``` 55 | -------------------------------------------------------------------------------- /Qt.Widgets/UserControls/UserControls.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | Line 4 | -------------------------------------------------------------------------------- /Qt.Widgets/Windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(Windows) 4 | 5 | add_subdirectory(MainWindow) 6 | -------------------------------------------------------------------------------- /Qt.Widgets/Windows/MainWindow/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20) 2 | 3 | project(MainWindow) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | find_package(Qt6 REQUIRED COMPONENTS Core Widgets) 9 | if (Qt6_FOUND) 10 | qt_standard_project_setup() 11 | else () 12 | find_package(Qt5 REQUIRED COMPONENTS Core Widgets) 13 | set(CMAKE_AUTOMOC ON) 14 | set(CMAKE_AUTORCC ON) 15 | set(CMAKE_AUTOUIC ON) 16 | endif () 17 | 18 | add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE src/MainWindow.cpp src/MainWindow.h) 19 | target_link_libraries(${PROJECT_NAME} Qt::Core Qt::Widgets) 20 | set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Qt.Widgets/Windows") 21 | -------------------------------------------------------------------------------- /Qt.Widgets/Windows/MainWindow/MainWindow.pro: -------------------------------------------------------------------------------- 1 | CONFIG += c++17 2 | QT = widgets 3 | SOURCES = src/MainWindow.cpp 4 | HEADERS = src/MainWindow.h 5 | -------------------------------------------------------------------------------- /Qt.Widgets/Windows/MainWindow/src/MainWindow.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "MainWindow.h" 3 | 4 | using namespace Examples; 5 | 6 | int main(int argc, char *argv[]) { 7 | auto application = QApplication {argc, argv}; 8 | MainWindow1 mainWindow1; 9 | mainWindow1.show(); 10 | return application.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Qt.Widgets/Windows/README.md: -------------------------------------------------------------------------------- 1 | # Windows 2 | 3 | [This folder](.) contains windows examples. 4 | 5 | * [MainWindow](MainWindow/README.md) shows how to create a window with QMainWindow. 6 | 7 | ## Generate and build 8 | 9 | ### Qt Creator 10 | 11 | To build these projects, open `Windows.pro` file with Qt Creator. 12 | 13 | ### CMake 14 | 15 | To build this project, open "Terminal" and type following lines: 16 | 17 | Set `CMAKE_PREFIX_PATH` with Qt6 install path. 18 | 19 | #### Windows : 20 | 21 | ``` cmake 22 | mkdir build 23 | cd build 24 | cmake .. 25 | start ./Windows.sln 26 | ``` 27 | 28 | #### macOS : 29 | 30 | ``` cmake 31 | mkdir build 32 | cd build 33 | cmake .. -G "Xcode" 34 | open ./Windows.xcodeproj 35 | ``` 36 | 37 | #### Linux with Code::Blocks : 38 | 39 | ``` cmake 40 | mkdir build 41 | cd build 42 | cmake .. -G "CodeBlocks - Unix Makefiles" 43 | xdg-open ./Windows.cbp > /dev/null 2>&1 44 | ``` 45 | 46 | #### Linux : 47 | 48 | ``` cmake 49 | mkdir build 50 | cd build 51 | cmake .. 52 | cmake --build . --config Debug 53 | ./AnyProject 54 | ``` 55 | -------------------------------------------------------------------------------- /Qt.Widgets/Windows/Windows.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = \ 3 | MainWindow 4 | 5 | -------------------------------------------------------------------------------- /docs/Pictures/AboutBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/AboutBox.png -------------------------------------------------------------------------------- /docs/Pictures/AboutBoxQt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/AboutBoxQt.png -------------------------------------------------------------------------------- /docs/Pictures/Application.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Application.png -------------------------------------------------------------------------------- /docs/Pictures/ApplicationAndException.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/ApplicationAndException.png -------------------------------------------------------------------------------- /docs/Pictures/ButtonWithStyleSheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/ButtonWithStyleSheet.png -------------------------------------------------------------------------------- /docs/Pictures/CheckBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/CheckBox.png -------------------------------------------------------------------------------- /docs/Pictures/CheckedListWidget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/CheckedListWidget.png -------------------------------------------------------------------------------- /docs/Pictures/ColorDialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/ColorDialog.png -------------------------------------------------------------------------------- /docs/Pictures/ComboBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/ComboBox.png -------------------------------------------------------------------------------- /docs/Pictures/Cursors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Cursors.png -------------------------------------------------------------------------------- /docs/Pictures/DarkMode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/DarkMode.png -------------------------------------------------------------------------------- /docs/Pictures/Dial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Dial.png -------------------------------------------------------------------------------- /docs/Pictures/DoubleSpinBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/DoubleSpinBox.png -------------------------------------------------------------------------------- /docs/Pictures/FolderBrowserDialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/FolderBrowserDialog.png -------------------------------------------------------------------------------- /docs/Pictures/FontDialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/FontDialog.png -------------------------------------------------------------------------------- /docs/Pictures/Forms/HelloWorldForms.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Forms/HelloWorldForms.png -------------------------------------------------------------------------------- /docs/Pictures/Forms/PictureBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Forms/PictureBox.png -------------------------------------------------------------------------------- /docs/Pictures/Forms/ProgressBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Forms/ProgressBar.png -------------------------------------------------------------------------------- /docs/Pictures/Forms/TabControl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Forms/TabControl.png -------------------------------------------------------------------------------- /docs/Pictures/Forms/TrackBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Forms/TrackBar.png -------------------------------------------------------------------------------- /docs/Pictures/Frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Frame.png -------------------------------------------------------------------------------- /docs/Pictures/GroupBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/GroupBox.png -------------------------------------------------------------------------------- /docs/Pictures/HelloWorldEmoticons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/HelloWorldEmoticons.png -------------------------------------------------------------------------------- /docs/Pictures/HelloWorldLabel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/HelloWorldLabel.png -------------------------------------------------------------------------------- /docs/Pictures/HelloWorldMessageBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/HelloWorldMessageBox.png -------------------------------------------------------------------------------- /docs/Pictures/HelloWorldPaint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/HelloWorldPaint.png -------------------------------------------------------------------------------- /docs/Pictures/HelloWorldUnitTest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/HelloWorldUnitTest.png -------------------------------------------------------------------------------- /docs/Pictures/InputDialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/InputDialog.png -------------------------------------------------------------------------------- /docs/Pictures/InputDialogMultiline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/InputDialogMultiline.png -------------------------------------------------------------------------------- /docs/Pictures/InputDialogPassword.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/InputDialogPassword.png -------------------------------------------------------------------------------- /docs/Pictures/LCDNumber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/LCDNumber.png -------------------------------------------------------------------------------- /docs/Pictures/LCDNumber2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/LCDNumber2.png -------------------------------------------------------------------------------- /docs/Pictures/Label.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Label.png -------------------------------------------------------------------------------- /docs/Pictures/Line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Line.png -------------------------------------------------------------------------------- /docs/Pictures/LineEdit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/LineEdit.png -------------------------------------------------------------------------------- /docs/Pictures/ListView.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/ListView.png -------------------------------------------------------------------------------- /docs/Pictures/ListView2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/ListView2.png -------------------------------------------------------------------------------- /docs/Pictures/ListWidget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/ListWidget.png -------------------------------------------------------------------------------- /docs/Pictures/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Logo.png -------------------------------------------------------------------------------- /docs/Pictures/MainWindow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/MainWindow.png -------------------------------------------------------------------------------- /docs/Pictures/MenuBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/MenuBar.png -------------------------------------------------------------------------------- /docs/Pictures/MessageBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/MessageBox.png -------------------------------------------------------------------------------- /docs/Pictures/OpenFileDialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/OpenFileDialog.png -------------------------------------------------------------------------------- /docs/Pictures/PictureBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/PictureBox.png -------------------------------------------------------------------------------- /docs/Pictures/PictureBox2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/PictureBox2.png -------------------------------------------------------------------------------- /docs/Pictures/ProgressBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/ProgressBar.png -------------------------------------------------------------------------------- /docs/Pictures/PushButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/PushButton.png -------------------------------------------------------------------------------- /docs/Pictures/RadioButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/RadioButton.png -------------------------------------------------------------------------------- /docs/Pictures/SaveFileDialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/SaveFileDialog.png -------------------------------------------------------------------------------- /docs/Pictures/Slider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Slider.png -------------------------------------------------------------------------------- /docs/Pictures/SpinBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/SpinBox.png -------------------------------------------------------------------------------- /docs/Pictures/SpinButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/SpinButton.png -------------------------------------------------------------------------------- /docs/Pictures/StatusBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/StatusBar.png -------------------------------------------------------------------------------- /docs/Pictures/TabWidget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/TabWidget.png -------------------------------------------------------------------------------- /docs/Pictures/Timer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Timer.png -------------------------------------------------------------------------------- /docs/Pictures/ToggleButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/ToggleButton.png -------------------------------------------------------------------------------- /docs/Pictures/ToolBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/ToolBar.png -------------------------------------------------------------------------------- /docs/Pictures/TreeView.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/TreeView.png -------------------------------------------------------------------------------- /docs/Pictures/TreeWidget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/TreeWidget.png -------------------------------------------------------------------------------- /docs/Pictures/Widget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Widget.png -------------------------------------------------------------------------------- /docs/Pictures/Wiggly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/Wiggly.png -------------------------------------------------------------------------------- /docs/Pictures/WindowShowHide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/WindowShowHide.png -------------------------------------------------------------------------------- /docs/Pictures/qt_header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gammasoft71/Examples_Qt/b2cfa742055a91a98a71ebc50b8e2a0f82cda252/docs/Pictures/qt_header.png --------------------------------------------------------------------------------