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
Servers for Qt installer are currently down

Button over QVideoWidget

Scheduled Pinned Locked Moved Solved Mobile and Embedded
24 Posts 7 Posters 3.6k 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.
  • J jsulm
    30 Apr 2024, 06:13

    @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);
    
    B Offline
    B Offline
    Bonty
    wrote on 30 Apr 2024, 09:34 last edited by
    #5

    Hi @jsulm,

    I am creating an application based on usb camera and I want some buttons overlay on video streaming from camera.

    1 Reply Last reply
    1
    • B Offline
      B Offline
      Bonty
      wrote on 1 May 2024, 05:43 last edited by
      #6

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

      J 1 Reply Last reply 2 May 2024, 05:55
      0
      • B Bonty
        1 May 2024, 05:43

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

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 2 May 2024, 05:55 last edited by
        #7

        @Bonty said in Button over QVideoWidget:

        but its not the same in Qt6

        What does this mean exactly? What happens in Qt6?

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

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Bonty
          wrote on 3 May 2024, 05:56 last edited by
          #8

          In QT6 the button hide behind video.

          A 1 Reply Last reply 5 May 2024, 14:07
          1
          • B Bonty
            3 May 2024, 05:56

            In QT6 the button hide behind video.

            A Offline
            A Offline
            arsinte_andrei
            wrote on 5 May 2024, 14:07 last edited by
            #9

            @Bonty look at the button properties..and bring it to front

            B 1 Reply Last reply 6 May 2024, 04:50
            0
            • A arsinte_andrei
              5 May 2024, 14:07

              @Bonty look at the button properties..and bring it to front

              B Offline
              B Offline
              Bonty
              wrote on 6 May 2024, 04:50 last edited by
              #10

              @arsinte_andrei

              Still not working, hide behind video.

              J 1 Reply Last reply 6 May 2024, 18:47
              1
              • 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
                    • SGaistS Offline
                      SGaistS 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
                      • SGaistS 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!!

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

                          SGaistS Offline
                          SGaistS 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
                            • QtFriend2024Q Offline
                              QtFriend2024Q 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!

                              J 1 Reply Last reply 28 Feb 2025, 06:16
                              0
                              • QtFriend2024Q 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!

                                J Offline
                                J 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

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

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

                                  QtFriend2024Q Offline
                                  QtFriend2024Q 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
                                  • QtFriend2024Q Offline
                                    QtFriend2024Q Offline
                                    QtFriend2024
                                    wrote 18 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
                                    • J jsulm
                                      28 Feb 2025, 06:16

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

                                      QtFriend2024Q Offline
                                      QtFriend2024Q Offline
                                      QtFriend2024
                                      wrote 14 days ago last edited by
                                      #22

                                      @jsulm I need this problem solved without QML.

                                      SGaistS 1 Reply Last reply 14 days ago
                                      0
                                      • QtFriend2024Q QtFriend2024
                                        14 days ago

                                        @jsulm I need this problem solved without QML.

                                        SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote 14 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
                                        • QtFriend2024Q Offline
                                          QtFriend2024Q Offline
                                          QtFriend2024
                                          wrote 14 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