Skills Plugins MCP Prompt Model 博客 我的中心

pyside6-qml-architecture

Use this skill when creating a new PySide6 + QML desktop application with MVC architecture, setting up project structure, implementing the application bootstrap / DI container, or understanding how the MVC layers connect. Covers project scaffolding, entry points, singleton application class, service locator, signal registry, and lifecycle management.

DeepseekModel 官方收录技能 质量 良好 · 64 v1.0.0

获取

https://deepseekmodel.com/api/download.php?id=sleepyvani-tablemax-agent-skills-pyside6-qml-architecture-skill-md&format=skill
下载 .skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用
.skill 文件中 system_prompt 字段的实际内容。
name pyside6-qml-architecture description Use this skill when creating a new PySide6 + QML desktop application with MVC architecture, setting up project structure, implementing the application bootstrap / DI container, or understanding how the MVC layers connect. Covers project scaffolding, entry points, singleton application class, service locator, signal registry, and lifecycle management. PySide6 QML MVC Architecture Desktop GUI applications in this workspace use Python + PySide6 with QML files for the view layer, following a strict Model-View-Controller (MVC) architecture. This skill documents the canonical project structure, bootstrap pattern, and layer responsibilities derived from the ds_pas/ application. Architecture Overview ┌─────────────────────────────────────────┐ │ View Layer (QML files) │ │ Declarative UI, data binding, signals │ └──────────────────┬──────────────────────┘ │ Properties, Signals, Slots ┌──────────────────▼──────────────────────┐ │ Python-QML Bridge │ │ QObject subclasses exposed to QML │ └──────────────────┬──────────────────────┘ │ ┌──────────────────▼──────────────────────┐ │ Controller Layer │ │ Coordinate models & services │ └──────────────────┬──────────────────────┘ │ ┌──────────────────▼──────────────────────┐ │ Model Layer │ │ Data structures, validation, signals │ └──────────────────┬──────────────────────┘ │ ┌──────────────────▼──────────────────────┐ │ Services Layer │ │ Database, files, network, broker │ └─────────────────────────────────────────┘ Project Structure my_app/ ├── app.py # Bootstrap & DI container (singleton) ├── __init__.py # Package init ├── __main__.py # Entry point: python -m my_app ├── controllers/ │ ├── __init__.py │ ├── base.py # BaseController with view registry │ └── *_controller.py # Domain controllers (job, settings, etc.) ├── models/ │ ├── __init__.py │ ├── base.py # BaseModel with property_changed signal │ ├── state.py # ApplicationState singleton │ └── *.py # Domain models (job, piece, customer, etc.) ├── views/ │ ├── __init__.py │ ├── bridge.py # QObject bridge classes exposed to QML │ ├── main_window.py # Main window setup (QQmlApplicationEngine) │ └── components/ # Reusable Python view helpers ├── services/ │ ├── __init__.py │ ├── database/ # Repository pattern for data access │ └── *.py # External interaction services ├── resources/ │ ├── qml/ │ │ ├── main.qml # Root QML component │ │ ├── components/ # Reusable QML components │ │ ├── pages/ # Page-level QML views │ │ └── styles/ # Theme and style definitions │ ├── icons/ # SVG/PNG icons │ └── qml.qrc # Qt resource file (optional) ├── utils/ │ ├── __init__.py │ ├── signals.py # Central SignalRegistry │ ├── types.py # Type aliases, protocols, ServiceLocator │ └── paths.py # Path resolution helpers └── tests/ └── *.py Layer Responsibilities Component Responsibility MUST NOT Model Data structures, validation, serialization, property_changed signals Touch UI, call services, reference QML View (QML) Declarative UI layout, data binding to bridge properties, user input capture Contain business logic, call services directly Bridge QObject subclasses that expose model data and controller actions to QML Contain business logic, directly manipulate QML Controller Coordinate models & services, handle actions, emit signals Manipulate UI directly, import QML types Service Database queries, file I/O, network calls, IPC Reference models, views, or controllers Application Bootstrap (DI Container) The application class is a singleton that wires all layers together: """app.py — Bootstrap & DI container.""" import sys import logging from typing import Any from pathlib import Path from PySide6.QtWidgets import QApplication from PySide6.QtQml import QQmlApplicationEngine from PySide6.QtCore import QObject, QUrl from my_app.utils.signals import SignalRegistry, get_signal_registry from my_app.utils.types import ServiceLocator logger = logging.getLogger(__name__) class MyApplication : """Singleton application with DI container.""" _instance: "MyApplication | None" = None def __new__ ( cls, dev_mode: bool = False ) -> "MyApplication" : if cls._instance is None : cls._instance = super ().__new__(cls) cls._instance._initialized = False return cls._instance def __init__ ( self, dev_mode: bool = False ) -> None : if self ._initialized: return self ._initialized = True self ._dev_mode = dev_mode self ._qt_app: QApplication | None = None self ._engine: QQmlApplicationEngine | None = None self ._services: dict [ str , Any ] = {} self ._controllers: dict [ str , Any ] = {} self ._signals = get_signal_registry() self ._service_locator = ServiceLocator() def _register_services ( self ) -> None : """Create and register all service instances.""" # self._services["db"] = DatabaseService(...) pass def _register_controllers ( self ) -> None : """Create controllers with injected dependencies.""" # self._controllers["job"] = JobController( # signals=self._signals, # repository=self._services["db"], # ) pass def _register_qml_types ( self ) -> None : """Register Python bridge objects as QML context properties.""" ctx = self ._engine.rootContext() # ctx.setContextProperty("jobBridge", self._bridges["job"]) pass def run ( self ) -> int : self ._qt_app = QApplication(sys.argv) self ._register_services() self ._register_controllers() self ._engine = QQmlApplicationEngine() self ._register_qml_types() qml_path = Path(__file__).parent / "resources" / "qml" / "main.qml" self ._engine.load(QUrl.fromLocalFile( str (qml_path))) if not self ._engine.rootObjects(): return - 1 return self ._qt_app. exec () Entry Point """__main__.py""" import sys from my_app.app import MyApplication def main (): app = MyApplication(dev_mode= "--dev" in sys.argv) sys.exit(app.run()) if __name__ == "__main__" : main() ServiceLocator Pattern """utils/types.py — Type aliases, protocols, and DI container.""" from typing import Any , Protocol, TypeVar, runtime_checkable T = TypeVar( "T" ) @runtime_checkable class IController ( Protocol ): def initialize ( self ) -> None : ... def cleanup ( self ) -> None : ... @runtime_checkable class IService ( Protocol ): def initialize ( self ) -> None : ... def shutdown ( self ) -> None : ... class ServiceLocator : """Lightweight DI container for service instances.""" _instance: "ServiceLocator | None" = None def __new__ ( cls ) -> "ServiceLocator" : if cls._instance is None : cls._instance = super ().__new__(cls) cls._instance._services = {} return cls._instance def register ( self, name: str , service: Any ) -> None : self ._services[name] = service def get ( self, name: str ) -> Any : if name not in self ._services: raise KeyError( f"Service ' {name} ' not registered" ) return self ._services[name] def has ( self, name: str ) -> bool : return name in self ._services Signal Flow User Action (QML) ↓ QML emits signal / calls slot on Bridge ↓ Bridge delegates to Controller ↓ Controller calls Service ↓ Service returns result ↓ Controller updates Model ↓ Model emits property_changed ↓ Bridge property notifies QML (via NOTIFY) ↓ QML binding automatically updates UI Key Design Rules QML files are declarative only — no JavaScript business logic, no direct service calls Python bridge objects are the sole interface between QML and the Python backend Controllers never import QML types — they operate through bridge signals/properties Models are pure data — no UI imports, no service calls Services are stateless workers — no model references, no UI knowledge All cross-layer communication flows through the SignalRegistry or Qt property bindings Singletons ( Application , SignalRegistry , ServiceLocator , ApplicationState ) use the __new__ pattern for thread-safe reuse File Size Guidelines Keep files focused on a single responsibility Split files exceeding ~300-400 lines into submodules Extract reusable QML components into resources/qml/components/ Group related controllers/services by domain (e.g., controllers/job_controller.py ) References PySide6 QML Integration Qt QML Documentation PySide6 Documentation
Agent 识别该技能的关键词,点击任意一个即可复制。

该技能未提供触发词。

下载的 .skill 包内含以下字段。
字段 说明
format格式标识(skill/v1)
skill_id技能唯一 ID
name技能名称
version版本号
description技能描述
category所属分类(数组)
trigger_words触发词列表
tags标签列表
source来源标识
source_url来源链接(本页地址)
exported_at导出时间(每次下载生成)
system_prompt系统提示词正文
model_config模型参数:provider / model / temperature / max_tokens / top_p
examples示例
install_guide各平台导入说明(Coze / Dify / Claude / 自定义框架)
同一份技能可按不同平台格式导出。
.skill 标准格式,含 system_prompt 与 model_config,导入任意 Agent 框架即可使用 下载
.skillpro 增强格式,额外含脚本 / 工具 / 依赖 / 钩子占位 下载
.json 纯 JSON 导出,只含 system_prompt 与模型参数 下载
Coze 带 frontmatter 的 Markdown,Coze 平台导入用 下载
Dify Dify DSL,创建应用后直接导入 下载

每日精选 Skill 推荐,免费送到你邮箱

输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

验证码 --

提交后我们会发送一封确认邮件,点击邮件里的链接才会开始收信。

完全免费,取消任意时间。我们不会发送垃圾邮件。