How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?

Here is a way to scroll the content of an axes with a PyQt QtScrollBar. This is done by changing the limits of the axes depending on the scroll bar’s value. To this end, a callback to the QtScrollBar‘s actionTriggered method is registered that changes the limits of the axes. import sys import matplotlib # … Read more

Qt Webengine not loading openstreetmap tiles

By default QtWebEngine does not set default headers like popular browsers do. In this case the openstreetmap server needs to know the “Accept-Language” to produce the maps since for example the names of the cities will depend on the language to filter non-browser traffic. The solution is to implement a QWebEngineUrlRequestInterceptor that adds that header: … Read more

PyQt5 – Show virtual keyboard

First, be the binaries associated with Qt VirtualKeyboard, and to not install Qt I have used aqtinstall(In this example Qt 5.15 was installed but it is recommended to use the same version that was used to compile pyqt5: python -c “from PyQt5.QtCore import QT_VERSION_STR; print(‘Qt version’, QT_VERSION_STR)”): python -m pip install aqtinstall python -m aqt … Read more

How Can I Update a Qml Object’s Property from my Python file?

There are several methods to modify a property of a QML element from python/C++, and each has its advantages and disadvantages. 1. Pulling References from QML Obtain the QML object through findChildren through another object. Modify or access the property with setProperty() or property(), respectively or with QQmlProperty. main.qml (the qml is for the next … Read more

How can I check if a keyboard modifier is pressed (Shift, Ctrl, or Alt)?

It looks like all you need to do is check the keyboardModifiers in your button handler, and select a different action as appropriate. The various modifiers can be OR’d together in order to check for multi-key combinations: PyQt5: import sys from PyQt5 import QtCore, QtWidgets class Window(QtWidgets.QWidget): def __init__(self): super().__init__() self.button = QtWidgets.QPushButton(‘Test’) self.button.clicked.connect(self.handleButton) layout … Read more

PyQt5 failing import of QtGui

Assuming everything was installed correctly, you need to adjust your imports slightly to port from PyQt4 to PyQt5. The main GUI elements are in the QtWidgets module, whilst the more basic GUI elements are in QtGui. See the Qt modules page for more details. The example code needs to be changed to something like: from … Read more