This project is a graphical implementation of the classic Minesweeper game using the Qt framework in C++. It demonstrates object-oriented design principles such as modularity, encapsulation, and GUI-driven event handling.
- Graphical Minesweeper grid with configurable board and mine count
- Left-click to reveal cells, right-click to flag
- Automatic win/loss detection
- Game reset via menu
- Visual indicators for adjacent mines
- Custom icons for flags and mines
File | Purpose |
---|---|
main.cpp |
Application entry point |
mainwindow.cpp/h |
Handles the main window UI and menu actions |
gameboard.cpp/h |
Manages game grid, mine placement, logic, and gameplay flow |
minecell.cpp/h |
Represents a single cell in the Minesweeper grid |
resources.qrc |
Qt resource file containing icons (e.g., flags, mines) |
Minesweeper.pro |
Qt project file for compilation and build setup |
- Qt 5 or 6 (tested with Qt 5.x)
- Qt Creator or command-line qmake and make
qmake Minesweeper.pro
make
./Minesweeper
Alternatively, open Minesweeper.pro
in Qt Creator and click Build & Run.
- A 30x16 grid with 99 hidden mines is generated at game start
- Clicking a cell reveals its content:
- A number: shows count of adjacent mines
- Blank: recursively reveals empty neighbors
- Mine: ends the game
- Right-click toggles flag, question mark, or clears the cell
- Winning or losing triggers a dialog prompt with reset option
- Menu Bar: Contains options to start a new game or exit
- Game Grid: Interactive cells respond to left/right clicks
- Icons: Used for mines and flags
- Encapsulation: Classes like
MineCell
andGameBoard
manage internal state - Modularity: Separated UI (
MainWindow
) from logic (GameBoard
,MineCell
) - Signal-Slot Mechanism: Used to communicate cell clicks and game state changes
This project is part of CS 3307B – Object-Oriented Design and Analysis at Western University. For academic use only.