I host an ActiveX control which displays video. It is wrapped in QAxWidget. I try painting within QAxWidget but it always appears behind:

Qt Code:
  1. void MainWindow::paintEvent(QPaintEvent* e)
  2. {
  3. QMainWindow::paintEvent(e);
  4. QPainter p(this);
  5. p.setPen(Qt::red);
  6. p.drawRect(10,10,100,100);
  7. }
To copy to clipboard, switch view to plain text mode 

I can see the left top and left bottom corners of the rect to know it’s drawn but don’t understand how to get the z-order changed. The items are laid out in QDesigner. Below is some of the derived header from the UI compiler:

Qt Code:
  1. centralWidget = new QWidget(MainWindow);
  2. centralWidget->setObjectName(QStringLiteral("centralWidget"));
  3. gridLayout = new QGridLayout(centralWidget);
  4. gridLayout->setSpacing(6);
  5. gridLayout->setContentsMargins(11, 11, 11, 11);
  6. gridLayout->setObjectName(QStringLiteral("gridLayout"));
  7. HDVideo = new QAxWidget(centralWidget);
  8. HDVideo->setControl(QStringLiteral("{cb1671db-6c24-4c48-b5f9-8276d135501e}"));
  9. HDVideo->setObjectName(QStringLiteral("HDVideo"));
  11. gridLayout->addWidget(HDVideo, 0, 0, 1, 1);
To copy to clipboard, switch view to plain text mode 

I’ve tried calling ui->HDVideo->lower as well as ui->HDVideo->stackUnder(this) which doesn’t work. How can you paint on a QAxWidget?