Issue
I'm using spyder.
When I run my code using QRandomGenerator.global()
method, error is thrown.
Because global
is a predetermined name.
from PySide2 import QtCore
import PySide2
import os, sys
dirname = os.path.dirname(PySide2.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path
def main():
app = QtCore.QCoreApplication(sys.argv) if QtCore.QCoreApplication.instance() is None else QtCore.QCoreApplication.instance()
r = QtCore.QRandomGenerator.global()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
Solution
All Qt functions that are named as reserved keywords in Python (like QTextDocument.print()
or QWidget.raise()
) use an underscore suffix.
r = QtCore.QRandomGenerator.global_()
Answered By - musicamante
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.