简体   繁体   English

Qt:QVideoWidget不显示并禁用应用程序内的所有按钮,或者极大地降低了应用程序的速度

[英]Qt: QVideoWidget doesn't show up and disables all buttons within application OR extremely slows down the application

To make it clear the question is: Why, when I add a QVideoWidget to my application, all buttons become not clickable, the scrollbars don't work, and the comboboxes as well become not clickable? 要明确说明的问题是:为什么当我在应用程序中添加QVideoWidget时,所有按钮都变得不可单击,滚动条不起作用,并且组合框也变得不可单击? Is QVideoWidget disabling those functionalities? QVideoWidget是否禁用这些功能? Or is that maybe (like I read in this SO question ) QVideoWidget is extremely slowing down my application, just by being added to the application? 还是像被添加到应用程序那样,QVideoWidget会极大地减慢我的应用程序的速度(就像我在这个SO问题中所读的那样 )?

Now the details: I really hope someone can help me with this. 现在是细节:我真的希望有人可以帮助我。 I'm trying to place a QvideoWidget into my desktop application with the following code (nothing special, just like in the tutorials): 我正在尝试使用以下代码将QvideoWidget放到桌面应用程序中(没什么特别的,就像教程中一样):

// ...
// more code above for other things...
// main video-player widget
video_widget = new QVideoWidget;
video_widget->setMaximumHeight(100);    // I could set any size here...this is not the point
video_widget->setMinimumHeight(100);
video_widget->setStyleSheet(STYLE_WIDGET_BG); // same background as the other widgets...
video_widget->setMaximumWidth(100);
video_widget->setMinimumWidth(100);
media_player = new QMediaPlayer(0, QMediaPlayer::VideoSurface);
TV_V_LAYOUT_MAIN_2->addWidget(video_widget);    // #define TV_V_LAYOUT_MAIN_2 ui.lvl_4_tv2_h_1 --> this a layout inside another layout...
media_player->setVideoOutput(video_widget);
return; // this function is called inside the MainWindow constructor

So there are the situations: 因此,有一些情况:

1) Without adding the videowidget, everything works fine... 1)无需添加videowidget, 一切正常...

2) As soon as I add the QVideoWidget with the code above: app overview 2)一旦我添加带有以上代码的QVideoWidget: 应用概述

What happens? 怎么了? The video player doesn't show up in any way. 视频播放器没有任何显示。 There should be at least the gray background like the other widgets, but nothing. 至少应该像其他小部件一样具有灰色背景,但没有其他内容。 Yet the buttons position lowers, so I guess the player was inserted...The problem is: all buttons (and I mean ALL buttons within my application ) are disabled. 但是按钮的位置降低了,所以我猜播放器已插入...问题是:所有按钮(我的意思是我的应用程序中的所有按钮 )都被禁用。 So are the comboboxes and the scrollbar . 组合框和滚动条也是如此 By disabled I mean, when you click them, it doesn't normally "animate" like when a button is cliked, and the scrollbar doesn't scroll... 禁用,我的意思是,当您单击它们时,它通常不会像单击按钮一样“动画”,并且滚动条不会滚动...

By the way the QVideoWidget is not places into the same layout as the buttons below. 顺便说一下,QVideoWidget的布局与下面的按钮不同。 You can see the layout hierarchy here: Layouts with Qt Designer 您可以在此处查看布局层次结构: Qt Designer的布局

I guess I'm missing something very simple. 我想我缺少了一些非常简单的东西。 Anyone got the solution for me? 有人为我找到了解决方案吗?

INFO: I'm programming with Visual Studio 2013 with Qt Add-In; 信息:我正在使用带有Qt加载项的Visual Studio 2013进行编程。 I use only standard libraries; 我只使用标准库; gstreamer is included in the project as well (nothing implemented yet). gstreamer也包括在项目中(尚未实现)。

OLD EDIT: it may be that the inserting of the video-widget extremely slows down the application , therefore giving the illusion that the scrollbar and the buttons don't work, just because it takes a lot of time for them to process the user interaction. 旧编辑:可能是视频小部件的插入极大地减慢了应用程序的速度 ,因此给人一种幻觉,即滚动条和按钮不起作用,只是因为它们需要花费很多时间来处理用户交互。 Is this possible? 这可能吗? Any solution for that? 有什么解决办法吗?

Got the solution: If your QVideoWidgets or QMediaPlayers extremely slow down your application, all you have to do, if you haven't yet, is to move all (or just the nedeed) Qt dll's into your project folder. 得到了解决方案:如果您的QVideoWidgets或QMediaPlayers极大地降低了您的应用程序的速度,那么您要做的就是将所有(或仅需要的)Qt dll移到您的项目文件夹中。

That's very basic, I know, yet that was my problem. 我知道那是非常基本的,但这是我的问题。 Now it works like heaven. 现在它像天堂一样运作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM