简体   繁体   中英

PyQt Qwt plot appears twice in a single frame

I'm trying to create a graph for my GUI but for some reason when I create a new frame for the plot, it appears twice.

Here is a picture of the GUI. I haven't done any positioning for the plot yet (it's going to be on top of the client/server combination).

流量产生器

Here is the relevant code

class Application(QtGui.QMainWindow):

        err1 = QtCore.pyqtSignal(int)
        reset = QtCore.pyqtSignal()

        def __init__(self, parent=None):
          super(Application, self).__init__()
          self.setGeometry(300, 300, 600, 200)
          self.setWindowTitle('IPv6 traffic generator')
          PlotWidget(self)
          self.createwidgets()

class PlotWidget(Qwt.QwtPlot):

        def __init__(self, parent = None):
          Qwt.QwtPlot.__init__(self, parent)
          plot = Qwt.QwtPlot()
          layout = QtGui.QHBoxLayout()
          layout.addWidget(plot)
          self.setCanvasBackground(QtCore.Qt.white)
          self.container = QtGui.QFrame(self)
          self.container.resize(200,200)
          self.container.setLayout(layout)
          self.container.show()

The problem was with my lack of understanding of python. The plot is created with the Qwt.QwtPlot. init (self, parent), and after that i'm just creating a second plot.

This is how I should have done it

class PlotWidget(Qwt.QwtPlot):

        def __init__(self, parent = None):
          Qwt.QwtPlot.__init__(self, parent)
          self.setCanvasBackground(QtCore.Qt.white)
          self.resize(550,200)
          self.move(10,20)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM