Hello,
I'm trying to load a .ui dynamically using PySide QUiLoader
I did
from PySide import QtCore, QtGui, QtUiTools
from PySide.QtGui import *
from PySide.QtCore import *
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
class PlotWidget(QWidget):
def __init__(self, parent):
super(TimelinePane, self).__init__()
print '\tPlotWidget init 1' # This doesn't print.
class MainWindow(QtGui.QDialog):
def __init__(self, parent = None):
super(MainWindow, self).__init__(parent)
loader = QtUiTools.QUiLoader()
#loader.registerCustomWidget(PlotWidget)
path = os.path.dirname(os.path.abspath(__file__))
uiFile = os.path.join(path, "mainwindow.ui")
self.ui = loader.load(uiFile)
def show(self):
self.ui.show()
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
d = MainWindow()
d.show()
app.exec_()
You can see also as attachment mainwindow.ui
I have promote a graphicsView to a personnal class "PlotWidget"
<widget class="PlotWidget" name="graphicsView"/>
but I get the following message
"QFormBuilder was unable to create a custom widget of the class 'PlotWidget'; defaulting to base class 'QGraphicsView'."
but a QGraphicsView appears instead of my PlotWidget
If I uncomment
loader.registerCustomWidget(PlotWidget)
I get these warning messages
"QFormBuilder was unable to create a custom widget of the class 'PlotWidget'; defaulting to base class 'QGraphicsView'."
"Empty widget item in QHBoxLayout 'horizontalLayout_6'."
Designer: The creation of a widget of the class '' failed.
Designer: The creation of a widget of the class '' failed.
Designer: The creation of a widget of the class '' failed.
and my PlotWidget doesn't appears
I would prefer to have a dynamically loaded ui (with .ui file)
instead of generating code with pyside-uic
I really hope you can help me
Kind regards
Sébastien