obs-cpp-qt-patterns

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OBS C++ and Qt Patterns

OBS C++与Qt集成模式

Purpose

用途

Integrate C++ and Qt6 into OBS Studio plugins for settings dialogs, frontend API access, and rich UI components. Covers CMake configuration, optional Qt builds, and platform fallbacks.
将C++与Qt6集成到OBS Studio插件中,用于实现设置对话框、前端API访问和丰富的UI组件。涵盖CMake配置、可选Qt构建以及平台降级方案。

When NOT to Use

不适用于以下场景

  • Cross-compiling → Use obs-cross-compiling
  • Windows-specific builds → Use obs-windows-building
  • Audio plugin core logic → Use obs-audio-plugin-writing
  • Code review → Use obs-plugin-reviewing
  • 交叉编译 → 使用obs-cross-compiling
  • Windows专属构建 → 使用obs-windows-building
  • 音频插件核心逻辑 → 使用obs-audio-plugin-writing
  • 代码评审 → 使用obs-plugin-reviewing

Quick Start: Qt Settings Dialog in 5 Steps

快速入门:5步实现Qt设置对话框

Step 1: Configure CMake for Qt

步骤1:为Qt配置CMake

cmake
cmake_minimum_required(VERSION 3.28)
project(my-plugin VERSION 1.0.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
cmake
cmake_minimum_required(VERSION 3.28)
project(my-plugin VERSION 1.0.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Enable Qt automoc (REQUIRED for Qt classes with Q_OBJECT)

Enable Qt automoc (REQUIRED for Qt classes with Q_OBJECT)

set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON)

Find Qt6 (optional)

Find Qt6 (optional)

find_package(Qt6 COMPONENTS Widgets QUIET) if(Qt6_FOUND) message(STATUS "Qt6 found - building with settings dialog") set(BUILD_WITH_QT ON) else() message(STATUS "Qt6 not found - building without settings dialog") set(BUILD_WITH_QT OFF) endif()
undefined
find_package(Qt6 COMPONENTS Widgets QUIET) if(Qt6_FOUND) message(STATUS "Qt6 found - building with settings dialog") set(BUILD_WITH_QT ON) else() message(STATUS "Qt6 not found - building without settings dialog") set(BUILD_WITH_QT OFF) endif()
undefined

Step 2: Add Qt Sources Conditionally

步骤2:条件添加Qt源码

cmake
undefined
cmake
undefined

Core plugin (C)

Core plugin (C)

add_library(${PROJECT_NAME} MODULE src/plugin-main.c src/my-source.c )
add_library(${PROJECT_NAME} MODULE src/plugin-main.c src/my-source.c )

Add Qt frontend (C++) if available

Add Qt frontend (C++) if available

if(BUILD_WITH_QT) target_sources(${PROJECT_NAME} PRIVATE src/frontend.cpp) target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_WITH_QT) target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets)
# Link OBS frontend API
find_package(obs-frontend-api QUIET)
if(obs-frontend-api_FOUND)
    target_link_libraries(${PROJECT_NAME} PRIVATE OBS::obs-frontend-api)
endif()
else() # Fallback: simple C frontend without dialog target_sources(${PROJECT_NAME} PRIVATE src/frontend-simple.c) endif()
undefined
if(BUILD_WITH_QT) target_sources(${PROJECT_NAME} PRIVATE src/frontend.cpp) target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_WITH_QT) target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets)
# Link OBS frontend API
find_package(obs-frontend-api QUIET)
if(obs-frontend-api_FOUND)
    target_link_libraries(${PROJECT_NAME} PRIVATE OBS::obs-frontend-api)
endif()
else() # Fallback: simple C frontend without dialog target_sources(${PROJECT_NAME} PRIVATE src/frontend-simple.c) endif()
undefined

Step 3: Create Settings Dialog Class

步骤3:创建设置对话框类

cpp
// settings-dialog.h
#pragma once

#include <QDialog>
#include <QLineEdit>
#include <QSpinBox>
#include <QPushButton>
#include <QVBoxLayout>
#include <QFormLayout>

class SettingsDialog : public QDialog {
    Q_OBJECT

public:
    explicit SettingsDialog(QWidget *parent = nullptr);

    QString host() const { return m_hostEdit->text(); }
    int port() const { return m_portSpin->value(); }

    void setHost(const QString &host) { m_hostEdit->setText(host); }
    void setPort(int port) { m_portSpin->setValue(port); }

private:
    QLineEdit *m_hostEdit;
    QSpinBox *m_portSpin;
};
cpp
// settings-dialog.h
#pragma once

#include <QDialog>
#include <QLineEdit>
#include <QSpinBox>
#include <QPushButton>
#include <QVBoxLayout>
#include <QFormLayout>

class SettingsDialog : public QDialog {
    Q_OBJECT

public:
    explicit SettingsDialog(QWidget *parent = nullptr);

    QString host() const { return m_hostEdit->text(); }
    int port() const { return m_portSpin->value(); }

    void setHost(const QString &host) { m_hostEdit->setText(host); }
    void setPort(int port) { m_portSpin->setValue(port); }

private:
    QLineEdit *m_hostEdit;
    QSpinBox *m_portSpin;
};

Step 4: Implement Dialog

步骤4:实现对话框

cpp
// settings-dialog.cpp
#include "settings-dialog.h"

SettingsDialog::SettingsDialog(QWidget *parent)
    : QDialog(parent)
{
    setWindowTitle(tr("Plugin Settings"));
    setMinimumWidth(300);

    // Create widgets
    m_hostEdit = new QLineEdit(this);
    m_hostEdit->setPlaceholderText(tr("127.0.0.1"));

    m_portSpin = new QSpinBox(this);
    m_portSpin->setRange(1, 65535);
    m_portSpin->setValue(5000);

    auto *okButton = new QPushButton(tr("OK"), this);
    auto *cancelButton = new QPushButton(tr("Cancel"), this);

    // Layout
    auto *formLayout = new QFormLayout;
    formLayout->addRow(tr("Host:"), m_hostEdit);
    formLayout->addRow(tr("Port:"), m_portSpin);

    auto *buttonLayout = new QHBoxLayout;
    buttonLayout->addStretch();
    buttonLayout->addWidget(okButton);
    buttonLayout->addWidget(cancelButton);

    auto *mainLayout = new QVBoxLayout(this);
    mainLayout->addLayout(formLayout);
    mainLayout->addLayout(buttonLayout);

    // Connections
    connect(okButton, &QPushButton::clicked, this, &QDialog::accept);
    connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
}
cpp
// settings-dialog.cpp
#include "settings-dialog.h"

SettingsDialog::SettingsDialog(QWidget *parent)
    : QDialog(parent)
{
    setWindowTitle(tr("Plugin Settings"));
    setMinimumWidth(300);

    // Create widgets
    m_hostEdit = new QLineEdit(this);
    m_hostEdit->setPlaceholderText(tr("127.0.0.1"));

    m_portSpin = new QSpinBox(this);
    m_portSpin->setRange(1, 65535);
    m_portSpin->setValue(5000);

    auto *okButton = new QPushButton(tr("OK"), this);
    auto *cancelButton = new QPushButton(tr("Cancel"), this);

    // Layout
    auto *formLayout = new QFormLayout;
    formLayout->addRow(tr("Host:"), m_hostEdit);
    formLayout->addRow(tr("Port:"), m_portSpin);

    auto *buttonLayout = new QHBoxLayout;
    buttonLayout->addStretch();
    buttonLayout->addWidget(okButton);
    buttonLayout->addWidget(cancelButton);

    auto *mainLayout = new QVBoxLayout(this);
    mainLayout->addLayout(formLayout);
    mainLayout->addLayout(buttonLayout);

    // Connections
    connect(okButton, &QPushButton::clicked, this, &QDialog::accept);
    connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
}

Step 5: Integrate with OBS Frontend API

步骤5:与OBS前端API集成

cpp
// frontend.cpp
#include <obs-module.h>
#include <obs-frontend-api.h>

#ifdef BUILD_WITH_QT
#include "settings-dialog.h"
#include <QMainWindow>
#endif

extern "C" {

static void on_frontend_event(enum obs_frontend_event event, void *data)
{
    (void)data;

    switch (event) {
    case OBS_FRONTEND_EVENT_FINISHED_LOADING:
        /* OBS UI is ready - safe to create Qt widgets */
        break;
    default:
        break;
    }
}

void frontend_init(void)
{
    obs_frontend_add_event_callback(on_frontend_event, NULL);
}

void frontend_cleanup(void)
{
    obs_frontend_remove_event_callback(on_frontend_event, NULL);
}

void frontend_show_settings(void)
{
#ifdef BUILD_WITH_QT
    QMainWindow *main_window = (QMainWindow *)obs_frontend_get_main_window();

    SettingsDialog dialog(main_window);
    if (dialog.exec() == QDialog::Accepted) {
        /* Save settings */
        const char *host = dialog.host().toUtf8().constData();
        int port = dialog.port();
        /* Apply settings... */
    }
#else
    blog(LOG_INFO, "Settings dialog not available (Qt not built)");
#endif
}

} /* extern "C" */
cpp
// frontend.cpp
#include <obs-module.h>
#include <obs-frontend-api.h>

#ifdef BUILD_WITH_QT
#include "settings-dialog.h"
#include <QMainWindow>
#endif

extern "C" {

static void on_frontend_event(enum obs_frontend_event event, void *data)
{
    (void)data;

    switch (event) {
    case OBS_FRONTEND_EVENT_FINISHED_LOADING:
        /* OBS UI is ready - safe to create Qt widgets */
        break;
    default:
        break;
    }
}

void frontend_init(void)
{
    obs_frontend_add_event_callback(on_frontend_event, NULL);
}

void frontend_cleanup(void)
{
    obs_frontend_remove_event_callback(on_frontend_event, NULL);
}

void frontend_show_settings(void)
{
#ifdef BUILD_WITH_QT
    QMainWindow *main_window = (QMainWindow *)obs_frontend_get_main_window();

    SettingsDialog dialog(main_window);
    if (dialog.exec() == QDialog::Accepted) {
        /* Save settings */
        const char *host = dialog.host().toUtf8().constData();
        int port = dialog.port();
        /* Apply settings... */
    }
#else
    blog(LOG_INFO, "Settings dialog not available (Qt not built)");
#endif
}

} /* extern "C" */

OBS Frontend API

OBS前端API

Key Functions

核心函数

FunctionPurpose
obs_frontend_get_main_window()
Get OBS main window (as QMainWindow*)
obs_frontend_add_event_callback()
Subscribe to frontend events
obs_frontend_remove_event_callback()
Unsubscribe from events
obs_frontend_add_tools_menu_item()
Add item to Tools menu
obs_frontend_add_dock()
Add dockable panel
函数名称用途
obs_frontend_get_main_window()
获取OBS主窗口(类型为QMainWindow*)
obs_frontend_add_event_callback()
订阅前端事件
obs_frontend_remove_event_callback()
取消订阅事件
obs_frontend_add_tools_menu_item()
向工具菜单添加项
obs_frontend_add_dock()
添加可停靠面板

Frontend Events

前端事件

cpp
enum obs_frontend_event {
    OBS_FRONTEND_EVENT_STREAMING_STARTING,
    OBS_FRONTEND_EVENT_STREAMING_STARTED,
    OBS_FRONTEND_EVENT_STREAMING_STOPPING,
    OBS_FRONTEND_EVENT_STREAMING_STOPPED,
    OBS_FRONTEND_EVENT_RECORDING_STARTING,
    OBS_FRONTEND_EVENT_RECORDING_STARTED,
    OBS_FRONTEND_EVENT_RECORDING_STOPPING,
    OBS_FRONTEND_EVENT_RECORDING_STOPPED,
    OBS_FRONTEND_EVENT_SCENE_CHANGED,
    OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED,
    OBS_FRONTEND_EVENT_TRANSITION_CHANGED,
    OBS_FRONTEND_EVENT_FINISHED_LOADING,
    OBS_FRONTEND_EVENT_EXIT,
    /* ... more events */
};
cpp
enum obs_frontend_event {
    OBS_FRONTEND_EVENT_STREAMING_STARTING,
    OBS_FRONTEND_EVENT_STREAMING_STARTED,
    OBS_FRONTEND_EVENT_STREAMING_STOPPING,
    OBS_FRONTEND_EVENT_STREAMING_STOPPED,
    OBS_FRONTEND_EVENT_RECORDING_STARTING,
    OBS_FRONTEND_EVENT_RECORDING_STARTED,
    OBS_FRONTEND_EVENT_RECORDING_STOPPING,
    OBS_FRONTEND_EVENT_RECORDING_STOPPED,
    OBS_FRONTEND_EVENT_SCENE_CHANGED,
    OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED,
    OBS_FRONTEND_EVENT_TRANSITION_CHANGED,
    OBS_FRONTEND_EVENT_FINISHED_LOADING,
    OBS_FRONTEND_EVENT_EXIT,
    /* ... more events */
};

Adding Tools Menu Item

添加工具菜单项

cpp
static void on_tools_menu_clicked(void *data)
{
    (void)data;
    frontend_show_settings();
}

void frontend_init(void)
{
    obs_frontend_add_tools_menu_item(
        obs_module_text("MyPlugin.Settings"),  /* Menu text */
        on_tools_menu_clicked,                  /* Callback */
        NULL                                    /* User data */
    );
}
cpp
static void on_tools_menu_clicked(void *data)
{
    (void)data;
    frontend_show_settings();
}

void frontend_init(void)
{
    obs_frontend_add_tools_menu_item(
        obs_module_text("MyPlugin.Settings"),  /* Menu text */
        on_tools_menu_clicked,                  /* Callback */
        NULL                                    /* User data */
    );
}

Qt Optional Build Pattern

Qt可选构建模式

CMake Configuration

CMake配置

cmake
undefined
cmake
undefined

Try to find Qt6, but don't fail if missing

Try to find Qt6, but don't fail if missing

find_package(Qt6 COMPONENTS Widgets QUIET)
if(Qt6_FOUND) set(BUILD_WITH_QT ON) message(STATUS "Qt6 found - building with UI") else() set(BUILD_WITH_QT OFF) message(STATUS "Qt6 not found - building without UI") endif()
find_package(Qt6 COMPONENTS Widgets QUIET)
if(Qt6_FOUND) set(BUILD_WITH_QT ON) message(STATUS "Qt6 found - building with UI") else() set(BUILD_WITH_QT OFF) message(STATUS "Qt6 not found - building without UI") endif()

Conditional compilation

Conditional compilation

if(BUILD_WITH_QT) target_sources(${PROJECT_NAME} PRIVATE src/frontend.cpp src/settings-dialog.cpp ) target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_WITH_QT) target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets) else() target_sources(${PROJECT_NAME} PRIVATE src/frontend-simple.c ) endif()
undefined
if(BUILD_WITH_QT) target_sources(${PROJECT_NAME} PRIVATE src/frontend.cpp src/settings-dialog.cpp ) target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_WITH_QT) target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets) else() target_sources(${PROJECT_NAME} PRIVATE src/frontend-simple.c ) endif()
undefined

C Fallback (frontend-simple.c)

C语言降级方案(frontend-simple.c)

c
/* frontend-simple.c - Minimal frontend without Qt
 *
 * Used when Qt is not available (e.g., cross-compilation).
 */

#include <obs-module.h>

void frontend_init(void)
{
    blog(LOG_INFO, "Plugin loaded without Qt UI");
}

void frontend_cleanup(void)
{
    /* Nothing to clean up */
}

void frontend_show_settings(void)
{
    blog(LOG_WARNING, "Settings dialog not available (Qt not built)");
}
c
/* frontend-simple.c - Minimal frontend without Qt
 *
 * Used when Qt is not available (e.g., cross-compilation).
 */

#include <obs-module.h>

void frontend_init(void)
{
    blog(LOG_INFO, "Plugin loaded without Qt UI");
}

void frontend_cleanup(void)
{
    /* Nothing to clean up */
}

void frontend_show_settings(void)
{
    blog(LOG_WARNING, "Settings dialog not available (Qt not built)");
}

Header Pattern

头文件模式

c
/* frontend.h - Frontend API (C-compatible) */
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

void frontend_init(void);
void frontend_cleanup(void);
void frontend_show_settings(void);

#ifdef __cplusplus
}
#endif
c
/* frontend.h - Frontend API (C-compatible) */
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

void frontend_init(void);
void frontend_cleanup(void);
void frontend_show_settings(void);

#ifdef __cplusplus
}
#endif

C and C++ Mixing Patterns

C与C++混合模式

extern "C" Wrapper

extern "C"包装器

cpp
// In C++ files that expose C API:
extern "C" {

#include <obs-module.h>

void my_cpp_function(void)
{
    // C++ code here
}

} /* extern "C" */
cpp
// In C++ files that expose C API:
extern "C" {

#include <obs-module.h>

void my_cpp_function(void)
{
    // C++ code here
}

} /* extern "C" */

C Header in C++

C++中引用C头文件

cpp
// Always use extern "C" when including C headers from C++
extern "C" {
#include <obs-module.h>
#include <obs-frontend-api.h>
}

// Now safe to use C++ features
#include <QString>
cpp
// Always use extern "C" when including C headers from C++
extern "C" {
#include <obs-module.h>
#include <obs-frontend-api.h>
}

// Now safe to use C++ features
#include <QString>

Plugin Main (C with C++ Features)

插件主入口(C语言调用C++功能)

c
/* plugin-main.c - C module entry point */

#include <obs-module.h>
#include "frontend.h"  /* C-compatible header */

OBS_DECLARE_MODULE()
OBS_MODULE_USE_DEFAULT_LOCALE("my-plugin", "en-US")

bool obs_module_load(void)
{
    obs_register_source(&my_source);

    /* Initialize frontend (may be C or C++) */
    frontend_init();

    return true;
}

void obs_module_unload(void)
{
    frontend_cleanup();
}
c
/* plugin-main.c - C module entry point */

#include <obs-module.h>
#include "frontend.h"  /* C-compatible header */

OBS_DECLARE_MODULE()
OBS_MODULE_USE_DEFAULT_LOCALE("my-plugin", "en-US")

bool obs_module_load(void)
{
    obs_register_source(&my_source);

    /* Initialize frontend (may be C or C++) */
    frontend_init();

    return true;
}

void obs_module_unload(void)
{
    frontend_cleanup();
}

CMAKE_AUTOMOC Explained

CMAKE_AUTOMOC详解

What AUTOMOC Does

AUTOMOC的作用

  • Scans C++ files for
    Q_OBJECT
    macro
  • Runs Qt's
    moc
    (Meta-Object Compiler) automatically
  • Generates
    moc_*.cpp
    files for signal/slot support
  • 扫描C++文件中的
    Q_OBJECT
  • 自动运行Qt的
    moc
    (元对象编译器)
  • 生成
    moc_*.cpp
    文件以支持信号与槽机制

Required Settings

必要配置

cmake
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)  # For .ui files
cmake
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)  # For .ui files

AUTOMOC requires C++ targets

AUTOMOC requires C++ targets

set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON)
undefined
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON)
undefined

Common Issues

常见问题

IssueCauseSolution
"undefined reference to vtable"Missing Q_OBJECTAdd Q_OBJECT to class
"moc not found"Qt not in PATHUse find_package(Qt6)
"undefined signal/slot"AUTOMOC didn't runEnsure .h is in SOURCES
问题原因解决方案
"undefined reference to vtable"缺少Q_OBJECT宏为类添加Q_OBJECT宏
"moc not found"Qt未在PATH中使用find_package(Qt6)
"undefined signal/slot"AUTOMOC未运行确保头文件已加入SOURCES

Threading with Qt

Qt线程处理

Safe Thread Communication

安全线程通信

cpp
// worker-thread.cpp
#include <QThread>
#include <QObject>

class WorkerThread : public QThread {
    Q_OBJECT

signals:
    void resultReady(const QString &result);

protected:
    void run() override {
        QString result = doWork();
        emit resultReady(result);  /* Signal is thread-safe */
    }

private:
    QString doWork() {
        /* Heavy work here */
        return "Done";
    }
};

// Usage from main thread:
WorkerThread *thread = new WorkerThread;
connect(thread, &WorkerThread::resultReady, this, &MyClass::handleResult);
connect(thread, &WorkerThread::finished, thread, &QObject::deleteLater);
thread->start();
cpp
// worker-thread.cpp
#include <QThread>
#include <QObject>

class WorkerThread : public QThread {
    Q_OBJECT

signals:
    void resultReady(const QString &result);

protected:
    void run() override {
        QString result = doWork();
        emit resultReady(result);  /* Signal is thread-safe */
    }

private:
    QString doWork() {
        /* Heavy work here */
        return "Done";
    }
};

// Usage from main thread:
WorkerThread *thread = new WorkerThread;
connect(thread, &WorkerThread::resultReady, this, &MyClass::handleResult);
connect(thread, &WorkerThread::finished, thread, &QObject::deleteLater);
thread->start();

Qt Event Loop Integration

Qt事件循环集成

cpp
// Don't block OBS main thread - use async patterns
void MyDialog::onButtonClicked()
{
    // WRONG: Blocks OBS UI
    // QThread::sleep(5);

    // CORRECT: Use QTimer or worker thread
    QTimer::singleShot(0, this, [this]() {
        // Runs after current event processing
        doSomething();
    });
}
cpp
// Don't block OBS main thread - use async patterns
void MyDialog::onButtonClicked()
{
    // WRONG: Blocks OBS UI
    // QThread::sleep(5);

    // CORRECT: Use QTimer or worker thread
    QTimer::singleShot(0, this, [this]() {
        // Runs after current event processing
        doSomething();
    });
}

FORBIDDEN Patterns

禁止使用的模式

PatternProblemSolution
Blocking in UI callbacksFreezes OBSUse worker threads
Missing Q_OBJECTSignals/slots failAdd Q_OBJECT macro
Qt widgets in audio threadCrashOnly UI in main thread
Mixing Qt versionsABI issuesStick to Qt6 only
Missing AUTOMOCLink errorsEnable CMAKE_AUTOMOC
Direct obs_frontend calls without checkCrash if no frontendCheck obs-frontend-api_FOUND
模式问题解决方案
UI回调中阻塞线程导致OBS界面冻结使用工作线程
缺少Q_OBJECT宏信号/槽机制失效添加Q_OBJECT宏
音频线程中使用Qt Widgets导致程序崩溃仅在主线程中处理UI
混合使用不同Qt版本ABI兼容性问题仅使用Qt6
未启用AUTOMOC链接错误启用CMAKE_AUTOMOC
未检查直接调用obs_frontend函数无前端时导致崩溃检查obs-frontend-api_FOUND

Platform-Specific UI Fallbacks

平台专属UI降级方案

Windows Native Dialog

Windows原生对话框

c
/* settings-dialog-win32.c - Fallback when Qt unavailable */
#ifdef _WIN32
#include <windows.h>
#include <commctrl.h>

void show_settings_dialog_win32(void *parent)
{
    MessageBoxW((HWND)parent,
                L"Settings dialog requires Qt.\nPlease install Qt6.",
                L"Plugin Settings",
                MB_OK | MB_ICONINFORMATION);
}
#endif
c
/* settings-dialog-win32.c - Fallback when Qt unavailable */
#ifdef _WIN32
#include <windows.h>
#include <commctrl.h>

void show_settings_dialog_win32(void *parent)
{
    MessageBoxW((HWND)parent,
                L"Settings dialog requires Qt.\nPlease install Qt6.",
                L"Plugin Settings",
                MB_OK | MB_ICONINFORMATION);
}
#endif

CMake Platform Selection

CMake平台选择

cmake
if(NOT BUILD_WITH_QT)
    if(WIN32)
        target_sources(${PROJECT_NAME} PRIVATE
            src/settings-dialog-win32.c
        )
    else()
        target_sources(${PROJECT_NAME} PRIVATE
            src/frontend-simple.c
        )
    endif()
endif()
cmake
if(NOT BUILD_WITH_QT)
    if(WIN32)
        target_sources(${PROJECT_NAME} PRIVATE
            src/settings-dialog-win32.c
        )
    else()
        target_sources(${PROJECT_NAME} PRIVATE
            src/frontend-simple.c
        )
    endif()
endif()

External Documentation

外部文档

Context7

Context7

mcp__context7__query-docs
libraryId: "/obsproject/obs-studio"
query: "Qt frontend API settings dialog"
mcp__context7__query-docs
libraryId: "/obsproject/obs-studio"
query: "Qt frontend API settings dialog"

Official References

官方参考

Related Skills

相关技能

  • obs-windows-building - Windows-specific builds
  • obs-cross-compiling - Cross-compilation (may not have Qt)
  • obs-plugin-developing - Plugin architecture overview
  • obs-audio-plugin-writing - Audio plugin implementation
  • obs-windows-building - Windows专属构建
  • obs-cross-compiling - 交叉编译(可能无Qt环境)
  • obs-plugin-developing - 插件架构概述
  • obs-audio-plugin-writing - 音频插件实现

Related Agent

相关Agent

Use obs-plugin-expert for coordinated guidance across all OBS plugin skills.
使用obs-plugin-expert获取OBS插件全技能的协同指导。