I develop a Gtkmm based application, which can be extended through a plugin mecanism. Each plugin must define a show() method
void MyExtension::show()
{
// here the code of the extension
}
I am trying to develop a plugin that uses Qt widgets. I am a newbie in Qt, but I tried the following simple code:
void MyExtension::show()
{
int argc = 1;
char argv1[] = "myapp";
char* argv[] = { argv1, NULL };
QApplication app(argc, argv);
QMessageBox::question(NULL, "title", "what?", QMessageBox::Yes|QMessageBox::No);
app.exec();
app.exit();
}
This source code builds perfectly, the first execution of the plugin is OK (the dialog box is shown), but after the first execution of the plugin, the QApplication seems to perturb the GTK event loop. I get messages like this ones:
Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
and the application fully crashes on third or fourth execution of the plugin.
Any idea to develop plugins (=shared lib loaded at runtime) with Qt widgets, and plugged into a Gtkmm app? Thanks a lot.