Migrating a plugin and started getting the error AttributeError: module 'qgis.PyQt.QtGui' has no attribute 'QVBoxLayout' I cannot find this one in the API changes I tied using qgis.PyQt5.QtGui but that didn't work. I thin it is usage or syntax according to this https://doc.qt.io/qt-5/qvboxlayout.html the in Qt5 the QVBoxLayout usage is a bit different. I have self.verticalLayout = QtGui.QVBoxLayout(Configuration) I am thinking Qt5 has a completely different way of setting ui's and there is a lot of ui settings in thsi; is there a converter out there for Qt4 to Qt5? Qgis2to3 didn't change any of this code.


All GUI objects are now in QtWidgets instead of QtGui.

from qgis.PyQt.QtWidgets import QVBoxLayout
| improve this answer | |
  • What I did was add QtWidgets to the end of from qgis.PyQt import QtCore, QtGui, QtWidgets and from qgis.PyQt.QtWidgets import QVBoxLayout just below that. Then changed all the QtGui.QVBoxLayout() to QtWidgetrs.QVBoxLayout(). When I reinstalled the plugin QGIS threw the next set of errors. Was there a cleaner way? – Tyler Veinot Apr 1 '19 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.