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.0k 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
    6 May 2024, 04:50

    @arsinte_andrei

    Still not working, hide behind video.

    J Offline
    J Offline
    JoeCFD
    wrote on 6 May 2024, 18:47 last edited by JoeCFD 5 Jun 2024, 18:48
    #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 7 May 2024, 04:59 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
      • J Offline
        J Offline
        JoeCFD
        wrote on 7 May 2024, 13:46 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
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 7 May 2024, 13:56 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 8 May 2024, 03:52
          1
          • B Bonty has marked this topic as solved on 8 May 2024, 03:50
          • S SGaist
            7 May 2024, 13:56

            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 8 May 2024, 03:52 last edited by Bonty 5 Aug 2024, 03:54
            #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!!

            S 1 Reply Last reply 9 May 2024, 18:46
            0
            • B Bonty
              8 May 2024, 03:52

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

              S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 9 May 2024, 18:46 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 30 Oct 2024, 09:35 last edited by
                #17
                This post is deleted!
                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  QtFriend2024
                  wrote on 27 Feb 2025, 20:53 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 28 Feb 2025, 06:16
                  0
                  • Q QtFriend2024
                    27 Feb 2025, 20:53

                    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 Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 28 Feb 2025, 06:16 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

                    Q 2 Replies Last reply 1 Mar 2025, 18:50
                    1
                    • jsulmJ jsulm
                      28 Feb 2025, 06:16

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

                      Q Offline
                      Q Offline
                      QtFriend2024
                      wrote on 1 Mar 2025, 18:50 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
                      • Q Offline
                        Q Offline
                        QtFriend2024
                        wrote 22 days ago 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
                          28 Feb 2025, 06:16

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

                          Q Offline
                          Q Offline
                          QtFriend2024
                          wrote 18 days ago last edited by
                          #22

                          @jsulm I need this problem solved without QML.

                          S 1 Reply Last reply 18 days ago
                          0
                          • Q QtFriend2024
                            18 days ago

                            @jsulm I need this problem solved without QML.

                            S Offline
                            S Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote 18 days ago 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
                            • Q Offline
                              Q Offline
                              QtFriend2024
                              wrote 18 days ago 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