# Shelf Query (Qt + Python)
**Shelf Query** is a desktop application built with **Qt (C++)** and **Python** for fetching books from OpenLibrary.
It saves the output to a CSV file and can display the data in a `tableView`.
---
## π― Features
- Randomly fetches 50 books from OpenLibrary from the year 2000 onwards
- CSV output with UTF-8 encoding, sorted by publication year
- Randomized output on each run
- Symbolic progress bar while Python script runs
- Displays books in a `tableView`
- Can be packaged as a portable release
---
## ποΈ Project Structure
shelf-query/
βββ python-fetcher/
β βββ books.py # Python script
βββ shelf-query.pro # Qt project file
βββ mainwindow.h / .cpp # Main Qt source files
βββ README.md
- When building Release, `shelf-query.exe` is generated.
- The `python-fetcher` folder must be next to the exe for the Python script to run.
---
## β‘ Running the Application
### 1οΈβ£ With Qt Creator (Debug)
- Open the project
- Build β Build All
- Run β the program launches
- TableView will always start on page 0
- Buttons:
- **pushButton_2** β Run Python script + progress bar 50% β 100%
- **pushButton_3** β Display books from CSV in tableView
---
### 2οΈβ£ With Qt Creator (Release / Portable)
- Switch **Build Configuration** β Release
- Build All β exe is generated
- Place the `python-fetcher` folder next to the exe
- (Optional) Use `windeployqt` to include all required Qt DLLs:
```powershell
"C:\Qt\6.6.2\msvc2019_64\bin\windeployqt.exe" "path\to\shelf-query.exe"
Now you have a portable, standalone application π Python Requirements
Python 3.x must be installed (or use Python embeddable package for portable deployment)
Required Python packages: requests
pip install requests
CSV output path is relative to the exe:
QString filePath = QDir(QCoreApplication::applicationDirPath())
.filePath("python-fetcher/books.csv");
π¦ Running the Python Script
pushButton_2 β runs books.py with the exe path as argument
Generates books.csv
Progress bar moves symbolically from 50% β 100%
π Displaying CSV in TableView
pushButton_3 β reads CSV and fills tableView
TableView always starts on page 0 when the program launches:
ui->stackedWidget->setCurrentIndex(0); // or ui->tableView->scrollTo(index)
π§ Portable / Release Notes
Copy all Qt DLLs using windeployqt next to the exe
Copy python-fetcher and books.py next to the exe
For portable Python: use Python embeddable + requests in Lib/site-packages
The exe is standalone and does not require Qt installed on the target system
π Important Notes
CSV output is always different (random query, shuffled pages, random selection of 50 books)
TableView and progress bar provide simple, user-friendly UX
Always starts on page 0 at launch
β‘ References
Qt Documentation
OpenLibrary API
Python embeddable package
---
π‘ Features of this README:
- Step-by-step instructions for Debug & Release
- Python + Qt usage
- Portable deployment explained
- Progress bar and tableView behavior documented
- File structure and relative paths clearly described
---
If you want, I can make a **version with diagrams/screenshots of the tableView + project structure**, so itβs super ready for GitHub or presentation.
Do you want me to do that?