首先,对不起我的英语。
我用QT写了一个FireBreath插件,插件可以正常显示。
但是当我单击插件窗口中的按钮时,没有任何反应。所有像这样的小部件。
但是当我调整浏览器大小时,该按钮发生了变化。
我是否忘记了QT中的一些事件处理或窗口更新操作?
感谢您的任何建议!
在onPluginReady()
函数中创建的QApplication
。
void MediaPlayerPlugin::onPluginReady()
{
static int argc=0;
static char **argv={ 0 };
new QApplication(argc, argv);
}
QWidget
是插件窗口的子类(注意:m_player
是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与之通信。