Widgets and painter is getting overlayed by QVideoWidget
-
I have a VideoWidget that is occupies the whole window. And i would like to have to have a QPushButton and some text via Qpainter that overlays on top of the video.
What is happening though is the button and the text is the one being overlayed by the VideoWidget. The button is there i can even click it, i just cant see it
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); video = new QVideoWidget(this); video->setGeometry(0,0,this->width(),this->height()); video->show(); this->repaint(); optionsButton = new QPushButton(this); optionsButton->setText("O"); optionsButton->setGeometry(20,20,40,40); optionsButton->show(); connect(optionsButton,SIGNAL(clicked()),this,SLOT(optionsButtonClicked())); player = new QMediaPlayer(this); audio = new QAudioOutput(this); connect(player,&QMediaPlayer::errorChanged,this,&MainWindow::mediaPlayerDebugError); connect(player,&QMediaPlayer::mediaStatusChanged,this,&MainWindow::mediaPlayerDebugStatus); player->setAudioOutput(audio); player->setVideoOutput(video); player->setSource(QUrl("rtsp://admin:admin@192.168.1.199:554/mpeg4/ch0/main/av_stream")); player->play(); } void MainWindow::paintEvent(QPaintEvent *) { QPainter painter(this); painter.setPen(Qt::blue); painter.setFont(QFont("Arial", 30)); painter.drawText(rect(), Qt::AlignCenter, "Qt"); }Here is a screen shot of what i see

and a screenshot without the VideoWidget

How can i bring to front the PushButton and Painter ?