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 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.
-
Hi @jsulm,
Thanks for replying !
Can you please give me some example code or link because I am using Qt6 and the resources are very limited on internet for Qt6.
@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 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);
-
Hi @jsulm ,
In Qt5.15.2 it is simply drag button over video widget and its working but its not the same in Qt6. So I don't think Qt5 and Qt6 is similar, even there is changes in Qt5.13 and Qt5.15 also.
Please help !!
@Bonty said in Button over QVideoWidget:
but its not the same in Qt6
What does this mean exactly? What happens in Qt6?
-
@Bonty look at the button properties..and bring it to front
-
@Bonty look at the button properties..and bring it to front
Still not working, hide behind video.
-
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. -
-
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. -
Hi @SGaist,
Thanks for suggestion! Its working using QML. But there is problem in QML is that I cant change camera input format and frame rate. If possible then how I can change?
Please help!!
-
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!
-
-
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.
-
-
@QtFriend2024 Please read what @SGaist wrote. It will not work with widgets, but should work with QML.
@jsulm Ok thank you. I was trying to avoid using QML, but I will try this.