pyqt5

Drag window to the edge to resize

牧云@^-^@ 提交于 2021-01-05 11:28:13
问题 I'm working on a plugin for QGIS and i'm using QtCreator. I wanted to implement a function that allows the user to drag the window to the edge of the screen to resize it (such as ordinary windows). My setup being a multiple screen desktop, I came up with this code: from PyQt5 import QtCore, QtGui tracking = False class Window(QtGui.QWidget): def __init__(self): super(Window, self).__init__() self.timer = QtCore.QTimer(self) self.timer.setInterval(50) self.timer.timeout.connect(self.Resize)

Create a truly headless QApplication instance

可紊 提交于 2021-01-04 05:34:25
问题 I have a Qt 5.8 (via PyQt5) application whose many tests require a live QApplication instance in order to test gui widget interactions. However on my new Mac OS X (10.11.6) machine when running these tests windows are constantly being created and destroyed, causing the entire system's UI to become highly unstable (although the tests pass as expected). My tests do not even call QApplication.exec() - the QApplication() constructor is enough to cause this. On my linux machine this is no issue,

Create a truly headless QApplication instance

倾然丶 夕夏残阳落幕 提交于 2021-01-04 05:34:22
问题 I have a Qt 5.8 (via PyQt5) application whose many tests require a live QApplication instance in order to test gui widget interactions. However on my new Mac OS X (10.11.6) machine when running these tests windows are constantly being created and destroyed, causing the entire system's UI to become highly unstable (although the tests pass as expected). My tests do not even call QApplication.exec() - the QApplication() constructor is enough to cause this. On my linux machine this is no issue,

How to show SVG image in PyQT5 from string/xml stream?

这一生的挚爱 提交于 2021-01-03 08:47:22
问题 In a Python3/QT5 application, I'm trying to show a SVG image built originally as a string. I need to manipulate this SVG image (e.g. change its color), so I have the string changing over time. Here is a minimal working example: import sys from PyQt5.QtWidgets import QApplication from PyQt5.QtSvg import QSvgWidget svg_str = """<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg width="300" height="300" viewBox="0 0 300 300" id="smile" version="1.1"> <path style="fill:#ffaaaa" d="M 150

How to make the background color the same as the form background?

余生颓废 提交于 2021-01-01 04:19:43
问题 In PyQt5 I'm getting some unexpected behavior from QTabWidget, the background seems to be white instead of the default form color (roughly light gray). Here is an example: # QTabWidget2.py from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLabel, QHBoxLayout, QVBoxLayout, QTabWidget, \ QGraphicsView, QFrame, QGridLayout from PyQt5.QtGui import QPalette from PyQt5.Qt import Qt def main(): app = QApplication([]) mainForm = MainForm() mainForm.show() app.exec() # end main class

How to make the background color the same as the form background?

二次信任 提交于 2021-01-01 04:18:03
问题 In PyQt5 I'm getting some unexpected behavior from QTabWidget, the background seems to be white instead of the default form color (roughly light gray). Here is an example: # QTabWidget2.py from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLabel, QHBoxLayout, QVBoxLayout, QTabWidget, \ QGraphicsView, QFrame, QGridLayout from PyQt5.QtGui import QPalette from PyQt5.Qt import Qt def main(): app = QApplication([]) mainForm = MainForm() mainForm.show() app.exec() # end main class

How to change display size changing with window size in PyQT5?

此生再无相见时 提交于 2020-12-30 04:35:59
问题 I am displaying webcam image from cv2 on QPixmap. I have PyQt5 and Python2.7. Now the issue is the display size doesn't change with Window size. I like to change image size together with display window size. Now is always 640x480. Attached images show image size is fixed. I like to have just slightly smaller than window size and change together with window size. My code is as follow. from PyQt5 import QtCore, QtGui, QtWidgets import cv2 class Thread(QtCore.QThread): changePixmap = QtCore

How to change display size changing with window size in PyQT5?

蓝咒 提交于 2020-12-30 04:35:11
问题 I am displaying webcam image from cv2 on QPixmap. I have PyQt5 and Python2.7. Now the issue is the display size doesn't change with Window size. I like to change image size together with display window size. Now is always 640x480. Attached images show image size is fixed. I like to have just slightly smaller than window size and change together with window size. My code is as follow. from PyQt5 import QtCore, QtGui, QtWidgets import cv2 class Thread(QtCore.QThread): changePixmap = QtCore

Get all widgets under cursor

本秂侑毒 提交于 2020-12-29 13:18:53
问题 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

Get all widgets under cursor

我的未来我决定 提交于 2020-12-29 13:18:16
问题 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