A beautiful, modern calculator application built with C++ and Qt6, featuring a sleek dark theme and intuitive user interface.
- Modern Dark Theme: Sleek, eye-friendly dark interface
- Full Calculator Functionality: Addition, subtraction, multiplication, division
- Additional Functions: Percentage, plus/minus toggle, clear functions
- Responsive Design: Clean, modern button layout with hover effects
- Keyboard Support: Full keyboard input support
- Error Handling: Proper error handling for division by zero
The calculator features:
- Large, easy-to-read display
- Color-coded buttons (gray for functions, orange for operators, dark for numbers)
- Smooth hover effects and animations
- Professional appearance inspired by modern mobile calculators
- Qt6: Qt6 Widgets module
- CMake: Version 3.16 or higher
- C++17: Compatible compiler (GCC, Clang, MSVC)
-
Clone or download the project files
-
Create a build directory:
mkdir build cd build -
Configure with CMake:
cmake ..
-
Build the project:
cmake --build . -
Run the calculator:
./bin/Calculator # On Linux/macOS .\bin\Calculator.exe # On Windows
- Open Qt Creator
- Open the
CMakeLists.txtfile as a project - Configure the project with your Qt6 installation
- Build and run
- Double-click
build.bator run it from Command Prompt - Wait for the build to complete
- Navigate to the output directory:
cd build\bin\Release - Run the calculator:
Calculator.exe
- Make the script executable (if needed):
chmod +x build.sh
- Run the build script:
./build.sh
- Run the calculator:
./build/bin/Calculator
-
Open Terminal/Command Prompt in the project directory
-
Create and enter build directory:
mkdir build cd build -
Configure the project:
cmake ..
-
Build the project:
cmake --build . --config Release -
Navigate to the executable location:
- Windows:
build\bin\Release\ - Linux/macOS:
build\bin\
- Windows:
-
Run the calculator:
- Windows:
Calculator.exe - Linux/macOS:
./Calculator
- Windows:
- Open Qt Creator
- Open Project: File → Open File or Project → Select
CMakeLists.txt - Configure Project: Choose your Qt6 kit and compiler
- Build Project: Click the hammer icon or press Ctrl+B
- Run Project: Click the play button or press Ctrl+R
- Open Visual Studio
- Open Folder: File → Open → Folder → Select project directory
- Configure: Select CMake configuration when prompted
- Build: Build → Build All (Ctrl+Shift+B)
- Run: Debug → Start Debugging (F5) or Start Without Debugging (Ctrl+F5)
- Install Extensions: C/C++, CMake Tools
- Open Project: File → Open Folder → Select project directory
- Configure: Press Ctrl+Shift+P → "CMake: Configure"
- Build: Press Ctrl+Shift+P → "CMake: Build"
- Run: Press F5 or Ctrl+Shift+P → "CMake: Run Without Debugging"
- Click number buttons (0-9) to input numbers
- Click operator buttons (+, -, ×, ÷) to perform calculations
- Click "=" to see the result
- Click "AC" to clear all
- Click "+/-" to toggle between positive and negative
- Click "%" to convert to percentage
- Numbers: 0-9 keys
- Operators: +, -, *, / keys
- Equals: Enter or Return key
- Clear: Escape key
- Decimal: Period key
- Backspace: Backspace key
Calculator/
├── CMakeLists.txt # Build configuration
├── main.cpp # Application entry point
├── calculator.h # Calculator class header
├── calculator.cpp # Calculator class implementation
├── calculator.ui # UI file (minimal, UI built programmatically)
├── build.bat # Windows build script
├── build.sh # Linux/macOS build script
└── README.md # This file
The calculator uses CSS-like styling through Qt's stylesheet system. You can customize:
- Colors: Modify the color values in the button styles
- Sizes: Change button sizes and window dimensions
- Fonts: Adjust font sizes and families
- Layout: Modify spacing and margins
- Qt6 not found: Ensure Qt6 is properly installed and CMake can find it
- Build errors: Make sure you have a C++17 compatible compiler
- Runtime errors: Ensure Qt6 runtime libraries are in your PATH
- Use Visual Studio or MinGW-w64 as your compiler
- Ensure Qt6 binaries are in your system PATH
- Consider using Qt's official installer for easier setup
- Install Qt6 development packages:
sudo apt install qt6-base-dev(Ubuntu/Debian) - Install CMake:
sudo apt install cmake(Ubuntu/Debian) - Ensure you have a C++ compiler:
sudo apt install build-essential
- Install Qt6 via Homebrew:
brew install qt6 - Install CMake:
brew install cmake - Install Xcode Command Line Tools:
xcode-select --install
"Application failed to start" (Windows)
- Ensure Qt6 runtime DLLs are in your PATH
- Copy Qt6 DLLs to the executable directory
- Use Qt's
windeployqttool to package dependencies
"Library not found" (Linux/macOS)
- Install Qt6 runtime libraries
- Set
LD_LIBRARY_PATH(Linux) orDYLD_LIBRARY_PATH(macOS) - Use Qt's
macdeployqttool (macOS)
"Permission denied" (Linux/macOS)
- Make the executable file executable:
chmod +x Calculator
This project is open source and available under the MIT License.
Feel free to submit issues, feature requests, or pull requests to improve the calculator!