Unsolved Problems importing PySide2.QCharts
-
I'm currently using Qt Creator 4.11.0
Python: 3.8
PySide 2 version 5.14When I'm trying to import QAbstractSeries from QtCharts I am getting an import error.
# This Python file uses the following encoding: utf-8 import sys from PySide2.QtWidgets import QApplication from PySide2.QtQml import QQmlApplicationEngine from PySide2.QtCore import QObject, qDebug, Signal, Slot, Property from PySide2.QtCharts import QAbstractSeries from audio.__main__ import test class Main(QObject): axisChanged = Signal() def __init__(self): QObject.__init__(self) self.axisY = 0 testSignal = Signal(QAbstractSeries, arguments=['setYpoints']) @Property(int, notify=axisChanged) def setAxisY(self): self.axisY = 150 return self.axisY def runOther(): audioChunk = test() print(audioChunk) @Slot(QAbstractSeries) def setYpoints(self, series): print(series) # audioChunk = test() # for x in range(len(audioChunk)): # yPoint = audioChunk[x] # self.testSignal.emit(yPoint) if __name__ == "__main__": app = QApplication(sys.argv) dataToUI = Main() engine = QQmlApplicationEngine() engine.rootContext().setContextProperty("dataToUI", dataToUI) engine.load('ApplicationWindow.qml') engine.quit.connect(app.quit) Main.runOther() sys.exit(app.exec_())
Output:
ImportError: cannot import name 'QAbstractSeries' from 'PySide2.QtCharts' (D:\4. Projecten\WLED_Entertainment\wled\lib\site-packages\PySide2\QtCharts.pyd)
The path leads to a virtual env that I have created.
Any help is appreciated, thanks!
-
Hi and welcome to devnet,
Can you import the module itself ?
-
@SGaist said in Problems importing PySide2.QCharts:
Hi and welcome to devnet,
Can you import the module itself ?
Yes I can when I import the module I can compile without any errors.
When I do:
import PySide2.QtCharts #And within the code I use: QtCharts.QAbstractSeries
Output:
NameError: name 'QtCharts' is not defined
-
If you want to use it like that, you have to write:
from PySide2 import QtCharts