Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to create multiple axes using Qt designer?



  • Hi,

    I have code for a plot. But I dont know how to do this with Qt designer tool.
    I have already created .ui for image1 I want ui file for image 2.
    I don't find any options to get axes and set labels and auto range etc in Qt designer tool.

    def setupUi(self, Form_Plot):
    Form_Plot.setObjectName("Form_Plot")
    Form_Plot.resize(1040, 745)

        self.graphicsView1 = PlotWidget(Form_Plot)
        self.graphicsView1.setGeometry(QtCore.QRect(10, 9, 900, 341))
        self.graphicsView1.setObjectName("graphicsView1")
        self.graphicsView1.setRange(xRange=(0,self.MaxGraphPts))
        self.graphicsView1.setAutoVisible(y=True)
        self.graphicsView1.enableAutoRange()
        self.graphicsView1_axis1 = self.graphicsView1.getAxis('left')
        self.graphicsView1_axis1.setPen(pg.mkPen(color=(COL_1_COLOUR), width=2))
    
        self.graphicsView1_Graph2 = pg.ViewBox()
        self.graphicsView1.scene().addItem(self.graphicsView1_Graph2)
        self.graphicsView1_axis2 = self.graphicsView1.getAxis('right')
        self.graphicsView1_axis2.linkToView(self.graphicsView1_Graph2)
        self.graphicsView1_axis2.setPen(pg.mkPen(color=(COL_2_COLOUR), width=2))
        
        self.graphicsView1_Graph2.setXLink(self.graphicsView1.plotItem)
        self.graphicsView1_Graph2.setXLink(self.graphicsView1)
        self.graphicsView1_Graph2.setRange(xRange=(0,self.MaxGraphPts))
        self.graphicsView1_Graph2.setAutoVisible(y=True)
        self.graphicsView1.setLabel('right', color=COL_2_COLOUR)
       
        
        self.curveA_1 = self.graphicsView1.plot(pen=pg.mkPen(color=COL_1_COLOUR))
        self.curveA_2 = self.graphicsView1.plot(pen=pg.mkPen(color=COL_2_COLOUR))
        self.graphicsView1_Graph2.enableAutoRange()
        self.graphicsView1_Graph2.addItem(self.curveA_2)
    

    This is a small part of the code in setupUI function. How can we generate .ui file for this code?
    image 1.JPG image 2.JPG


Log in to reply