Okay I might be making a bit of progress here. I'm not sure how this will turn out but it's worth a shot. First of all, in the Qt plugin, I export a function which renders the widgets:
extern "C" void RenderWidgets(PixelArray_t &pixelData, int const w, int const h) { assert( nullptr != &pixelData ); // just for debug parentWidget->setGeometry(0, 0, w, h); QPixmap pixmap( parentWidget->size() ); pixmap.fill(Qt::transparent); QPainter painter(&pixmap); parentWidget->render(&painter); painter.end(); QImage image = pixmap.toImage(); int const width = image.width(); int const height = image.height(); pixelData.resize( width, PixelArray_t::value_type(height) ); // 2D array of QColor for ( int x = 0; x < width; ++x ) { for ( int y = 0; y < height; ++y ) { pixelData[x][y] = (unsigned)image.pixel(x, y); } } }In my main program which runs wxWidgets, I have a handler for the Paint event for the panel, implemented as follows:
void OnPaint(wxPaintEvent& event) { wxPaintDC dc(this); // Create a paint DC for the panel int const w = dc.GetSize().GetWidth (); int const h = dc.GetSize().GetHeight(); pfnRender(pixels, w, h); // Call the function exported by the Qt plugin assert( this->pixels.size() > 0 ); assert( this->pixels.front().size() > 0 ); wxBitmap bitmap(w, h); // Create a bitmap that matches the panel size wxMemoryDC memDC(bitmap); // Create a memory DC to work with the bitmap for ( int x = 0; x < w; ++x ) { for ( int y = 0; y < h; ++y ) { unsigned const pixel = pixels[x][y]; unsigned char r = (pixel >> 24) & 0xFF; unsigned char g = (pixel >> 16) & 0xFF; unsigned char b = (pixel >> 8) & 0xFF; unsigned char a = (pixel >> 0) & 0xFF; memDC.SetPen( wxPen(wxColour(r, g, b), 1) ); memDC.SetBrush(wxBrush(wxColour(r, g, b), wxSOLID)); //memDC.SetAlpha(a); memDC.DrawRectangle(x, y, 1, 1); // Draw 1x1 pixel } } dc.DrawBitmap(bitmap, 0, 0); }I've tested this out and it works. So I'm able to display widgets.
But next . . . here's what I need to do:
In the wxWidgets main program, record mouse movements and mouse clicks, and send them to the Qt plugin. Then inside the Qt plugin, I need to take these movements and clicks and somehow send them to the widgets (even though the widgets aren't on screen in the canonical sense). Can anyone help me with this part?