QWidget和xvimagesink问题!
我需要一些帮助! 在 qt 应用程序中我有一个中央小部件。在这个中央小部件中,我有一个 QLabel
和另一个 QWidget
。现在,在 gstreamer 的帮助下,我可以从网络摄像头获取视频并通过第二个小部件显示它。现在的问题是我想截取这个小部件的屏幕截图并将其放在标签上。但我使用的方法只给出了一个空白屏幕。
我尝试了这个:
QPixmap wpix = QPixmap::grabWidget(ui->videoWidget,0,0,640,480);
ui->label->setPixmap(wpix);
和这个:
QPixmap wpix=QPixmap(ui->videoWidget->size());
wpix.fill(Qt::transparent);
ui->videoWidget->render(&wpix,QPoint(0,0),QRect(0,0,640,480),QWidget::DrawWindowBackground | QWidget::DrawChildren);
唯一有效的是使用grabWindow,但这里还有另一件事:
grabWindow() 函数从屏幕而不是窗口抓取像素,即,如果有另一个窗口部分或完全覆盖您抓取的窗口,您也会从上面的窗口获取像素。
现在grabWindow()因为这个效果就没用了,上面的2个方法也不想工作了!
有人可以告诉我问题是什么吗?可能是因为我将 videoWidget 设置为 nativeWindow (如果我不设置它,我的视频流将不会显示)?
请帮忙!如果您需要更多信息,请告诉我!请原谅我糟糕的英语!
I need some help!
In qt app I have a central widget. In this central widget I have a QLabel
,and another QWidget
. Now with the help of gstreamer I can get the video from my webcam and show it via the second widget. Now the problem is that I want to take a screenshot of this widget and put it on the label. But the methods which I used only gave a blank screen.
I tried this :
QPixmap wpix = QPixmap::grabWidget(ui->videoWidget,0,0,640,480);
ui->label->setPixmap(wpix);
and this :
QPixmap wpix=QPixmap(ui->videoWidget->size());
wpix.fill(Qt::transparent);
ui->videoWidget->render(&wpix,QPoint(0,0),QRect(0,0,640,480),QWidget::DrawWindowBackground | QWidget::DrawChildren);
The only thing that works is to use grabWindow but here another thing:
The grabWindow() function grabs pixels from the screen, not from the window, i.e. if there >is another window partially or entirely over the one you grab, you get pixels from the >overlying window, too.
Now the grabWindow() is no use because of this effect, and the above 2 methods don't want to work!
Can someone please tell me what is the problem.Might it be the fact that I set the videoWidget to be a nativeWindow (if I don't set it my video stream would not be shown)?
Please help! If you need more info let me know! And please excuse my bad english!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)