0

I want to show some others widget in a QVideoWidget so that I can control the playing of video when fullscreen as this code:

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>VideoScreen</class>
 <widget class="QMainWindow" name="VideoScreen">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>800</width>
    <height>600</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QVideoWidget" name="videoScreen">
   <widget class="QPushButton" name="play">
    <property name="geometry">
     <rect>
      <x>80</x>
      <y>240</y>
      <width>101</width>
      <height>31</height>
     </rect>
    </property>
    <property name="text">
     <string>Play</string>
    </property>
   </widget>
   <widget class="QPushButton" name="stop">
    <property name="geometry">
     <rect>
      <x>280</x>
      <y>170</y>
      <width>101</width>
      <height>31</height>
     </rect>
    </property>
    <property name="text">
     <string>Stop</string>
    </property>
   </widget>
  </widget>
 </widget>
 <customwidgets>
  <customwidget>
   <class>QVideoWidget</class>
   <extends>QWidget</extends>
   <header>QVideoWidget</header>
   <container>1</container>
  </customwidget>
 </customwidgets>
 <resources/>
 <connections/>
</ui>

enter image description here

(I created a .ui file using designer to show a QMainWindow. In that, I promoted the central widget to QVideoWidget as the image).
When I play a video, this just show the video, there are no others widget like buttons I added in designer.

I just want to ask that can we add widgets to a QVideoWidget then let them be show when showing a video?

aviit
  • 1,957
  • 1
  • 27
  • 50
  • 1
    Conceptually my solution in the question that I indicate as duplicate is equivalent to adding the following in the constructor: `ui->play->setParent(this); ui->stop->setParent(this);` – eyllanesc Sep 29 '18 at 04:04
  • 1
    The problem is caused because the painting of the QVideoWidget is always in one layer on top of the other children widgets, so the buttons are hidden. The solution is to make the buttons be sibling of the centralwidget, as you see in the property tree the buttons are children of the centralwidget so to be brothers you must pass them as a parent the VideoScreen – eyllanesc Sep 29 '18 at 04:07
  • Thanks for making my question as duplicate because the other can resolve my issue but my question is different because I want to organize the control widgets inside the `QVideoWidget`. The sibling solution will be the answer if the children control widget is impossible. Thanks! (Qt let we create children widgets inside `QVideoWidget` but don't let them be show). – aviit Sep 29 '18 at 04:29

0 Answers0