I have the following problem I have 2 frames inside a qdialog but I need the frame to take the width () and height () properties as the size of the qdialog.
This is what I tried self.frame.resize(self.QDialog.width(),self.height())
but it does not work here I leave my code.py
from PyQt5.QtWidgets import QMainWindow,QApplication,QDialog
from PyQt5 import uic, QtCore
class Principal(QDialog):
def __init__(self):
QDialog.__init__(self)
uic.loadUi("12.ui",self)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.setSizeGripEnabled(True)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground,True)
self.frame.resize(self.QDialog.width(),self.height())
self.frame_2.resize(self.frame.width()-900,self.frame.height())
app = QApplication([])
p = Principal()
p.show()
#p.resize(1000,600)
app.exec_()
And my code .ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>393</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QFrame" name="frame">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>401</width>
<height>301</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 211), stop:1 rgba(255, 255, 255, 221));</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QFrame" name="frame_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>120</width>
<height>301</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background:red;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>