Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Qt Widgets + GStreamer + Overlay + Screen Capture

    General and Desktop
    c++ widgets gstreamer video overlay screenshot
    3
    15
    452
    Loading More Posts
    • 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 @SeeRich last edited by

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

      JoeCFD 1 Reply Last reply Reply Quote 0
      • JoeCFD
        JoeCFD @SeeRich last edited by JoeCFD

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

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

          JoeCFD 1 Reply Last reply Reply Quote 0
          • JoeCFD
            JoeCFD @SeeRich last edited by 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 1 Reply Last reply Reply Quote 0
            • S
              SeeRich @JoeCFD last edited by

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

              JoeCFD 1 Reply Last reply Reply Quote 0
              • JoeCFD
                JoeCFD @SeeRich last edited by 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 1 Reply Last reply Reply Quote 0
                • S
                  SeeRich @JoeCFD last edited by

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

                  JoeCFD 1 Reply Last reply Reply Quote 0
                  • JoeCFD
                    JoeCFD @SeeRich last edited by 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 1 Reply Last reply Reply Quote 0
                    • S
                      SeeRich @JoeCFD last edited by

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

                      JoeCFD 1 Reply Last reply Reply Quote 0
                      • JoeCFD
                        JoeCFD @SeeRich last edited by

                        @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 Reply Quote 0
                        • First post
                          Last post