I use PySide instead, therefore in my program, instead
from PySide.QtGui import QVBoxLayout
Normally it works for importing but then when I called method .setMargin() as the tutorial : https://doc.qt.io/qtforpython/tutorials/expenses/expenses.html#right-side-layout , I got an error:
self.right = QVBoxLayout()
self.right.setMargin(10)
AttributeError: 'PySide.QtGui.QVBoxLayout' object has no attribute 'setMargin'
I tried to find the setMargin() in the library and it appear here: https://doc.qt.io/qtforpython/PySide2/QtWidgets/QLayout.html#PySide2.QtWidgets.PySide2.QtWidgets.QLayout.setMargin . That means I can call it by importing QLayout from Pyside.QtGui but that doesn't work. The cmd say:
NotImplementedError: 'QLayout' represents a C++ abstract class and cannot be instantiated
Could you please show me how to use setMargin() by an alternative way in my case?
setMargin()
does not exist in Qt4 (PySide), it existed in initial versions of Qt5 but is currently deprecated, instead you must use the setContentsMargins()
method:
self.right = QVBoxLayout()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.