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
QtWS25 Last Chance

Qt Widgets + GStreamer + Overlay + Screen Capture

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++widgetsgstreamer videooverlayscreenshot
15 Posts 3 Posters 3.2k Views
  • 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

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

    SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on 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
    0
    • SGaistS SGaist

      @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 last edited by SeeRich
      #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
      0
      • S SeeRich

        @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 last edited by
        #6

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

        JoeCFDJ 1 Reply Last reply
        0
        • S SeeRich

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

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by JoeCFD
          #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
          0
          • JoeCFDJ JoeCFD

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

            JoeCFDJ 1 Reply Last reply
            0
            • S SeeRich

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

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on 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
              0
              • JoeCFDJ JoeCFD

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

                JoeCFDJ 1 Reply Last reply
                0
                • S SeeRich

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

                  JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on 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
                  0
                  • JoeCFDJ JoeCFD

                    @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 last edited by
                    #12

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

                    JoeCFDJ 1 Reply Last reply
                    0
                    • S SeeRich

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

                      JoeCFDJ Offline
                      JoeCFDJ Offline
                      JoeCFD
                      wrote on 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
                      0
                      • JoeCFDJ JoeCFD

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

                        JoeCFDJ 1 Reply Last reply
                        0
                        • S SeeRich

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

                          JoeCFDJ Offline
                          JoeCFDJ Offline
                          JoeCFD
                          wrote on 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