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
    27 Apr 2024, 08:38

    Hi,

    I want to know how to display button over QvideoWidget?

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 29 Apr 2024, 06:04 last edited by
    #2

    @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.

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

    B 1 Reply Last reply 30 Apr 2024, 04:28
    0
    • J jsulm
      29 Apr 2024, 06:04

      @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.

      B Offline
      B Offline
      Bonty
      wrote on 30 Apr 2024, 04:28 last edited by
      #3

      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.

      J 1 Reply Last reply 30 Apr 2024, 06:13
      1
      • B Bonty
        30 Apr 2024, 04:28

        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.

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 30 Apr 2024, 06:13 last edited by
        #4

        @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);
        

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

        B 1 Reply Last reply 30 Apr 2024, 09:34
        1
        • 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 23 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

                                          • Login

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