Hello All,
This a very small issue mostly windows people come across while using Qt.
Basically If you have created a widget in designer(assuming person knows how to use Qt Designer),
converted with command line or from inside of maya to python (ui to py) – output_2.py
to inherit the output_2.py class in another class.
Please check the below approach and this should come in handy.
Non-Parented version of ui
import sys
sys.path.append("D:\\All_Projs\\Qt_Designer_Proj\\ui_to_maya_testing")
from output_2 import Ui_Form
from PySide2 import QtWidgets
from PySide2 import QtGui
class Trial(QtWidgets.QWidget):
def __init__(self):
super(Trial, self).__init__()
self.ui = Ui_Form()
self.ui.setupUi(self)
window = Trial()
window.show()
Parented version of ui
from PySide2 import QtCore, QtGui, QtWidgets
import sys
sys.path.append("D:\\All_Projs\\Qt_Designer_Proj\\ui_to_maya_testing\\")
from output_2 import Ui_Form
import maya.OpenMayaUI as omui
from shiboken2 import wrapInstance
ptr = omui.MQtUtil.mainWindow()
ptr_instance = wrapInstance(long(ptr), QtWidgets.QWidget)
class Widget(QtWidgets.QWidget):
def __init__(self, parent=None):
super(Widget, self).__init__(parent)
self.setParent(ptr_instance)
self.setWindowFlags(QtCore.Qt.Window)
self.ui = Ui_Form()
self.ui.setupUi(self)
def main():
app = Widget()
app.show()
main()
This is one of the approach that i am aware of, i had read it on a site, but I lost the site. If you have any other approach do let me know.
Have a Qt day.