【问题标题】:Create QT plugin with FireBreath on Windows在 Windows 上使用 FireBreath 创建 QT 插件
【发布时间】:2014-12-23 09:17:16
【问题描述】:

首先,对不起我的英语。

我用QT写了一个FireBreath插件,插件可以正常显示。

但是当我点击插件窗口中的一个按钮时,什么都没有发生。所有的小部件都是这样的。

但是当我调整浏览器大小时,那个按钮发生了变化。

我是否忘记了 QT 中的一些事件处理或窗口更新操作?

感谢您的建议!

onPluginReady()函数中创建的QApplication

void MediaPlayerPlugin::onPluginReady()
{
    static int argc=0;
    static char **argv={ 0 };
    new QApplication(argc, argv);
}

QWidget 是插件窗口的子类(注意:m_playerQWidget 子类)。

bool MediaPlayerPlugin::onWindowAttached(FB::AttachedEvent *evt, FB::PluginWindow *pluginWindow)
{
    FB::PluginWindowWin* wnd = reinterpret_cast<FB::PluginWindowWin*>(pluginWindow);
    HWND hwnd = wnd->getHWND();

    m_player = new MediaPlayer();

    HWND childHwnd = (HWND)m_player->winId();

    LONG oldLong = GetWindowLong(hwnd, GWL_STYLE);

    ::SetWindowLong(hwnd, GWL_STYLE, oldLong | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
    ::SetWindowLong(childHwnd, GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
    ::SetParent(childHwnd, hwnd);


    FB::Rect pos = wnd->getWindowPosition();
    m_player->setGeometry(pos.left,pos.top,pos.right-pos.left,pos.bottom-pos.top);
    m_player->show();
    return true;
}

【问题讨论】:

    标签: qt plugins firebreath


    【解决方案1】:

    我的猜测是 QApplication 将基本上接管它正在运行的进程,当您作为插件运行时这是一个问题。您不拥有流程 - 您无法决定任何有趣的细节。

    简短的回答是,如果有办法做到这一点,我还没有找到。在一个我需要做类似事情的情况下,我最终将 QApplication 可执行文件作为一个单独的进程启动并通过 STDIN/STDOUT 与其通信。

    【讨论】:

    • 谢谢,我已经解决了我的问题。我只是在onPluginReady()函数中创建另一个线程,并在线程中创建QApplication。这对我有帮助——link
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多