pyqt5

Get all widgets under cursor

那年仲夏 提交于 2020-12-29 13:18:09
问题 The widgetAt function gives me the widget directly under the cursor, at the highest z-order. pos = QtGui.QCursor.pos() widget = QtGui.qApp.widgetAt(pos) But how can I get all widgets under the cursor? Including those behind the top-most one? Something like: pos = QtGui.QCursor.pos() widgets = QtGui.qApp.widgetsAt(pos) Example As an example of use, picture an overlay which adds animated graphics, like ripples on the surface of water, wherever the user clicked. Naturally, the overlay would need

PyQt5 QScrollArea widget with dynamically created GroupBoxes

时光总嘲笑我的痴心妄想 提交于 2020-12-26 13:58:44
问题 I'm trying to make a toolbox widget that will do various different things. But I'm having trouble with the layout management regarding the QScrollArea. Following the stripped version of the code I have: from PyQt5 import QtWidgets import sys class MyScrollWidget(QtWidgets.QWidget): def __init__(self): super(MyScrollWidget, self).__init__() scrollArea = QtWidgets.QScrollArea(self) top_widget = QtWidgets.QWidget() top_layout = QtWidgets.QVBoxLayout() for i in range(10): group_box = QtWidgets

PyQt5 QScrollArea widget with dynamically created GroupBoxes

送分小仙女□ 提交于 2020-12-26 13:39:23
问题 I'm trying to make a toolbox widget that will do various different things. But I'm having trouble with the layout management regarding the QScrollArea. Following the stripped version of the code I have: from PyQt5 import QtWidgets import sys class MyScrollWidget(QtWidgets.QWidget): def __init__(self): super(MyScrollWidget, self).__init__() scrollArea = QtWidgets.QScrollArea(self) top_widget = QtWidgets.QWidget() top_layout = QtWidgets.QVBoxLayout() for i in range(10): group_box = QtWidgets

Threading with QRunnable - Proper manner of sending bi-directional callbacks

和自甴很熟 提交于 2020-12-26 07:56:24
问题 From a tutorial, I've seen that signals and slots can be used to make callbacks from a worker thread into the main GUI thread, but I'm uncertain how to establish bi-directional communication using signals and slots. The following is what I am working with: class RespondedToWorkerSignals(QObject): callback_from_worker = pyqtSignal() class RespondedToWorker(QRunnable): def __init__(self, func, *args, **kwargs): super(RespondedToWorker, self).__init__() self._func = func self.args = args self

How to render a part of QGraphicsScene and save It as image file PyQt5

こ雲淡風輕ζ 提交于 2020-12-26 04:57:11
问题 Suppose I have QGraphicsPixmapItem from loaded image which is added to QGraphicsScene . And suppose I'll add several QGraphicsPolygonItem 's on scene. How I can render a part of the scene as full-size image both with polygons that are not in blank area and save this area as image file. class ImageView(QtWidgets.QGraphicsView): def __init__(self, parent): super(ImageView, self).__init__(parent) self.setFocus() self._zoom = 0 self._empty = True self.scene = QtWidgets.QGraphicsScene(self) self.

Double right-click listener for a QTableWidget

为君一笑 提交于 2020-12-26 04:02:45
问题 I have a PyQt5 QTableWidget for which I want to detect double-right-click events. Here is my 'design.py' module: from PyQt5 import QtCore, QtWidgets class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(790, 472) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.tbwMain = QtWidgets.QTabWidget(self.centralwidget) self.tbwMain.setGeometry(QtCore.QRect(0, 0, 801, 451)) self

menuBar() in PyQt5

倖福魔咒の 提交于 2020-12-25 01:57:19
问题 I am trying to load a menubar onto my gui, but my class object has no attribute for self.menuBar(). Can someone help me, no tutorials seem to offer any way around. class EmailBlast(QtWidgets.QWidget): def __init__(self): super().__init__() bar = QtWidgets.menuBar() file_menu = bar.addMenu('File') file_edit = bar.addMenu('Edit') Error message: File "BasicEmail.py", line 84, in email_config self.ui = EmailBlast() File "BasicEmail.py", line 96, in __init__ self.menuBar() AttributeError:

menuBar() in PyQt5

99封情书 提交于 2020-12-25 01:42:49
问题 I am trying to load a menubar onto my gui, but my class object has no attribute for self.menuBar(). Can someone help me, no tutorials seem to offer any way around. class EmailBlast(QtWidgets.QWidget): def __init__(self): super().__init__() bar = QtWidgets.menuBar() file_menu = bar.addMenu('File') file_edit = bar.addMenu('Edit') Error message: File "BasicEmail.py", line 84, in email_config self.ui = EmailBlast() File "BasicEmail.py", line 96, in __init__ self.menuBar() AttributeError:

menuBar() in PyQt5

别说谁变了你拦得住时间么 提交于 2020-12-25 01:40:36
问题 I am trying to load a menubar onto my gui, but my class object has no attribute for self.menuBar(). Can someone help me, no tutorials seem to offer any way around. class EmailBlast(QtWidgets.QWidget): def __init__(self): super().__init__() bar = QtWidgets.menuBar() file_menu = bar.addMenu('File') file_edit = bar.addMenu('Edit') Error message: File "BasicEmail.py", line 84, in email_config self.ui = EmailBlast() File "BasicEmail.py", line 96, in __init__ self.menuBar() AttributeError:

menuBar() in PyQt5

混江龙づ霸主 提交于 2020-12-25 01:40:22
问题 I am trying to load a menubar onto my gui, but my class object has no attribute for self.menuBar(). Can someone help me, no tutorials seem to offer any way around. class EmailBlast(QtWidgets.QWidget): def __init__(self): super().__init__() bar = QtWidgets.menuBar() file_menu = bar.addMenu('File') file_edit = bar.addMenu('Edit') Error message: File "BasicEmail.py", line 84, in email_config self.ui = EmailBlast() File "BasicEmail.py", line 96, in __init__ self.menuBar() AttributeError: