pyqt

PyQt5 Gui Thread to worker Thread signal/Slot

烈酒焚心 提交于 2021-01-29 01:47:30
问题 I am trying to make a simple communication between a worker thread, in this case it is called WorkToDo via the PyQt5 Signals and Slots mechanism. I can reliably send data from the Worker to the Gui thread via this mechanism, but I cannot do the same to the gui thread. From my research I have found that this is due to the fact that I have overridden the run function with my own logic. My question, is there any way to manually handle the execution of signals in the worker thread? Is there a

Highlight date interval in a Qt5 Calendar Widget

谁说胖子不能爱 提交于 2021-01-29 00:32:18
问题 I want to highlight every day in a CalendarWidget that is between a selected start and end date. My problem is that a CalendarWidget only allows SingleSelection in QTCreator but says that other things can be changed programmatically though. I found some hints to use a QPainter and the paintCell() Method but i till dont know where to begin. The Internet wasn't helpful in my case. I tried to change a single date first on buttonClick but even this didnt work, can you give me an advice how to use

Add a spacer line between layouts PyQt

社会主义新天地 提交于 2021-01-28 22:03:16
问题 I would like to add a spacer line between two layouts: Separador = QFrame() Separador.Shape(QFrame.HLine) Separador.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Expanding) Separador.setLineWidth(3) HPOUT1_layout = QVBoxLayout() HPOUT1_layout.addLayout(HPOUT1L_layout) HPOUT1_layout.addWidget(Separador) HPOUT1_layout.addLayout(HPOUT1R_layout) However, this code only separate the layouts a little, but there is no line visible between them. Is there another way, What I'm doing wrong? 回答1: You

Add a spacer line between layouts PyQt

醉酒当歌 提交于 2021-01-28 22:00:37
问题 I would like to add a spacer line between two layouts: Separador = QFrame() Separador.Shape(QFrame.HLine) Separador.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Expanding) Separador.setLineWidth(3) HPOUT1_layout = QVBoxLayout() HPOUT1_layout.addLayout(HPOUT1L_layout) HPOUT1_layout.addWidget(Separador) HPOUT1_layout.addLayout(HPOUT1R_layout) However, this code only separate the layouts a little, but there is no line visible between them. Is there another way, What I'm doing wrong? 回答1: You

Add a spacer line between layouts PyQt

元气小坏坏 提交于 2021-01-28 21:51:56
问题 I would like to add a spacer line between two layouts: Separador = QFrame() Separador.Shape(QFrame.HLine) Separador.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Expanding) Separador.setLineWidth(3) HPOUT1_layout = QVBoxLayout() HPOUT1_layout.addLayout(HPOUT1L_layout) HPOUT1_layout.addWidget(Separador) HPOUT1_layout.addLayout(HPOUT1R_layout) However, this code only separate the layouts a little, but there is no line visible between them. Is there another way, What I'm doing wrong? 回答1: You

QGraphicScene Background

风流意气都作罢 提交于 2021-01-28 19:22:46
问题 I'm learning PyQt5 to develop a small academy project. I need to set a background for the QGraphicScene, but I'm not able to make the image fit well into the scene. It is sometimes repeaded or too large depending on the scale I apply. Here is my code: class MainWindow(QWidget): def __init__(self): super().__init__() self.title = "title"; self.top = 100 self.left = 100 self.width = 1500 self.height = 900 self.initUI() def initUI(self): scene = QGraphicsScene(0, 0, width, heigth) view =

PyQt: QGraphicsItem added at a wrong position

老子叫甜甜 提交于 2021-01-28 19:09:38
问题 I have a subclass of QGraphicsItem and I want to add instances of it to the scene on 'Control+LMB click'. The trouble is that the item is added at the position with coordinates that are two times larger than they should be. At the same time adding ellipses with scene.addEllipse(...) works fine. #!/usr/bin/env python import sys from PyQt4.QtCore import (QPointF, QRectF, Qt, ) from PyQt4.QtGui import (QApplication, QMainWindow, QGraphicsItem, QGraphicsScene, QGraphicsView, QPen, QStyle) MapSize

QStyledItemDelegate truncates text horizontally and doesn't add a horizontal scroll bar

混江龙づ霸主 提交于 2021-01-28 19:08:29
问题 I got the following code, which I slightly modified, as an answer on how to use HTML formatted text in a QListWidget. main.ui <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>Dialog</class> <widget class="QDialog" name="Dialog"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>341</width> <height>161</height> </rect> </property> <property name="windowTitle"> <string>Dialog</string> </property> <widget class="QWidget" name="verticalLayoutWidget"> <property name=

QListView.indexAt in PyQt5 returning wrong index?

孤街浪徒 提交于 2021-01-28 14:51:56
问题 I'm trying to pop up a context menu when a user right-clicks on an item in a QListView and a different context menu if the user right-clicks outside of any of the items (any of the whitespace). What I'm finding is that the index I'm receiving when performing the indexAt command is not accurate, and I can't figure out why. I initialize the QListView as its own class: class RBKDataTypesTab(QWidget): def __init__(self): super().__init__() self.models = [] grid = QGridLayout() self.list =

QListView.indexAt in PyQt5 returning wrong index?

妖精的绣舞 提交于 2021-01-28 14:49:49
问题 I'm trying to pop up a context menu when a user right-clicks on an item in a QListView and a different context menu if the user right-clicks outside of any of the items (any of the whitespace). What I'm finding is that the index I'm receiving when performing the indexAt command is not accurate, and I can't figure out why. I initialize the QListView as its own class: class RBKDataTypesTab(QWidget): def __init__(self): super().__init__() self.models = [] grid = QGridLayout() self.list =