Qt cpp

From CodeAtCode/oss-ai-skills · View interactive version

Qt cpp is an AI agent skill from the GitHub repository CodeAtCode/oss-ai-skills. Use when developing desktop applications with Qt in C++ - CMake setup, signals and slots, QThread and QtConcurrent, QML integration, model/view programming, Qt5 to Qt6 migration, or windeployqt/macdeployqt/linuxdeployqt deployment

How to use this skill

Skill file

Objective: Use this skill to reduce segfaults from raw pointers, signal/slot connection failures, memory leaks from parentless QObjects, and thread-assertion violations by enforcing ownership rules, connection patterns, and RAII discipline below.

Qt C++ Development

Complete reference for building cross-platform desktop applications with Qt framework in C++.

Overview

Qt is a powerful C++ framework for cross-platform application development. It provides rich GUI capabilities, networking, database access, and more.

Qt Versions

Qt5 vs Qt6

| Feature | Qt5 | Qt6 |

|---------|-----|-----|

| C++ Standard | C++11 | C++17 minimum |

| Graphics | OpenGL | Vulkan/Metal/DirectX |

| High-DPI | Manual | Enabled by default |

| QString | UTF-16 | UTF-8 by default |

| Status | Maintenance | Active development |

Use Qt 6 for: New projects, modern C++17/20 features, better graphics performance

Use Qt 5 for: Legacy codebases, Qt 5-only modules, platform constraints

Installation

See official installation guide or your platform's package manager.

Quick Setup

Deep Dives

Load these reference files for detailed guidance:

Signals and Slots

See references/signals-slots.md for connection syntax, lambda patterns, connection types, and signal forwarding.

Model/View Programming

See references/model-view.md for QAbstractListModel implementation and QML ListView integration.

Qt 6 Specific Features

See references/qt6-features.md for QString UTF-8 changes, graphics stack, and property syntax.

Best Practices

Do X because Y prevents Z patterns:

  1. Use parent pointers for all QObjects because orphaned objects leak memory when the event loop exits
  2. Prefer modern signal-slot syntax (&Sender::signal) because the old SIGNAL()/SLOT() macros bypass compile-time checking and cause runtime connection failures
  3. Call deleteLater() instead of delete because immediate deletion can crash if the object is still processing an event
  4. Enable AUTOMOC, AUTOUIC, AUTORCC in CMake because missing MOC generation causes "undefined reference to vtable" errors
  5. Use Q_PROPERTY for QML-exposed data because QML bindings require property notifications to update the UI
  6. Move long-running work to worker threads because blocking the main thread freezes the UI and triggers watchdog timeouts
  7. Use moveToThread() for worker objects because it ensures signals/slots queue correctly across thread boundaries
  8. Test deployment on each target platform early because windeployqt/macdeployqt issues often require platform-specific fixes
  9. Validate all user input at boundaries because Qt's string handling (especially UTF-8 in Qt6) can expose encoding bugs

Resources

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.