'Pycharm doesnt show static fields while code completion using Qt5
I am using PyQt5 (ver 5.15.6) While accessing some static fields like Qt.WindingFill Qt.NoBrush or QGraphicsItem.ItemIsSelectable the auto code completion (ctrl + space) doesn't show other options (it doesn't even show my option) while the interpreter can run the code successfully and after correctly writing the static methods name pycharm doesn't complain. Why is the reason ?
example code:
import math
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
import sys
class QDMGraphicsScene(QGraphicsScene):
def __init__(self, parent=None):
super().__init__(parent)
self._color_background = QColor("#123456")
self.scene_width, self.scene_height = 64000, 64000
self.setSceneRect(-self.scene_width//2, -self.scene_height//2, self.scene_width, self.scene_height)
self.setBackgroundBrush(self._color_background)
def drawBackground(self, painter, rect):
super().drawBackground(painter, rect)
class NodeEditorWnd(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.initUI()
def initUI(self):
self.setGeometry(200, 200, 800, 600)
self.layout = QVBoxLayout()
self.layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(self.layout)
# crate graphics scene
self.grScene = QDMGraphicsScene()
# create graphics view
self.view = QGraphicsView(self)
self.view.setScene(self.grScene)
self.layout.addWidget(self.view)
self.setWindowTitle("test123")
self.show()
self.addDebugContent()
def addDebugContent(self):
greenBrush = QBrush(Qt.green)
outlinePen = QPen(Qt.black)
outlinePen.setWidth(2)
rect = self.grScene.addRect(-100, -100, 80, 100, outlinePen, greenBrush)
rect.setFlag(QGraphicsItem.ItemIsMovable)
text = self.grScene.addText("testtext")
text.setFlag(QGraphicsItem.ItemIsSelectable)
text.setFlag(QGraphicsItem.ItemIsMovable)
text.setDefaultTextColor(QColor.fromRgbF(1.0,.7,.1))
widget1 = QPushButton("hello wo")
proxy1 = self.grScene.addWidget(widget1)
proxy1.setFlag(QGraphicsItem.ItemIsMovable)
proxy1.setPos(0,30)
widget2 = QTextEdit()
proxy2 = self.grScene.addWidget(widget2)
proxy2.setFlag(QGraphicsItem.ItemIsSelectable)
proxy2.setPos(0,60)
line = self.grScene.addLine(-200, -200, 400, -100, outlinePen)
line.setFlag(QGraphicsItem.ItemIsMovable)
line.setFlag(QGraphicsItem.ItemIsSelectable)
if __name__ == '__main__':
app = QApplication(sys.argv)
wnd = NodeEditorWnd()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
