Skip to content

Tag: pyqt5

Drawing straight line between two points using QPainterPath

I have a scene where I would like to draw a line between two points(mouse press should be the start point and mouse release as the endpoint) using the QPainterpath. Here is a demonstration of how I want it to be. Here is what’s happening with my current code. Below is the code I have tried Answer Every …

How to move rect in pyqtgraph

I try to have a rect which moves with the mouse pointer. However, I seem to have a problem with calling the paint method. It either doesn’t draw or creates artifacts. The only clean picture I get is with a forced redraw (zoom the graph). Here’s my mwe Answer Just redrawing the contents of an inter…

Transformation of coordinates between PyQt and matplotlib

I would like to show a context menu on the position of mouse click and then create a new line on that position in the graph. For that I need both the PyQt position and the graph data position. I thought that I could use the matplotlib transformation functions, but somehow when clicking the lower left and uppe…

Determine the element which previously had focus?

In Java a FocusEvent has a method getOppositeComponent() which is where the focus came from or went to. In PyQt5 is there any way to find what previously had focus when overriding focusInEvent? As explained in a note, I want to be able to start an edit session automatically when the table view gets focus, end…

Create a dependent window?

I want to create a secondary window which is free-floating in relation to the main window. But I also want it to close when the main window closes. Indeed, I want the application to end completely when the main window closes, and assumed this would be default behaviour. MRE: As the code is, closing the main w…