Reputation: 644
using Pyside2 and command
pyside2-uic "untitled.ui" -o "gui.py"
I faced such exception
AttributeError: 'PySide2.QtWidgets.QMainWindow' object has no
attribute 'setSizeGripEnabled'
and did not find a solution in internet. Flag -x doesn't help. It answeres:
uic: Unknown option 'x'.
My main.py:
import sys
from PySide2 import QtWidgets
from PySide2.QtCore import QFile
from gui import Ui_Dialog
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
ex = Ui_Dialog()
w = QtWidgets.QMainWindow()
ex.setupUi(w)
w.show()
sys.exit(app.exec_())
gui.py:
class Ui_Dialog(object):
def setupUi(self, Dialog):
if not Dialog.objectName():
Dialog.setObjectName(u"Dialog")
Dialog.resize(511, 400)
sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
...
Dialog.setSizeGripEnabled(True)
self.verticalLayoutWidget = QWidget(Dialog)
...
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QCoreApplication.translate("Dialog", u"Currency Converter", None))
self.comboBox.setCurrentText("")
...
# retranslateUi
Upvotes: 2
Views: 2632
Reputation:
Your code w = QtWidgets.QMainWindow()
is not correct
try change your code to w = QtWidgets.QDialog()
I had the same error, but I solved it with this code.
from PySide2.QtWidgets import QApplication, QDialog
from resources.gui import Ui_notes
class Window(QDialog, Ui_notes):
def __init__(self):
super(Window, self).__init__()
self.setupUi(self)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())`
Upvotes: 4
Reputation: 644
My window object in QT Designer is called "Dialog" and in 'gui.py' made from .ui file I have such line:
Dialog.setSizeGripEnabled(True)
that cuses a problem. But if we just comment this line - UI interface starts to work!
Upvotes: 0