pyqt

What is best way to remove items from layout in pyqt

余生长醉 提交于 2021-02-07 23:28:39
问题 I am having some issue with layout in pyqt. After closing the items from the layout still if layout.count() returns the old item count. So I think .close() not really removing items from the layout. Here is a full working example. import sys from PyQt4 import QtGui,QtCore class LayoutTest(QtGui.QWidget): def __init__(self): super(LayoutTest, self).__init__() self.vvbox = QtGui.QVBoxLayout() self.dvbox = QtGui.QVBoxLayout() vbox = QtGui.QVBoxLayout() vbox.addLayout(self.vvbox) vbox.addLayout

What is best way to remove items from layout in pyqt

你离开我真会死。 提交于 2021-02-07 23:26:54
问题 I am having some issue with layout in pyqt. After closing the items from the layout still if layout.count() returns the old item count. So I think .close() not really removing items from the layout. Here is a full working example. import sys from PyQt4 import QtGui,QtCore class LayoutTest(QtGui.QWidget): def __init__(self): super(LayoutTest, self).__init__() self.vvbox = QtGui.QVBoxLayout() self.dvbox = QtGui.QVBoxLayout() vbox = QtGui.QVBoxLayout() vbox.addLayout(self.vvbox) vbox.addLayout

How to get cursor click position in QGraphicsItem coordinate system?

淺唱寂寞╮ 提交于 2021-02-07 20:57:51
问题 I have a QGraphicsScene with QGraphicsItem added to it. Suppose I clicked on a map image ( QGraphicsItem ) where green circle is drawn. How to get click position in terms of this QGraphicsItem and not QGraphicsScene coordinate system. P.S. Please, don't write code with mouse event handling. Just how to map click position correctly. Thanks in advance. 回答1: The idea is to convert the coordinate with respect to the scene to a coordinate with respect to the item. - Override mousePressEvent in

How to get cursor click position in QGraphicsItem coordinate system?

天大地大妈咪最大 提交于 2021-02-07 20:56:50
问题 I have a QGraphicsScene with QGraphicsItem added to it. Suppose I clicked on a map image ( QGraphicsItem ) where green circle is drawn. How to get click position in terms of this QGraphicsItem and not QGraphicsScene coordinate system. P.S. Please, don't write code with mouse event handling. Just how to map click position correctly. Thanks in advance. 回答1: The idea is to convert the coordinate with respect to the scene to a coordinate with respect to the item. - Override mousePressEvent in

How to get cursor click position in QGraphicsItem coordinate system?

99封情书 提交于 2021-02-07 20:55:29
问题 I have a QGraphicsScene with QGraphicsItem added to it. Suppose I clicked on a map image ( QGraphicsItem ) where green circle is drawn. How to get click position in terms of this QGraphicsItem and not QGraphicsScene coordinate system. P.S. Please, don't write code with mouse event handling. Just how to map click position correctly. Thanks in advance. 回答1: The idea is to convert the coordinate with respect to the scene to a coordinate with respect to the item. - Override mousePressEvent in

Mouse coordinates of pytqt graph line

时光怂恿深爱的人放手 提交于 2021-02-07 20:28:38
问题 I am trying to get the (x,y) values of my random function plot whenever I move the moused on top of the graph. I am using pyqtgraph.SignalProxy and connect it to a callback mousedMoved. I am getting this as error: NameError: global name 'mouseMoved' is not defined Here is the code: import sys from pyqtgraph.Qt import QtGui, QtCore import numpy as np import pyqtgraph as pg import time import random class TestClass(QtGui.QMainWindow): ##################################################### def _

Mouse coordinates of pytqt graph line

流过昼夜 提交于 2021-02-07 20:28:15
问题 I am trying to get the (x,y) values of my random function plot whenever I move the moused on top of the graph. I am using pyqtgraph.SignalProxy and connect it to a callback mousedMoved. I am getting this as error: NameError: global name 'mouseMoved' is not defined Here is the code: import sys from pyqtgraph.Qt import QtGui, QtCore import numpy as np import pyqtgraph as pg import time import random class TestClass(QtGui.QMainWindow): ##################################################### def _

How to create a 3-color gradient dial indicator (the one that shows green-yellow-red)

ⅰ亾dé卋堺 提交于 2021-02-07 19:22:42
问题 So I have this dial image I'm using for a PyQt widget. Right now, as you can see, the gradient indicator, the arc of green-yellow-red is static and is part of the image. I want to create this dynamically, so that based on some ranges, the color can be determined. For example, instead of equal parts green and red, I might want about 60 degrees worth of it to be red and the rest green and yellow. For this, I shall specify some range (eg. 0-90 degrees worth should be green etc). Any ideas on how

How to create a 3-color gradient dial indicator (the one that shows green-yellow-red)

喜夏-厌秋 提交于 2021-02-07 19:22:14
问题 So I have this dial image I'm using for a PyQt widget. Right now, as you can see, the gradient indicator, the arc of green-yellow-red is static and is part of the image. I want to create this dynamically, so that based on some ranges, the color can be determined. For example, instead of equal parts green and red, I might want about 60 degrees worth of it to be red and the rest green and yellow. For this, I shall specify some range (eg. 0-90 degrees worth should be green etc). Any ideas on how

Unable to fully remove border of PyQt QGraphicsView

喜你入骨 提交于 2021-02-07 19:11:43
问题 I have tried calling self.setStyleSheet("background: transparent; border: transparent;") on a QGraphicsView, but it still leaves a 1 pixel border on the top edge. I have also tried replacing border: transparent; with border-style: none; , but it didn't work either. Here is a screenshot of the problem: What command will fully remove the border from the QGraphicsView? 回答1: You can use one of the following css rule: graphicsView.setStyleSheet("border-width: 0px; border-style: solid") or