Button over QVideoWidget
-
Hi,
In Qt 6, the QVideoWidget uses a QWindow based class to do the rendering which means OpenGL is used for the rendering and it's likely a top level surface hence your buttons that renders behind it.
You might want to consider making use of QML for that part. -
@Bonty By putting it on the QvideoWidget. QvideoWidget is a QWidget, so you can put other widgets on it. You can set QvideoWidget as parent of you button and then position the button using move(x, y). You could also try to use a layout on QvideoWidget.
-
@Bonty There is not much difference between Qt5 and Qt6.
Also, don't know what examples you need? Just create a button, set QVideoWidget as its parent and position it like you want on the parent. Qt has good documentation, you can find all this easily there.QPushButton *button = new QPushButton(videoWidget); button->move(100, 100);
-
@Bonty said in Button over QVideoWidget:
but its not the same in Qt6
What does this mean exactly? What happens in Qt6?
-
Still not working, hide behind video.
-
Hi @JoeCFD
Thanks for replying!
Here is my code and application output image
but still same issue:-
#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); m_camera.reset(new QCamera(QMediaDevices::defaultVideoInput())); m_captureSession.setCamera(m_camera.data()); m_captureSession.setVideoOutput(ui->videoWidget); m_camera->start(); QPushButton *button = new QPushButton(ui->videoWidget->parentWidget() ); button->setGeometry(100,100,100,100); } MainWindow::~MainWindow() { delete ui; }
-
Hi,
In Qt 6, the QVideoWidget uses a QWindow based class to do the rendering which means OpenGL is used for the rendering and it's likely a top level surface hence your buttons that renders behind it.
You might want to consider making use of QML for that part. -
-
Hello, I have the same problem.
QT 6.7.3
QT Creator: 15.*
Target O.S.: Windows 11I want QPushButton(s) [and QLabel(s)] to display in front of my QVideoWidget object, but the QVideoWidget object keeps getting forced to the front, so all other QObjects get hidden behind the QVideoWidget object. My QVideoWidget displays within a window (not within a QDialog).
-
I've tried QWidget::lower() / QWidget::raise() on the QVideoWiget and QPushButton but the QVideoWidget still gets forced to the front.
-
I've tried setting the parent of the QPushButton to the QVideoWidget object but am still not able to force the QPushButton to display in front of the QWidget object.
-
I've tried adding the QVideoWidget and QPushButton to a QVBoxLayout then used move() and raise() to move the QPushButton to the front of the QVideoWidget object but the QVideoWidget remains forced to the front.
Note: I AM able to get a QDialog to display in front of the QVideoWidget but this is not what I want.
How can I get a QPushButton to display in front of the QVideoWidget?
Thanks!
-
-
@QtFriend2024 Please read what @SGaist wrote. It will not work with widgets, but should work with QML.