This is a simple Minesweeper game implemented using C++ and Qt .
This project was a personal learning experience aimed at revisiting and reinforcing the core concepts of Qt in a fun and practical way. By building a classic game like Minesweeper, I gained hands-on experience with Qt widgets, event handling, layout management, and signals/slots.
-
Interactive Grid : Click on tiles to reveal them, and flag them with right-click.
-
Timer : A countdown timer keeps track of how long you've been playing.
-
Flags : Place flags to mark suspected mine locations.
-
Game Over and Win Notifications : Alerts when you hit a mine or successfully clear all non-mine cells.
- Qt Creator : You'll need Qt Creator (with a version compatible with C++11 or higher) to build and run the project if you are working from source.
- You can download the executable
Minesweeper.exefrom theexefolder (if available) and run it directly.
- Follow the steps below to build the project.
-
Download and install Qt Creator from the official Qt website: https://www.qt.io/download .
-
Clone this repository to your local machine.
-
Navigate to the project directory and open the
CMakeLists.txtfile in Qt Creator . -
Click on the Build button to compile the project. This will generate the executable.
-
After building, you can run the project directly from Qt Creator.
-
Download the
Minesweeper.exefile from theexefolder in the project. -
Navigate to the
exefolder. -
Double-click
Minesweeper.exeto run the game.
Packaging the Executable for Windows (Using windeployqt)
If you're building the executable on Windows and want to distribute it, follow these steps to package the application:
-
After building the project using Qt Creator , go to the directory where
windeployqt.exeis located. This is typically inside the Qt installation folder (for example:C:\Qt\5.x.x\mingwXX_64\bin). -
Open Command Prompt (Terminal).
-
Navigate to the folder where the
Minesweeper.exewas built. -
Run the following command, replacing
<path-to-mine-sweeper-exe>with the path of theMinesweeper.exefile generated from the Qt Creator build:
windeployqt.exe <path-to-mine-sweeper-exe>This will automatically copy all the necessary Qt libraries and dependencies into the folder with your executable, allowing you to run the game on other Windows machines without needing to install Qt.
-
Left-click : Reveal a tile.
-
Right-click : Place or remove a flag on a tile.
-
Game Over : The game ends if you reveal a mine.
-
Win : The game is won when all non-mined tiles are revealed.