How to set QComboBox to item from item’s text in PyQt/PySide

Yes, there is QComboBox.findText, which will return the index of the matched item (or -1, if there isn’t one). By default, the search does exact, case-sensitive matching, but you can tweak the behaviour by passing some match-flags as the second argument. For example, to do case-insensitive matching: index = combo.findText(text, QtCore.Qt.MatchFixedString) if index >= 0: … Read more

Process finished with exit code -1073741819 (0xC0000005) Pycharm

Assume you are running under Windows. Application Error code 0xc0000005, also known as Access Violation error, is a common problem experienced by Windows users, regardless of os version. There are various causes to trigger Application Error 0xc0000005. For my case, I’m running debug mode in PyCharm (or Eclipse) with code that includes the following: from … Read more

DLL load failed when importing PyQt5

It is because of missing Python3.dll (stub dll, that re-exports Python3x.dll functions, so that one version of extension can work for multiple versions of python). If your Python distro doesn’t bundle python3.dll, you can try one from WinPython (https://winpython.github.io/). At least the 2017/04/01 versions should have it. 1) Download WinPython (‘Zero’ version suffices; must be … Read more

PyQt proper use of emit() and pyqtSignal()

You can define your own slot (any python callable) and connect that to the signal, then call the other slots from that one slot. class Example(QWidget): def __init__(self): super().__init__() self.initUI() def printLabel(self, str): print(str) def logLabel(self, str): ”’log to a file”’ pass @QtCore.pyqtSlot(int) def on_sld_valueChanged(self, value): self.lcd.display(value) self.printLabel(value) self.logLabel(value) def initUI(self): self.lcd = QLCDNumber(self) self.sld … 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

Dark theme for Qt widgets?

No, but you may use my fairly comprehensive stylesheets that should look excellent on most platforms (it’s inspired by KDE’s Breeze Theme, which is a dark theme that is quite elegant). This was (hard) forked from the excellent QDarkStylesheet, which I felt had theme issues in numerous areas, so I modified it extensively for my … Read more

ImportError: No module named PytQt5

If you are on ubuntu, just install pyqt5 with apt-get command: sudo apt-get install python3-pyqt5 # for python3 or sudo apt-get install python-pyqt5 # for python2 However, on Ubuntu 14.04 the python-pyqt5 package is left out [source] and need to be installed manually [source]

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)