在Windows上使用FireBreath创建QT插件

在Windows上使用FireBreath创建QT插件,qt,plugins,firebreath,Qt,Plugins,Firebreath,首先,对不起我的英语 我用QT写了一个FireBreath插件,该插件可以正常显示 但是当我点击插件窗口中的一个按钮时,什么也没发生。所有的小部件都是这样的 但当我调整浏览器大小时,该按钮发生了变化 我是否忘记了QT中的一些事件处理或窗口更新操作 谢谢你的建议 在onPluginReadyfunction中创建的QApplication QWidget是插件windownote的子类:m_播放器是QWidget的子类 bool MediaPlayerPlugin::onWindowAttache

首先,对不起我的英语

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

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

但当我调整浏览器大小时,该按钮发生了变化

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

谢谢你的建议

在onPluginReadyfunction中创建的QApplication

QWidget是插件windownote的子类:m_播放器是QWidget的子类

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;
}

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


简而言之,如果有办法做到这一点,我还没有找到。有一次我需要做类似的事情,结果我启动了QApplication可执行文件作为一个单独的进程,并通过STDIN/STDOUT与之通信。

谢谢,我已经解决了我的问题。我只是在onpluginredyFunction中创建了另一个线程,并在线程中创建了QApplication。这对我很有帮助-
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;
}