Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Button over QVideoWidget
Forum Updated to NodeBB v4.3 + New Features

Button over QVideoWidget

Scheduled Pinned Locked Moved Solved Mobile and Embedded
24 Posts 7 Posters 4.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Bonty

    @arsinte_andrei

    Still not working, hide behind video.

    JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by JoeCFD
    #11

    @Bonty can you try to create the button with the parent of videoWidget?

    QPushButton *button = new QPushButton(videoWidget->parentWidget() );
    

    then move it to the right position

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonty
      wrote on last edited by
      #12

      Hi @JoeCFD

      Thanks for replying!

      Here is my code and application output image Screenshot from 2024-05-07 10-27-59.png 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;
      }
      
      1 Reply Last reply
      1
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #13

        Try the following as well and add some background color(like green for testing)
        button->setWindowFlags((Qt::WindowFlags)(Qt::WindowStaysOnTopHint ) );

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #14

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          B 1 Reply Last reply
          1
          • B Bonty has marked this topic as solved on
          • SGaistS SGaist

            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.

            B Offline
            B Offline
            Bonty
            wrote on last edited by Bonty
            #15

            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!!

            SGaistS 1 Reply Last reply
            0
            • B Bonty

              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!!

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #16

              @Bonty How is your QtQuick code looking currently ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • X Offline
                X Offline
                xylo212
                wrote on last edited by
                #17
                This post is deleted!
                1 Reply Last reply
                0
                • QtFriend2024Q Offline
                  QtFriend2024Q Offline
                  QtFriend2024
                  wrote on last edited by QtFriend2024
                  #18

                  Hello, I have the same problem.

                  QT 6.7.3

                  QT Creator: 15.*
                  Target O.S.: Windows 11

                  I 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!

                  jsulmJ 1 Reply Last reply
                  0
                  • QtFriend2024Q QtFriend2024

                    Hello, I have the same problem.

                    QT 6.7.3

                    QT Creator: 15.*
                    Target O.S.: Windows 11

                    I 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!

                    jsulmJ Online
                    jsulmJ Online
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #19

                    @QtFriend2024 Please read what @SGaist wrote. It will not work with widgets, but should work with QML.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    QtFriend2024Q 2 Replies Last reply
                    1
                    • jsulmJ jsulm

                      @QtFriend2024 Please read what @SGaist wrote. It will not work with widgets, but should work with QML.

                      QtFriend2024Q Offline
                      QtFriend2024Q Offline
                      QtFriend2024
                      wrote on last edited by
                      #20

                      @jsulm Ok thank you. I was trying to avoid using QML, but I will try this.

                      1 Reply Last reply
                      0
                      • QtFriend2024Q Offline
                        QtFriend2024Q Offline
                        QtFriend2024
                        wrote last edited by QtFriend2024
                        #21

                        For QWidget Applications, will this ever be resolved - being able to stack QPushButton in front of a QVideoWidget, or must we always resort to QML and QTQuick applications? My application was already built as a Widget application. This is frustrating. I've spent many hours getting this to work. For my widget application, I have to throw in a dummy QQuickWidget in the stack (1px x 1px) just to get QT 6.7.3 to stack the QVideoWidget correctly inconsistently.

                        1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @QtFriend2024 Please read what @SGaist wrote. It will not work with widgets, but should work with QML.

                          QtFriend2024Q Offline
                          QtFriend2024Q Offline
                          QtFriend2024
                          wrote last edited by
                          #22

                          @jsulm I need this problem solved without QML.

                          SGaistS 1 Reply Last reply
                          0
                          • QtFriend2024Q QtFriend2024

                            @jsulm I need this problem solved without QML.

                            SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote last edited by
                            #23

                            @QtFriend2024 You mention that you managed to make it work with that workaround. Can you provide a minimal compilable example that shows it in action ?

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0
                            • QtFriend2024Q Offline
                              QtFriend2024Q Offline
                              QtFriend2024
                              wrote last edited by QtFriend2024
                              #24

                              One Solution Without QML

                              I've figured a way to get the QVideoWidget to stack behind QPushButton and QLabel in a Widgets application without using QML - the camera has to be started before the stacking order is set. Otherwise, the QVideoWidget gets forced to the front no matter what you do. This worked for me.

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved