Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt Widgets + GStreamer + Overlay + Screen Capture
Forum Updated to NodeBB v4.3 + New Features

Qt Widgets + GStreamer + Overlay + Screen Capture

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++widgetsgstreamer videooverlayscreenshot
15 Posts 3 Posters 3.4k Views 1 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.
  • S SeeRich
    8 Feb 2023, 19:39

    @SGaist Thank you for looking at this. Are you suggesting that I should change my parameters being passed to drawText(...)?

    I am wanting to get rid of the black box behind the overlay text. In this case, it should show yellow text on top of the white, yellow, and cyan vertical stripes from the video.

    S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 8 Feb 2023, 20:00 last edited by
    #4

    @SeeRich yes, that overload should do what you want directly.

    As for the black background, I suspect it's because you set the brush to NoBrush.

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

    S 1 Reply Last reply 9 Feb 2023, 13:14
    0
    • S SGaist
      8 Feb 2023, 20:00

      @SeeRich yes, that overload should do what you want directly.

      As for the black background, I suspect it's because you set the brush to NoBrush.

      S Offline
      S Offline
      SeeRich
      wrote on 9 Feb 2023, 13:14 last edited by SeeRich 2 Sept 2023, 13:15
      #5

      @SGaist thank you for your help. I guess I am a little confused.

      Is the overload of drawText(...) that you are pointing me to supposed to help me fix the positioning (i.e. centered vertically and horizontally) or is it supposed to fix the black background around the overlay text?

      As for the brush, what enumeration would you suggest? I didn't see one that's more equivalent to transparent which I believe is what I want in this case.

      I believe the root cause of this issue is because GStreamer is rendering the video to the native window using the video widget's winId() function. It seems to me that the background isn't handled well because this is essentially bypassing Qt to render the video and the background that shows up behind the overlay text is what Qt believes is there (i.e. the MainWindow background).

      What do you think?

      S 1 Reply Last reply 10 Feb 2023, 19:31
      0
      • S SeeRich
        9 Feb 2023, 13:14

        @SGaist thank you for your help. I guess I am a little confused.

        Is the overload of drawText(...) that you are pointing me to supposed to help me fix the positioning (i.e. centered vertically and horizontally) or is it supposed to fix the black background around the overlay text?

        As for the brush, what enumeration would you suggest? I didn't see one that's more equivalent to transparent which I believe is what I want in this case.

        I believe the root cause of this issue is because GStreamer is rendering the video to the native window using the video widget's winId() function. It seems to me that the background isn't handled well because this is essentially bypassing Qt to render the video and the background that shows up behind the overlay text is what Qt believes is there (i.e. the MainWindow background).

        What do you think?

        S Offline
        S Offline
        SeeRich
        wrote on 10 Feb 2023, 19:31 last edited by
        #6

        @SGaist would it be helpful if I provided a CMakeLists.txt file to compile this example code?

        J 1 Reply Last reply 10 Feb 2023, 20:26
        0
        • S SeeRich
          10 Feb 2023, 19:31

          @SGaist would it be helpful if I provided a CMakeLists.txt file to compile this example code?

          J Offline
          J Offline
          JoeCFD
          wrote on 10 Feb 2023, 20:26 last edited by JoeCFD 2 Oct 2023, 20:33
          #7

          @SeeRich Use a QLabel(not QWidget) as your overlay widget and make it transparent. Then, the black background will be gone.

          S 1 Reply Last reply 13 Feb 2023, 14:34
          0
          • J JoeCFD
            10 Feb 2023, 20:26

            @SeeRich Use a QLabel(not QWidget) as your overlay widget and make it transparent. Then, the black background will be gone.

            S Offline
            S Offline
            SeeRich
            wrote on 13 Feb 2023, 14:34 last edited by
            #8

            @JoeCFD Thank you for the suggestion! Unfortunately, it gave me the same result. I specifically changed the overlay code to be this:

            class OverlayWidget : public QLabel
            {
                Q_OBJECT
            public:
                OverlayWidget(QWidget* parent) : QLabel(parent)
                {
                    // setAttribute(Qt::WA_TranslucentBackground);
                    // setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
                    setStyleSheet("background-color: transparent");
                }
            

            Is this what you were suggesting?

            J 1 Reply Last reply 13 Feb 2023, 16:19
            0
            • S SeeRich
              13 Feb 2023, 14:34

              @JoeCFD Thank you for the suggestion! Unfortunately, it gave me the same result. I specifically changed the overlay code to be this:

              class OverlayWidget : public QLabel
              {
                  Q_OBJECT
              public:
                  OverlayWidget(QWidget* parent) : QLabel(parent)
                  {
                      // setAttribute(Qt::WA_TranslucentBackground);
                      // setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
                      setStyleSheet("background-color: transparent");
                  }
              

              Is this what you were suggesting?

              J Offline
              J Offline
              JoeCFD
              wrote on 13 Feb 2023, 16:19 last edited by JoeCFD
              #9

              @SeeRich Yes, something like that. Can you try
              setStyleSheet("background-color: green");
              to see if the background color is green?

              if the green color works, try the following:
              QLabel * _overlayLabel{nullptr}; /* no need to create a overlay widget class */
              _overlayLabel = new Qlabel( this );
              _overlayLabel->setStyleSheet("border:none; background:transparent;");

              S 1 Reply Last reply 13 Feb 2023, 20:09
              0
              • J JoeCFD
                13 Feb 2023, 16:19

                @SeeRich Yes, something like that. Can you try
                setStyleSheet("background-color: green");
                to see if the background color is green?

                if the green color works, try the following:
                QLabel * _overlayLabel{nullptr}; /* no need to create a overlay widget class */
                _overlayLabel = new Qlabel( this );
                _overlayLabel->setStyleSheet("border:none; background:transparent;");

                S Offline
                S Offline
                SeeRich
                wrote on 13 Feb 2023, 20:09 last edited by
                #10

                @JoeCFD The green background did work; however, the _overlayLabel still has a black background. Could this be because Qt isn't aware of what gstreamer is rendering?

                J 1 Reply Last reply 13 Feb 2023, 20:21
                0
                • S SeeRich
                  13 Feb 2023, 20:09

                  @JoeCFD The green background did work; however, the _overlayLabel still has a black background. Could this be because Qt isn't aware of what gstreamer is rendering?

                  J Offline
                  J Offline
                  JoeCFD
                  wrote on 13 Feb 2023, 20:21 last edited by JoeCFD
                  #11

                  @SeeRich your mainwindow has a black background stylesheet which affects its children. Assign its object name to its stylesheet and its children will not be affected anymore.

                      MainWindow()
                      {
                          resize(720, 600);
                          setAttribute(Qt::WA_StyledBackground);
                          setObjectName( "mainWindiw" );
                          setStyleSheet( QString( "MainWindow#%1 { background-color: black; }" ) .arg( objectName() );
                  
                  S 1 Reply Last reply 14 Feb 2023, 17:42
                  0
                  • J JoeCFD
                    13 Feb 2023, 20:21

                    @SeeRich your mainwindow has a black background stylesheet which affects its children. Assign its object name to its stylesheet and its children will not be affected anymore.

                        MainWindow()
                        {
                            resize(720, 600);
                            setAttribute(Qt::WA_StyledBackground);
                            setObjectName( "mainWindiw" );
                            setStyleSheet( QString( "MainWindow#%1 { background-color: black; }" ) .arg( objectName() );
                    
                    S Offline
                    S Offline
                    SeeRich
                    wrote on 14 Feb 2023, 17:42 last edited by
                    #12

                    @JoeCFD I really thought that was going to fix it, but unfortunately, same result.

                    J 1 Reply Last reply 15 Feb 2023, 18:53
                    0
                    • S SeeRich
                      14 Feb 2023, 17:42

                      @JoeCFD I really thought that was going to fix it, but unfortunately, same result.

                      J Offline
                      J Offline
                      JoeCFD
                      wrote on 15 Feb 2023, 18:53 last edited by JoeCFD
                      #13

                      @SeeRich Change the background-color to blue to make sure the color from mainwindow stylesheet

                          MainWindow()
                          {
                              resize(720, 600);
                              setAttribute(Qt::WA_StyledBackground);
                              setObjectName( "mainWindow" );
                              setStyleSheet( QString( "MainWindow#%1 { background-color: blue; }" ) .arg( objectName() );
                      

                      also try the following:

                      _overlayLabel = new Qlabel( this );
                      _overlayLabel->setAttribute(Qt::WA_StyledBackground);
                      _overlayLabel->setStyleSheet("border:none; background:transparent;");
                      
                      S 1 Reply Last reply 1 Mar 2023, 20:06
                      0
                      • J JoeCFD
                        15 Feb 2023, 18:53

                        @SeeRich Change the background-color to blue to make sure the color from mainwindow stylesheet

                            MainWindow()
                            {
                                resize(720, 600);
                                setAttribute(Qt::WA_StyledBackground);
                                setObjectName( "mainWindow" );
                                setStyleSheet( QString( "MainWindow#%1 { background-color: blue; }" ) .arg( objectName() );
                        

                        also try the following:

                        _overlayLabel = new Qlabel( this );
                        _overlayLabel->setAttribute(Qt::WA_StyledBackground);
                        _overlayLabel->setStyleSheet("border:none; background:transparent;");
                        
                        S Offline
                        S Offline
                        SeeRich
                        wrote on 1 Mar 2023, 20:06 last edited by
                        #14

                        @JoeCFD Sorry for the delay...

                        It is definitely the mainwindow background as the change to blue causes the text background box to change colors as well.

                        Setting the Qt::WA_StyledBackground attribute didn't change anything either.

                        J 1 Reply Last reply 1 Mar 2023, 20:36
                        0
                        • S SeeRich
                          1 Mar 2023, 20:06

                          @JoeCFD Sorry for the delay...

                          It is definitely the mainwindow background as the change to blue causes the text background box to change colors as well.

                          Setting the Qt::WA_StyledBackground attribute didn't change anything either.

                          J Offline
                          J Offline
                          JoeCFD
                          wrote on 1 Mar 2023, 20:36 last edited by
                          #15

                          @SeeRich
                          can you change

                                  setAttribute(Qt::WA_StyledBackground);
                                  setObjectName( "mainWindow" );
                                  setStyleSheet( QString( "MainWindow#%1 { background-color: blue; }" ) .arg( objectName() );
                          

                          to

                                  setAttribute(Qt::WA_StyledBackground);
                                  setObjectName( "mainWindow" );
                                  setStyleSheet( QString( "QWidget#%1 { background-color: blue; }" ) .arg( objectName() );
                          

                          there is no MainWindow stylesheet. It should be QMainWindow.

                          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