First, ensure you have Python 3.7 or higher installed:
Windows:
winget install Python.Python.3.11
macOS:
Linux (Ubuntu/Debian):
sudo apt update
sudo apt install python3 python3-pip python3-venv
Always use a virtual environment to manage dependencies:
mkdir my_qt_project
cd my_qt_project
python -m venv venv
venv\Scripts\activate
source venv/bin/activate
Your terminal should now show (venv) indicating the virtual environment is active.
Important: Make sure your virtual environment is activated (you see (venv) in your terminal).
Choose and install one of these Qt bindings:
Note: For this tutorial, we'll use PySide6 as it's the most modern and freely available.
Install the custom widgets package (make sure venv is active):
pip install QT-PyQt-PySide-Custom-Widgets
Verify installation:
python -c "import Custom_Widgets; print('Custom Widgets installed successfully!')"
Important: Run this command from INSIDE your activated virtual environment folder:
Custom_Widgets --create-project
What happens when you run the project creator:
- It detects your current directory as the project location
- It checks if the folder is empty (or only contains logs)
- It guides you through the setup process interactively
The project creator will guide you through:
- Qt Binding Selection: Choose your Qt library
- Color Scheme: Select icons and theme colors
- App Information: Enter app name and organization details
- Automatic Setup: Creates all necessary files and folders
my_qt_project/ # Your project folder
├── venv/ # Virtual environment (already created)
│ ├── bin/ # or Scripts/ on Windows
│ ├── lib/
│ └── pyvenv.cfg
└── (project files will be created here by the creator)
Common Mistake to Avoid:
- Don't run the command from inside the
venv folder
- Run it from your project root folder where
venv is located
If you prefer manual setup, create this structure in your project root:
my_qt_project/
├── venv/ # Virtual environment
├── main.py # Main application file
├── ui/ # UI files directory
│ └── main_window.ui
├── json-styles/ # Theme configuration
│ └── style.json
├── requirements.txt # Dependencies
└── README.md # Documentation
After running the project creator from inside your venv folder, you'll have:
my_qt_project/
├── venv/ # Virtual environment
├── main.py # Main application file
├── ui/ # UI files directory
│ └── QCustomQMainWindow.ui
├── json-styles/ # Theme configuration
│ └── style.json
├── requirements.txt # Dependencies
└── README.md # Documentation
Before designing your interface, register the custom widgets (from your activated venv):
Custom_Widgets --register-widgets
Expected Output:
Registering QCustomQMainWindow...
Registering QCustomSidebar...
Registering QCustomProgressBar...
... (all widgets registered successfully)
Start Qt Designer with the custom widgets loaded (from activated venv):
Custom_Widgets --start-designer --plugins
Alternative methods:
designer
pyside6-designer
qt5-designer
When Qt Designer opens, look for these widget groups in the widget box:
-
MainWindow Section:
QCustomQMainWindow - Enhanced main window with theme support
-
Sidebar Section:
QCustomSidebar - Customizable sidebar navigation
QCustomSidebarButton - Buttons for sidebar
QCustomSidebarLabel - Labels for sidebar
-
Progressbars Section:
QCustomRoundProgressBar - Circular progress indicator
AnalogGaugeWidget - Analog gauge display
-
Component Container Section:
QCustomComponent - Container for organizing widgets
QCustomComponentContainer - Main container component
-
Start with QCustomQMainWindow:
- Drag
QCustomQMainWindow from the widget box to the form
- This becomes your main application window
-
Add a Sidebar:
- Drag
QCustomSidebar to the left side of your main window
- Add
QCustomSidebarButton widgets inside the sidebar
- Set button text and icons in the property editor
-
Add Content Area:
- Use
QCustomComponent as content containers
- Add standard Qt widgets (buttons, labels, etc.) inside components
- Use
QCustomQStackedWidget to manage multiple pages
-
Style Your Interface:
- Use the property editor to set object names
- Apply custom styles through the JSON configuration later
-
Save Your Design:
- Save the file as
main_window.ui in the ui/ folder
- Qt Designer files use
.ui extension
Keep this running while you design (from activated venv):
Custom_Widgets --monitor-ui ui --qt-library PySide6
What this does:
- Watches the
ui/ folder for any changes
- Automatically converts
.ui files to Python when you save
- Updates your application in real-time
If you prefer manual conversion:
Custom_Widgets --convert-ui ui/main_window.ui --qt-library PySide6
Custom_Widgets --convert-ui ui --qt-library PySide6
Edit the json-styles/style.json file to customize your app's appearance:
{
"QtBinding": "PySide6",
"QMainWindow": {
"title": "My Awesome App"
},
"QSettings": {
"AppSettings": {
"OrginizationName": "My Company",
"ApplicationName": "My App",
"OrginizationDormain": "myapp.org"
},
"ThemeSettings": {
"QtDesignerIconsColor": "#ffffff",
"CustomThemes": [
{
"Background-color": "#2b2b2b",
"Text-color": "#ffffff",
"Accent-color": "#0078d4",
"Icons-color": "#ffffff",
"Theme-name": "Default Dark",
"Default-Theme": true
}
]
}
}
}
Key Configuration Options:
Background-color: Main app background
Text-color: Default text color
Accent-color: Primary accent color for buttons, highlights
Icons-color: Color of all icons in the app
Execute your application (from activated venv):
Your custom-styled application should launch with:
- The theme colors you configured
- All custom widgets functioning
- Your designed interface layout
- Activate Venv: Always start with
source venv/bin/activate (or venv\Scripts\activate on Windows)
- Design: Work in Qt Designer with custom widgets
- Save: Save your
.ui file (auto-conversion happens if monitoring)
- Test: Run your app to see changes
- Repeat: Go back to design and continue iterating
Custom_Widgets --monitor-ui ui --qt-library PySide6
Custom_Widgets --start-designer --plugins
python main.py
cd my_qt_project
source venv/bin/activate
Custom_Widgets --monitor-ui ui --qt-library PySide6
cd my_qt_project
source venv/bin/activate
Custom_Widgets --start-designer --plugins
python main.py
Add additional themes to your style.json:
"CustomThemes": [
{
"Background-color": "#2b2b2b",
"Text-color": "#ffffff",
"Accent-color": "#0078d4",
"Icons-color": "#ffffff",
"Theme-name": "Dark Blue",
"Default-Theme": true
},
{
"Background-color": "#f0f0f0",
"Text-color": "#000000",
"Accent-color": "#e74c3c",
"Icons-color": "#000000",
"Theme-name": "Light Red",
"Default-Theme": false
}
]
Each custom widget has specific properties you can set in Qt Designer:
- QCustomSidebar:
backgroundColor, activeColor, iconSize
- QCustomProgressBar:
progressColor, background_color, text_color
- QCustomQMainWindow:
enableCustomTitleBar, enableGradient
which python
source venv/bin/activate
venv\Scripts\activate
Custom_Widgets --register-widgets
Custom_Widgets --start-designer --plugins
Custom_Widgets --monitor-ui ui --qt-library PySide6
Custom_Widgets --convert-ui ui/main_window.ui --qt-library PySide6
pip install QT-PyQt-PySide-Custom-Widgets
which python
Now that you have a basic application running:
- Explore More Widgets: Try different custom widgets in your designs
- Custom Styles: Experiment with different color schemes in the JSON file
- Advanced Layouts: Combine custom widgets with standard Qt widgets
- Animation: Add transitions and animations to your interface
- Database Integration: Connect your GUI to databases or APIs
Congratulations! You've successfully set up a Qt application with custom widgets using proper virtual environment practices. The automated workflow will make your development process much smoother as you continue building your application.
Key Takeaway: Always remember to activate your virtual environment before running any Custom_Widgets commands or your Python application!