Qt Widgets + GStreamer + Overlay + Screen Capture
-
@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.
-
@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?
-
@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?
-
@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;"); -
@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() );
-
@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;");
-
@SeeRich
can you changesetAttribute(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.