0
에 대한 질문은 내가이 문제에 완전히 붙어있어 . 키보드 입력과 마우스 휠에 대해 SingleStep과 PageStep이 잘 작동합니다. 틱은 모두 설정됩니다 ... 그러나 마우스를 사용하여 슬라이더를 드래그하면 모든 틱, 단계 등이 무시되고, 한 틱 다른.PyQt는 QSlider 및 QGraphicsTextItem
self.ui.x_coord.setMaximum(l_d*1000)
self.ui.x_coord.setSingleStep(l_d/N*1000)
self.ui.x_coord.setTickInterval(l_d/N*1000)
self.ui.x_coord.setTickPosition(QtGui.QSlider.TicksBothSides)
self.ui.x_coord.setPageStep(l_d/N * 10000)
은 내 코드에서 누락 되었습니까 (아마도 setMouseStep과 비슷합니다)? QSlider의 함수
self.graph = BPlot(self.ui)
self.ui.x_coord.valueChanged.connect(self.setCoordLabelValue)
....
def setCoordLabelValue(self):
x = self.ui.x_coord.value()/1000
y = self.ui.y_coord.value()/1000
self.graph.setCoordText(x,y)
....
class BPlot(QtGui.QGraphicsView):
def __init__(self, ui, parent=None):
super(BPlot, self).__init__(parent)
self.scene = QtGui.QGraphicsScene()
self.ui = ui
self.coordText = QtGui.QGraphicsTextItem(None, self.scene)
self.coordText.setPlainText("123")
self.x_offset = 40
self.y_offset = 20
self.currentPoint = QtGui.QGraphicsRectItem(None, self.scene)
self.cph = 4
self.cpw = 4
def resizeEvent(self, event):
size = event.size()
def showEvent(self, event):
aw = self.viewport().width()
ah = self.viewport().height()
self.scene.setSceneRect(0,0,aw,ah)
self.setScene(self.scene)
self.axis_pen = QtGui.QPen(QtCore.Qt.DashDotLine)
self.scene.addLine(0, 3/4*ah, aw, 3/4*ah, self.axis_pen)
self.normal_pen = QtGui.QPen(QtCore.Qt.SolidLine)
self.scene.addLine(self.x_offset, 3/4*ah - self.y_offset, aw - self.x_offset, 3/4*ah - self.y_offset)
self.currentPoint.setRect(self.x_offset - self.cpw/2, 3/4*ah - self.y_offset - self.cph/2, self.cpw, self.cph)
def setCoordText(self, x, y):
self.coordText.setPlainText(str(x) + ":" + str(y))
문제에 연결 그건
2) coordText를 다시 그리기하지 않는 setCoordText의 FUNC입니다. print (coordText.toPlainText())를 사용하면 올바른 출력을 얻을 수 있지만 화면에 여전히 __init__의 "123"이 표시됩니다.
이미 self.scene.update) 행운을 함께 setCoordText 끝에.